@pisell/pisellos 2.1.4 → 2.1.6
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 +77 -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 +60 -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,97 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
7
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
+
import { CURRENCY_DENOMINATIONS, recommendOptimalPayments } from "./cashRecommendationAlgorithm";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 现金支付实现
|
|
14
|
+
*/
|
|
15
|
+
export var CashPaymentImpl = /*#__PURE__*/function () {
|
|
16
|
+
function CashPaymentImpl(paymentModule) {
|
|
17
|
+
_classCallCheck(this, CashPaymentImpl);
|
|
18
|
+
this.paymentModule = paymentModule;
|
|
19
|
+
}
|
|
20
|
+
_createClass(CashPaymentImpl, [{
|
|
21
|
+
key: "processCashPayment",
|
|
22
|
+
value: function () {
|
|
23
|
+
var _processCashPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(amount, orderUuid) {
|
|
24
|
+
var cashMethod, paymentItem;
|
|
25
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
26
|
+
while (1) switch (_context.prev = _context.next) {
|
|
27
|
+
case 0:
|
|
28
|
+
_context.next = 2;
|
|
29
|
+
return this.paymentModule.getCashPaymentMethod();
|
|
30
|
+
case 2:
|
|
31
|
+
cashMethod = _context.sent;
|
|
32
|
+
if (cashMethod) {
|
|
33
|
+
_context.next = 5;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
throw new Error('现金支付方式未找到');
|
|
37
|
+
case 5:
|
|
38
|
+
paymentItem = {
|
|
39
|
+
amount: amount.toString(),
|
|
40
|
+
code: cashMethod.code,
|
|
41
|
+
id: cashMethod.id,
|
|
42
|
+
name: cashMethod.name,
|
|
43
|
+
type: cashMethod.type,
|
|
44
|
+
voucher_id: ''
|
|
45
|
+
};
|
|
46
|
+
_context.next = 8;
|
|
47
|
+
return this.paymentModule.addPaymentItemAsync(orderUuid, paymentItem);
|
|
48
|
+
case 8:
|
|
49
|
+
case "end":
|
|
50
|
+
return _context.stop();
|
|
51
|
+
}
|
|
52
|
+
}, _callee, this);
|
|
53
|
+
}));
|
|
54
|
+
function processCashPayment(_x, _x2) {
|
|
55
|
+
return _processCashPayment.apply(this, arguments);
|
|
56
|
+
}
|
|
57
|
+
return processCashPayment;
|
|
58
|
+
}()
|
|
59
|
+
}, {
|
|
60
|
+
key: "getCashBalance",
|
|
61
|
+
value: function () {
|
|
62
|
+
var _getCashBalance = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
63
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
64
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
65
|
+
case 0:
|
|
66
|
+
return _context2.abrupt("return", 0);
|
|
67
|
+
case 1:
|
|
68
|
+
case "end":
|
|
69
|
+
return _context2.stop();
|
|
70
|
+
}
|
|
71
|
+
}, _callee2);
|
|
72
|
+
}));
|
|
73
|
+
function getCashBalance() {
|
|
74
|
+
return _getCashBalance.apply(this, arguments);
|
|
75
|
+
}
|
|
76
|
+
return getCashBalance;
|
|
77
|
+
}()
|
|
78
|
+
/**
|
|
79
|
+
* 获取推荐支付金额
|
|
80
|
+
* 基于目标金额和货币类型,返回最优支付金额建议
|
|
81
|
+
* @param money 目标支付金额
|
|
82
|
+
* @param currency 货币代码 (如: 'CNY', 'USD', 'EUR' 等)
|
|
83
|
+
* @returns 推荐支付金额数组
|
|
84
|
+
*/
|
|
85
|
+
}, {
|
|
86
|
+
key: "getRecommendedAmount",
|
|
87
|
+
value: function getRecommendedAmount(money, currency) {
|
|
88
|
+
// 获取对应货币的面额配置
|
|
89
|
+
var upperCurrency = currency.toUpperCase();
|
|
90
|
+
var denominations = CURRENCY_DENOMINATIONS[upperCurrency] || CURRENCY_DENOMINATIONS['DEFAULT'];
|
|
91
|
+
|
|
92
|
+
// 直接调用算法,所有验证和容错处理都在算法内部
|
|
93
|
+
return recommendOptimalPayments(money, denominations);
|
|
94
|
+
}
|
|
95
|
+
}]);
|
|
96
|
+
return CashPaymentImpl;
|
|
97
|
+
}();
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 现金支付推荐算法
|
|
3
|
+
*
|
|
4
|
+
* 核心原理:
|
|
5
|
+
* 1. 每个推荐金额都应该是独立的最优组合
|
|
6
|
+
* 2. 不推荐在已有最优解基础上添加额外面额的组合
|
|
7
|
+
* 3. 优先推荐使用不同数量币种的组合
|
|
8
|
+
* 4. 根据组合判断去重,避免扩展组合
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* 常见国家货币面额配置
|
|
12
|
+
*/
|
|
13
|
+
export declare const CURRENCY_DENOMINATIONS: Record<string, number[]>;
|
|
14
|
+
/**
|
|
15
|
+
* 最优支付金额推荐算法
|
|
16
|
+
* 推荐通过不同数量面额组合刚好足够支付的最小金额
|
|
17
|
+
*
|
|
18
|
+
* @param targetAmount 目标金额
|
|
19
|
+
* @param denominations 币种面值数组
|
|
20
|
+
* @returns 推荐支付金额数组
|
|
21
|
+
*/
|
|
22
|
+
export declare function recommendOptimalPayments(targetAmount: number, denominations: number[]): number[];
|
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
+
/**
|
|
8
|
+
* 现金支付推荐算法
|
|
9
|
+
*
|
|
10
|
+
* 核心原理:
|
|
11
|
+
* 1. 每个推荐金额都应该是独立的最优组合
|
|
12
|
+
* 2. 不推荐在已有最优解基础上添加额外面额的组合
|
|
13
|
+
* 3. 优先推荐使用不同数量币种的组合
|
|
14
|
+
* 4. 根据组合判断去重,避免扩展组合
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 常见国家货币面额配置
|
|
19
|
+
*/
|
|
20
|
+
export var CURRENCY_DENOMINATIONS = {
|
|
21
|
+
// 美元
|
|
22
|
+
'USD': [100, 50, 20, 10, 5, 2, 1, 0.5, 0.25, 0.1, 0.05, 0.01],
|
|
23
|
+
// 人民币
|
|
24
|
+
'CNY': [100, 50, 20, 10, 5, 1, 0.5, 0.1, 0.05, 0.01],
|
|
25
|
+
'RMB': [100, 50, 20, 10, 5, 1, 0.5, 0.1, 0.05, 0.01],
|
|
26
|
+
// 欧元
|
|
27
|
+
'EUR': [500, 200, 100, 50, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, 0.02, 0.01],
|
|
28
|
+
// 日元
|
|
29
|
+
'JPY': [10000, 5000, 2000, 1000, 500, 100, 50, 10, 5, 1],
|
|
30
|
+
// 英镑
|
|
31
|
+
'GBP': [50, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, 0.02, 0.01],
|
|
32
|
+
// 澳元
|
|
33
|
+
'AUD': [100, 50, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1],
|
|
34
|
+
// 加元
|
|
35
|
+
'CAD': [100, 50, 20, 10, 5, 2, 1, 0.25, 0.1, 0.05],
|
|
36
|
+
// 港元
|
|
37
|
+
'HKD': [1000, 500, 100, 50, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1],
|
|
38
|
+
// 新台币
|
|
39
|
+
'TWD': [2000, 1000, 500, 200, 100, 50, 10, 5, 1],
|
|
40
|
+
// 韩元
|
|
41
|
+
'KRW': [50000, 10000, 5000, 1000, 500, 100, 50, 10, 5, 1],
|
|
42
|
+
// 新加坡元
|
|
43
|
+
'SGD': [10000, 1000, 100, 50, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, 0.01],
|
|
44
|
+
// 瑞士法郎
|
|
45
|
+
'CHF': [1000, 200, 100, 50, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05],
|
|
46
|
+
// 默认通用面额(如果币种不在列表中)
|
|
47
|
+
'DEFAULT': [100, 50, 20, 10, 5, 1, 0.5, 0.25, 0.1, 0.05, 0.01]
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 支付组合类型定义
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 最优支付金额推荐算法
|
|
56
|
+
* 推荐通过不同数量面额组合刚好足够支付的最小金额
|
|
57
|
+
*
|
|
58
|
+
* @param targetAmount 目标金额
|
|
59
|
+
* @param denominations 币种面值数组
|
|
60
|
+
* @returns 推荐支付金额数组
|
|
61
|
+
*/
|
|
62
|
+
export function recommendOptimalPayments(targetAmount, denominations) {
|
|
63
|
+
// 参数验证
|
|
64
|
+
if (targetAmount <= 0 || !isFinite(targetAmount) || isNaN(targetAmount)) {
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
if (!denominations || !Array.isArray(denominations) || denominations.length === 0) {
|
|
68
|
+
return [Math.ceil(targetAmount)];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 过滤有效面额并限制搜索空间以提高性能
|
|
72
|
+
var maxReasonableDenom = targetAmount * 5; // 适度限制搜索空间
|
|
73
|
+
var validDenoms = denominations.filter(function (denom) {
|
|
74
|
+
return denom > 0 && isFinite(denom) && !isNaN(denom) && denom <= maxReasonableDenom;
|
|
75
|
+
}).slice(0, 8); // 限制面额数量以提高性能
|
|
76
|
+
|
|
77
|
+
if (validDenoms.length === 0) {
|
|
78
|
+
// 如果没有合适的面额,返回最接近的整数金额
|
|
79
|
+
return [Math.ceil(targetAmount)];
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
// 处理精度问题,将金额转换为整数计算
|
|
83
|
+
var precision = 100; // 假设最小单位是0.01
|
|
84
|
+
var target = Math.round(targetAmount * precision);
|
|
85
|
+
var denoms = validDenoms.map(function (d) {
|
|
86
|
+
return Math.round(d * precision);
|
|
87
|
+
}).sort(function (a, b) {
|
|
88
|
+
return b - a;
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// 存储不同的支付组合方案
|
|
92
|
+
var paymentOptions = [];
|
|
93
|
+
|
|
94
|
+
// 首先尝试找到精确匹配的组合
|
|
95
|
+
var exactCombination = findExactCombination(target, denoms, precision);
|
|
96
|
+
if (exactCombination) {
|
|
97
|
+
paymentOptions.push(exactCombination);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// 为了提高效率,我们将按币种数量来生成组合
|
|
101
|
+
// 1币种组合:只用一种面额
|
|
102
|
+
for (var i = 0; i < Math.min(denoms.length, 6); i++) {
|
|
103
|
+
var denom = denoms[i];
|
|
104
|
+
var count = Math.ceil(target / denom);
|
|
105
|
+
var sum = count * denom;
|
|
106
|
+
if (sum >= target && count <= 12) {
|
|
107
|
+
// 限制硬币数量以提高性能
|
|
108
|
+
paymentOptions.push({
|
|
109
|
+
combination: Array(count).fill(denom / precision),
|
|
110
|
+
sum: sum / precision,
|
|
111
|
+
coinCount: count,
|
|
112
|
+
denomTypes: 1
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// 2币种组合:使用两种面额(大幅限制搜索范围以提高性能)
|
|
118
|
+
for (var _i = 0; _i < Math.min(denoms.length - 1, 5); _i++) {
|
|
119
|
+
for (var j = _i + 1; j < Math.min(denoms.length, 6); j++) {
|
|
120
|
+
var denom1 = denoms[_i];
|
|
121
|
+
var denom2 = denoms[j];
|
|
122
|
+
|
|
123
|
+
// 大幅限制搜索范围,基于目标金额动态调整
|
|
124
|
+
var maxCount1 = Math.min(Math.ceil(target / denom1) + 1, 8);
|
|
125
|
+
var maxCount2 = Math.min(Math.ceil(target / denom2) + 1, 10);
|
|
126
|
+
for (var count1 = 1; count1 <= maxCount1; count1++) {
|
|
127
|
+
for (var count2 = 1; count2 <= maxCount2; count2++) {
|
|
128
|
+
var _sum = count1 * denom1 + count2 * denom2;
|
|
129
|
+
if (_sum >= target) {
|
|
130
|
+
var combination = [].concat(_toConsumableArray(Array(count1).fill(denom1 / precision)), _toConsumableArray(Array(count2).fill(denom2 / precision)));
|
|
131
|
+
paymentOptions.push({
|
|
132
|
+
combination: combination,
|
|
133
|
+
sum: _sum / precision,
|
|
134
|
+
coinCount: count1 + count2,
|
|
135
|
+
denomTypes: 2
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// 3币种组合:使用三种面额(大幅限制搜索以提高效率)
|
|
144
|
+
for (var _i2 = 0; _i2 < Math.min(denoms.length - 2, 3); _i2++) {
|
|
145
|
+
for (var _j = _i2 + 1; _j < Math.min(denoms.length - 1, 4); _j++) {
|
|
146
|
+
for (var k = _j + 1; k < Math.min(denoms.length, 5); k++) {
|
|
147
|
+
var _denom = denoms[_i2];
|
|
148
|
+
var _denom2 = denoms[_j];
|
|
149
|
+
var denom3 = denoms[k];
|
|
150
|
+
|
|
151
|
+
// 大幅限制搜索范围
|
|
152
|
+
var _maxCount = Math.min(Math.ceil(target / _denom) + 1, 5);
|
|
153
|
+
var _maxCount2 = Math.min(Math.ceil(target / _denom2) + 1, 6);
|
|
154
|
+
var maxCount3 = Math.min(Math.ceil(target / denom3) + 1, 8);
|
|
155
|
+
for (var _count = 1; _count <= _maxCount; _count++) {
|
|
156
|
+
for (var _count2 = 1; _count2 <= _maxCount2; _count2++) {
|
|
157
|
+
for (var count3 = 1; count3 <= maxCount3; count3++) {
|
|
158
|
+
var _sum2 = _count * _denom + _count2 * _denom2 + count3 * denom3;
|
|
159
|
+
if (_sum2 >= target) {
|
|
160
|
+
var _combination = [].concat(_toConsumableArray(Array(_count).fill(_denom / precision)), _toConsumableArray(Array(_count2).fill(_denom2 / precision)), _toConsumableArray(Array(count3).fill(denom3 / precision)));
|
|
161
|
+
paymentOptions.push({
|
|
162
|
+
combination: _combination,
|
|
163
|
+
sum: _sum2 / precision,
|
|
164
|
+
coinCount: _count + _count2 + count3,
|
|
165
|
+
denomTypes: 3
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// 4币种组合:使用四种面额(极度限制搜索以提高性能)
|
|
176
|
+
for (var _i3 = 0; _i3 < Math.min(denoms.length - 3, 2); _i3++) {
|
|
177
|
+
for (var _j2 = _i3 + 1; _j2 < Math.min(denoms.length - 2, 3); _j2++) {
|
|
178
|
+
for (var _k = _j2 + 1; _k < Math.min(denoms.length - 1, 4); _k++) {
|
|
179
|
+
for (var l = _k + 1; l < Math.min(denoms.length, 5); l++) {
|
|
180
|
+
var _denom3 = denoms[_i3];
|
|
181
|
+
var _denom4 = denoms[_j2];
|
|
182
|
+
var _denom5 = denoms[_k];
|
|
183
|
+
var denom4 = denoms[l];
|
|
184
|
+
|
|
185
|
+
// 极度限制搜索范围
|
|
186
|
+
var _maxCount3 = Math.min(Math.ceil(target / _denom3) + 1, 3);
|
|
187
|
+
var _maxCount4 = Math.min(Math.ceil(target / _denom4) + 1, 4);
|
|
188
|
+
var _maxCount5 = Math.min(Math.ceil(target / _denom5) + 1, 5);
|
|
189
|
+
var maxCount4 = Math.min(Math.ceil(target / denom4) + 1, 6);
|
|
190
|
+
for (var _count3 = 1; _count3 <= _maxCount3; _count3++) {
|
|
191
|
+
for (var _count4 = 1; _count4 <= _maxCount4; _count4++) {
|
|
192
|
+
for (var _count5 = 1; _count5 <= _maxCount5; _count5++) {
|
|
193
|
+
for (var count4 = 1; count4 <= maxCount4; count4++) {
|
|
194
|
+
var _sum3 = _count3 * _denom3 + _count4 * _denom4 + _count5 * _denom5 + count4 * denom4;
|
|
195
|
+
if (_sum3 >= target) {
|
|
196
|
+
var _combination2 = [].concat(_toConsumableArray(Array(_count3).fill(_denom3 / precision)), _toConsumableArray(Array(_count4).fill(_denom4 / precision)), _toConsumableArray(Array(_count5).fill(_denom5 / precision)), _toConsumableArray(Array(count4).fill(denom4 / precision)));
|
|
197
|
+
paymentOptions.push({
|
|
198
|
+
combination: _combination2,
|
|
199
|
+
sum: _sum3 / precision,
|
|
200
|
+
coinCount: _count3 + _count4 + _count5 + count4,
|
|
201
|
+
denomTypes: 4
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// 如果没有找到任何组合,提供默认建议
|
|
214
|
+
if (paymentOptions.length === 0) {
|
|
215
|
+
// 找到大于等于目标金额的最小面额
|
|
216
|
+
var minValidDenom = validDenoms.find(function (denom) {
|
|
217
|
+
return denom >= targetAmount;
|
|
218
|
+
});
|
|
219
|
+
if (minValidDenom) {
|
|
220
|
+
return [minValidDenom];
|
|
221
|
+
} else {
|
|
222
|
+
// 使用最大面额的组合
|
|
223
|
+
var maxDenom = Math.max.apply(Math, _toConsumableArray(validDenoms));
|
|
224
|
+
var _count6 = Math.ceil(targetAmount / maxDenom);
|
|
225
|
+
return [_count6 * maxDenom];
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// 移除重复和扩展组合
|
|
230
|
+
var uniqueCombinations = removeDuplicateAndExtendedCombinations(paymentOptions, targetAmount);
|
|
231
|
+
|
|
232
|
+
// 按币种类型数量排序,然后按总硬币数量排序,最后按金额排序
|
|
233
|
+
uniqueCombinations.sort(function (a, b) {
|
|
234
|
+
if (a.denomTypes !== b.denomTypes) {
|
|
235
|
+
return a.denomTypes - b.denomTypes;
|
|
236
|
+
}
|
|
237
|
+
if (a.coinCount !== b.coinCount) {
|
|
238
|
+
return a.coinCount - b.coinCount;
|
|
239
|
+
}
|
|
240
|
+
return a.sum - b.sum;
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
// 按金额去重并返回推荐的支付金额
|
|
244
|
+
var uniqueAmounts = new Set();
|
|
245
|
+
var finalResults = [];
|
|
246
|
+
for (var _i4 = 0, _uniqueCombinations = uniqueCombinations; _i4 < _uniqueCombinations.length; _i4++) {
|
|
247
|
+
var item = _uniqueCombinations[_i4];
|
|
248
|
+
var roundedAmount = Math.round(item.sum * 100) / 100; // 处理浮点数精度
|
|
249
|
+
if (!uniqueAmounts.has(roundedAmount) && finalResults.length < 10) {
|
|
250
|
+
uniqueAmounts.add(roundedAmount);
|
|
251
|
+
finalResults.push(roundedAmount);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return finalResults.sort(function (a, b) {
|
|
255
|
+
return a - b;
|
|
256
|
+
});
|
|
257
|
+
} catch (error) {
|
|
258
|
+
// 发生错误时返回安全的默认值
|
|
259
|
+
console.warn('推荐支付金额计算出错:', error);
|
|
260
|
+
// 返回最接近的整数金额作为兜底
|
|
261
|
+
var safeAmount = Math.ceil(targetAmount);
|
|
262
|
+
return [targetAmount, safeAmount];
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* 尝试找到精确匹配目标金额的组合
|
|
268
|
+
*/
|
|
269
|
+
function findExactCombination(target, denoms, precision) {
|
|
270
|
+
// 简单的深度优先搜索,限制搜索深度
|
|
271
|
+
function dfs(remaining, denomIndex, currentCombination) {
|
|
272
|
+
if (remaining === 0) {
|
|
273
|
+
return currentCombination;
|
|
274
|
+
}
|
|
275
|
+
if (remaining < 0 || denomIndex >= denoms.length || currentCombination.length > 10) {
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
var denom = denoms[denomIndex];
|
|
279
|
+
|
|
280
|
+
// 尝试使用当前面额 0 到 maxCount 次
|
|
281
|
+
var maxCount = Math.min(Math.floor(remaining / denom), 8);
|
|
282
|
+
for (var count = maxCount; count >= 0; count--) {
|
|
283
|
+
var newCombination = [].concat(_toConsumableArray(currentCombination), _toConsumableArray(Array(count).fill(denom)));
|
|
284
|
+
var result = dfs(remaining - count * denom, denomIndex + 1, newCombination);
|
|
285
|
+
if (result) {
|
|
286
|
+
return result;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
var exactMatch = dfs(target, 0, []);
|
|
292
|
+
if (exactMatch && exactMatch.length > 0) {
|
|
293
|
+
var denomTypes = new Set(exactMatch).size;
|
|
294
|
+
return {
|
|
295
|
+
combination: exactMatch.map(function (d) {
|
|
296
|
+
return d / precision;
|
|
297
|
+
}),
|
|
298
|
+
sum: target / precision,
|
|
299
|
+
coinCount: exactMatch.length,
|
|
300
|
+
denomTypes: denomTypes
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
return null;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* 移除重复和扩展组合
|
|
308
|
+
* 核心原理:如果组合A包含组合B的所有硬币,并且还有额外硬币,则A是B的扩展,应该被移除
|
|
309
|
+
*/
|
|
310
|
+
function removeDuplicateAndExtendedCombinations(combinations, targetAmount) {
|
|
311
|
+
var result = [];
|
|
312
|
+
|
|
313
|
+
// 按币种类型数量、硬币数量、金额排序,确保较简单的组合在前面
|
|
314
|
+
combinations.sort(function (a, b) {
|
|
315
|
+
if (a.denomTypes !== b.denomTypes) {
|
|
316
|
+
return a.denomTypes - b.denomTypes;
|
|
317
|
+
}
|
|
318
|
+
if (a.coinCount !== b.coinCount) {
|
|
319
|
+
return a.coinCount - b.coinCount;
|
|
320
|
+
}
|
|
321
|
+
return a.sum - b.sum;
|
|
322
|
+
});
|
|
323
|
+
for (var i = 0; i < combinations.length; i++) {
|
|
324
|
+
var current = combinations[i];
|
|
325
|
+
var shouldSkip = false;
|
|
326
|
+
|
|
327
|
+
// 检查当前组合是否与已添加的组合重复或者是扩展
|
|
328
|
+
for (var j = 0; j < result.length; j++) {
|
|
329
|
+
var existing = result[j];
|
|
330
|
+
|
|
331
|
+
// 如果完全相同,跳过
|
|
332
|
+
if (isSameCombination(current.combination, existing.combination)) {
|
|
333
|
+
shouldSkip = true;
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// 如果当前组合是已存在组合的扩展,跳过
|
|
338
|
+
if (isExtensionOf(current.combination, existing.combination)) {
|
|
339
|
+
shouldSkip = true;
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// 检查是否有其他组合是当前组合的扩展,如果有,移除那些扩展
|
|
345
|
+
if (!shouldSkip) {
|
|
346
|
+
// 移除所有当前组合的扩展
|
|
347
|
+
for (var _j3 = result.length - 1; _j3 >= 0; _j3--) {
|
|
348
|
+
if (isExtensionOf(result[_j3].combination, current.combination)) {
|
|
349
|
+
result.splice(_j3, 1);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
result.push(current);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return result;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* 检查组合A是否是组合B的扩展(即A包含B的所有硬币,并且还有额外的硬币)
|
|
360
|
+
*/
|
|
361
|
+
function isExtensionOf(combinationA, combinationB) {
|
|
362
|
+
// 如果A的硬币数量少于等于B,A不可能是B的扩展
|
|
363
|
+
if (combinationA.length <= combinationB.length) {
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// 统计每个面额的数量
|
|
368
|
+
var countA = {};
|
|
369
|
+
var countB = {};
|
|
370
|
+
combinationA.forEach(function (coin) {
|
|
371
|
+
countA[coin] = (countA[coin] || 0) + 1;
|
|
372
|
+
});
|
|
373
|
+
combinationB.forEach(function (coin) {
|
|
374
|
+
countB[coin] = (countB[coin] || 0) + 1;
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
// 检查B的所有面额在A中是否都有足够的数量
|
|
378
|
+
for (var coin in countB) {
|
|
379
|
+
if (!countA[coin] || countA[coin] < countB[coin]) {
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// 检查A是否有B没有的额外硬币
|
|
385
|
+
var hasExtra = false;
|
|
386
|
+
for (var _coin in countA) {
|
|
387
|
+
if (countA[_coin] > (countB[_coin] || 0)) {
|
|
388
|
+
hasExtra = true;
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
return hasExtra;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* 检查两个组合是否本质相同(相同的面额组合)
|
|
397
|
+
*/
|
|
398
|
+
function isSameCombination(combinationA, combinationB) {
|
|
399
|
+
if (combinationA.length !== combinationB.length) {
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
var countA = {};
|
|
403
|
+
var countB = {};
|
|
404
|
+
combinationA.forEach(function (coin) {
|
|
405
|
+
countA[coin] = (countA[coin] || 0) + 1;
|
|
406
|
+
});
|
|
407
|
+
combinationB.forEach(function (coin) {
|
|
408
|
+
countB[coin] = (countB[coin] || 0) + 1;
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
// 检查两个组合是否有相同的面额和数量
|
|
412
|
+
for (var coin in countA) {
|
|
413
|
+
if (countA[coin] !== (countB[coin] || 0)) {
|
|
414
|
+
return false;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
for (var _coin2 in countB) {
|
|
418
|
+
if (countB[_coin2] !== (countA[_coin2] || 0)) {
|
|
419
|
+
return false;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
return true;
|
|
423
|
+
}
|
|
@@ -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
|
+
}
|