@pisell/pisellos 2.1.4 → 2.1.5
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/core/index.js +2 -1
- package/dist/effects/index.d.ts +4 -3
- package/dist/effects/index.js +15 -6
- package/dist/modules/AccountList/index.d.ts +7 -1
- package/dist/modules/AccountList/index.js +81 -14
- package/dist/modules/AccountList/types.d.ts +28 -0
- package/dist/modules/AccountList/types.js +8 -0
- package/dist/modules/Cart/index.js +1 -1
- package/dist/modules/Customer/constants.d.ts +7 -0
- package/dist/modules/Customer/constants.js +12 -0
- package/dist/modules/Customer/index.d.ts +122 -0
- package/dist/modules/Customer/index.js +697 -0
- package/dist/modules/Customer/types.d.ts +146 -0
- package/dist/modules/Customer/types.js +41 -0
- package/dist/modules/Discount/index.d.ts +1 -0
- package/dist/modules/Order/index.d.ts +25 -1
- package/dist/modules/Order/index.js +224 -2
- package/dist/modules/Order/types.d.ts +45 -0
- package/dist/modules/Order/types.js +8 -0
- package/dist/modules/Payment/cash.d.ts +19 -0
- package/dist/modules/Payment/cash.js +97 -0
- package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts +22 -0
- package/dist/modules/Payment/cashRecommendationAlgorithm.js +423 -0
- package/dist/modules/Payment/eftpos.d.ts +11 -0
- package/dist/modules/Payment/eftpos.js +80 -0
- package/dist/modules/Payment/index.d.ts +184 -9
- package/dist/modules/Payment/index.js +2012 -108
- package/dist/modules/Payment/mx51.d.ts +0 -0
- package/dist/modules/Payment/mx51.js +0 -0
- package/dist/modules/Payment/types.d.ts +750 -30
- package/dist/modules/Payment/types.js +236 -12
- package/dist/modules/Payment/utils.d.ts +17 -0
- package/dist/modules/Payment/utils.js +62 -0
- package/dist/modules/Payment/walletpass.d.ts +99 -0
- package/dist/modules/Payment/walletpass.js +701 -0
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/ProductList/index.d.ts +12 -1
- package/dist/modules/ProductList/index.js +27 -3
- package/dist/modules/Rules/index.d.ts +2 -0
- package/dist/modules/Rules/index.js +39 -17
- package/dist/modules/Rules/types.d.ts +1 -0
- package/dist/modules/Schedule/index.d.ts +9 -0
- package/dist/modules/Schedule/index.js +68 -0
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +1 -0
- package/dist/plugins/app-types/app/app.d.ts +83 -0
- package/dist/plugins/app-types/app/const.d.ts +4 -0
- package/dist/plugins/app-types/app/index.d.ts +14 -0
- package/dist/plugins/app-types/applicationManager/application.d.ts +50 -0
- package/dist/plugins/app-types/applicationManager/index.d.ts +13 -0
- package/dist/plugins/app-types/config.d.ts +3 -0
- package/dist/plugins/app-types/cookie/index.d.ts +13 -0
- package/dist/plugins/app-types/data/index.d.ts +8 -0
- package/dist/plugins/app-types/history/config.d.ts +24 -0
- package/dist/plugins/app-types/history/index.d.ts +20 -0
- package/dist/plugins/app-types/history/type.d.ts +2 -0
- package/dist/plugins/app-types/hooks/index.d.ts +12 -0
- package/dist/plugins/app-types/hooks/useDelayedValue/index.d.ts +2 -0
- package/dist/plugins/app-types/hooks/useDispatch/index.d.ts +2 -0
- package/dist/plugins/app-types/hooks/useLowCode/index.d.ts +13 -0
- package/dist/plugins/app-types/hooks/useStore/index.d.ts +6 -0
- package/dist/plugins/app-types/index.d.ts +6 -0
- package/dist/plugins/app-types/indexDB/index.d.ts +178 -0
- package/dist/plugins/app-types/locales/en.d.ts +3 -0
- package/dist/plugins/app-types/locales/index.d.ts +37 -0
- package/dist/plugins/app-types/locales/original.d.ts +3 -0
- package/dist/plugins/app-types/locales/type.d.ts +19 -0
- package/dist/plugins/app-types/locales/zh-CN.d.ts +3 -0
- package/dist/plugins/app-types/locales/zh-HK.d.ts +3 -0
- package/dist/plugins/app-types/logger/feishu.d.ts +11 -0
- package/dist/plugins/app-types/logger/index.d.ts +122 -0
- package/dist/plugins/app-types/menuManager/hooks.d.ts +17 -0
- package/dist/plugins/app-types/menuManager/index.d.ts +28 -0
- package/dist/plugins/app-types/models/global.d.ts +32 -0
- package/dist/plugins/app-types/models/index.d.ts +45 -0
- package/dist/plugins/app-types/models/type.d.ts +2 -0
- package/dist/plugins/app-types/package.json +15 -0
- package/dist/plugins/app-types/plugin/index.d.ts +0 -0
- package/dist/plugins/app-types/pubsub/example.d.ts +5 -0
- package/dist/plugins/app-types/pubsub/index.d.ts +63 -0
- package/dist/plugins/app-types/request/cache.d.ts +46 -0
- package/dist/plugins/app-types/request/cancelToken.d.ts +38 -0
- package/dist/plugins/app-types/request/config.d.ts +3 -0
- package/dist/plugins/app-types/request/constants.d.ts +2 -0
- package/dist/plugins/app-types/request/index.d.ts +24 -0
- package/dist/plugins/app-types/request/pisell2Request.d.ts +6 -0
- package/dist/plugins/app-types/request/type.d.ts +41 -0
- package/dist/plugins/app-types/request/utils.d.ts +46 -0
- package/dist/plugins/app-types/routes/config.d.ts +7 -0
- package/dist/plugins/app-types/routes/index.d.ts +28 -0
- package/dist/plugins/app-types/socket/components/SocketMonitorPage.d.ts +6 -0
- package/dist/plugins/app-types/socket/components/index.d.ts +2 -0
- package/dist/plugins/app-types/socket/constants.d.ts +33 -0
- package/dist/plugins/app-types/socket/events.d.ts +31 -0
- package/dist/plugins/app-types/socket/heartbeat.d.ts +66 -0
- package/dist/plugins/app-types/socket/index.d.ts +61 -0
- package/dist/plugins/app-types/socket/monitor.d.ts +169 -0
- package/dist/plugins/app-types/socket/reconnect.d.ts +61 -0
- package/dist/plugins/app-types/socket/socket.d.ts +129 -0
- package/dist/plugins/app-types/socket/types.d.ts +85 -0
- package/dist/plugins/app-types/storage/index.d.ts +17 -0
- package/dist/plugins/app-types/tasks/index.d.ts +77 -0
- package/dist/plugins/app-types/tasks/type.d.ts +62 -0
- package/dist/plugins/app-types/tasks/useTasks.d.ts +5 -0
- package/dist/plugins/app-types/type.d.ts +2 -0
- package/dist/plugins/app-types/variables/VariablesProvider.d.ts +7 -0
- package/dist/plugins/app-types/variables/config.d.ts +3 -0
- package/dist/plugins/app-types/variables/index.d.ts +6 -0
- package/dist/plugins/app-types/variables/type.d.ts +2 -0
- package/dist/plugins/app-types/website/index.d.ts +6 -0
- package/dist/plugins/app.d.ts +8 -0
- package/dist/plugins/app.js +1 -0
- package/dist/plugins/window.d.ts +1 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +1 -1
- package/dist/solution/BookingTicket/index.d.ts +180 -0
- package/dist/solution/BookingTicket/index.js +689 -0
- package/dist/solution/BookingTicket/types.d.ts +68 -0
- package/dist/solution/BookingTicket/types.js +43 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +159 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +22 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +189 -0
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +81 -0
- package/dist/solution/BookingTicket/utils/scan/index.js +285 -0
- package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
- package/dist/solution/BookingTicket/utils/scan/scanCache.js +305 -0
- package/dist/solution/Checkout/appointmentDemo.json +1 -0
- package/dist/solution/Checkout/index.d.ts +509 -0
- package/dist/solution/Checkout/index.js +4874 -0
- package/dist/solution/Checkout/types.d.ts +923 -0
- package/dist/solution/Checkout/types.js +148 -0
- package/dist/solution/Checkout/utils/index.d.ts +117 -0
- package/dist/solution/Checkout/utils/index.js +549 -0
- package/dist/solution/ShopDiscount/index.d.ts +4 -9
- package/dist/solution/ShopDiscount/index.js +106 -54
- package/dist/solution/ShopDiscount/types.d.ts +10 -1
- package/dist/solution/index.d.ts +2 -0
- package/dist/solution/index.js +3 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/utils/task.d.ts +40 -0
- package/dist/utils/task.js +171 -0
- package/dist/utils/watch.d.ts +102 -0
- package/dist/utils/watch.js +294 -0
- package/lib/core/index.js +1 -1
- package/lib/effects/index.d.ts +4 -3
- package/lib/effects/index.js +4 -1
- package/lib/modules/AccountList/index.d.ts +7 -1
- package/lib/modules/AccountList/index.js +27 -0
- package/lib/modules/AccountList/types.d.ts +28 -0
- package/lib/modules/Cart/index.js +1 -1
- package/lib/modules/Customer/constants.d.ts +7 -0
- package/lib/modules/Customer/constants.js +39 -0
- package/lib/modules/Customer/index.d.ts +122 -0
- package/lib/modules/Customer/index.js +440 -0
- package/lib/modules/Customer/types.d.ts +146 -0
- package/lib/modules/Customer/types.js +37 -0
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Order/index.d.ts +25 -1
- package/lib/modules/Order/index.js +182 -0
- package/lib/modules/Order/types.d.ts +45 -0
- package/lib/modules/Payment/cash.d.ts +19 -0
- package/lib/modules/Payment/cash.js +64 -0
- package/lib/modules/Payment/cashRecommendationAlgorithm.d.ts +22 -0
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +342 -0
- package/lib/modules/Payment/eftpos.d.ts +11 -0
- package/lib/modules/Payment/eftpos.js +51 -0
- package/lib/modules/Payment/index.d.ts +184 -9
- package/lib/modules/Payment/index.js +1044 -50
- package/lib/modules/Payment/mx51.d.ts +0 -0
- package/lib/modules/Payment/mx51.js +0 -0
- package/lib/modules/Payment/types.d.ts +750 -30
- package/lib/modules/Payment/types.js +79 -6
- package/lib/modules/Payment/utils.d.ts +17 -0
- package/lib/modules/Payment/utils.js +67 -0
- package/lib/modules/Payment/walletpass.d.ts +99 -0
- package/lib/modules/Payment/walletpass.js +468 -0
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/ProductList/index.d.ts +12 -1
- package/lib/modules/ProductList/index.js +29 -2
- package/lib/modules/Rules/index.d.ts +2 -0
- package/lib/modules/Rules/index.js +32 -15
- package/lib/modules/Rules/types.d.ts +1 -0
- package/lib/modules/Schedule/index.d.ts +9 -0
- package/lib/modules/Schedule/index.js +51 -0
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +2 -0
- package/lib/plugins/app-types/app/app.d.ts +83 -0
- package/lib/plugins/app-types/app/const.d.ts +4 -0
- package/lib/plugins/app-types/app/index.d.ts +14 -0
- package/lib/plugins/app-types/applicationManager/application.d.ts +50 -0
- package/lib/plugins/app-types/applicationManager/index.d.ts +13 -0
- package/lib/plugins/app-types/config.d.ts +3 -0
- package/lib/plugins/app-types/cookie/index.d.ts +13 -0
- package/lib/plugins/app-types/data/index.d.ts +8 -0
- package/lib/plugins/app-types/history/config.d.ts +24 -0
- package/lib/plugins/app-types/history/index.d.ts +20 -0
- package/lib/plugins/app-types/history/type.d.ts +2 -0
- package/lib/plugins/app-types/hooks/index.d.ts +12 -0
- package/lib/plugins/app-types/hooks/useDelayedValue/index.d.ts +2 -0
- package/lib/plugins/app-types/hooks/useDispatch/index.d.ts +2 -0
- package/lib/plugins/app-types/hooks/useLowCode/index.d.ts +13 -0
- package/lib/plugins/app-types/hooks/useStore/index.d.ts +6 -0
- package/lib/plugins/app-types/index.d.ts +6 -0
- package/lib/plugins/app-types/indexDB/index.d.ts +178 -0
- package/lib/plugins/app-types/locales/en.d.ts +3 -0
- package/lib/plugins/app-types/locales/index.d.ts +37 -0
- package/lib/plugins/app-types/locales/original.d.ts +3 -0
- package/lib/plugins/app-types/locales/type.d.ts +19 -0
- package/lib/plugins/app-types/locales/zh-CN.d.ts +3 -0
- package/lib/plugins/app-types/locales/zh-HK.d.ts +3 -0
- package/lib/plugins/app-types/logger/feishu.d.ts +11 -0
- package/lib/plugins/app-types/logger/index.d.ts +122 -0
- package/lib/plugins/app-types/menuManager/hooks.d.ts +17 -0
- package/lib/plugins/app-types/menuManager/index.d.ts +28 -0
- package/lib/plugins/app-types/models/global.d.ts +32 -0
- package/lib/plugins/app-types/models/index.d.ts +45 -0
- package/lib/plugins/app-types/models/type.d.ts +2 -0
- package/lib/plugins/app-types/package.json +15 -0
- package/lib/plugins/app-types/plugin/index.d.ts +0 -0
- package/lib/plugins/app-types/pubsub/example.d.ts +5 -0
- package/lib/plugins/app-types/pubsub/index.d.ts +63 -0
- package/lib/plugins/app-types/request/cache.d.ts +46 -0
- package/lib/plugins/app-types/request/cancelToken.d.ts +38 -0
- package/lib/plugins/app-types/request/config.d.ts +3 -0
- package/lib/plugins/app-types/request/constants.d.ts +2 -0
- package/lib/plugins/app-types/request/index.d.ts +24 -0
- package/lib/plugins/app-types/request/pisell2Request.d.ts +6 -0
- package/lib/plugins/app-types/request/type.d.ts +41 -0
- package/lib/plugins/app-types/request/utils.d.ts +46 -0
- package/lib/plugins/app-types/routes/config.d.ts +7 -0
- package/lib/plugins/app-types/routes/index.d.ts +28 -0
- package/lib/plugins/app-types/socket/components/SocketMonitorPage.d.ts +6 -0
- package/lib/plugins/app-types/socket/components/index.d.ts +2 -0
- package/lib/plugins/app-types/socket/constants.d.ts +33 -0
- package/lib/plugins/app-types/socket/events.d.ts +31 -0
- package/lib/plugins/app-types/socket/heartbeat.d.ts +66 -0
- package/lib/plugins/app-types/socket/index.d.ts +61 -0
- package/lib/plugins/app-types/socket/monitor.d.ts +169 -0
- package/lib/plugins/app-types/socket/reconnect.d.ts +61 -0
- package/lib/plugins/app-types/socket/socket.d.ts +129 -0
- package/lib/plugins/app-types/socket/types.d.ts +85 -0
- package/lib/plugins/app-types/storage/index.d.ts +17 -0
- package/lib/plugins/app-types/tasks/index.d.ts +77 -0
- package/lib/plugins/app-types/tasks/type.d.ts +62 -0
- package/lib/plugins/app-types/tasks/useTasks.d.ts +5 -0
- package/lib/plugins/app-types/type.d.ts +2 -0
- package/lib/plugins/app-types/variables/VariablesProvider.d.ts +7 -0
- package/lib/plugins/app-types/variables/config.d.ts +3 -0
- package/lib/plugins/app-types/variables/index.d.ts +6 -0
- package/lib/plugins/app-types/variables/type.d.ts +2 -0
- package/lib/plugins/app-types/website/index.d.ts +6 -0
- package/lib/plugins/app.d.ts +8 -0
- package/lib/plugins/app.js +17 -0
- package/lib/plugins/window.d.ts +1 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +1 -2
- package/lib/solution/BookingTicket/index.d.ts +180 -0
- package/lib/solution/BookingTicket/index.js +420 -0
- package/lib/solution/BookingTicket/types.d.ts +68 -0
- package/lib/solution/BookingTicket/types.js +72 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +117 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +22 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +132 -0
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +81 -0
- package/lib/solution/BookingTicket/utils/scan/index.js +210 -0
- package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +231 -0
- package/lib/solution/Checkout/appointmentDemo.json +1 -0
- package/lib/solution/Checkout/index.d.ts +509 -0
- package/lib/solution/Checkout/index.js +3002 -0
- package/lib/solution/Checkout/types.d.ts +923 -0
- package/lib/solution/Checkout/types.js +87 -0
- package/lib/solution/Checkout/utils/index.d.ts +117 -0
- package/lib/solution/Checkout/utils/index.js +403 -0
- package/lib/solution/ShopDiscount/index.d.ts +4 -9
- package/lib/solution/ShopDiscount/index.js +41 -13
- package/lib/solution/ShopDiscount/types.d.ts +10 -1
- package/lib/solution/index.d.ts +2 -0
- package/lib/solution/index.js +5 -1
- package/lib/types/index.d.ts +3 -1
- package/lib/utils/task.d.ts +40 -0
- package/lib/utils/task.js +109 -0
- package/lib/utils/watch.d.ts +102 -0
- package/lib/utils/watch.js +217 -0
- package/package.json +4 -2
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/solution/Checkout/types.ts
|
|
20
|
+
var types_exports = {};
|
|
21
|
+
__export(types_exports, {
|
|
22
|
+
CheckoutErrorType: () => CheckoutErrorType,
|
|
23
|
+
CheckoutHooks: () => CheckoutHooks,
|
|
24
|
+
CheckoutStatus: () => CheckoutStatus,
|
|
25
|
+
CheckoutStep: () => CheckoutStep
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(types_exports);
|
|
28
|
+
var CheckoutStatus = /* @__PURE__ */ ((CheckoutStatus2) => {
|
|
29
|
+
CheckoutStatus2["Initializing"] = "initializing";
|
|
30
|
+
CheckoutStatus2["Ready"] = "ready";
|
|
31
|
+
CheckoutStatus2["CreatingOrder"] = "creating_order";
|
|
32
|
+
CheckoutStatus2["OrderCreated"] = "order_created";
|
|
33
|
+
CheckoutStatus2["ProcessingPayment"] = "processing_payment";
|
|
34
|
+
CheckoutStatus2["PaymentCompleted"] = "payment_completed";
|
|
35
|
+
CheckoutStatus2["Completed"] = "completed";
|
|
36
|
+
CheckoutStatus2["Cancelled"] = "cancelled";
|
|
37
|
+
CheckoutStatus2["Error"] = "error";
|
|
38
|
+
return CheckoutStatus2;
|
|
39
|
+
})(CheckoutStatus || {});
|
|
40
|
+
var CheckoutStep = /* @__PURE__ */ ((CheckoutStep2) => {
|
|
41
|
+
CheckoutStep2["OrderConfirmation"] = "order_confirmation";
|
|
42
|
+
CheckoutStep2["PaymentMethod"] = "payment_method";
|
|
43
|
+
CheckoutStep2["PaymentProcessing"] = "payment_processing";
|
|
44
|
+
CheckoutStep2["Complete"] = "complete";
|
|
45
|
+
return CheckoutStep2;
|
|
46
|
+
})(CheckoutStep || {});
|
|
47
|
+
var CheckoutErrorType = /* @__PURE__ */ ((CheckoutErrorType2) => {
|
|
48
|
+
CheckoutErrorType2["OrderCreationFailed"] = "order_creation_failed";
|
|
49
|
+
CheckoutErrorType2["PaymentFailed"] = "payment_failed";
|
|
50
|
+
CheckoutErrorType2["ValidationFailed"] = "validation_failed";
|
|
51
|
+
CheckoutErrorType2["NetworkError"] = "network_error";
|
|
52
|
+
CheckoutErrorType2["UnknownError"] = "unknown_error";
|
|
53
|
+
return CheckoutErrorType2;
|
|
54
|
+
})(CheckoutErrorType || {});
|
|
55
|
+
var CheckoutHooks = /* @__PURE__ */ ((CheckoutHooks2) => {
|
|
56
|
+
CheckoutHooks2["OnCheckoutInitialized"] = "checkout:onInitialized";
|
|
57
|
+
CheckoutHooks2["OnStatusChanged"] = "checkout:onStatusChanged";
|
|
58
|
+
CheckoutHooks2["OnStepChanged"] = "checkout:onStepChanged";
|
|
59
|
+
CheckoutHooks2["OnOrderCreated"] = "checkout:onOrderCreated";
|
|
60
|
+
CheckoutHooks2["OnOrderCreationFailed"] = "checkout:onOrderCreationFailed";
|
|
61
|
+
CheckoutHooks2["OnPaymentStarted"] = "checkout:onPaymentStarted";
|
|
62
|
+
CheckoutHooks2["OnPaymentSuccess"] = "checkout:onPaymentSuccess";
|
|
63
|
+
CheckoutHooks2["OnPaymentFailed"] = "checkout:onPaymentFailed";
|
|
64
|
+
CheckoutHooks2["OnCheckoutCompleted"] = "checkout:onCompleted";
|
|
65
|
+
CheckoutHooks2["OnCheckoutCancelled"] = "checkout:onCancelled";
|
|
66
|
+
CheckoutHooks2["OnError"] = "checkout:onError";
|
|
67
|
+
CheckoutHooks2["OnStateAmountChanged"] = "checkout:onStateAmountChanged";
|
|
68
|
+
CheckoutHooks2["OnBalanceDueAmountChanged"] = "checkout:onBalanceDueAmountChanged";
|
|
69
|
+
CheckoutHooks2["OnOrderPaymentCompleted"] = "checkout:onOrderPaymentCompleted";
|
|
70
|
+
CheckoutHooks2["OnOrderSynced"] = "checkout:onOrderSynced";
|
|
71
|
+
CheckoutHooks2["OnOrderSyncFailed"] = "checkout:onOrderSyncFailed";
|
|
72
|
+
CheckoutHooks2["OnOrderNoteChanged"] = "checkout:onOrderNoteChanged";
|
|
73
|
+
CheckoutHooks2["OnShopDiscountChanged"] = "checkout:onShopDiscountChanged";
|
|
74
|
+
CheckoutHooks2["OnOrderCancelled"] = "checkout:onOrderCancelled";
|
|
75
|
+
CheckoutHooks2["OnOrderCleared"] = "checkout:onOrderCleared";
|
|
76
|
+
CheckoutHooks2["OnOrderSubmitStart"] = "checkout:onOrderSubmitStart";
|
|
77
|
+
CheckoutHooks2["OnOrderSubmitEnd"] = "checkout:onOrderSubmitEnd";
|
|
78
|
+
CheckoutHooks2["OnWalletDataInitialized"] = "checkout:onWalletDataInitialized";
|
|
79
|
+
return CheckoutHooks2;
|
|
80
|
+
})(CheckoutHooks || {});
|
|
81
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
82
|
+
0 && (module.exports = {
|
|
83
|
+
CheckoutErrorType,
|
|
84
|
+
CheckoutHooks,
|
|
85
|
+
CheckoutStatus,
|
|
86
|
+
CheckoutStep
|
|
87
|
+
});
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { CheckoutInitParams, CheckoutError, CheckoutErrorType, CheckoutStatus, CheckoutStep, LocalOrderData, CartSummaryItem, ExtractedAmountInfo } from '../types';
|
|
2
|
+
import { CartItem } from '../../../modules/Cart/types';
|
|
3
|
+
/**
|
|
4
|
+
* 验证结账数据
|
|
5
|
+
*/
|
|
6
|
+
export declare function validateCheckoutData(params: CheckoutInitParams): {
|
|
7
|
+
valid: boolean;
|
|
8
|
+
errors: string[];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* 创建结账错误对象
|
|
12
|
+
*/
|
|
13
|
+
export declare function createCheckoutError(type: CheckoutErrorType, message: string, details?: any): CheckoutError;
|
|
14
|
+
/**
|
|
15
|
+
* 计算结账进度
|
|
16
|
+
*/
|
|
17
|
+
export declare function calculateProgress(status: CheckoutStatus, step: CheckoutStep): number;
|
|
18
|
+
/**
|
|
19
|
+
* 格式化金额
|
|
20
|
+
*/
|
|
21
|
+
export declare function formatAmount(amount: string | number): string;
|
|
22
|
+
/**
|
|
23
|
+
* 验证金额
|
|
24
|
+
*/
|
|
25
|
+
export declare function validateAmount(amount: string | number): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* 生成唯一订单ID
|
|
28
|
+
*/
|
|
29
|
+
export declare function generateOrderId(prefix?: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* 检查是否为有效的支付方式代码
|
|
32
|
+
*/
|
|
33
|
+
export declare function isValidPaymentMethodCode(code: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* 安全地解析JSON
|
|
36
|
+
*/
|
|
37
|
+
export declare function safeJsonParse<T>(jsonString: string, defaultValue: T): T;
|
|
38
|
+
/**
|
|
39
|
+
* 深度克隆对象
|
|
40
|
+
*/
|
|
41
|
+
export declare function deepClone<T>(obj: T): T;
|
|
42
|
+
/**
|
|
43
|
+
* 防抖函数
|
|
44
|
+
*/
|
|
45
|
+
export declare function debounce<T extends (...args: any[]) => any>(func: T, wait: number): (...args: Parameters<T>) => void;
|
|
46
|
+
/**
|
|
47
|
+
* 节流函数
|
|
48
|
+
*/
|
|
49
|
+
export declare function throttle<T extends (...args: any[]) => any>(func: T, wait: number): (...args: Parameters<T>) => void;
|
|
50
|
+
/**
|
|
51
|
+
* 重试函数
|
|
52
|
+
*/
|
|
53
|
+
export declare function retry<T>(fn: () => Promise<T>, maxAttempts?: number, delay?: number): Promise<T>;
|
|
54
|
+
/**
|
|
55
|
+
* 检查对象是否为空
|
|
56
|
+
*/
|
|
57
|
+
export declare function isEmpty(obj: any): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* 获取错误消息
|
|
60
|
+
*/
|
|
61
|
+
export declare function getErrorMessage(error: unknown): string;
|
|
62
|
+
/**
|
|
63
|
+
* 检查是否为生产环境
|
|
64
|
+
*/
|
|
65
|
+
export declare function isProduction(): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* 日志记录器
|
|
68
|
+
*/
|
|
69
|
+
export declare const logger: {
|
|
70
|
+
info: (message: string, ...args: any[]) => void;
|
|
71
|
+
warn: (message: string, ...args: any[]) => void;
|
|
72
|
+
error: (message: string, ...args: any[]) => void;
|
|
73
|
+
debug: (message: string, ...args: any[]) => void;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* 验证本地订单数据
|
|
77
|
+
*/
|
|
78
|
+
export declare function validateLocalOrderData(orderData: LocalOrderData): {
|
|
79
|
+
valid: boolean;
|
|
80
|
+
errors: string[];
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* 生成本地订单ID
|
|
84
|
+
*/
|
|
85
|
+
export declare function generateLocalOrderId(): string;
|
|
86
|
+
/**
|
|
87
|
+
* 格式化日期时间为 YYYY-MM-DD hh:mm:ss 格式
|
|
88
|
+
*
|
|
89
|
+
* @param date 要格式化的日期对象
|
|
90
|
+
* @returns 格式化后的日期时间字符串
|
|
91
|
+
*/
|
|
92
|
+
export declare function formatDateTime(date: Date): string;
|
|
93
|
+
/**
|
|
94
|
+
* 从购物车小计数据中提取金额信息
|
|
95
|
+
*/
|
|
96
|
+
export declare function extractAmountFromCartSummary(cartSummary: CartSummaryItem[]): ExtractedAmountInfo;
|
|
97
|
+
/**
|
|
98
|
+
* 计算购物车总金额
|
|
99
|
+
*/
|
|
100
|
+
export declare function calculateTotalAmount(cartItems: CartItem[]): string;
|
|
101
|
+
/**
|
|
102
|
+
* 判断订单ID是否为本地生成的虚拟ID
|
|
103
|
+
*
|
|
104
|
+
* @param orderId 订单ID
|
|
105
|
+
* @returns true 表示是虚拟ID,false 表示是真实的后端ID
|
|
106
|
+
*/
|
|
107
|
+
export declare function isVirtualOrderId(orderId: string): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* 判断支付方式是否需要同步订单到后端
|
|
110
|
+
*
|
|
111
|
+
* 现金支付(CASHMANUAL)和自定义支付不需要同步,其他支付方式需要同步
|
|
112
|
+
*
|
|
113
|
+
* @param paymentCode 支付方式代码
|
|
114
|
+
* @param paymentType 支付方式类型
|
|
115
|
+
* @returns 是否需要同步订单
|
|
116
|
+
*/
|
|
117
|
+
export declare function shouldSyncOrderForPayment(paymentCode: string, paymentType: string): boolean;
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/solution/Checkout/utils/index.ts
|
|
20
|
+
var utils_exports = {};
|
|
21
|
+
__export(utils_exports, {
|
|
22
|
+
calculateProgress: () => calculateProgress,
|
|
23
|
+
calculateTotalAmount: () => calculateTotalAmount,
|
|
24
|
+
createCheckoutError: () => createCheckoutError,
|
|
25
|
+
debounce: () => debounce,
|
|
26
|
+
deepClone: () => deepClone,
|
|
27
|
+
extractAmountFromCartSummary: () => extractAmountFromCartSummary,
|
|
28
|
+
formatAmount: () => formatAmount,
|
|
29
|
+
formatDateTime: () => formatDateTime,
|
|
30
|
+
generateLocalOrderId: () => generateLocalOrderId,
|
|
31
|
+
generateOrderId: () => generateOrderId,
|
|
32
|
+
getErrorMessage: () => getErrorMessage,
|
|
33
|
+
isEmpty: () => isEmpty,
|
|
34
|
+
isProduction: () => isProduction,
|
|
35
|
+
isValidPaymentMethodCode: () => isValidPaymentMethodCode,
|
|
36
|
+
isVirtualOrderId: () => isVirtualOrderId,
|
|
37
|
+
logger: () => logger,
|
|
38
|
+
retry: () => retry,
|
|
39
|
+
safeJsonParse: () => safeJsonParse,
|
|
40
|
+
shouldSyncOrderForPayment: () => shouldSyncOrderForPayment,
|
|
41
|
+
throttle: () => throttle,
|
|
42
|
+
validateAmount: () => validateAmount,
|
|
43
|
+
validateCheckoutData: () => validateCheckoutData,
|
|
44
|
+
validateLocalOrderData: () => validateLocalOrderData
|
|
45
|
+
});
|
|
46
|
+
module.exports = __toCommonJS(utils_exports);
|
|
47
|
+
var import_types = require("../types");
|
|
48
|
+
var import_types2 = require("../../../modules/Payment/types");
|
|
49
|
+
function validateCheckoutData(params) {
|
|
50
|
+
const errors = [];
|
|
51
|
+
if (!params.cartItems || params.cartItems.length === 0) {
|
|
52
|
+
errors.push("购物车不能为空");
|
|
53
|
+
}
|
|
54
|
+
if (params.cartItems) {
|
|
55
|
+
params.cartItems.forEach((item, index) => {
|
|
56
|
+
if (!item.id) {
|
|
57
|
+
errors.push(`购物车商品 ${index + 1} 缺少商品ID`);
|
|
58
|
+
}
|
|
59
|
+
if (!item.price || parseFloat(String(item.price)) < 0) {
|
|
60
|
+
errors.push(`购物车商品 ${index + 1} 价格无效`);
|
|
61
|
+
}
|
|
62
|
+
if (!item.num || item.num <= 0) {
|
|
63
|
+
errors.push(`购物车商品 ${index + 1} 数量无效`);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (params.orderType && !["virtual", "appointment_booking"].includes(params.orderType)) {
|
|
68
|
+
errors.push("订单类型无效,必须是 virtual 或 appointment_booking");
|
|
69
|
+
}
|
|
70
|
+
if (params.platform && !["pc", "h5"].includes(params.platform)) {
|
|
71
|
+
errors.push("平台类型无效,必须是 pc 或 h5");
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
valid: errors.length === 0,
|
|
75
|
+
errors
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function createCheckoutError(type, message, details) {
|
|
79
|
+
return {
|
|
80
|
+
type,
|
|
81
|
+
message,
|
|
82
|
+
details,
|
|
83
|
+
timestamp: Date.now()
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function calculateProgress(status, step) {
|
|
87
|
+
let baseProgress = 0;
|
|
88
|
+
switch (status) {
|
|
89
|
+
case import_types.CheckoutStatus.Initializing:
|
|
90
|
+
baseProgress = 5;
|
|
91
|
+
break;
|
|
92
|
+
case import_types.CheckoutStatus.Ready:
|
|
93
|
+
baseProgress = 10;
|
|
94
|
+
break;
|
|
95
|
+
case import_types.CheckoutStatus.CreatingOrder:
|
|
96
|
+
baseProgress = 25;
|
|
97
|
+
break;
|
|
98
|
+
case import_types.CheckoutStatus.OrderCreated:
|
|
99
|
+
baseProgress = 40;
|
|
100
|
+
break;
|
|
101
|
+
case import_types.CheckoutStatus.ProcessingPayment:
|
|
102
|
+
baseProgress = 65;
|
|
103
|
+
break;
|
|
104
|
+
case import_types.CheckoutStatus.PaymentCompleted:
|
|
105
|
+
baseProgress = 85;
|
|
106
|
+
break;
|
|
107
|
+
case import_types.CheckoutStatus.Completed:
|
|
108
|
+
baseProgress = 100;
|
|
109
|
+
break;
|
|
110
|
+
case import_types.CheckoutStatus.Cancelled:
|
|
111
|
+
case import_types.CheckoutStatus.Error:
|
|
112
|
+
baseProgress = 0;
|
|
113
|
+
break;
|
|
114
|
+
default:
|
|
115
|
+
baseProgress = 0;
|
|
116
|
+
}
|
|
117
|
+
let stepProgress = 0;
|
|
118
|
+
switch (step) {
|
|
119
|
+
case import_types.CheckoutStep.OrderConfirmation:
|
|
120
|
+
stepProgress = 0;
|
|
121
|
+
break;
|
|
122
|
+
case import_types.CheckoutStep.PaymentMethod:
|
|
123
|
+
stepProgress = 10;
|
|
124
|
+
break;
|
|
125
|
+
case import_types.CheckoutStep.PaymentProcessing:
|
|
126
|
+
stepProgress = 15;
|
|
127
|
+
break;
|
|
128
|
+
case import_types.CheckoutStep.Complete:
|
|
129
|
+
stepProgress = 0;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
return Math.min(100, baseProgress + stepProgress);
|
|
133
|
+
}
|
|
134
|
+
function formatAmount(amount) {
|
|
135
|
+
const numAmount = typeof amount === "string" ? parseFloat(amount) : amount;
|
|
136
|
+
if (isNaN(numAmount))
|
|
137
|
+
return "0.00";
|
|
138
|
+
return numAmount.toFixed(2);
|
|
139
|
+
}
|
|
140
|
+
function validateAmount(amount) {
|
|
141
|
+
const numAmount = typeof amount === "string" ? parseFloat(amount) : amount;
|
|
142
|
+
return !isNaN(numAmount) && numAmount >= 0;
|
|
143
|
+
}
|
|
144
|
+
function generateOrderId(prefix = "order") {
|
|
145
|
+
const timestamp = Date.now();
|
|
146
|
+
const random = Math.floor(Math.random() * 1e4).toString().padStart(4, "0");
|
|
147
|
+
return `${prefix}_${timestamp}_${random}`;
|
|
148
|
+
}
|
|
149
|
+
function isValidPaymentMethodCode(code) {
|
|
150
|
+
return typeof code === "string" && code.length > 0 && /^[a-zA-Z0-9_-]+$/.test(code);
|
|
151
|
+
}
|
|
152
|
+
function safeJsonParse(jsonString, defaultValue) {
|
|
153
|
+
try {
|
|
154
|
+
return JSON.parse(jsonString);
|
|
155
|
+
} catch {
|
|
156
|
+
return defaultValue;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function deepClone(obj) {
|
|
160
|
+
if (obj === null || typeof obj !== "object") {
|
|
161
|
+
return obj;
|
|
162
|
+
}
|
|
163
|
+
if (obj instanceof Date) {
|
|
164
|
+
return new Date(obj.getTime());
|
|
165
|
+
}
|
|
166
|
+
if (obj instanceof Array) {
|
|
167
|
+
return obj.map((item) => deepClone(item));
|
|
168
|
+
}
|
|
169
|
+
if (typeof obj === "object") {
|
|
170
|
+
const clonedObj = {};
|
|
171
|
+
for (const key in obj) {
|
|
172
|
+
if (obj.hasOwnProperty(key)) {
|
|
173
|
+
clonedObj[key] = deepClone(obj[key]);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return clonedObj;
|
|
177
|
+
}
|
|
178
|
+
return obj;
|
|
179
|
+
}
|
|
180
|
+
function debounce(func, wait) {
|
|
181
|
+
let timeout = null;
|
|
182
|
+
return (...args) => {
|
|
183
|
+
if (timeout) {
|
|
184
|
+
clearTimeout(timeout);
|
|
185
|
+
}
|
|
186
|
+
timeout = setTimeout(() => {
|
|
187
|
+
func.apply(null, args);
|
|
188
|
+
}, wait);
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function throttle(func, wait) {
|
|
192
|
+
let lastTime = 0;
|
|
193
|
+
return (...args) => {
|
|
194
|
+
const now = Date.now();
|
|
195
|
+
if (now - lastTime >= wait) {
|
|
196
|
+
lastTime = now;
|
|
197
|
+
func.apply(null, args);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
async function retry(fn, maxAttempts = 3, delay = 1e3) {
|
|
202
|
+
let lastError;
|
|
203
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
204
|
+
try {
|
|
205
|
+
return await fn();
|
|
206
|
+
} catch (error) {
|
|
207
|
+
lastError = error;
|
|
208
|
+
if (attempt === maxAttempts) {
|
|
209
|
+
throw lastError;
|
|
210
|
+
}
|
|
211
|
+
await new Promise((resolve) => setTimeout(resolve, delay * attempt));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
throw lastError;
|
|
215
|
+
}
|
|
216
|
+
function isEmpty(obj) {
|
|
217
|
+
if (obj == null)
|
|
218
|
+
return true;
|
|
219
|
+
if (Array.isArray(obj) || typeof obj === "string")
|
|
220
|
+
return obj.length === 0;
|
|
221
|
+
if (typeof obj === "object")
|
|
222
|
+
return Object.keys(obj).length === 0;
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
function getErrorMessage(error) {
|
|
226
|
+
if (error instanceof Error) {
|
|
227
|
+
return error.message;
|
|
228
|
+
}
|
|
229
|
+
if (typeof error === "string") {
|
|
230
|
+
return error;
|
|
231
|
+
}
|
|
232
|
+
if (error && typeof error === "object" && "message" in error) {
|
|
233
|
+
return String(error.message);
|
|
234
|
+
}
|
|
235
|
+
return "未知错误";
|
|
236
|
+
}
|
|
237
|
+
function isProduction() {
|
|
238
|
+
return process.env.NODE_ENV === "production";
|
|
239
|
+
}
|
|
240
|
+
var logger = {
|
|
241
|
+
info: (message, ...args) => {
|
|
242
|
+
console.log(`[Checkout] ${message}`, ...args);
|
|
243
|
+
},
|
|
244
|
+
warn: (message, ...args) => {
|
|
245
|
+
console.warn(`[Checkout] ${message}`, ...args);
|
|
246
|
+
},
|
|
247
|
+
error: (message, ...args) => {
|
|
248
|
+
console.error(`[Checkout] ${message}`, ...args);
|
|
249
|
+
},
|
|
250
|
+
debug: (message, ...args) => {
|
|
251
|
+
if (!isProduction()) {
|
|
252
|
+
console.debug(`[Checkout] ${message}`, ...args);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
function validateLocalOrderData(orderData) {
|
|
257
|
+
var _a;
|
|
258
|
+
const errors = [];
|
|
259
|
+
if (!orderData.type) {
|
|
260
|
+
errors.push("订单类型不能为空");
|
|
261
|
+
}
|
|
262
|
+
if (!orderData.platform) {
|
|
263
|
+
errors.push("平台信息不能为空");
|
|
264
|
+
}
|
|
265
|
+
if ((!orderData.bookings || orderData.bookings.length === 0) && !((_a = orderData == null ? void 0 : orderData.relation_products) == null ? void 0 : _a.length)) {
|
|
266
|
+
errors.push("预订信息不能为空");
|
|
267
|
+
}
|
|
268
|
+
if (orderData.bookings) {
|
|
269
|
+
orderData.bookings.forEach((booking, index) => {
|
|
270
|
+
if (!booking.product || !booking.product.product_id) {
|
|
271
|
+
errors.push(`预订项 ${index + 1} 缺少商品信息`);
|
|
272
|
+
}
|
|
273
|
+
if (!booking.start_date) {
|
|
274
|
+
errors.push(`预订项 ${index + 1} 缺少开始日期`);
|
|
275
|
+
}
|
|
276
|
+
if (!booking.start_time) {
|
|
277
|
+
errors.push(`预订项 ${index + 1} 缺少开始时间`);
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
return {
|
|
282
|
+
valid: errors.length === 0,
|
|
283
|
+
errors
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function generateLocalOrderId() {
|
|
287
|
+
const timestamp = Date.now();
|
|
288
|
+
const random = Math.floor(Math.random() * 1e4).toString().padStart(4, "0");
|
|
289
|
+
return `local_order_${timestamp}_${random}`;
|
|
290
|
+
}
|
|
291
|
+
function formatDateTime(date) {
|
|
292
|
+
const year = date.getFullYear();
|
|
293
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
294
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
295
|
+
const hours = String(date.getHours()).padStart(2, "0");
|
|
296
|
+
const minutes = String(date.getMinutes()).padStart(2, "0");
|
|
297
|
+
const seconds = String(date.getSeconds()).padStart(2, "0");
|
|
298
|
+
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
299
|
+
}
|
|
300
|
+
function extractAmountFromCartSummary(cartSummary) {
|
|
301
|
+
const result = {
|
|
302
|
+
totalAmount: "0.00",
|
|
303
|
+
subTotal: "0.00",
|
|
304
|
+
taxAmount: "0.00",
|
|
305
|
+
discountAmount: "0.00",
|
|
306
|
+
shopDiscountAmount: "0.00",
|
|
307
|
+
roundingAmount: "0.00"
|
|
308
|
+
};
|
|
309
|
+
cartSummary.forEach((item) => {
|
|
310
|
+
const value = Number(item.value).toFixed(2);
|
|
311
|
+
switch (item.key) {
|
|
312
|
+
case "expect_amount":
|
|
313
|
+
result.totalAmount = value;
|
|
314
|
+
break;
|
|
315
|
+
case "sub_total":
|
|
316
|
+
result.subTotal = value;
|
|
317
|
+
break;
|
|
318
|
+
case "tax":
|
|
319
|
+
result.taxAmount = value;
|
|
320
|
+
if (item.tax) {
|
|
321
|
+
result.taxDetails = item.tax;
|
|
322
|
+
}
|
|
323
|
+
break;
|
|
324
|
+
case "discount":
|
|
325
|
+
result.discountAmount = value;
|
|
326
|
+
break;
|
|
327
|
+
case "shop_discount":
|
|
328
|
+
result.shopDiscountAmount = value;
|
|
329
|
+
break;
|
|
330
|
+
case "custom_roundingAmount":
|
|
331
|
+
result.roundingAmount = value;
|
|
332
|
+
break;
|
|
333
|
+
default:
|
|
334
|
+
if (item.key.includes("deposit")) {
|
|
335
|
+
result.depositAmount = value;
|
|
336
|
+
}
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
console.log("[Checkout] 从购物车小计提取金额信息:", {
|
|
341
|
+
totalAmount: result.totalAmount,
|
|
342
|
+
subTotal: result.subTotal,
|
|
343
|
+
taxAmount: result.taxAmount,
|
|
344
|
+
discountAmount: result.discountAmount,
|
|
345
|
+
shopDiscountAmount: result.shopDiscountAmount,
|
|
346
|
+
roundingAmount: result.roundingAmount
|
|
347
|
+
});
|
|
348
|
+
return result;
|
|
349
|
+
}
|
|
350
|
+
function calculateTotalAmount(cartItems) {
|
|
351
|
+
const total = cartItems.reduce((sum, item) => {
|
|
352
|
+
const price = parseFloat(String(item.price) || "0");
|
|
353
|
+
const quantity = item.quantity || 1;
|
|
354
|
+
return sum + price * quantity;
|
|
355
|
+
}, 0);
|
|
356
|
+
return total.toFixed(2);
|
|
357
|
+
}
|
|
358
|
+
function isVirtualOrderId(orderId) {
|
|
359
|
+
return orderId.startsWith("local_order_");
|
|
360
|
+
}
|
|
361
|
+
function shouldSyncOrderForPayment(paymentCode, paymentType) {
|
|
362
|
+
const codeUpper = (paymentCode == null ? void 0 : paymentCode.toUpperCase()) || "";
|
|
363
|
+
const typeUpper = (paymentType == null ? void 0 : paymentType.toUpperCase()) || "";
|
|
364
|
+
const cashIdentifiers = ["CASHMANUAL", "CASH", "MANUAL"];
|
|
365
|
+
if (cashIdentifiers.some(
|
|
366
|
+
(id) => codeUpper.includes(id) || typeUpper.includes(id)
|
|
367
|
+
)) {
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
if (paymentCode === import_types2.PaymentMethodType.Cash || paymentType === import_types2.PaymentMethodType.Cash) {
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
373
|
+
if (codeUpper.includes("CUSTOM") || typeUpper.includes("CUSTOM")) {
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
376
|
+
return true;
|
|
377
|
+
}
|
|
378
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
379
|
+
0 && (module.exports = {
|
|
380
|
+
calculateProgress,
|
|
381
|
+
calculateTotalAmount,
|
|
382
|
+
createCheckoutError,
|
|
383
|
+
debounce,
|
|
384
|
+
deepClone,
|
|
385
|
+
extractAmountFromCartSummary,
|
|
386
|
+
formatAmount,
|
|
387
|
+
formatDateTime,
|
|
388
|
+
generateLocalOrderId,
|
|
389
|
+
generateOrderId,
|
|
390
|
+
getErrorMessage,
|
|
391
|
+
isEmpty,
|
|
392
|
+
isProduction,
|
|
393
|
+
isValidPaymentMethodCode,
|
|
394
|
+
isVirtualOrderId,
|
|
395
|
+
logger,
|
|
396
|
+
retry,
|
|
397
|
+
safeJsonParse,
|
|
398
|
+
shouldSyncOrderForPayment,
|
|
399
|
+
throttle,
|
|
400
|
+
validateAmount,
|
|
401
|
+
validateCheckoutData,
|
|
402
|
+
validateLocalOrderData
|
|
403
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore } from '../../types';
|
|
2
2
|
import { BaseModule } from '../../modules/BaseModule';
|
|
3
|
-
import { Customer } from './types';
|
|
3
|
+
import { Customer, SetDiscountSelectedParams } from './types';
|
|
4
4
|
import { Discount } from '../../modules/Discount/types';
|
|
5
5
|
export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
6
6
|
protected defaultName: string;
|
|
@@ -19,17 +19,11 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
19
19
|
private registerDependentModules;
|
|
20
20
|
private registerEventListeners;
|
|
21
21
|
setCustomer(customer: Customer): Promise<void>;
|
|
22
|
-
calcDiscount(productList: Record<string, any>[], options?: {
|
|
23
|
-
discountId: number;
|
|
24
|
-
isSelected: boolean;
|
|
25
|
-
}): {
|
|
22
|
+
calcDiscount(productList: Record<string, any>[], options?: SetDiscountSelectedParams): {
|
|
26
23
|
productList: Record<string, any>[];
|
|
27
24
|
discountList: Discount[];
|
|
28
25
|
};
|
|
29
|
-
setDiscountSelected(
|
|
30
|
-
discountId: number;
|
|
31
|
-
isSelected: boolean;
|
|
32
|
-
}): {
|
|
26
|
+
setDiscountSelected(params: SetDiscountSelectedParams): {
|
|
33
27
|
productList: Record<string, any>[];
|
|
34
28
|
discountList: Discount[];
|
|
35
29
|
};
|
|
@@ -47,6 +41,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
47
41
|
private setDiscountList;
|
|
48
42
|
private getDiscountList;
|
|
49
43
|
private getCustomerWallet;
|
|
44
|
+
private bestDiscount;
|
|
50
45
|
private loadPrepareConfig;
|
|
51
46
|
}
|
|
52
47
|
export default ShopDiscountImpl;
|