@pisell/pisellos 2.1.3 → 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/Date/index.d.ts +17 -0
- package/dist/modules/Date/index.js +92 -4
- 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/Date/index.d.ts +17 -0
- package/lib/modules/Date/index.js +64 -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,342 @@
|
|
|
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/modules/Payment/cashRecommendationAlgorithm.ts
|
|
20
|
+
var cashRecommendationAlgorithm_exports = {};
|
|
21
|
+
__export(cashRecommendationAlgorithm_exports, {
|
|
22
|
+
CURRENCY_DENOMINATIONS: () => CURRENCY_DENOMINATIONS,
|
|
23
|
+
recommendOptimalPayments: () => recommendOptimalPayments
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(cashRecommendationAlgorithm_exports);
|
|
26
|
+
var CURRENCY_DENOMINATIONS = {
|
|
27
|
+
// 美元
|
|
28
|
+
"USD": [100, 50, 20, 10, 5, 2, 1, 0.5, 0.25, 0.1, 0.05, 0.01],
|
|
29
|
+
// 人民币
|
|
30
|
+
"CNY": [100, 50, 20, 10, 5, 1, 0.5, 0.1, 0.05, 0.01],
|
|
31
|
+
"RMB": [100, 50, 20, 10, 5, 1, 0.5, 0.1, 0.05, 0.01],
|
|
32
|
+
// 欧元
|
|
33
|
+
"EUR": [500, 200, 100, 50, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, 0.02, 0.01],
|
|
34
|
+
// 日元
|
|
35
|
+
"JPY": [1e4, 5e3, 2e3, 1e3, 500, 100, 50, 10, 5, 1],
|
|
36
|
+
// 英镑
|
|
37
|
+
"GBP": [50, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, 0.02, 0.01],
|
|
38
|
+
// 澳元
|
|
39
|
+
"AUD": [100, 50, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1],
|
|
40
|
+
// 加元
|
|
41
|
+
"CAD": [100, 50, 20, 10, 5, 2, 1, 0.25, 0.1, 0.05],
|
|
42
|
+
// 港元
|
|
43
|
+
"HKD": [1e3, 500, 100, 50, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1],
|
|
44
|
+
// 新台币
|
|
45
|
+
"TWD": [2e3, 1e3, 500, 200, 100, 50, 10, 5, 1],
|
|
46
|
+
// 韩元
|
|
47
|
+
"KRW": [5e4, 1e4, 5e3, 1e3, 500, 100, 50, 10, 5, 1],
|
|
48
|
+
// 新加坡元
|
|
49
|
+
"SGD": [1e4, 1e3, 100, 50, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, 0.01],
|
|
50
|
+
// 瑞士法郎
|
|
51
|
+
"CHF": [1e3, 200, 100, 50, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05],
|
|
52
|
+
// 默认通用面额(如果币种不在列表中)
|
|
53
|
+
"DEFAULT": [100, 50, 20, 10, 5, 1, 0.5, 0.25, 0.1, 0.05, 0.01]
|
|
54
|
+
};
|
|
55
|
+
function recommendOptimalPayments(targetAmount, denominations) {
|
|
56
|
+
if (targetAmount <= 0 || !isFinite(targetAmount) || isNaN(targetAmount)) {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
if (!denominations || !Array.isArray(denominations) || denominations.length === 0) {
|
|
60
|
+
return [Math.ceil(targetAmount)];
|
|
61
|
+
}
|
|
62
|
+
const maxReasonableDenom = targetAmount * 5;
|
|
63
|
+
const validDenoms = denominations.filter((denom) => denom > 0 && isFinite(denom) && !isNaN(denom) && denom <= maxReasonableDenom).slice(0, 8);
|
|
64
|
+
if (validDenoms.length === 0) {
|
|
65
|
+
return [Math.ceil(targetAmount)];
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
const precision = 100;
|
|
69
|
+
const target = Math.round(targetAmount * precision);
|
|
70
|
+
const denoms = validDenoms.map((d) => Math.round(d * precision)).sort((a, b) => b - a);
|
|
71
|
+
const paymentOptions = [];
|
|
72
|
+
const exactCombination = findExactCombination(target, denoms, precision);
|
|
73
|
+
if (exactCombination) {
|
|
74
|
+
paymentOptions.push(exactCombination);
|
|
75
|
+
}
|
|
76
|
+
for (let i = 0; i < Math.min(denoms.length, 6); i++) {
|
|
77
|
+
const denom = denoms[i];
|
|
78
|
+
const count = Math.ceil(target / denom);
|
|
79
|
+
const sum = count * denom;
|
|
80
|
+
if (sum >= target && count <= 12) {
|
|
81
|
+
paymentOptions.push({
|
|
82
|
+
combination: Array(count).fill(denom / precision),
|
|
83
|
+
sum: sum / precision,
|
|
84
|
+
coinCount: count,
|
|
85
|
+
denomTypes: 1
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
for (let i = 0; i < Math.min(denoms.length - 1, 5); i++) {
|
|
90
|
+
for (let j = i + 1; j < Math.min(denoms.length, 6); j++) {
|
|
91
|
+
const denom1 = denoms[i];
|
|
92
|
+
const denom2 = denoms[j];
|
|
93
|
+
const maxCount1 = Math.min(Math.ceil(target / denom1) + 1, 8);
|
|
94
|
+
const maxCount2 = Math.min(Math.ceil(target / denom2) + 1, 10);
|
|
95
|
+
for (let count1 = 1; count1 <= maxCount1; count1++) {
|
|
96
|
+
for (let count2 = 1; count2 <= maxCount2; count2++) {
|
|
97
|
+
const sum = count1 * denom1 + count2 * denom2;
|
|
98
|
+
if (sum >= target) {
|
|
99
|
+
const combination = [
|
|
100
|
+
...Array(count1).fill(denom1 / precision),
|
|
101
|
+
...Array(count2).fill(denom2 / precision)
|
|
102
|
+
];
|
|
103
|
+
paymentOptions.push({
|
|
104
|
+
combination,
|
|
105
|
+
sum: sum / precision,
|
|
106
|
+
coinCount: count1 + count2,
|
|
107
|
+
denomTypes: 2
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
for (let i = 0; i < Math.min(denoms.length - 2, 3); i++) {
|
|
115
|
+
for (let j = i + 1; j < Math.min(denoms.length - 1, 4); j++) {
|
|
116
|
+
for (let k = j + 1; k < Math.min(denoms.length, 5); k++) {
|
|
117
|
+
const denom1 = denoms[i];
|
|
118
|
+
const denom2 = denoms[j];
|
|
119
|
+
const denom3 = denoms[k];
|
|
120
|
+
const maxCount1 = Math.min(Math.ceil(target / denom1) + 1, 5);
|
|
121
|
+
const maxCount2 = Math.min(Math.ceil(target / denom2) + 1, 6);
|
|
122
|
+
const maxCount3 = Math.min(Math.ceil(target / denom3) + 1, 8);
|
|
123
|
+
for (let count1 = 1; count1 <= maxCount1; count1++) {
|
|
124
|
+
for (let count2 = 1; count2 <= maxCount2; count2++) {
|
|
125
|
+
for (let count3 = 1; count3 <= maxCount3; count3++) {
|
|
126
|
+
const sum = count1 * denom1 + count2 * denom2 + count3 * denom3;
|
|
127
|
+
if (sum >= target) {
|
|
128
|
+
const combination = [
|
|
129
|
+
...Array(count1).fill(denom1 / precision),
|
|
130
|
+
...Array(count2).fill(denom2 / precision),
|
|
131
|
+
...Array(count3).fill(denom3 / precision)
|
|
132
|
+
];
|
|
133
|
+
paymentOptions.push({
|
|
134
|
+
combination,
|
|
135
|
+
sum: sum / precision,
|
|
136
|
+
coinCount: count1 + count2 + count3,
|
|
137
|
+
denomTypes: 3
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
for (let i = 0; i < Math.min(denoms.length - 3, 2); i++) {
|
|
147
|
+
for (let j = i + 1; j < Math.min(denoms.length - 2, 3); j++) {
|
|
148
|
+
for (let k = j + 1; k < Math.min(denoms.length - 1, 4); k++) {
|
|
149
|
+
for (let l = k + 1; l < Math.min(denoms.length, 5); l++) {
|
|
150
|
+
const denom1 = denoms[i];
|
|
151
|
+
const denom2 = denoms[j];
|
|
152
|
+
const denom3 = denoms[k];
|
|
153
|
+
const denom4 = denoms[l];
|
|
154
|
+
const maxCount1 = Math.min(Math.ceil(target / denom1) + 1, 3);
|
|
155
|
+
const maxCount2 = Math.min(Math.ceil(target / denom2) + 1, 4);
|
|
156
|
+
const maxCount3 = Math.min(Math.ceil(target / denom3) + 1, 5);
|
|
157
|
+
const maxCount4 = Math.min(Math.ceil(target / denom4) + 1, 6);
|
|
158
|
+
for (let count1 = 1; count1 <= maxCount1; count1++) {
|
|
159
|
+
for (let count2 = 1; count2 <= maxCount2; count2++) {
|
|
160
|
+
for (let count3 = 1; count3 <= maxCount3; count3++) {
|
|
161
|
+
for (let count4 = 1; count4 <= maxCount4; count4++) {
|
|
162
|
+
const sum = count1 * denom1 + count2 * denom2 + count3 * denom3 + count4 * denom4;
|
|
163
|
+
if (sum >= target) {
|
|
164
|
+
const combination = [
|
|
165
|
+
...Array(count1).fill(denom1 / precision),
|
|
166
|
+
...Array(count2).fill(denom2 / precision),
|
|
167
|
+
...Array(count3).fill(denom3 / precision),
|
|
168
|
+
...Array(count4).fill(denom4 / precision)
|
|
169
|
+
];
|
|
170
|
+
paymentOptions.push({
|
|
171
|
+
combination,
|
|
172
|
+
sum: sum / precision,
|
|
173
|
+
coinCount: count1 + count2 + count3 + count4,
|
|
174
|
+
denomTypes: 4
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (paymentOptions.length === 0) {
|
|
186
|
+
const minValidDenom = validDenoms.find((denom) => denom >= targetAmount);
|
|
187
|
+
if (minValidDenom) {
|
|
188
|
+
return [minValidDenom];
|
|
189
|
+
} else {
|
|
190
|
+
const maxDenom = Math.max(...validDenoms);
|
|
191
|
+
const count = Math.ceil(targetAmount / maxDenom);
|
|
192
|
+
return [count * maxDenom];
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
const uniqueCombinations = removeDuplicateAndExtendedCombinations(paymentOptions, targetAmount);
|
|
196
|
+
uniqueCombinations.sort((a, b) => {
|
|
197
|
+
if (a.denomTypes !== b.denomTypes) {
|
|
198
|
+
return a.denomTypes - b.denomTypes;
|
|
199
|
+
}
|
|
200
|
+
if (a.coinCount !== b.coinCount) {
|
|
201
|
+
return a.coinCount - b.coinCount;
|
|
202
|
+
}
|
|
203
|
+
return a.sum - b.sum;
|
|
204
|
+
});
|
|
205
|
+
const uniqueAmounts = /* @__PURE__ */ new Set();
|
|
206
|
+
const finalResults = [];
|
|
207
|
+
for (const item of uniqueCombinations) {
|
|
208
|
+
const roundedAmount = Math.round(item.sum * 100) / 100;
|
|
209
|
+
if (!uniqueAmounts.has(roundedAmount) && finalResults.length < 10) {
|
|
210
|
+
uniqueAmounts.add(roundedAmount);
|
|
211
|
+
finalResults.push(roundedAmount);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return finalResults.sort((a, b) => a - b);
|
|
215
|
+
} catch (error) {
|
|
216
|
+
console.warn("推荐支付金额计算出错:", error);
|
|
217
|
+
const safeAmount = Math.ceil(targetAmount);
|
|
218
|
+
return [targetAmount, safeAmount];
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
function findExactCombination(target, denoms, precision) {
|
|
222
|
+
function dfs(remaining, denomIndex, currentCombination) {
|
|
223
|
+
if (remaining === 0) {
|
|
224
|
+
return currentCombination;
|
|
225
|
+
}
|
|
226
|
+
if (remaining < 0 || denomIndex >= denoms.length || currentCombination.length > 10) {
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
const denom = denoms[denomIndex];
|
|
230
|
+
const maxCount = Math.min(Math.floor(remaining / denom), 8);
|
|
231
|
+
for (let count = maxCount; count >= 0; count--) {
|
|
232
|
+
const newCombination = [...currentCombination, ...Array(count).fill(denom)];
|
|
233
|
+
const result = dfs(remaining - count * denom, denomIndex + 1, newCombination);
|
|
234
|
+
if (result) {
|
|
235
|
+
return result;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
const exactMatch = dfs(target, 0, []);
|
|
241
|
+
if (exactMatch && exactMatch.length > 0) {
|
|
242
|
+
const denomTypes = new Set(exactMatch).size;
|
|
243
|
+
return {
|
|
244
|
+
combination: exactMatch.map((d) => d / precision),
|
|
245
|
+
sum: target / precision,
|
|
246
|
+
coinCount: exactMatch.length,
|
|
247
|
+
denomTypes
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
function removeDuplicateAndExtendedCombinations(combinations, targetAmount) {
|
|
253
|
+
const result = [];
|
|
254
|
+
combinations.sort((a, b) => {
|
|
255
|
+
if (a.denomTypes !== b.denomTypes) {
|
|
256
|
+
return a.denomTypes - b.denomTypes;
|
|
257
|
+
}
|
|
258
|
+
if (a.coinCount !== b.coinCount) {
|
|
259
|
+
return a.coinCount - b.coinCount;
|
|
260
|
+
}
|
|
261
|
+
return a.sum - b.sum;
|
|
262
|
+
});
|
|
263
|
+
for (let i = 0; i < combinations.length; i++) {
|
|
264
|
+
const current = combinations[i];
|
|
265
|
+
let shouldSkip = false;
|
|
266
|
+
for (let j = 0; j < result.length; j++) {
|
|
267
|
+
const existing = result[j];
|
|
268
|
+
if (isSameCombination(current.combination, existing.combination)) {
|
|
269
|
+
shouldSkip = true;
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
if (isExtensionOf(current.combination, existing.combination)) {
|
|
273
|
+
shouldSkip = true;
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
if (!shouldSkip) {
|
|
278
|
+
for (let j = result.length - 1; j >= 0; j--) {
|
|
279
|
+
if (isExtensionOf(result[j].combination, current.combination)) {
|
|
280
|
+
result.splice(j, 1);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
result.push(current);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return result;
|
|
287
|
+
}
|
|
288
|
+
function isExtensionOf(combinationA, combinationB) {
|
|
289
|
+
if (combinationA.length <= combinationB.length) {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
const countA = {};
|
|
293
|
+
const countB = {};
|
|
294
|
+
combinationA.forEach((coin) => {
|
|
295
|
+
countA[coin] = (countA[coin] || 0) + 1;
|
|
296
|
+
});
|
|
297
|
+
combinationB.forEach((coin) => {
|
|
298
|
+
countB[coin] = (countB[coin] || 0) + 1;
|
|
299
|
+
});
|
|
300
|
+
for (const coin in countB) {
|
|
301
|
+
if (!countA[coin] || countA[coin] < countB[coin]) {
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
let hasExtra = false;
|
|
306
|
+
for (const coin in countA) {
|
|
307
|
+
if (countA[coin] > (countB[coin] || 0)) {
|
|
308
|
+
hasExtra = true;
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return hasExtra;
|
|
313
|
+
}
|
|
314
|
+
function isSameCombination(combinationA, combinationB) {
|
|
315
|
+
if (combinationA.length !== combinationB.length) {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
const countA = {};
|
|
319
|
+
const countB = {};
|
|
320
|
+
combinationA.forEach((coin) => {
|
|
321
|
+
countA[coin] = (countA[coin] || 0) + 1;
|
|
322
|
+
});
|
|
323
|
+
combinationB.forEach((coin) => {
|
|
324
|
+
countB[coin] = (countB[coin] || 0) + 1;
|
|
325
|
+
});
|
|
326
|
+
for (const coin in countA) {
|
|
327
|
+
if (countA[coin] !== (countB[coin] || 0)) {
|
|
328
|
+
return false;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
for (const coin in countB) {
|
|
332
|
+
if (countB[coin] !== (countA[coin] || 0)) {
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return true;
|
|
337
|
+
}
|
|
338
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
339
|
+
0 && (module.exports = {
|
|
340
|
+
CURRENCY_DENOMINATIONS,
|
|
341
|
+
recommendOptimalPayments
|
|
342
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EftposPayment } from './types';
|
|
2
|
+
import type { PaymentModule } from './index';
|
|
3
|
+
/**
|
|
4
|
+
* Eftpos支付实现
|
|
5
|
+
*/
|
|
6
|
+
export declare class EftposPaymentImpl implements EftposPayment {
|
|
7
|
+
private paymentModule;
|
|
8
|
+
constructor(paymentModule: PaymentModule);
|
|
9
|
+
processEftposPayment(amount: number, orderUuid: string): Promise<void>;
|
|
10
|
+
checkDeviceStatus(): Promise<boolean>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
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/modules/Payment/eftpos.ts
|
|
20
|
+
var eftpos_exports = {};
|
|
21
|
+
__export(eftpos_exports, {
|
|
22
|
+
EftposPaymentImpl: () => EftposPaymentImpl
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(eftpos_exports);
|
|
25
|
+
var EftposPaymentImpl = class {
|
|
26
|
+
constructor(paymentModule) {
|
|
27
|
+
this.paymentModule = paymentModule;
|
|
28
|
+
}
|
|
29
|
+
async processEftposPayment(amount, orderUuid) {
|
|
30
|
+
const eftposMethod = await this.paymentModule.getEftposPaymentMethod();
|
|
31
|
+
if (!eftposMethod) {
|
|
32
|
+
throw new Error("Eftpos支付方式未找到");
|
|
33
|
+
}
|
|
34
|
+
const paymentItem = {
|
|
35
|
+
amount: amount.toString(),
|
|
36
|
+
code: eftposMethod.code,
|
|
37
|
+
id: eftposMethod.id,
|
|
38
|
+
name: eftposMethod.name,
|
|
39
|
+
type: eftposMethod.type,
|
|
40
|
+
voucher_id: ""
|
|
41
|
+
};
|
|
42
|
+
await this.paymentModule.addPaymentItemAsync(orderUuid, paymentItem);
|
|
43
|
+
}
|
|
44
|
+
async checkDeviceStatus() {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
EftposPaymentImpl
|
|
51
|
+
});
|
|
@@ -1,16 +1,191 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
|
+
import { RequestPlugin } from '../../plugins';
|
|
2
3
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import {
|
|
4
|
+
import { PaymentModuleAPI, PaymentMethod, PaymentOrder, PaymentItem, PaymentItemInput, PaymentUpdateFields, PushOrderParams, CashPayment, EftposPayment, WalletPassPayment, RoundingRule, RoundingInterval, RoundingResult } from './types';
|
|
5
|
+
export * from './types';
|
|
6
|
+
export { generateRequestUniqueId };
|
|
7
|
+
/**
|
|
8
|
+
* 生成请求唯一ID
|
|
9
|
+
* 格式: 年月日时分秒毫秒+4位随机数
|
|
10
|
+
* 示例: 20241201143025123456
|
|
11
|
+
*/
|
|
12
|
+
declare function generateRequestUniqueId(): string;
|
|
13
|
+
/**
|
|
14
|
+
* 支付模块实现
|
|
15
|
+
*
|
|
16
|
+
* 负责处理支付相关的数据管理和本地存储
|
|
17
|
+
*/
|
|
4
18
|
export declare class PaymentModule extends BaseModule implements Module, PaymentModuleAPI {
|
|
5
19
|
protected defaultName: string;
|
|
6
20
|
protected defaultVersion: string;
|
|
7
|
-
|
|
21
|
+
request: RequestPlugin;
|
|
22
|
+
private app;
|
|
23
|
+
private store;
|
|
24
|
+
private dbManager;
|
|
25
|
+
private logger;
|
|
26
|
+
protected otherParams: any;
|
|
27
|
+
cash: CashPayment;
|
|
28
|
+
eftpos: EftposPayment;
|
|
29
|
+
wallet: WalletPassPayment;
|
|
8
30
|
constructor(name?: string, version?: string);
|
|
9
|
-
initialize(core: PisellCore, options
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
31
|
+
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* 记录信息日志
|
|
34
|
+
*/
|
|
35
|
+
logInfo(title: string, metadata?: any): void;
|
|
36
|
+
/**
|
|
37
|
+
* 记录警告日志
|
|
38
|
+
*/
|
|
39
|
+
logWarning(title: string, metadata?: any): void;
|
|
40
|
+
/**
|
|
41
|
+
* 记录错误日志
|
|
42
|
+
*/
|
|
43
|
+
logError(title: string, error?: any, metadata?: any): void;
|
|
44
|
+
/**
|
|
45
|
+
* 记录调试日志
|
|
46
|
+
*/
|
|
47
|
+
logDebug(title: string, metadata?: any): void;
|
|
48
|
+
/**
|
|
49
|
+
* 网络恢复以后,尝试执行队列
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
52
|
+
private registerNetworkHandlers;
|
|
53
|
+
/**
|
|
54
|
+
* 获取支付方式列表
|
|
55
|
+
*/
|
|
56
|
+
getPayMethodListAsync(): Promise<PaymentMethod[]>;
|
|
57
|
+
/**
|
|
58
|
+
* 后台刷新支付方式列表
|
|
59
|
+
*/
|
|
60
|
+
private refreshPaymentMethodsInBackground;
|
|
61
|
+
/**
|
|
62
|
+
* 检查支付方式列表是否有变化
|
|
63
|
+
*/
|
|
64
|
+
private hasPaymentMethodsChanged;
|
|
65
|
+
/**
|
|
66
|
+
* 获取订单列表
|
|
67
|
+
*/
|
|
68
|
+
getOrderListAsync(): Promise<PaymentOrder[]>;
|
|
69
|
+
/**
|
|
70
|
+
* 根据订单UUID获取支付订单(新方法)
|
|
71
|
+
*/
|
|
72
|
+
getPaymentOrderByUuidAsync(orderUuid: string): Promise<PaymentOrder | null>;
|
|
73
|
+
/**
|
|
74
|
+
* 创建支付订单(新方法,专注支付数据)
|
|
75
|
+
*/
|
|
76
|
+
createPaymentOrderAsync(params: PushOrderParams): Promise<PaymentOrder>;
|
|
77
|
+
/**
|
|
78
|
+
* 删除支付订单(新方法)
|
|
79
|
+
*/
|
|
80
|
+
deletePaymentOrderAsync(orderUuid: string): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* 更新订单
|
|
83
|
+
*/
|
|
84
|
+
updateOrderAsync(orderUuid: string, params: Partial<PaymentOrder>): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* 基于UUID替换订单ID
|
|
87
|
+
*
|
|
88
|
+
* 此方法用于将本地虚拟订单ID替换为真实的订单ID。
|
|
89
|
+
* 当前端模拟下单流程完成后,后端返回真实订单ID时调用此方法。
|
|
90
|
+
*
|
|
91
|
+
* @param orderUuid 订单的UUID
|
|
92
|
+
* @param newOrderId 新的订单ID (来自后端)
|
|
93
|
+
* @returns 更新后的订单对象,如果订单不存在则返回null
|
|
94
|
+
*/
|
|
95
|
+
replaceOrderIdByUuidAsync(orderUuid: string, newOrderId: string): Promise<PaymentOrder | null>;
|
|
96
|
+
/**
|
|
97
|
+
* 获取支付项(新方法)
|
|
98
|
+
*
|
|
99
|
+
* @param orderUuid 订单UUID
|
|
100
|
+
* @param includeVoided 是否包含已撤销的支付项,默认为false
|
|
101
|
+
* @returns 支付项数组
|
|
102
|
+
*/
|
|
103
|
+
getPaymentItemsAsync(orderUuid: string, includeVoided?: boolean): Promise<PaymentItem[]>;
|
|
104
|
+
/**
|
|
105
|
+
* 获取所有支付项(包括已撤销的)
|
|
106
|
+
*
|
|
107
|
+
* @param orderUuid 订单UUID
|
|
108
|
+
* @returns 所有支付项数组(包括撤销的)
|
|
109
|
+
*/
|
|
110
|
+
getAllPaymentItemsAsync(orderUuid: string): Promise<PaymentItem[]>;
|
|
111
|
+
/**
|
|
112
|
+
* 为某个订单添加支付项(新方法)
|
|
113
|
+
*/
|
|
114
|
+
addPaymentItemAsync(orderUuid: string, paymentItem: PaymentItemInput): Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* 删除一个支付项 - 标记删除而非物理删除
|
|
117
|
+
*/
|
|
118
|
+
deletePaymentAsync(orderUuid: string, paymentUuid: string): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* 批量更新代金券类支付项(覆盖更新)
|
|
121
|
+
*
|
|
122
|
+
* 删除所有现有的带 voucher_id 的支付项,然后添加新的代金券支付项
|
|
123
|
+
* 这是一个覆盖式更新,确保代金券支付项的一致性
|
|
124
|
+
*/
|
|
125
|
+
updateVoucherPaymentItemsAsync(orderUuid: string, voucherPaymentItems: PaymentItemInput[]): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* 更新一个支付项
|
|
128
|
+
*/
|
|
129
|
+
updatePaymentAsync(orderUuid: string, paymentUuid: string, params: PaymentUpdateFields): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* 提交支付
|
|
132
|
+
*/
|
|
133
|
+
submitPayAsync(orderUuid?: string): Promise<{
|
|
134
|
+
status: 'success' | 'failed';
|
|
135
|
+
}>;
|
|
136
|
+
/**
|
|
137
|
+
* 提交单个订单的支付(推送到任务队列)
|
|
138
|
+
*/
|
|
139
|
+
private submitSingleOrderPayment;
|
|
140
|
+
/**
|
|
141
|
+
* 获取订单剩余待付金额
|
|
142
|
+
*/
|
|
143
|
+
getRemainingOrderAmountAsync(orderUuid: string): Promise<number>;
|
|
144
|
+
/**
|
|
145
|
+
* 在比如现金支付界面的地方,用户输入了一个金额,在下方显示剩余多少金额,通过此方法获取
|
|
146
|
+
*/
|
|
147
|
+
getRemainingOrderAmountWithInputAsync(inputAmount: string | number, orderUuid: string): Promise<number>;
|
|
148
|
+
/**
|
|
149
|
+
* 重新计算订单金额
|
|
150
|
+
*/
|
|
151
|
+
private recalculateOrderAmount;
|
|
152
|
+
/**
|
|
153
|
+
* 获取现金支付方式
|
|
154
|
+
*/
|
|
155
|
+
getCashPaymentMethod(): Promise<PaymentMethod | null>;
|
|
156
|
+
/**
|
|
157
|
+
* 获取Eftpos支付方式
|
|
158
|
+
*/
|
|
159
|
+
getEftposPaymentMethod(): Promise<PaymentMethod | null>;
|
|
160
|
+
/**
|
|
161
|
+
* 获取钱包支付方式
|
|
162
|
+
*/
|
|
163
|
+
getWalletPaymentMethod(): Promise<PaymentMethod | null>;
|
|
164
|
+
/**
|
|
165
|
+
* 确保支付模块所需的数据库表已创建
|
|
166
|
+
*/
|
|
167
|
+
private ensurePaymentTables;
|
|
168
|
+
/**
|
|
169
|
+
* 获取部分支付的订单
|
|
170
|
+
*/
|
|
171
|
+
getPartiallyPaidOrdersAsync(): Promise<PaymentOrder[]>;
|
|
172
|
+
/**
|
|
173
|
+
* 智能金额舍入
|
|
174
|
+
*
|
|
175
|
+
* 根据指定的舍入间隔和规则对金额进行舍入处理
|
|
176
|
+
*
|
|
177
|
+
* @param originalAmount 原始金额
|
|
178
|
+
* @param interval 舍入间隔 (0.05, 0.1, 0.5, 1)
|
|
179
|
+
* @param rule 舍入规则 (standard, standard_down, always_up, always_down)
|
|
180
|
+
* @returns 舍入结果详情(包含原始金额、舍入后金额和舍入差额)
|
|
181
|
+
*/
|
|
182
|
+
roundAmountAsync(originalAmount: number | string, interval: RoundingInterval | number, rule: RoundingRule | string): Promise<RoundingResult>;
|
|
183
|
+
/**
|
|
184
|
+
* 标准舍入处理(处理中点情况)
|
|
185
|
+
*
|
|
186
|
+
* @param value 要舍入的值
|
|
187
|
+
* @param midpointUp 中点是否向上舍入
|
|
188
|
+
* @returns 舍入后的值
|
|
189
|
+
*/
|
|
190
|
+
private standardRound;
|
|
16
191
|
}
|