@pisell/pisellos 0.0.479 → 0.0.481
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.d.ts +3 -2
- package/dist/core/index.js +7 -0
- package/dist/effects/index.d.ts +2 -2
- package/dist/effects/index.js +34 -81
- package/dist/model/strategy/adapter/promotion/evaluator.js +99 -26
- package/dist/model/strategy/adapter/walletPass/type.d.ts +9 -2
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +6 -6
- package/dist/model/strategy/adapter/walletPass/utils.js +111 -72
- package/dist/modules/Customer/index.js +1 -1
- package/dist/modules/Discount/index.d.ts +6 -2
- package/dist/modules/Discount/index.js +14 -8
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +18 -13
- package/dist/modules/Payment/index.d.ts +4 -0
- package/dist/modules/Payment/index.js +774 -649
- package/dist/modules/Payment/walletpass.js +44 -17
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Product/types.d.ts +2 -0
- package/dist/modules/ProductList/index.d.ts +3 -0
- package/dist/modules/ProductList/index.js +9 -7
- package/dist/modules/Rules/index.d.ts +2 -2
- package/dist/modules/Rules/index.js +37 -31
- package/dist/modules/Rules/types.d.ts +2 -2
- package/dist/modules/Schedule/index.d.ts +9 -0
- package/dist/modules/Schedule/index.js +15 -2
- package/dist/plugins/app-types/app/app.d.ts +1 -0
- package/dist/plugins/request.d.ts +2 -0
- package/dist/server/index.d.ts +107 -2
- package/dist/server/index.js +1507 -279
- package/dist/server/modules/index.d.ts +6 -0
- package/dist/server/modules/index.js +7 -0
- package/dist/server/modules/menu/index.d.ts +19 -0
- package/dist/server/modules/menu/index.js +221 -71
- package/dist/server/modules/order/index.d.ts +87 -0
- package/dist/server/modules/order/index.js +916 -0
- package/dist/server/modules/order/types.d.ts +530 -0
- package/dist/server/modules/order/types.js +141 -0
- package/dist/server/modules/order/utils/filterBookings.d.ts +6 -0
- package/dist/server/modules/order/utils/filterBookings.js +350 -0
- package/dist/server/modules/order/utils/filterOrders.d.ts +15 -0
- package/dist/server/modules/order/utils/filterOrders.js +226 -0
- package/dist/server/modules/products/index.d.ts +117 -5
- package/dist/server/modules/products/index.js +1450 -240
- package/dist/server/modules/products/types.d.ts +25 -1
- package/dist/server/modules/products/types.js +3 -0
- package/dist/server/modules/resource/index.d.ts +86 -0
- package/dist/server/modules/resource/index.js +1128 -0
- package/dist/server/modules/resource/types.d.ts +121 -0
- package/dist/server/modules/resource/types.js +47 -0
- package/dist/server/modules/schedule/index.d.ts +19 -0
- package/dist/server/modules/schedule/index.js +229 -68
- package/dist/server/utils/product.d.ts +5 -0
- package/dist/server/utils/product.js +71 -31
- package/dist/solution/BookingTicket/index.d.ts +10 -2
- package/dist/solution/BookingTicket/index.js +41 -28
- package/dist/solution/BookingTicket/utils/scan/index.js +1 -1
- package/dist/solution/Checkout/index.d.ts +1 -0
- package/dist/solution/Checkout/index.js +286 -188
- package/dist/solution/Checkout/utils/index.d.ts +2 -1
- package/dist/solution/Checkout/utils/index.js +6 -4
- package/dist/solution/RegisterAndLogin/config.js +340 -1
- package/dist/solution/Sales/index.d.ts +96 -0
- package/dist/solution/Sales/index.js +566 -0
- package/dist/solution/Sales/types.d.ts +67 -0
- package/dist/solution/Sales/types.js +26 -0
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +35 -22
- package/dist/solution/ShopDiscount/types.d.ts +6 -0
- package/dist/solution/ShopDiscount/utils.d.ts +9 -0
- package/dist/solution/ShopDiscount/utils.js +21 -27
- package/dist/solution/index.d.ts +2 -1
- package/dist/solution/index.js +2 -1
- package/dist/types/index.d.ts +5 -0
- package/lib/core/index.d.ts +3 -2
- package/lib/core/index.js +4 -0
- package/lib/effects/index.d.ts +2 -2
- package/lib/effects/index.js +22 -31
- package/lib/model/strategy/adapter/promotion/evaluator.js +57 -8
- package/lib/model/strategy/adapter/walletPass/type.d.ts +9 -2
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +6 -6
- package/lib/model/strategy/adapter/walletPass/utils.js +115 -48
- package/lib/modules/Customer/index.js +1 -1
- package/lib/modules/Discount/index.d.ts +6 -2
- package/lib/modules/Discount/index.js +3 -1
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +20 -18
- package/lib/modules/Payment/index.d.ts +4 -0
- package/lib/modules/Payment/index.js +134 -66
- package/lib/modules/Payment/walletpass.js +23 -4
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/types.d.ts +2 -0
- package/lib/modules/ProductList/index.d.ts +3 -0
- package/lib/modules/ProductList/index.js +2 -2
- package/lib/modules/Rules/index.d.ts +2 -2
- package/lib/modules/Rules/index.js +69 -73
- package/lib/modules/Rules/types.d.ts +2 -2
- package/lib/modules/Schedule/index.d.ts +9 -0
- package/lib/modules/Schedule/index.js +11 -0
- package/lib/plugins/app-types/app/app.d.ts +1 -0
- package/lib/plugins/request.d.ts +2 -0
- package/lib/server/index.d.ts +107 -2
- package/lib/server/index.js +773 -51
- package/lib/server/modules/index.d.ts +6 -0
- package/lib/server/modules/index.js +16 -2
- package/lib/server/modules/menu/index.d.ts +19 -0
- package/lib/server/modules/menu/index.js +121 -2
- package/lib/server/modules/order/index.d.ts +87 -0
- package/lib/server/modules/order/index.js +543 -0
- package/lib/server/modules/order/types.d.ts +530 -0
- package/lib/server/modules/order/types.js +34 -0
- package/lib/server/modules/order/utils/filterBookings.d.ts +6 -0
- package/lib/server/modules/order/utils/filterBookings.js +320 -0
- package/lib/server/modules/order/utils/filterOrders.d.ts +15 -0
- package/lib/server/modules/order/utils/filterOrders.js +197 -0
- package/lib/server/modules/products/index.d.ts +117 -5
- package/lib/server/modules/products/index.js +799 -62
- package/lib/server/modules/products/types.d.ts +25 -1
- package/lib/server/modules/products/types.js +1 -0
- package/lib/server/modules/resource/index.d.ts +86 -0
- package/lib/server/modules/resource/index.js +557 -0
- package/lib/server/modules/resource/types.d.ts +121 -0
- package/lib/server/modules/resource/types.js +35 -0
- package/lib/server/modules/schedule/index.d.ts +19 -0
- package/lib/server/modules/schedule/index.js +141 -12
- package/lib/server/utils/product.d.ts +5 -0
- package/lib/server/utils/product.js +56 -27
- package/lib/solution/BookingTicket/index.d.ts +10 -2
- package/lib/solution/BookingTicket/index.js +10 -2
- package/lib/solution/BookingTicket/utils/scan/index.js +0 -1
- package/lib/solution/Checkout/index.d.ts +1 -0
- package/lib/solution/Checkout/index.js +399 -331
- package/lib/solution/Checkout/utils/index.d.ts +2 -1
- package/lib/solution/Checkout/utils/index.js +6 -4
- package/lib/solution/RegisterAndLogin/config.js +266 -1
- package/lib/solution/Sales/index.d.ts +96 -0
- package/lib/solution/Sales/index.js +416 -0
- package/lib/solution/Sales/types.d.ts +67 -0
- package/lib/solution/Sales/types.js +35 -0
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +14 -6
- package/lib/solution/ShopDiscount/types.d.ts +6 -0
- package/lib/solution/ShopDiscount/utils.d.ts +9 -0
- package/lib/solution/ShopDiscount/utils.js +6 -10
- package/lib/solution/index.d.ts +2 -1
- package/lib/solution/index.js +4 -2
- package/lib/types/index.d.ts +5 -0
- package/package.json +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
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 _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
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 _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; }
|
|
5
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
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; }
|
|
8
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); } }
|
|
9
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 ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
8
|
+
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); }
|
|
9
|
+
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; }
|
|
10
10
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
11
|
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); } }
|
|
12
12
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -102,6 +102,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
102
102
|
// IndexDBManager 实例
|
|
103
103
|
_defineProperty(_assertThisInitialized(_this), "logger", void 0);
|
|
104
104
|
// LoggerManager 实例
|
|
105
|
+
_defineProperty(_assertThisInitialized(_this), "voucherUpdateLockByOrderUuid", new Map());
|
|
105
106
|
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
106
107
|
// 支付方式实例
|
|
107
108
|
_defineProperty(_assertThisInitialized(_this), "cash", void 0);
|
|
@@ -113,6 +114,50 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
113
114
|
return _this;
|
|
114
115
|
}
|
|
115
116
|
_createClass(PaymentModule, [{
|
|
117
|
+
key: "runVoucherUpdateLocked",
|
|
118
|
+
value: function runVoucherUpdateLocked(orderUuid, task) {
|
|
119
|
+
var _this2 = this;
|
|
120
|
+
var previous = this.voucherUpdateLockByOrderUuid.get(orderUuid) || Promise.resolve();
|
|
121
|
+
var next = previous.catch(function () {
|
|
122
|
+
return undefined;
|
|
123
|
+
}).then(task).finally(function () {
|
|
124
|
+
if (_this2.voucherUpdateLockByOrderUuid.get(orderUuid) === next) {
|
|
125
|
+
_this2.voucherUpdateLockByOrderUuid.delete(orderUuid);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
this.voucherUpdateLockByOrderUuid.set(orderUuid, next);
|
|
129
|
+
return next;
|
|
130
|
+
}
|
|
131
|
+
}, {
|
|
132
|
+
key: "normalizeVoucherPaymentItems",
|
|
133
|
+
value: function normalizeVoucherPaymentItems(voucherPaymentItems) {
|
|
134
|
+
var normalized = new Map();
|
|
135
|
+
var _iterator = _createForOfIteratorHelper(voucherPaymentItems || []),
|
|
136
|
+
_step;
|
|
137
|
+
try {
|
|
138
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
139
|
+
var item = _step.value;
|
|
140
|
+
if (!(item !== null && item !== void 0 && item.voucher_id)) {
|
|
141
|
+
throw new Error("\u4EE3\u91D1\u5238\u652F\u4ED8\u9879\u7F3A\u5C11 voucher_id: ".concat(JSON.stringify(item)));
|
|
142
|
+
}
|
|
143
|
+
var orderPaymentType = item.order_payment_type || 'normal';
|
|
144
|
+
var key = "".concat(item.voucher_id, "|").concat(orderPaymentType);
|
|
145
|
+
normalized.set(key, _objectSpread(_objectSpread({}, item), {}, {
|
|
146
|
+
order_payment_type: orderPaymentType
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
} catch (err) {
|
|
150
|
+
_iterator.e(err);
|
|
151
|
+
} finally {
|
|
152
|
+
_iterator.f();
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
items: Array.from(normalized.values()),
|
|
156
|
+
originalCount: (voucherPaymentItems === null || voucherPaymentItems === void 0 ? void 0 : voucherPaymentItems.length) || 0,
|
|
157
|
+
normalizedCount: normalized.size
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
}, {
|
|
116
161
|
key: "initialize",
|
|
117
162
|
value: function () {
|
|
118
163
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
@@ -248,7 +293,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
248
293
|
}, {
|
|
249
294
|
key: "registerNetworkHandlers",
|
|
250
295
|
value: function registerNetworkHandlers() {
|
|
251
|
-
var
|
|
296
|
+
var _this3 = this;
|
|
252
297
|
var network = this.app.plugins.get('network');
|
|
253
298
|
this.logInfo('Registering network status listener');
|
|
254
299
|
network === null || network === void 0 || network.addListener('networkStatusChange', /*#__PURE__*/function () {
|
|
@@ -257,12 +302,12 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
257
302
|
while (1) switch (_context2.prev = _context2.next) {
|
|
258
303
|
case 0:
|
|
259
304
|
console.log('网络状态:', status.connected);
|
|
260
|
-
|
|
305
|
+
_this3.logInfo('Network status changed', {
|
|
261
306
|
connected: status.connected,
|
|
262
307
|
previousStatus: status.previousStatus
|
|
263
308
|
});
|
|
264
309
|
if (status.connected) {
|
|
265
|
-
|
|
310
|
+
_this3.logInfo('Network reconnected');
|
|
266
311
|
// 网络恢复时的处理逻辑可以在这里添加
|
|
267
312
|
}
|
|
268
313
|
case 3:
|
|
@@ -276,105 +321,142 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
276
321
|
};
|
|
277
322
|
}());
|
|
278
323
|
}
|
|
279
|
-
|
|
324
|
+
}, {
|
|
325
|
+
key: "filterPayMethods",
|
|
326
|
+
value: function () {
|
|
327
|
+
var _filterPayMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(payMethods) {
|
|
328
|
+
var walletPassMethod;
|
|
329
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
330
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
331
|
+
case 0:
|
|
332
|
+
// 1. 筛选 status === 1 && disable === 0的数据
|
|
333
|
+
// 2. 检查列表里是否有 code=WALLET_PASS的数据,如果没有,则列表里如果有 PRODUCTVOUCHER 、 GIFTCARD 、 POINTCARD 则删除他们
|
|
334
|
+
// 如果有 code = WALLET_PASS的数据,则列表里PRODUCTVOUCHER 、 GIFTCARD 、 POINTCARD 的channel_application 指向 WALLET_PASS 的 channel_application
|
|
335
|
+
payMethods = payMethods.filter(function (method) {
|
|
336
|
+
return method.status === 1 && method.disable === 0;
|
|
337
|
+
});
|
|
338
|
+
walletPassMethod = payMethods.find(function (method) {
|
|
339
|
+
return method.code === 'WALLET_PASS';
|
|
340
|
+
});
|
|
341
|
+
if (walletPassMethod) {
|
|
342
|
+
payMethods.forEach(function (method) {
|
|
343
|
+
if (method.code === 'PRODUCTVOUCHER' || method.code === 'GIFTCARD' || method.code === 'POINTCARD') {
|
|
344
|
+
method.channel_application = walletPassMethod.channel_application;
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
} else {
|
|
348
|
+
payMethods = payMethods.filter(function (method) {
|
|
349
|
+
return method.code !== 'PRODUCTVOUCHER' && method.code !== 'GIFTCARD' && method.code !== 'POINTCARD';
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
return _context3.abrupt("return", payMethods);
|
|
353
|
+
case 4:
|
|
354
|
+
case "end":
|
|
355
|
+
return _context3.stop();
|
|
356
|
+
}
|
|
357
|
+
}, _callee3);
|
|
358
|
+
}));
|
|
359
|
+
function filterPayMethods(_x4) {
|
|
360
|
+
return _filterPayMethods.apply(this, arguments);
|
|
361
|
+
}
|
|
362
|
+
return filterPayMethods;
|
|
363
|
+
}()
|
|
280
364
|
/**
|
|
281
365
|
* 获取支付方式列表
|
|
282
366
|
*/
|
|
283
367
|
}, {
|
|
284
368
|
key: "getPayMethodListAsync",
|
|
285
369
|
value: (function () {
|
|
286
|
-
var _getPayMethodListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
287
|
-
var cachedMethods, hasCache, response, payMethods,
|
|
288
|
-
return _regeneratorRuntime().wrap(function
|
|
289
|
-
while (1) switch (
|
|
370
|
+
var _getPayMethodListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
371
|
+
var cachedMethods, hasCache, response, payMethods, _iterator2, _step2, method;
|
|
372
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
373
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
290
374
|
case 0:
|
|
291
375
|
this.logInfo('Starting getPayMethodListAsync');
|
|
292
|
-
|
|
376
|
+
_context4.prev = 1;
|
|
293
377
|
// 先尝试从 IndexDB 获取缓存
|
|
294
378
|
cachedMethods = [];
|
|
295
|
-
|
|
296
|
-
|
|
379
|
+
_context4.prev = 3;
|
|
380
|
+
_context4.next = 6;
|
|
297
381
|
return this.dbManager.getAll('pay_method');
|
|
298
382
|
case 6:
|
|
299
|
-
cachedMethods =
|
|
300
|
-
|
|
383
|
+
cachedMethods = _context4.sent;
|
|
384
|
+
_context4.next = 12;
|
|
301
385
|
break;
|
|
302
386
|
case 9:
|
|
303
|
-
|
|
304
|
-
|
|
387
|
+
_context4.prev = 9;
|
|
388
|
+
_context4.t0 = _context4["catch"](3);
|
|
305
389
|
console.warn('[PaymentModule] pay_method 表不存在,将从服务器获取数据');
|
|
306
390
|
case 12:
|
|
307
391
|
// 如果有缓存,先返回缓存数据
|
|
308
392
|
hasCache = cachedMethods.length > 0;
|
|
309
393
|
if (!hasCache) {
|
|
310
|
-
|
|
394
|
+
_context4.next = 16;
|
|
311
395
|
break;
|
|
312
396
|
}
|
|
313
397
|
// 后台异步获取最新数据
|
|
314
398
|
this.refreshPaymentMethodsInBackground(cachedMethods);
|
|
315
|
-
return
|
|
399
|
+
return _context4.abrupt("return", cachedMethods);
|
|
316
400
|
case 16:
|
|
317
|
-
|
|
318
|
-
return this.request.get('/pay/custom-payment/
|
|
319
|
-
channel: 'pos'
|
|
320
|
-
});
|
|
401
|
+
_context4.next = 18;
|
|
402
|
+
return this.request.get('/pay/custom-payment/all');
|
|
321
403
|
case 18:
|
|
322
|
-
response =
|
|
404
|
+
response = _context4.sent;
|
|
405
|
+
response.data = this.filterPayMethods(response.data);
|
|
323
406
|
payMethods = response.data || []; // 尝试缓存到 IndexDB
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
case
|
|
329
|
-
if ((
|
|
330
|
-
|
|
407
|
+
_context4.prev = 21;
|
|
408
|
+
_iterator2 = _createForOfIteratorHelper(payMethods);
|
|
409
|
+
_context4.prev = 23;
|
|
410
|
+
_iterator2.s();
|
|
411
|
+
case 25:
|
|
412
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
413
|
+
_context4.next = 31;
|
|
331
414
|
break;
|
|
332
415
|
}
|
|
333
|
-
method =
|
|
334
|
-
|
|
416
|
+
method = _step2.value;
|
|
417
|
+
_context4.next = 29;
|
|
335
418
|
return this.dbManager.update('pay_method', method);
|
|
336
|
-
case
|
|
337
|
-
|
|
419
|
+
case 29:
|
|
420
|
+
_context4.next = 25;
|
|
338
421
|
break;
|
|
339
|
-
case
|
|
340
|
-
|
|
422
|
+
case 31:
|
|
423
|
+
_context4.next = 36;
|
|
341
424
|
break;
|
|
342
|
-
case
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
case
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
return
|
|
350
|
-
case
|
|
351
|
-
|
|
425
|
+
case 33:
|
|
426
|
+
_context4.prev = 33;
|
|
427
|
+
_context4.t1 = _context4["catch"](23);
|
|
428
|
+
_iterator2.e(_context4.t1);
|
|
429
|
+
case 36:
|
|
430
|
+
_context4.prev = 36;
|
|
431
|
+
_iterator2.f();
|
|
432
|
+
return _context4.finish(36);
|
|
433
|
+
case 39:
|
|
434
|
+
_context4.next = 44;
|
|
352
435
|
break;
|
|
353
|
-
case
|
|
354
|
-
|
|
355
|
-
|
|
436
|
+
case 41:
|
|
437
|
+
_context4.prev = 41;
|
|
438
|
+
_context4.t2 = _context4["catch"](21);
|
|
356
439
|
console.warn('[PaymentModule] 无法缓存支付方式,pay_method 表不存在');
|
|
357
|
-
case
|
|
358
|
-
|
|
440
|
+
case 44:
|
|
441
|
+
_context4.next = 46;
|
|
359
442
|
return this.core.effects.emit("".concat(this.name, ":onPaymentMethodsLoaded"), payMethods);
|
|
360
|
-
case
|
|
443
|
+
case 46:
|
|
361
444
|
this.logInfo('getPayMethodListAsync completed successfully', {
|
|
362
|
-
|
|
363
|
-
hasCache: cachedMethods.length > 0
|
|
445
|
+
payMethods: payMethods
|
|
364
446
|
});
|
|
365
|
-
return
|
|
366
|
-
case
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
console.error('[PaymentModule] 获取支付方式列表失败',
|
|
370
|
-
this.logError('getPayMethodListAsync failed',
|
|
447
|
+
return _context4.abrupt("return", payMethods);
|
|
448
|
+
case 50:
|
|
449
|
+
_context4.prev = 50;
|
|
450
|
+
_context4.t3 = _context4["catch"](1);
|
|
451
|
+
console.error('[PaymentModule] 获取支付方式列表失败', _context4.t3);
|
|
452
|
+
this.logError('getPayMethodListAsync failed', _context4.t3);
|
|
371
453
|
// 如果所有操作都失败,返回空数组
|
|
372
|
-
return
|
|
373
|
-
case
|
|
454
|
+
return _context4.abrupt("return", []);
|
|
455
|
+
case 55:
|
|
374
456
|
case "end":
|
|
375
|
-
return
|
|
457
|
+
return _context4.stop();
|
|
376
458
|
}
|
|
377
|
-
},
|
|
459
|
+
}, _callee4, this, [[1, 50], [3, 9], [21, 41], [23, 33, 36, 39]]);
|
|
378
460
|
}));
|
|
379
461
|
function getPayMethodListAsync() {
|
|
380
462
|
return _getPayMethodListAsync.apply(this, arguments);
|
|
@@ -388,28 +470,27 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
388
470
|
}, {
|
|
389
471
|
key: "refreshPaymentMethodsInBackground",
|
|
390
472
|
value: (function () {
|
|
391
|
-
var _refreshPaymentMethodsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
392
|
-
var response, newPayMethods, hasChanges,
|
|
393
|
-
return _regeneratorRuntime().wrap(function
|
|
394
|
-
while (1) switch (
|
|
473
|
+
var _refreshPaymentMethodsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(cachedMethods) {
|
|
474
|
+
var response, newPayMethods, hasChanges, _iterator3, _step3, method, _iterator4, _step4, _method, eventData;
|
|
475
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
476
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
395
477
|
case 0:
|
|
396
478
|
this.logInfo('Starting refreshPaymentMethodsInBackground', {
|
|
397
479
|
cachedMethodsCount: cachedMethods.length
|
|
398
480
|
});
|
|
399
|
-
|
|
481
|
+
_context5.prev = 1;
|
|
400
482
|
console.log('[PaymentModule] 后台刷新支付方式列表...');
|
|
401
483
|
|
|
402
484
|
// 从服务器获取最新数据
|
|
403
|
-
|
|
404
|
-
return this.request.get('/pay/custom-payment/
|
|
405
|
-
channel: 'pos'
|
|
406
|
-
});
|
|
485
|
+
_context5.next = 5;
|
|
486
|
+
return this.request.get('/pay/custom-payment/all');
|
|
407
487
|
case 5:
|
|
408
|
-
response =
|
|
488
|
+
response = _context5.sent;
|
|
489
|
+
response.data = this.filterPayMethods(response.data);
|
|
409
490
|
newPayMethods = response.data || []; // 检查是否有变化
|
|
410
491
|
hasChanges = this.hasPaymentMethodsChanged(cachedMethods, newPayMethods);
|
|
411
492
|
if (!hasChanges) {
|
|
412
|
-
|
|
493
|
+
_context5.next = 57;
|
|
413
494
|
break;
|
|
414
495
|
}
|
|
415
496
|
console.log('[PaymentModule] 支付方式列表已更新');
|
|
@@ -419,94 +500,94 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
419
500
|
});
|
|
420
501
|
|
|
421
502
|
// 更新缓存
|
|
422
|
-
|
|
503
|
+
_context5.prev = 12;
|
|
423
504
|
// 先清除旧数据
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
case
|
|
428
|
-
if ((
|
|
429
|
-
|
|
505
|
+
_iterator3 = _createForOfIteratorHelper(cachedMethods);
|
|
506
|
+
_context5.prev = 14;
|
|
507
|
+
_iterator3.s();
|
|
508
|
+
case 16:
|
|
509
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
510
|
+
_context5.next = 22;
|
|
430
511
|
break;
|
|
431
512
|
}
|
|
432
|
-
method =
|
|
433
|
-
|
|
513
|
+
method = _step3.value;
|
|
514
|
+
_context5.next = 20;
|
|
434
515
|
return this.dbManager.delete('pay_method', method.id);
|
|
435
|
-
case
|
|
436
|
-
|
|
516
|
+
case 20:
|
|
517
|
+
_context5.next = 16;
|
|
437
518
|
break;
|
|
438
|
-
case
|
|
439
|
-
|
|
519
|
+
case 22:
|
|
520
|
+
_context5.next = 27;
|
|
440
521
|
break;
|
|
441
|
-
case
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
case
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
return
|
|
449
|
-
case
|
|
522
|
+
case 24:
|
|
523
|
+
_context5.prev = 24;
|
|
524
|
+
_context5.t0 = _context5["catch"](14);
|
|
525
|
+
_iterator3.e(_context5.t0);
|
|
526
|
+
case 27:
|
|
527
|
+
_context5.prev = 27;
|
|
528
|
+
_iterator3.f();
|
|
529
|
+
return _context5.finish(27);
|
|
530
|
+
case 30:
|
|
450
531
|
// 添加新数据
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
case
|
|
455
|
-
if ((
|
|
456
|
-
|
|
532
|
+
_iterator4 = _createForOfIteratorHelper(newPayMethods);
|
|
533
|
+
_context5.prev = 31;
|
|
534
|
+
_iterator4.s();
|
|
535
|
+
case 33:
|
|
536
|
+
if ((_step4 = _iterator4.n()).done) {
|
|
537
|
+
_context5.next = 39;
|
|
457
538
|
break;
|
|
458
539
|
}
|
|
459
|
-
_method =
|
|
460
|
-
|
|
540
|
+
_method = _step4.value;
|
|
541
|
+
_context5.next = 37;
|
|
461
542
|
return this.dbManager.update('pay_method', _method);
|
|
462
|
-
case
|
|
463
|
-
|
|
543
|
+
case 37:
|
|
544
|
+
_context5.next = 33;
|
|
464
545
|
break;
|
|
465
|
-
case
|
|
466
|
-
|
|
546
|
+
case 39:
|
|
547
|
+
_context5.next = 44;
|
|
467
548
|
break;
|
|
468
|
-
case
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
case
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
return
|
|
476
|
-
case
|
|
477
|
-
|
|
549
|
+
case 41:
|
|
550
|
+
_context5.prev = 41;
|
|
551
|
+
_context5.t1 = _context5["catch"](31);
|
|
552
|
+
_iterator4.e(_context5.t1);
|
|
553
|
+
case 44:
|
|
554
|
+
_context5.prev = 44;
|
|
555
|
+
_iterator4.f();
|
|
556
|
+
return _context5.finish(44);
|
|
557
|
+
case 47:
|
|
558
|
+
_context5.next = 52;
|
|
478
559
|
break;
|
|
479
|
-
case
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
console.warn('[PaymentModule] 无法更新支付方式缓存',
|
|
483
|
-
case
|
|
560
|
+
case 49:
|
|
561
|
+
_context5.prev = 49;
|
|
562
|
+
_context5.t2 = _context5["catch"](12);
|
|
563
|
+
console.warn('[PaymentModule] 无法更新支付方式缓存', _context5.t2);
|
|
564
|
+
case 52:
|
|
484
565
|
// 通知外部支付方式已变化
|
|
485
566
|
eventData = {
|
|
486
567
|
oldMethods: cachedMethods,
|
|
487
568
|
newMethods: newPayMethods
|
|
488
569
|
};
|
|
489
|
-
|
|
570
|
+
_context5.next = 55;
|
|
490
571
|
return this.core.effects.emit("".concat(this.name, ":onPaymentMethodsChanged"), eventData);
|
|
491
|
-
case
|
|
492
|
-
|
|
572
|
+
case 55:
|
|
573
|
+
_context5.next = 58;
|
|
493
574
|
break;
|
|
494
|
-
case 56:
|
|
495
|
-
console.log('[PaymentModule] 支付方式列表无变化');
|
|
496
575
|
case 57:
|
|
497
|
-
|
|
576
|
+
console.log('[PaymentModule] 支付方式列表无变化');
|
|
577
|
+
case 58:
|
|
578
|
+
_context5.next = 63;
|
|
498
579
|
break;
|
|
499
|
-
case
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
console.error('[PaymentModule] 后台刷新支付方式失败',
|
|
503
|
-
case
|
|
580
|
+
case 60:
|
|
581
|
+
_context5.prev = 60;
|
|
582
|
+
_context5.t3 = _context5["catch"](1);
|
|
583
|
+
console.error('[PaymentModule] 后台刷新支付方式失败', _context5.t3);
|
|
584
|
+
case 63:
|
|
504
585
|
case "end":
|
|
505
|
-
return
|
|
586
|
+
return _context5.stop();
|
|
506
587
|
}
|
|
507
|
-
},
|
|
588
|
+
}, _callee5, this, [[1, 60], [12, 49], [14, 24, 27, 30], [31, 41, 44, 47]]);
|
|
508
589
|
}));
|
|
509
|
-
function refreshPaymentMethodsInBackground(
|
|
590
|
+
function refreshPaymentMethodsInBackground(_x5) {
|
|
510
591
|
return _refreshPaymentMethodsInBackground.apply(this, arguments);
|
|
511
592
|
}
|
|
512
593
|
return refreshPaymentMethodsInBackground;
|
|
@@ -528,11 +609,11 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
528
609
|
}));
|
|
529
610
|
|
|
530
611
|
// 检查每个新方法是否与旧方法相同
|
|
531
|
-
var
|
|
532
|
-
|
|
612
|
+
var _iterator5 = _createForOfIteratorHelper(newMethods),
|
|
613
|
+
_step5;
|
|
533
614
|
try {
|
|
534
|
-
for (
|
|
535
|
-
var newMethod =
|
|
615
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
616
|
+
var newMethod = _step5.value;
|
|
536
617
|
var oldMethod = oldMethodsMap.get(newMethod.id);
|
|
537
618
|
if (!oldMethod) {
|
|
538
619
|
return true; // 新增方法
|
|
@@ -601,9 +682,9 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
601
682
|
}
|
|
602
683
|
}
|
|
603
684
|
} catch (err) {
|
|
604
|
-
|
|
685
|
+
_iterator5.e(err);
|
|
605
686
|
} finally {
|
|
606
|
-
|
|
687
|
+
_iterator5.f();
|
|
607
688
|
}
|
|
608
689
|
return false;
|
|
609
690
|
}
|
|
@@ -614,25 +695,25 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
614
695
|
}, {
|
|
615
696
|
key: "getOrderListAsync",
|
|
616
697
|
value: (function () {
|
|
617
|
-
var _getOrderListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
618
|
-
return _regeneratorRuntime().wrap(function
|
|
619
|
-
while (1) switch (
|
|
698
|
+
var _getOrderListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
699
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
700
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
620
701
|
case 0:
|
|
621
|
-
|
|
622
|
-
|
|
702
|
+
_context6.prev = 0;
|
|
703
|
+
_context6.next = 3;
|
|
623
704
|
return this.dbManager.getAll('order');
|
|
624
705
|
case 3:
|
|
625
|
-
return
|
|
706
|
+
return _context6.abrupt("return", _context6.sent);
|
|
626
707
|
case 6:
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
console.error('[PaymentModule] 获取订单列表失败',
|
|
630
|
-
return
|
|
708
|
+
_context6.prev = 6;
|
|
709
|
+
_context6.t0 = _context6["catch"](0);
|
|
710
|
+
console.error('[PaymentModule] 获取订单列表失败', _context6.t0);
|
|
711
|
+
return _context6.abrupt("return", []);
|
|
631
712
|
case 10:
|
|
632
713
|
case "end":
|
|
633
|
-
return
|
|
714
|
+
return _context6.stop();
|
|
634
715
|
}
|
|
635
|
-
},
|
|
716
|
+
}, _callee6, this, [[0, 6]]);
|
|
636
717
|
}));
|
|
637
718
|
function getOrderListAsync() {
|
|
638
719
|
return _getOrderListAsync.apply(this, arguments);
|
|
@@ -646,27 +727,27 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
646
727
|
}, {
|
|
647
728
|
key: "getPaymentOrderByUuidAsync",
|
|
648
729
|
value: (function () {
|
|
649
|
-
var _getPaymentOrderByUuidAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
650
|
-
return _regeneratorRuntime().wrap(function
|
|
651
|
-
while (1) switch (
|
|
730
|
+
var _getPaymentOrderByUuidAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(orderUuid) {
|
|
731
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
732
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
652
733
|
case 0:
|
|
653
|
-
|
|
654
|
-
|
|
734
|
+
_context7.prev = 0;
|
|
735
|
+
_context7.next = 3;
|
|
655
736
|
return this.dbManager.get('order', orderUuid, true);
|
|
656
737
|
case 3:
|
|
657
|
-
return
|
|
738
|
+
return _context7.abrupt("return", _context7.sent);
|
|
658
739
|
case 6:
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
console.error('[PaymentModule] 获取支付订单失败',
|
|
662
|
-
return
|
|
740
|
+
_context7.prev = 6;
|
|
741
|
+
_context7.t0 = _context7["catch"](0);
|
|
742
|
+
console.error('[PaymentModule] 获取支付订单失败', _context7.t0);
|
|
743
|
+
return _context7.abrupt("return", null);
|
|
663
744
|
case 10:
|
|
664
745
|
case "end":
|
|
665
|
-
return
|
|
746
|
+
return _context7.stop();
|
|
666
747
|
}
|
|
667
|
-
},
|
|
748
|
+
}, _callee7, this, [[0, 6]]);
|
|
668
749
|
}));
|
|
669
|
-
function getPaymentOrderByUuidAsync(
|
|
750
|
+
function getPaymentOrderByUuidAsync(_x6) {
|
|
670
751
|
return _getPaymentOrderByUuidAsync.apply(this, arguments);
|
|
671
752
|
}
|
|
672
753
|
return getPaymentOrderByUuidAsync;
|
|
@@ -678,17 +759,17 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
678
759
|
}, {
|
|
679
760
|
key: "createPaymentOrderAsync",
|
|
680
761
|
value: (function () {
|
|
681
|
-
var _createPaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
682
|
-
var
|
|
762
|
+
var _createPaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
|
|
763
|
+
var _this4 = this;
|
|
683
764
|
var newOrder, currentTime, dbAddStartTime, dbAddDuration;
|
|
684
|
-
return _regeneratorRuntime().wrap(function
|
|
685
|
-
while (1) switch (
|
|
765
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
766
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
686
767
|
case 0:
|
|
687
768
|
this.logInfo('Starting createPaymentOrderAsync', {
|
|
688
769
|
orderId: params.order_id,
|
|
689
770
|
totalAmount: params.total_amount
|
|
690
771
|
});
|
|
691
|
-
|
|
772
|
+
_context8.prev = 1;
|
|
692
773
|
// 检测是否有重复的 order_id
|
|
693
774
|
// console.time('createLocalOrderAsync: getExistingOrder')
|
|
694
775
|
// const existingOrder = await this.dbManager.get('order', params.order_id);
|
|
@@ -774,7 +855,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
774
855
|
|
|
775
856
|
// 🚀 性能监控:记录数据库添加操作耗时
|
|
776
857
|
dbAddStartTime = Date.now();
|
|
777
|
-
|
|
858
|
+
_context8.next = 7;
|
|
778
859
|
return this.dbManager.add('order', newOrder, true);
|
|
779
860
|
case 7:
|
|
780
861
|
dbAddDuration = Date.now() - dbAddStartTime;
|
|
@@ -787,24 +868,24 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
787
868
|
performance: dbAddDuration > 100 ? 'slow' : dbAddDuration > 50 ? 'medium' : 'fast'
|
|
788
869
|
});
|
|
789
870
|
setTimeout(function () {
|
|
790
|
-
|
|
871
|
+
_this4.core.effects.emit("".concat(_this4.name, ":onOrderAdded"), newOrder);
|
|
791
872
|
}, 0);
|
|
792
|
-
return
|
|
873
|
+
return _context8.abrupt("return", newOrder);
|
|
793
874
|
case 13:
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
console.error('[PaymentModule] 创建支付订单失败',
|
|
797
|
-
this.logError('createPaymentOrderAsync failed',
|
|
875
|
+
_context8.prev = 13;
|
|
876
|
+
_context8.t0 = _context8["catch"](1);
|
|
877
|
+
console.error('[PaymentModule] 创建支付订单失败', _context8.t0);
|
|
878
|
+
this.logError('createPaymentOrderAsync failed', _context8.t0, {
|
|
798
879
|
orderId: params.order_id
|
|
799
880
|
});
|
|
800
|
-
throw
|
|
881
|
+
throw _context8.t0;
|
|
801
882
|
case 18:
|
|
802
883
|
case "end":
|
|
803
|
-
return
|
|
884
|
+
return _context8.stop();
|
|
804
885
|
}
|
|
805
|
-
},
|
|
886
|
+
}, _callee8, this, [[1, 13]]);
|
|
806
887
|
}));
|
|
807
|
-
function createPaymentOrderAsync(
|
|
888
|
+
function createPaymentOrderAsync(_x7) {
|
|
808
889
|
return _createPaymentOrderAsync.apply(this, arguments);
|
|
809
890
|
}
|
|
810
891
|
return createPaymentOrderAsync;
|
|
@@ -816,42 +897,42 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
816
897
|
}, {
|
|
817
898
|
key: "deletePaymentOrderAsync",
|
|
818
899
|
value: (function () {
|
|
819
|
-
var _deletePaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
900
|
+
var _deletePaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(orderUuid) {
|
|
820
901
|
var order;
|
|
821
|
-
return _regeneratorRuntime().wrap(function
|
|
822
|
-
while (1) switch (
|
|
902
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
903
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
823
904
|
case 0:
|
|
824
|
-
|
|
825
|
-
|
|
905
|
+
_context9.prev = 0;
|
|
906
|
+
_context9.next = 3;
|
|
826
907
|
return this.dbManager.get('order', orderUuid);
|
|
827
908
|
case 3:
|
|
828
|
-
order =
|
|
909
|
+
order = _context9.sent;
|
|
829
910
|
if (!order) {
|
|
830
|
-
|
|
911
|
+
_context9.next = 10;
|
|
831
912
|
break;
|
|
832
913
|
}
|
|
833
|
-
|
|
914
|
+
_context9.next = 7;
|
|
834
915
|
return this.dbManager.delete('order', orderUuid);
|
|
835
916
|
case 7:
|
|
836
|
-
|
|
917
|
+
_context9.next = 9;
|
|
837
918
|
return this.core.effects.emit("".concat(this.name, ":onOrderDeleted"), order);
|
|
838
919
|
case 9:
|
|
839
920
|
console.log('[PaymentModule] 支付订单删除成功:', orderUuid);
|
|
840
921
|
case 10:
|
|
841
|
-
|
|
922
|
+
_context9.next = 16;
|
|
842
923
|
break;
|
|
843
924
|
case 12:
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
console.error('[PaymentModule] 删除支付订单失败',
|
|
847
|
-
throw
|
|
925
|
+
_context9.prev = 12;
|
|
926
|
+
_context9.t0 = _context9["catch"](0);
|
|
927
|
+
console.error('[PaymentModule] 删除支付订单失败', _context9.t0);
|
|
928
|
+
throw _context9.t0;
|
|
848
929
|
case 16:
|
|
849
930
|
case "end":
|
|
850
|
-
return
|
|
931
|
+
return _context9.stop();
|
|
851
932
|
}
|
|
852
|
-
},
|
|
933
|
+
}, _callee9, this, [[0, 12]]);
|
|
853
934
|
}));
|
|
854
|
-
function deletePaymentOrderAsync(
|
|
935
|
+
function deletePaymentOrderAsync(_x8) {
|
|
855
936
|
return _deletePaymentOrderAsync.apply(this, arguments);
|
|
856
937
|
}
|
|
857
938
|
return deletePaymentOrderAsync;
|
|
@@ -863,49 +944,49 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
863
944
|
}, {
|
|
864
945
|
key: "updateOrderAsync",
|
|
865
946
|
value: (function () {
|
|
866
|
-
var _updateOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
947
|
+
var _updateOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(orderUuid, params) {
|
|
867
948
|
var order, updatedOrder;
|
|
868
|
-
return _regeneratorRuntime().wrap(function
|
|
869
|
-
while (1) switch (
|
|
949
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
950
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
870
951
|
case 0:
|
|
871
|
-
|
|
872
|
-
|
|
952
|
+
_context10.prev = 0;
|
|
953
|
+
_context10.next = 3;
|
|
873
954
|
return this.dbManager.get('order', orderUuid);
|
|
874
955
|
case 3:
|
|
875
|
-
order =
|
|
956
|
+
order = _context10.sent;
|
|
876
957
|
if (!order) {
|
|
877
|
-
|
|
958
|
+
_context10.next = 13;
|
|
878
959
|
break;
|
|
879
960
|
}
|
|
880
961
|
updatedOrder = _objectSpread(_objectSpread({}, order), params);
|
|
881
962
|
this.recalculateOrderAmount(updatedOrder);
|
|
882
|
-
|
|
963
|
+
_context10.next = 9;
|
|
883
964
|
return this.dbManager.update('order', updatedOrder);
|
|
884
965
|
case 9:
|
|
885
|
-
|
|
966
|
+
_context10.next = 11;
|
|
886
967
|
return this.core.effects.emit("".concat(this.name, ":onOrderUpdated"), updatedOrder);
|
|
887
968
|
case 11:
|
|
888
|
-
|
|
969
|
+
_context10.next = 13;
|
|
889
970
|
return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
|
|
890
971
|
action: 'update',
|
|
891
972
|
order: updatedOrder,
|
|
892
973
|
originalOrder: order
|
|
893
974
|
});
|
|
894
975
|
case 13:
|
|
895
|
-
|
|
976
|
+
_context10.next = 19;
|
|
896
977
|
break;
|
|
897
978
|
case 15:
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
console.error('[PaymentModule] 更新订单失败',
|
|
901
|
-
throw
|
|
979
|
+
_context10.prev = 15;
|
|
980
|
+
_context10.t0 = _context10["catch"](0);
|
|
981
|
+
console.error('[PaymentModule] 更新订单失败', _context10.t0);
|
|
982
|
+
throw _context10.t0;
|
|
902
983
|
case 19:
|
|
903
984
|
case "end":
|
|
904
|
-
return
|
|
985
|
+
return _context10.stop();
|
|
905
986
|
}
|
|
906
|
-
},
|
|
987
|
+
}, _callee10, this, [[0, 15]]);
|
|
907
988
|
}));
|
|
908
|
-
function updateOrderAsync(
|
|
989
|
+
function updateOrderAsync(_x9, _x10) {
|
|
909
990
|
return _updateOrderAsync.apply(this, arguments);
|
|
910
991
|
}
|
|
911
992
|
return updateOrderAsync;
|
|
@@ -924,38 +1005,38 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
924
1005
|
}, {
|
|
925
1006
|
key: "replaceOrderIdByUuidAsync",
|
|
926
1007
|
value: (function () {
|
|
927
|
-
var _replaceOrderIdByUuidAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1008
|
+
var _replaceOrderIdByUuidAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(orderUuid, newOrderId) {
|
|
928
1009
|
var existingOrder, allOrders, duplicateOrder, originalOrderId, updatedOrder;
|
|
929
|
-
return _regeneratorRuntime().wrap(function
|
|
930
|
-
while (1) switch (
|
|
1010
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
1011
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
931
1012
|
case 0:
|
|
932
1013
|
this.logInfo('Starting replaceOrderIdByUuidAsync', {
|
|
933
1014
|
orderUuid: orderUuid,
|
|
934
1015
|
newOrderId: newOrderId
|
|
935
1016
|
});
|
|
936
|
-
|
|
937
|
-
|
|
1017
|
+
_context11.prev = 1;
|
|
1018
|
+
_context11.next = 4;
|
|
938
1019
|
return this.dbManager.get('order', orderUuid);
|
|
939
1020
|
case 4:
|
|
940
|
-
existingOrder =
|
|
1021
|
+
existingOrder = _context11.sent;
|
|
941
1022
|
if (existingOrder) {
|
|
942
|
-
|
|
1023
|
+
_context11.next = 8;
|
|
943
1024
|
break;
|
|
944
1025
|
}
|
|
945
1026
|
this.logWarning('Order not found for UUID replacement', {
|
|
946
1027
|
orderUuid: orderUuid
|
|
947
1028
|
});
|
|
948
|
-
return
|
|
1029
|
+
return _context11.abrupt("return", null);
|
|
949
1030
|
case 8:
|
|
950
|
-
|
|
1031
|
+
_context11.next = 10;
|
|
951
1032
|
return this.dbManager.getAll('order');
|
|
952
1033
|
case 10:
|
|
953
|
-
allOrders =
|
|
1034
|
+
allOrders = _context11.sent;
|
|
954
1035
|
duplicateOrder = allOrders.find(function (order) {
|
|
955
1036
|
return String(order.order_id) === String(newOrderId) && order.uuid !== orderUuid;
|
|
956
1037
|
});
|
|
957
1038
|
if (!duplicateOrder) {
|
|
958
|
-
|
|
1039
|
+
_context11.next = 15;
|
|
959
1040
|
break;
|
|
960
1041
|
}
|
|
961
1042
|
this.logWarning('New order ID already exists', {
|
|
@@ -977,13 +1058,13 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
977
1058
|
updated_at: new Date().toISOString()
|
|
978
1059
|
})
|
|
979
1060
|
}); // 更新到数据库
|
|
980
|
-
|
|
1061
|
+
_context11.next = 19;
|
|
981
1062
|
return this.dbManager.update('order', updatedOrder);
|
|
982
1063
|
case 19:
|
|
983
|
-
|
|
1064
|
+
_context11.next = 21;
|
|
984
1065
|
return this.core.effects.emit("".concat(this.name, ":onOrderUpdated"), updatedOrder);
|
|
985
1066
|
case 21:
|
|
986
|
-
|
|
1067
|
+
_context11.next = 23;
|
|
987
1068
|
return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
|
|
988
1069
|
action: 'order_id_replaced',
|
|
989
1070
|
order: updatedOrder,
|
|
@@ -1000,23 +1081,23 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1000
1081
|
newOrderId: newOrderId
|
|
1001
1082
|
});
|
|
1002
1083
|
console.log("[PaymentModule] \u8BA2\u5355ID\u66FF\u6362\u6210\u529F: ".concat(originalOrderId, " \u2192 ").concat(newOrderId));
|
|
1003
|
-
return
|
|
1084
|
+
return _context11.abrupt("return", updatedOrder);
|
|
1004
1085
|
case 28:
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
console.error('[PaymentModule] 替换订单ID失败',
|
|
1008
|
-
this.logError('replaceOrderIdByUuidAsync failed',
|
|
1086
|
+
_context11.prev = 28;
|
|
1087
|
+
_context11.t0 = _context11["catch"](1);
|
|
1088
|
+
console.error('[PaymentModule] 替换订单ID失败', _context11.t0);
|
|
1089
|
+
this.logError('replaceOrderIdByUuidAsync failed', _context11.t0, {
|
|
1009
1090
|
orderUuid: orderUuid,
|
|
1010
1091
|
newOrderId: newOrderId
|
|
1011
1092
|
});
|
|
1012
|
-
throw
|
|
1093
|
+
throw _context11.t0;
|
|
1013
1094
|
case 33:
|
|
1014
1095
|
case "end":
|
|
1015
|
-
return
|
|
1096
|
+
return _context11.stop();
|
|
1016
1097
|
}
|
|
1017
|
-
},
|
|
1098
|
+
}, _callee11, this, [[1, 28]]);
|
|
1018
1099
|
}));
|
|
1019
|
-
function replaceOrderIdByUuidAsync(
|
|
1100
|
+
function replaceOrderIdByUuidAsync(_x11, _x12) {
|
|
1020
1101
|
return _replaceOrderIdByUuidAsync.apply(this, arguments);
|
|
1021
1102
|
}
|
|
1022
1103
|
return replaceOrderIdByUuidAsync;
|
|
@@ -1032,42 +1113,42 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1032
1113
|
}, {
|
|
1033
1114
|
key: "getPaymentItemsAsync",
|
|
1034
1115
|
value: (function () {
|
|
1035
|
-
var _getPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1116
|
+
var _getPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(orderUuid) {
|
|
1036
1117
|
var includeVoided,
|
|
1037
1118
|
order,
|
|
1038
1119
|
allPayments,
|
|
1039
|
-
|
|
1040
|
-
return _regeneratorRuntime().wrap(function
|
|
1041
|
-
while (1) switch (
|
|
1120
|
+
_args12 = arguments;
|
|
1121
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1122
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1042
1123
|
case 0:
|
|
1043
|
-
includeVoided =
|
|
1124
|
+
includeVoided = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : false;
|
|
1044
1125
|
if (orderUuid) {
|
|
1045
|
-
|
|
1126
|
+
_context12.next = 3;
|
|
1046
1127
|
break;
|
|
1047
1128
|
}
|
|
1048
1129
|
throw new Error('orderUuid is required');
|
|
1049
1130
|
case 3:
|
|
1050
|
-
|
|
1131
|
+
_context12.next = 5;
|
|
1051
1132
|
return this.getPaymentOrderByUuidAsync(orderUuid);
|
|
1052
1133
|
case 5:
|
|
1053
|
-
order =
|
|
1134
|
+
order = _context12.sent;
|
|
1054
1135
|
allPayments = (order === null || order === void 0 ? void 0 : order.payment) || [];
|
|
1055
1136
|
if (!includeVoided) {
|
|
1056
|
-
|
|
1137
|
+
_context12.next = 9;
|
|
1057
1138
|
break;
|
|
1058
1139
|
}
|
|
1059
|
-
return
|
|
1140
|
+
return _context12.abrupt("return", allPayments);
|
|
1060
1141
|
case 9:
|
|
1061
|
-
return
|
|
1142
|
+
return _context12.abrupt("return", allPayments.filter(function (payment) {
|
|
1062
1143
|
return payment.status !== 'voided';
|
|
1063
1144
|
}));
|
|
1064
1145
|
case 10:
|
|
1065
1146
|
case "end":
|
|
1066
|
-
return
|
|
1147
|
+
return _context12.stop();
|
|
1067
1148
|
}
|
|
1068
|
-
},
|
|
1149
|
+
}, _callee12, this);
|
|
1069
1150
|
}));
|
|
1070
|
-
function getPaymentItemsAsync(
|
|
1151
|
+
function getPaymentItemsAsync(_x13) {
|
|
1071
1152
|
return _getPaymentItemsAsync.apply(this, arguments);
|
|
1072
1153
|
}
|
|
1073
1154
|
return getPaymentItemsAsync;
|
|
@@ -1082,18 +1163,18 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1082
1163
|
}, {
|
|
1083
1164
|
key: "getAllPaymentItemsAsync",
|
|
1084
1165
|
value: (function () {
|
|
1085
|
-
var _getAllPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1086
|
-
return _regeneratorRuntime().wrap(function
|
|
1087
|
-
while (1) switch (
|
|
1166
|
+
var _getAllPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderUuid) {
|
|
1167
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1168
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1088
1169
|
case 0:
|
|
1089
|
-
return
|
|
1170
|
+
return _context13.abrupt("return", this.getPaymentItemsAsync(orderUuid, true));
|
|
1090
1171
|
case 1:
|
|
1091
1172
|
case "end":
|
|
1092
|
-
return
|
|
1173
|
+
return _context13.stop();
|
|
1093
1174
|
}
|
|
1094
|
-
},
|
|
1175
|
+
}, _callee13, this);
|
|
1095
1176
|
}));
|
|
1096
|
-
function getAllPaymentItemsAsync(
|
|
1177
|
+
function getAllPaymentItemsAsync(_x14) {
|
|
1097
1178
|
return _getAllPaymentItemsAsync.apply(this, arguments);
|
|
1098
1179
|
}
|
|
1099
1180
|
return getAllPaymentItemsAsync;
|
|
@@ -1105,10 +1186,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1105
1186
|
}, {
|
|
1106
1187
|
key: "addPaymentItemAsync",
|
|
1107
1188
|
value: (function () {
|
|
1108
|
-
var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1189
|
+
var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderUuid, paymentItem) {
|
|
1109
1190
|
var _paymentItem$metadata, _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, expectAmount, paidDepositAmount, expectedDepositAmount, warningMessage, paymentUuid, currentTime, newPaymentItem;
|
|
1110
|
-
return _regeneratorRuntime().wrap(function
|
|
1111
|
-
while (1) switch (
|
|
1191
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1192
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1112
1193
|
case 0:
|
|
1113
1194
|
this.logInfo('Starting addPaymentItemAsync', {
|
|
1114
1195
|
orderUuid: orderUuid,
|
|
@@ -1116,20 +1197,20 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1116
1197
|
paymentCode: paymentItem.code,
|
|
1117
1198
|
orderPaymentType: paymentItem.order_payment_type
|
|
1118
1199
|
});
|
|
1119
|
-
|
|
1200
|
+
_context14.prev = 1;
|
|
1120
1201
|
this.logInfo('准备获取订单', {
|
|
1121
1202
|
orderUuid: orderUuid
|
|
1122
1203
|
});
|
|
1123
|
-
|
|
1204
|
+
_context14.next = 5;
|
|
1124
1205
|
return this.getPaymentOrderByUuidAsync(orderUuid);
|
|
1125
1206
|
case 5:
|
|
1126
|
-
order =
|
|
1207
|
+
order = _context14.sent;
|
|
1127
1208
|
this.logInfo('获取订单信息成功', {
|
|
1128
1209
|
orderUuid: orderUuid,
|
|
1129
1210
|
order: order
|
|
1130
1211
|
});
|
|
1131
1212
|
if (order) {
|
|
1132
|
-
|
|
1213
|
+
_context14.next = 9;
|
|
1133
1214
|
break;
|
|
1134
1215
|
}
|
|
1135
1216
|
throw new Error("Order not found: ".concat(orderUuid));
|
|
@@ -1144,7 +1225,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1144
1225
|
}, new Decimal(0));
|
|
1145
1226
|
expectedDepositAmount = new Decimal(order.deposit_amount || '0').sub(paidDepositAmount); // 有一种特殊情况,订单金额为 0,但是定金金额>0,且此时是定金状态的,允许添加支付项
|
|
1146
1227
|
if (!(expectAmount.lte(0) && expectedDepositAmount.eq(0))) {
|
|
1147
|
-
|
|
1228
|
+
_context14.next = 17;
|
|
1148
1229
|
break;
|
|
1149
1230
|
}
|
|
1150
1231
|
warningMessage = "\u8BA2\u5355 ".concat(orderUuid, " \u5F85\u4ED8\u91D1\u989D\u5DF2\u4E3A0\uFF0C\u4E0D\u5141\u8BB8\u6DFB\u52A0\u65B0\u7684\u652F\u4ED8\u9879");
|
|
@@ -1199,7 +1280,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1199
1280
|
orderUuid: orderUuid,
|
|
1200
1281
|
order: order
|
|
1201
1282
|
});
|
|
1202
|
-
|
|
1283
|
+
_context14.next = 25;
|
|
1203
1284
|
return this.dbManager.update('order', order, true);
|
|
1204
1285
|
case 25:
|
|
1205
1286
|
this.logInfo('更新订单支付项完成', {
|
|
@@ -1222,24 +1303,24 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1222
1303
|
actualPaidAmount: (_newPaymentItem$metad2 = newPaymentItem.metadata) === null || _newPaymentItem$metad2 === void 0 ? void 0 : _newPaymentItem$metad2.actual_paid_amount,
|
|
1223
1304
|
changeGivenAmount: (_newPaymentItem$metad3 = newPaymentItem.metadata) === null || _newPaymentItem$metad3 === void 0 ? void 0 : _newPaymentItem$metad3.change_given_amount
|
|
1224
1305
|
});
|
|
1225
|
-
|
|
1306
|
+
_context14.next = 35;
|
|
1226
1307
|
break;
|
|
1227
1308
|
case 30:
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
console.error('[PaymentModule] 添加支付项失败',
|
|
1231
|
-
this.logError('addPaymentItemAsync failed',
|
|
1309
|
+
_context14.prev = 30;
|
|
1310
|
+
_context14.t0 = _context14["catch"](1);
|
|
1311
|
+
console.error('[PaymentModule] 添加支付项失败', _context14.t0);
|
|
1312
|
+
this.logError('addPaymentItemAsync failed', _context14.t0, {
|
|
1232
1313
|
orderUuid: orderUuid,
|
|
1233
1314
|
paymentItem: paymentItem
|
|
1234
1315
|
});
|
|
1235
|
-
throw
|
|
1316
|
+
throw _context14.t0;
|
|
1236
1317
|
case 35:
|
|
1237
1318
|
case "end":
|
|
1238
|
-
return
|
|
1319
|
+
return _context14.stop();
|
|
1239
1320
|
}
|
|
1240
|
-
},
|
|
1321
|
+
}, _callee14, this, [[1, 30]]);
|
|
1241
1322
|
}));
|
|
1242
|
-
function addPaymentItemAsync(
|
|
1323
|
+
function addPaymentItemAsync(_x15, _x16) {
|
|
1243
1324
|
return _addPaymentItemAsync.apply(this, arguments);
|
|
1244
1325
|
}
|
|
1245
1326
|
return addPaymentItemAsync;
|
|
@@ -1251,22 +1332,22 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1251
1332
|
}, {
|
|
1252
1333
|
key: "deletePaymentAsync",
|
|
1253
1334
|
value: (function () {
|
|
1254
|
-
var _deletePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1335
|
+
var _deletePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(orderUuid, paymentUuid) {
|
|
1255
1336
|
var order, paymentItem;
|
|
1256
|
-
return _regeneratorRuntime().wrap(function
|
|
1257
|
-
while (1) switch (
|
|
1337
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1338
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1258
1339
|
case 0:
|
|
1259
1340
|
this.logInfo('Starting deletePaymentAsync (mark as voided)', {
|
|
1260
1341
|
orderUuid: orderUuid,
|
|
1261
1342
|
paymentUuid: paymentUuid
|
|
1262
1343
|
});
|
|
1263
|
-
|
|
1264
|
-
|
|
1344
|
+
_context15.prev = 1;
|
|
1345
|
+
_context15.next = 4;
|
|
1265
1346
|
return this.dbManager.get('order', orderUuid);
|
|
1266
1347
|
case 4:
|
|
1267
|
-
order =
|
|
1348
|
+
order = _context15.sent;
|
|
1268
1349
|
if (order) {
|
|
1269
|
-
|
|
1350
|
+
_context15.next = 7;
|
|
1270
1351
|
break;
|
|
1271
1352
|
}
|
|
1272
1353
|
throw new Error('订单不存在');
|
|
@@ -1275,17 +1356,17 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1275
1356
|
return payment.uuid === paymentUuid;
|
|
1276
1357
|
});
|
|
1277
1358
|
if (paymentItem) {
|
|
1278
|
-
|
|
1359
|
+
_context15.next = 10;
|
|
1279
1360
|
break;
|
|
1280
1361
|
}
|
|
1281
1362
|
throw new Error("\u652F\u4ED8\u9879\u4E0D\u5B58\u5728: ".concat(paymentUuid));
|
|
1282
1363
|
case 10:
|
|
1283
1364
|
if (!(paymentItem.status === 'voided')) {
|
|
1284
|
-
|
|
1365
|
+
_context15.next = 13;
|
|
1285
1366
|
break;
|
|
1286
1367
|
}
|
|
1287
1368
|
console.warn("[PaymentModule] \u652F\u4ED8\u9879 ".concat(paymentUuid, " \u5DF2\u7ECF\u88AB\u5220\u9664\uFF0C\u8DF3\u8FC7\u64CD\u4F5C"));
|
|
1288
|
-
return
|
|
1369
|
+
return _context15.abrupt("return");
|
|
1289
1370
|
case 13:
|
|
1290
1371
|
// 标记删除而不是物理删除
|
|
1291
1372
|
paymentItem.status = 'voided';
|
|
@@ -1302,16 +1383,16 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1302
1383
|
this.recalculateOrderAmount(order);
|
|
1303
1384
|
|
|
1304
1385
|
// 更新到 IndexDB
|
|
1305
|
-
|
|
1386
|
+
_context15.next = 20;
|
|
1306
1387
|
return this.dbManager.update('order', order);
|
|
1307
1388
|
case 20:
|
|
1308
|
-
|
|
1389
|
+
_context15.next = 22;
|
|
1309
1390
|
return this.core.effects.emit("".concat(this.name, ":onPaymentDeleted"), {
|
|
1310
1391
|
order: order,
|
|
1311
1392
|
paymentItem: paymentItem
|
|
1312
1393
|
});
|
|
1313
1394
|
case 22:
|
|
1314
|
-
|
|
1395
|
+
_context15.next = 24;
|
|
1315
1396
|
return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
|
|
1316
1397
|
action: 'payment_delete',
|
|
1317
1398
|
order: order,
|
|
@@ -1324,24 +1405,24 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1324
1405
|
originalAmount: paymentItem.origin_amount,
|
|
1325
1406
|
newExpectAmount: order.expect_amount
|
|
1326
1407
|
});
|
|
1327
|
-
|
|
1408
|
+
_context15.next = 32;
|
|
1328
1409
|
break;
|
|
1329
1410
|
case 27:
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
console.error('[PaymentModule] 删除支付项失败',
|
|
1333
|
-
this.logError('deletePaymentAsync failed',
|
|
1411
|
+
_context15.prev = 27;
|
|
1412
|
+
_context15.t0 = _context15["catch"](1);
|
|
1413
|
+
console.error('[PaymentModule] 删除支付项失败', _context15.t0);
|
|
1414
|
+
this.logError('deletePaymentAsync failed', _context15.t0, {
|
|
1334
1415
|
orderUuid: orderUuid,
|
|
1335
1416
|
paymentUuid: paymentUuid
|
|
1336
1417
|
});
|
|
1337
|
-
throw
|
|
1418
|
+
throw _context15.t0;
|
|
1338
1419
|
case 32:
|
|
1339
1420
|
case "end":
|
|
1340
|
-
return
|
|
1421
|
+
return _context15.stop();
|
|
1341
1422
|
}
|
|
1342
|
-
},
|
|
1423
|
+
}, _callee15, this, [[1, 27]]);
|
|
1343
1424
|
}));
|
|
1344
|
-
function deletePaymentAsync(
|
|
1425
|
+
function deletePaymentAsync(_x17, _x18) {
|
|
1345
1426
|
return _deletePaymentAsync.apply(this, arguments);
|
|
1346
1427
|
}
|
|
1347
1428
|
return deletePaymentAsync;
|
|
@@ -1356,159 +1437,202 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1356
1437
|
}, {
|
|
1357
1438
|
key: "updateVoucherPaymentItemsAsync",
|
|
1358
1439
|
value: (function () {
|
|
1359
|
-
var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1360
|
-
var
|
|
1361
|
-
return _regeneratorRuntime().wrap(function
|
|
1362
|
-
while (1) switch (
|
|
1440
|
+
var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(orderUuid, voucherPaymentItems) {
|
|
1441
|
+
var _this5 = this;
|
|
1442
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1443
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1363
1444
|
case 0:
|
|
1364
|
-
this.
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1445
|
+
return _context17.abrupt("return", this.runVoucherUpdateLocked(orderUuid, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
1446
|
+
var _this5$normalizeVouch, normalizedVoucherItems, originalCount, normalizedCount, order, existingVoucherItems, _iterator6, _step6, voucherItem, orderAfterDelete, existingActiveVoucherKeys, _iterator7, _step7, _voucherItem, orderPaymentType, key, updatedOrder;
|
|
1447
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1448
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1449
|
+
case 0:
|
|
1450
|
+
_this5$normalizeVouch = _this5.normalizeVoucherPaymentItems(voucherPaymentItems), normalizedVoucherItems = _this5$normalizeVouch.items, originalCount = _this5$normalizeVouch.originalCount, normalizedCount = _this5$normalizeVouch.normalizedCount;
|
|
1451
|
+
_this5.logInfo('Starting updateVoucherPaymentItemsAsync', {
|
|
1452
|
+
orderUuid: orderUuid,
|
|
1453
|
+
originalVoucherCount: originalCount,
|
|
1454
|
+
normalizedVoucherCount: normalizedCount,
|
|
1455
|
+
voucherItems: normalizedVoucherItems.map(function (item) {
|
|
1456
|
+
return {
|
|
1457
|
+
code: item.code,
|
|
1458
|
+
amount: item.amount,
|
|
1459
|
+
voucher_id: item.voucher_id,
|
|
1460
|
+
order_payment_type: item.order_payment_type
|
|
1461
|
+
};
|
|
1462
|
+
})
|
|
1463
|
+
});
|
|
1464
|
+
if (originalCount !== normalizedCount) {
|
|
1465
|
+
console.warn('[PaymentModule] voucherPaymentItems detected duplicates (deduped by voucher_id + order_payment_type)', {
|
|
1466
|
+
orderUuid: orderUuid,
|
|
1467
|
+
originalCount: originalCount,
|
|
1468
|
+
normalizedCount: normalizedCount
|
|
1469
|
+
});
|
|
1470
|
+
}
|
|
1471
|
+
_context16.prev = 3;
|
|
1472
|
+
_context16.next = 6;
|
|
1473
|
+
return _this5.getPaymentOrderByUuidAsync(orderUuid);
|
|
1474
|
+
case 6:
|
|
1475
|
+
order = _context16.sent;
|
|
1476
|
+
if (order) {
|
|
1477
|
+
_context16.next = 9;
|
|
1478
|
+
break;
|
|
1479
|
+
}
|
|
1480
|
+
throw new Error("\u8BA2\u5355\u4E0D\u5B58\u5728: ".concat(orderUuid));
|
|
1481
|
+
case 9:
|
|
1482
|
+
// 1. 查找所有现有的代金券类支付项(带 voucher_id 且状态不是 voided)并且还没有同步给后端
|
|
1483
|
+
// 如果同步给了后端的voucher 不允许删除
|
|
1484
|
+
existingVoucherItems = order.payment.filter(function (payment) {
|
|
1485
|
+
return payment.voucher_id && payment.status !== 'voided' && !payment.isSynced;
|
|
1486
|
+
});
|
|
1487
|
+
console.log('[PaymentModule] 发现现有代金券支付项:', {
|
|
1488
|
+
orderUuid: orderUuid,
|
|
1489
|
+
existingVoucherCount: existingVoucherItems.length,
|
|
1490
|
+
existingItems: existingVoucherItems.map(function (item) {
|
|
1491
|
+
return {
|
|
1492
|
+
uuid: item.uuid,
|
|
1493
|
+
code: item.code,
|
|
1494
|
+
amount: item.amount,
|
|
1495
|
+
voucher_id: item.voucher_id,
|
|
1496
|
+
isSynced: item.isSynced
|
|
1497
|
+
};
|
|
1498
|
+
})
|
|
1499
|
+
});
|
|
1405
1500
|
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1501
|
+
// 2. 删除所有现有的代金券支付项(仅删除未同步的)
|
|
1502
|
+
_iterator6 = _createForOfIteratorHelper(existingVoucherItems);
|
|
1503
|
+
_context16.prev = 12;
|
|
1504
|
+
_iterator6.s();
|
|
1505
|
+
case 14:
|
|
1506
|
+
if ((_step6 = _iterator6.n()).done) {
|
|
1507
|
+
_context16.next = 21;
|
|
1508
|
+
break;
|
|
1509
|
+
}
|
|
1510
|
+
voucherItem = _step6.value;
|
|
1511
|
+
console.log("[PaymentModule] \u5220\u9664\u73B0\u6709\u4EE3\u91D1\u5238\u652F\u4ED8\u9879: ".concat(voucherItem.uuid));
|
|
1512
|
+
_context16.next = 19;
|
|
1513
|
+
return _this5.deletePaymentAsync(orderUuid, voucherItem.uuid);
|
|
1514
|
+
case 19:
|
|
1515
|
+
_context16.next = 14;
|
|
1516
|
+
break;
|
|
1517
|
+
case 21:
|
|
1518
|
+
_context16.next = 26;
|
|
1519
|
+
break;
|
|
1520
|
+
case 23:
|
|
1521
|
+
_context16.prev = 23;
|
|
1522
|
+
_context16.t0 = _context16["catch"](12);
|
|
1523
|
+
_iterator6.e(_context16.t0);
|
|
1524
|
+
case 26:
|
|
1525
|
+
_context16.prev = 26;
|
|
1526
|
+
_iterator6.f();
|
|
1527
|
+
return _context16.finish(26);
|
|
1528
|
+
case 29:
|
|
1529
|
+
_context16.next = 31;
|
|
1530
|
+
return _this5.getPaymentOrderByUuidAsync(orderUuid);
|
|
1531
|
+
case 31:
|
|
1532
|
+
orderAfterDelete = _context16.sent;
|
|
1533
|
+
if (orderAfterDelete) {
|
|
1534
|
+
_context16.next = 34;
|
|
1535
|
+
break;
|
|
1536
|
+
}
|
|
1537
|
+
throw new Error("\u8BA2\u5355\u4E0D\u5B58\u5728: ".concat(orderUuid));
|
|
1538
|
+
case 34:
|
|
1539
|
+
existingActiveVoucherKeys = new Set(orderAfterDelete.payment.filter(function (p) {
|
|
1540
|
+
return p.voucher_id && p.status !== 'voided' && !p.isSynced;
|
|
1541
|
+
}).map(function (p) {
|
|
1542
|
+
return "".concat(p.voucher_id, "|").concat(p.order_payment_type || 'normal');
|
|
1543
|
+
}));
|
|
1544
|
+
console.log('[PaymentModule] 添加新的代金券支付项:', {
|
|
1545
|
+
orderUuid: orderUuid,
|
|
1546
|
+
newItemCount: normalizedVoucherItems.length
|
|
1547
|
+
});
|
|
1548
|
+
_iterator7 = _createForOfIteratorHelper(normalizedVoucherItems);
|
|
1549
|
+
_context16.prev = 37;
|
|
1550
|
+
_iterator7.s();
|
|
1551
|
+
case 39:
|
|
1552
|
+
if ((_step7 = _iterator7.n()).done) {
|
|
1553
|
+
_context16.next = 52;
|
|
1554
|
+
break;
|
|
1555
|
+
}
|
|
1556
|
+
_voucherItem = _step7.value;
|
|
1557
|
+
orderPaymentType = _voucherItem.order_payment_type || 'normal';
|
|
1558
|
+
key = "".concat(_voucherItem.voucher_id, "|").concat(orderPaymentType);
|
|
1559
|
+
if (!existingActiveVoucherKeys.has(key)) {
|
|
1560
|
+
_context16.next = 46;
|
|
1561
|
+
break;
|
|
1562
|
+
}
|
|
1563
|
+
console.warn('[PaymentModule] Skip adding voucher payment item because it already exists (active)', {
|
|
1564
|
+
orderUuid: orderUuid,
|
|
1565
|
+
voucher_id: _voucherItem.voucher_id,
|
|
1566
|
+
order_payment_type: orderPaymentType
|
|
1567
|
+
});
|
|
1568
|
+
return _context16.abrupt("continue", 50);
|
|
1569
|
+
case 46:
|
|
1570
|
+
console.log("[PaymentModule] \u6DFB\u52A0\u4EE3\u91D1\u5238\u652F\u4ED8\u9879:", {
|
|
1571
|
+
code: _voucherItem.code,
|
|
1572
|
+
amount: _voucherItem.amount,
|
|
1573
|
+
voucher_id: _voucherItem.voucher_id,
|
|
1574
|
+
order_payment_type: orderPaymentType
|
|
1575
|
+
});
|
|
1576
|
+
_context16.next = 49;
|
|
1577
|
+
return _this5.addPaymentItemAsync(orderUuid, _voucherItem);
|
|
1578
|
+
case 49:
|
|
1579
|
+
existingActiveVoucherKeys.add(key);
|
|
1580
|
+
case 50:
|
|
1581
|
+
_context16.next = 39;
|
|
1582
|
+
break;
|
|
1583
|
+
case 52:
|
|
1584
|
+
_context16.next = 57;
|
|
1585
|
+
break;
|
|
1586
|
+
case 54:
|
|
1587
|
+
_context16.prev = 54;
|
|
1588
|
+
_context16.t1 = _context16["catch"](37);
|
|
1589
|
+
_iterator7.e(_context16.t1);
|
|
1590
|
+
case 57:
|
|
1591
|
+
_context16.prev = 57;
|
|
1592
|
+
_iterator7.f();
|
|
1593
|
+
return _context16.finish(57);
|
|
1594
|
+
case 60:
|
|
1595
|
+
_context16.next = 62;
|
|
1596
|
+
return _this5.getPaymentOrderByUuidAsync(orderUuid);
|
|
1597
|
+
case 62:
|
|
1598
|
+
updatedOrder = _context16.sent;
|
|
1599
|
+
_context16.next = 65;
|
|
1600
|
+
return _this5.core.effects.emit("".concat(_this5.name, ":onPaymentAdded"), {
|
|
1601
|
+
orderUuid: orderUuid,
|
|
1602
|
+
order: updatedOrder,
|
|
1603
|
+
payment: null // 批量操作不提供单个支付项
|
|
1604
|
+
});
|
|
1605
|
+
case 65:
|
|
1606
|
+
_this5.logInfo('updateVoucherPaymentItemsAsync completed successfully', {
|
|
1607
|
+
orderUuid: orderUuid,
|
|
1608
|
+
removedVoucherCount: existingVoucherItems.length,
|
|
1609
|
+
addedVoucherCount: normalizedVoucherItems.length,
|
|
1610
|
+
finalExpectAmount: updatedOrder === null || updatedOrder === void 0 ? void 0 : updatedOrder.expect_amount
|
|
1611
|
+
});
|
|
1612
|
+
_context16.next = 73;
|
|
1613
|
+
break;
|
|
1614
|
+
case 68:
|
|
1615
|
+
_context16.prev = 68;
|
|
1616
|
+
_context16.t2 = _context16["catch"](3);
|
|
1617
|
+
console.error('[PaymentModule] 批量更新代金券支付项失败:', _context16.t2);
|
|
1618
|
+
_this5.logError('updateVoucherPaymentItemsAsync failed', _context16.t2, {
|
|
1619
|
+
orderUuid: orderUuid,
|
|
1620
|
+
voucherPaymentItems: voucherPaymentItems
|
|
1621
|
+
});
|
|
1622
|
+
throw _context16.t2;
|
|
1623
|
+
case 73:
|
|
1624
|
+
case "end":
|
|
1625
|
+
return _context16.stop();
|
|
1626
|
+
}
|
|
1627
|
+
}, _callee16, null, [[3, 68], [12, 23, 26, 29], [37, 54, 57, 60]]);
|
|
1628
|
+
}))));
|
|
1629
|
+
case 1:
|
|
1506
1630
|
case "end":
|
|
1507
|
-
return
|
|
1631
|
+
return _context17.stop();
|
|
1508
1632
|
}
|
|
1509
|
-
},
|
|
1633
|
+
}, _callee17, this);
|
|
1510
1634
|
}));
|
|
1511
|
-
function updateVoucherPaymentItemsAsync(
|
|
1635
|
+
function updateVoucherPaymentItemsAsync(_x19, _x20) {
|
|
1512
1636
|
return _updateVoucherPaymentItemsAsync.apply(this, arguments);
|
|
1513
1637
|
}
|
|
1514
1638
|
return updateVoucherPaymentItemsAsync;
|
|
@@ -1520,18 +1644,18 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1520
1644
|
}, {
|
|
1521
1645
|
key: "updatePaymentAsync",
|
|
1522
1646
|
value: (function () {
|
|
1523
|
-
var _updatePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1647
|
+
var _updatePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(orderUuid, paymentUuid, params) {
|
|
1524
1648
|
var order, paymentItem, formattedParams;
|
|
1525
|
-
return _regeneratorRuntime().wrap(function
|
|
1526
|
-
while (1) switch (
|
|
1649
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1650
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1527
1651
|
case 0:
|
|
1528
|
-
|
|
1529
|
-
|
|
1652
|
+
_context18.prev = 0;
|
|
1653
|
+
_context18.next = 3;
|
|
1530
1654
|
return this.dbManager.get('order', orderUuid);
|
|
1531
1655
|
case 3:
|
|
1532
|
-
order =
|
|
1656
|
+
order = _context18.sent;
|
|
1533
1657
|
if (order) {
|
|
1534
|
-
|
|
1658
|
+
_context18.next = 6;
|
|
1535
1659
|
break;
|
|
1536
1660
|
}
|
|
1537
1661
|
throw new Error('订单不存在');
|
|
@@ -1540,7 +1664,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1540
1664
|
return payment.uuid === paymentUuid;
|
|
1541
1665
|
});
|
|
1542
1666
|
if (!paymentItem) {
|
|
1543
|
-
|
|
1667
|
+
_context18.next = 18;
|
|
1544
1668
|
break;
|
|
1545
1669
|
}
|
|
1546
1670
|
// 如果更新参数中包含 amount,先格式化
|
|
@@ -1554,36 +1678,36 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1554
1678
|
this.recalculateOrderAmount(order);
|
|
1555
1679
|
|
|
1556
1680
|
// 更新到 IndexDB
|
|
1557
|
-
|
|
1681
|
+
_context18.next = 14;
|
|
1558
1682
|
return this.dbManager.update('order', order);
|
|
1559
1683
|
case 14:
|
|
1560
|
-
|
|
1684
|
+
_context18.next = 16;
|
|
1561
1685
|
return this.core.effects.emit("".concat(this.name, ":onPaymentUpdated"), {
|
|
1562
1686
|
order: order,
|
|
1563
1687
|
paymentItem: paymentItem
|
|
1564
1688
|
});
|
|
1565
1689
|
case 16:
|
|
1566
|
-
|
|
1690
|
+
_context18.next = 18;
|
|
1567
1691
|
return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
|
|
1568
1692
|
action: 'payment_update',
|
|
1569
1693
|
order: order,
|
|
1570
1694
|
paymentItem: paymentItem
|
|
1571
1695
|
});
|
|
1572
1696
|
case 18:
|
|
1573
|
-
|
|
1697
|
+
_context18.next = 24;
|
|
1574
1698
|
break;
|
|
1575
1699
|
case 20:
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
console.error('[PaymentModule] 更新支付项失败',
|
|
1579
|
-
throw
|
|
1700
|
+
_context18.prev = 20;
|
|
1701
|
+
_context18.t0 = _context18["catch"](0);
|
|
1702
|
+
console.error('[PaymentModule] 更新支付项失败', _context18.t0);
|
|
1703
|
+
throw _context18.t0;
|
|
1580
1704
|
case 24:
|
|
1581
1705
|
case "end":
|
|
1582
|
-
return
|
|
1706
|
+
return _context18.stop();
|
|
1583
1707
|
}
|
|
1584
|
-
},
|
|
1708
|
+
}, _callee18, this, [[0, 20]]);
|
|
1585
1709
|
}));
|
|
1586
|
-
function updatePaymentAsync(
|
|
1710
|
+
function updatePaymentAsync(_x21, _x22, _x23) {
|
|
1587
1711
|
return _updatePaymentAsync.apply(this, arguments);
|
|
1588
1712
|
}
|
|
1589
1713
|
return updatePaymentAsync;
|
|
@@ -1595,61 +1719,61 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1595
1719
|
}, {
|
|
1596
1720
|
key: "submitPayAsync",
|
|
1597
1721
|
value: (function () {
|
|
1598
|
-
var _submitPayAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1599
|
-
var orderToSubmit, order, allOrders,
|
|
1600
|
-
return _regeneratorRuntime().wrap(function
|
|
1601
|
-
while (1) switch (
|
|
1722
|
+
var _submitPayAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(orderUuid) {
|
|
1723
|
+
var orderToSubmit, order, allOrders, _iterator8, _step8, _order, result;
|
|
1724
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1725
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1602
1726
|
case 0:
|
|
1603
1727
|
this.logInfo('Starting submitPayAsync', {
|
|
1604
1728
|
orderUuid: orderUuid
|
|
1605
1729
|
});
|
|
1606
|
-
|
|
1730
|
+
_context19.prev = 1;
|
|
1607
1731
|
if (!orderUuid) {
|
|
1608
|
-
|
|
1732
|
+
_context19.next = 9;
|
|
1609
1733
|
break;
|
|
1610
1734
|
}
|
|
1611
|
-
|
|
1735
|
+
_context19.next = 5;
|
|
1612
1736
|
return this.dbManager.get('order', orderUuid);
|
|
1613
1737
|
case 5:
|
|
1614
|
-
order =
|
|
1738
|
+
order = _context19.sent;
|
|
1615
1739
|
orderToSubmit = order ? [order] : [];
|
|
1616
|
-
|
|
1740
|
+
_context19.next = 13;
|
|
1617
1741
|
break;
|
|
1618
1742
|
case 9:
|
|
1619
|
-
|
|
1743
|
+
_context19.next = 11;
|
|
1620
1744
|
return this.dbManager.getAll('order');
|
|
1621
1745
|
case 11:
|
|
1622
|
-
allOrders =
|
|
1746
|
+
allOrders = _context19.sent;
|
|
1623
1747
|
// 包括正在处理中的订单和部分支付的订单(可能添加了新的支付项)
|
|
1624
1748
|
orderToSubmit = allOrders.filter(function (order) {
|
|
1625
1749
|
return order.payment_status === PaymentStatus.Processing || order.payment_status === PaymentStatus.PartiallyPaid;
|
|
1626
1750
|
});
|
|
1627
1751
|
case 13:
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1752
|
+
_iterator8 = _createForOfIteratorHelper(orderToSubmit);
|
|
1753
|
+
_context19.prev = 14;
|
|
1754
|
+
_iterator8.s();
|
|
1631
1755
|
case 16:
|
|
1632
|
-
if ((
|
|
1633
|
-
|
|
1756
|
+
if ((_step8 = _iterator8.n()).done) {
|
|
1757
|
+
_context19.next = 22;
|
|
1634
1758
|
break;
|
|
1635
1759
|
}
|
|
1636
|
-
_order =
|
|
1637
|
-
|
|
1760
|
+
_order = _step8.value;
|
|
1761
|
+
_context19.next = 20;
|
|
1638
1762
|
return this.submitSingleOrderPayment(_order);
|
|
1639
1763
|
case 20:
|
|
1640
|
-
|
|
1764
|
+
_context19.next = 16;
|
|
1641
1765
|
break;
|
|
1642
1766
|
case 22:
|
|
1643
|
-
|
|
1767
|
+
_context19.next = 27;
|
|
1644
1768
|
break;
|
|
1645
1769
|
case 24:
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1770
|
+
_context19.prev = 24;
|
|
1771
|
+
_context19.t0 = _context19["catch"](14);
|
|
1772
|
+
_iterator8.e(_context19.t0);
|
|
1649
1773
|
case 27:
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
return
|
|
1774
|
+
_context19.prev = 27;
|
|
1775
|
+
_iterator8.f();
|
|
1776
|
+
return _context19.finish(27);
|
|
1653
1777
|
case 30:
|
|
1654
1778
|
result = {
|
|
1655
1779
|
status: 'success'
|
|
@@ -1658,24 +1782,24 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1658
1782
|
result: result.status,
|
|
1659
1783
|
processedOrdersCount: orderToSubmit.length
|
|
1660
1784
|
});
|
|
1661
|
-
return
|
|
1785
|
+
return _context19.abrupt("return", result);
|
|
1662
1786
|
case 35:
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
console.error('[PaymentModule] 提交支付失败',
|
|
1666
|
-
this.logError('submitPayAsync failed',
|
|
1787
|
+
_context19.prev = 35;
|
|
1788
|
+
_context19.t1 = _context19["catch"](1);
|
|
1789
|
+
console.error('[PaymentModule] 提交支付失败', _context19.t1);
|
|
1790
|
+
this.logError('submitPayAsync failed', _context19.t1, {
|
|
1667
1791
|
orderUuid: orderUuid
|
|
1668
1792
|
});
|
|
1669
|
-
return
|
|
1793
|
+
return _context19.abrupt("return", {
|
|
1670
1794
|
status: 'failed'
|
|
1671
1795
|
});
|
|
1672
1796
|
case 40:
|
|
1673
1797
|
case "end":
|
|
1674
|
-
return
|
|
1798
|
+
return _context19.stop();
|
|
1675
1799
|
}
|
|
1676
|
-
},
|
|
1800
|
+
}, _callee19, this, [[1, 35], [14, 24, 27, 30]]);
|
|
1677
1801
|
}));
|
|
1678
|
-
function submitPayAsync(
|
|
1802
|
+
function submitPayAsync(_x24) {
|
|
1679
1803
|
return _submitPayAsync.apply(this, arguments);
|
|
1680
1804
|
}
|
|
1681
1805
|
return submitPayAsync;
|
|
@@ -1687,12 +1811,12 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1687
1811
|
}, {
|
|
1688
1812
|
key: "submitSingleOrderPayment",
|
|
1689
1813
|
value: (function () {
|
|
1690
|
-
var _submitSingleOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1814
|
+
var _submitSingleOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(order) {
|
|
1691
1815
|
var paymentData, totalPaidAmount, orderTotalAmount;
|
|
1692
|
-
return _regeneratorRuntime().wrap(function
|
|
1693
|
-
while (1) switch (
|
|
1816
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1817
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1694
1818
|
case 0:
|
|
1695
|
-
|
|
1819
|
+
_context20.prev = 0;
|
|
1696
1820
|
paymentData = {
|
|
1697
1821
|
payments: order.payment.map(function (payment) {
|
|
1698
1822
|
return {
|
|
@@ -1728,11 +1852,11 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1728
1852
|
paymentData.payment_status = order.payment_status === PaymentStatus.Finished ? 'paid' : 'partially_paid';
|
|
1729
1853
|
|
|
1730
1854
|
// 更新订单状态到数据库
|
|
1731
|
-
|
|
1855
|
+
_context20.next = 8;
|
|
1732
1856
|
return this.dbManager.update('order', order);
|
|
1733
1857
|
case 8:
|
|
1734
1858
|
if (!(paymentData.payments.length === 0)) {
|
|
1735
|
-
|
|
1859
|
+
_context20.next = 12;
|
|
1736
1860
|
break;
|
|
1737
1861
|
}
|
|
1738
1862
|
console.log("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u652F\u4ED8\u5217\u8868\u4E3A\u7A7A\uFF0C\u8DF3\u8FC7\u652F\u4ED8\u5904\u7406"));
|
|
@@ -1740,31 +1864,31 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1740
1864
|
orderUuid: order.uuid,
|
|
1741
1865
|
orderId: order.order_id
|
|
1742
1866
|
});
|
|
1743
|
-
return
|
|
1867
|
+
return _context20.abrupt("return");
|
|
1744
1868
|
case 12:
|
|
1745
|
-
|
|
1869
|
+
_context20.next = 14;
|
|
1746
1870
|
return this.core.effects.emit("".concat(this.name, ":onPaymentSubmitted"), order);
|
|
1747
1871
|
case 14:
|
|
1748
|
-
|
|
1872
|
+
_context20.next = 16;
|
|
1749
1873
|
return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
|
|
1750
1874
|
action: 'submit',
|
|
1751
1875
|
order: order
|
|
1752
1876
|
});
|
|
1753
1877
|
case 16:
|
|
1754
|
-
|
|
1878
|
+
_context20.next = 22;
|
|
1755
1879
|
break;
|
|
1756
1880
|
case 18:
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
console.error("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u652F\u4ED8\u63D0\u4EA4\u5931\u8D25"),
|
|
1760
|
-
throw
|
|
1881
|
+
_context20.prev = 18;
|
|
1882
|
+
_context20.t0 = _context20["catch"](0);
|
|
1883
|
+
console.error("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u652F\u4ED8\u63D0\u4EA4\u5931\u8D25"), _context20.t0);
|
|
1884
|
+
throw _context20.t0;
|
|
1761
1885
|
case 22:
|
|
1762
1886
|
case "end":
|
|
1763
|
-
return
|
|
1887
|
+
return _context20.stop();
|
|
1764
1888
|
}
|
|
1765
|
-
},
|
|
1889
|
+
}, _callee20, this, [[0, 18]]);
|
|
1766
1890
|
}));
|
|
1767
|
-
function submitSingleOrderPayment(
|
|
1891
|
+
function submitSingleOrderPayment(_x25) {
|
|
1768
1892
|
return _submitSingleOrderPayment.apply(this, arguments);
|
|
1769
1893
|
}
|
|
1770
1894
|
return submitSingleOrderPayment;
|
|
@@ -1776,29 +1900,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1776
1900
|
}, {
|
|
1777
1901
|
key: "getRemainingOrderAmountAsync",
|
|
1778
1902
|
value: (function () {
|
|
1779
|
-
var _getRemainingOrderAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1903
|
+
var _getRemainingOrderAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(orderUuid) {
|
|
1780
1904
|
var order;
|
|
1781
|
-
return _regeneratorRuntime().wrap(function
|
|
1782
|
-
while (1) switch (
|
|
1905
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1906
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1783
1907
|
case 0:
|
|
1784
|
-
|
|
1908
|
+
_context21.next = 2;
|
|
1785
1909
|
return this.getPaymentOrderByUuidAsync(orderUuid);
|
|
1786
1910
|
case 2:
|
|
1787
|
-
order =
|
|
1911
|
+
order = _context21.sent;
|
|
1788
1912
|
if (order) {
|
|
1789
|
-
|
|
1913
|
+
_context21.next = 5;
|
|
1790
1914
|
break;
|
|
1791
1915
|
}
|
|
1792
1916
|
throw new Error('订单不存在');
|
|
1793
1917
|
case 5:
|
|
1794
|
-
return
|
|
1918
|
+
return _context21.abrupt("return", new Decimal(order.expect_amount).toNumber());
|
|
1795
1919
|
case 6:
|
|
1796
1920
|
case "end":
|
|
1797
|
-
return
|
|
1921
|
+
return _context21.stop();
|
|
1798
1922
|
}
|
|
1799
|
-
},
|
|
1923
|
+
}, _callee21, this);
|
|
1800
1924
|
}));
|
|
1801
|
-
function getRemainingOrderAmountAsync(
|
|
1925
|
+
function getRemainingOrderAmountAsync(_x26) {
|
|
1802
1926
|
return _getRemainingOrderAmountAsync.apply(this, arguments);
|
|
1803
1927
|
}
|
|
1804
1928
|
return getRemainingOrderAmountAsync;
|
|
@@ -1810,65 +1934,65 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1810
1934
|
}, {
|
|
1811
1935
|
key: "getRemainingOrderAmountWithInputAsync",
|
|
1812
1936
|
value: (function () {
|
|
1813
|
-
var _getRemainingOrderAmountWithInputAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1937
|
+
var _getRemainingOrderAmountWithInputAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(inputAmount, orderUuid) {
|
|
1814
1938
|
var order, inputDecimal;
|
|
1815
|
-
return _regeneratorRuntime().wrap(function
|
|
1816
|
-
while (1) switch (
|
|
1939
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1940
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1817
1941
|
case 0:
|
|
1818
|
-
|
|
1942
|
+
_context22.next = 2;
|
|
1819
1943
|
return this.getPaymentOrderByUuidAsync(orderUuid);
|
|
1820
1944
|
case 2:
|
|
1821
|
-
order =
|
|
1945
|
+
order = _context22.sent;
|
|
1822
1946
|
if (order) {
|
|
1823
|
-
|
|
1947
|
+
_context22.next = 5;
|
|
1824
1948
|
break;
|
|
1825
1949
|
}
|
|
1826
1950
|
throw new Error('订单不存在');
|
|
1827
1951
|
case 5:
|
|
1828
1952
|
if (!(inputAmount === null || inputAmount === undefined)) {
|
|
1829
|
-
|
|
1953
|
+
_context22.next = 7;
|
|
1830
1954
|
break;
|
|
1831
1955
|
}
|
|
1832
|
-
return
|
|
1956
|
+
return _context22.abrupt("return", new Decimal(order.expect_amount).toNumber());
|
|
1833
1957
|
case 7:
|
|
1834
1958
|
if (!(typeof inputAmount === 'string')) {
|
|
1835
|
-
|
|
1959
|
+
_context22.next = 10;
|
|
1836
1960
|
break;
|
|
1837
1961
|
}
|
|
1838
1962
|
if (!(inputAmount.trim() === '')) {
|
|
1839
|
-
|
|
1963
|
+
_context22.next = 10;
|
|
1840
1964
|
break;
|
|
1841
1965
|
}
|
|
1842
|
-
return
|
|
1966
|
+
return _context22.abrupt("return", new Decimal(order.expect_amount).toNumber());
|
|
1843
1967
|
case 10:
|
|
1844
1968
|
if (!(typeof inputAmount === 'number')) {
|
|
1845
|
-
|
|
1969
|
+
_context22.next = 14;
|
|
1846
1970
|
break;
|
|
1847
1971
|
}
|
|
1848
1972
|
if (!(isNaN(inputAmount) || !isFinite(inputAmount))) {
|
|
1849
|
-
|
|
1973
|
+
_context22.next = 14;
|
|
1850
1974
|
break;
|
|
1851
1975
|
}
|
|
1852
1976
|
// 如果输入是 NaN 或无穷大,返回原始的待付金额
|
|
1853
1977
|
console.warn("[PaymentModule] \u8F93\u5165\u91D1\u989D\u4E0D\u662F\u6709\u6548\u6570\u5B57: ".concat(inputAmount, "\uFF0C\u8FD4\u56DE\u539F\u59CB\u5F85\u4ED8\u91D1\u989D"));
|
|
1854
|
-
return
|
|
1978
|
+
return _context22.abrupt("return", new Decimal(order.expect_amount).toNumber());
|
|
1855
1979
|
case 14:
|
|
1856
|
-
|
|
1980
|
+
_context22.prev = 14;
|
|
1857
1981
|
inputDecimal = new Decimal(inputAmount);
|
|
1858
|
-
return
|
|
1982
|
+
return _context22.abrupt("return", new Decimal(order.expect_amount).minus(inputDecimal).toNumber());
|
|
1859
1983
|
case 19:
|
|
1860
|
-
|
|
1861
|
-
|
|
1984
|
+
_context22.prev = 19;
|
|
1985
|
+
_context22.t0 = _context22["catch"](14);
|
|
1862
1986
|
// 如果输入不是有效的数字,返回原始的待付金额
|
|
1863
1987
|
console.warn("[PaymentModule] \u8F93\u5165\u91D1\u989D\u683C\u5F0F\u65E0\u6548: ".concat(inputAmount, "\uFF0C\u8FD4\u56DE\u539F\u59CB\u5F85\u4ED8\u91D1\u989D"));
|
|
1864
|
-
return
|
|
1988
|
+
return _context22.abrupt("return", new Decimal(order.expect_amount).toNumber());
|
|
1865
1989
|
case 23:
|
|
1866
1990
|
case "end":
|
|
1867
|
-
return
|
|
1991
|
+
return _context22.stop();
|
|
1868
1992
|
}
|
|
1869
|
-
},
|
|
1993
|
+
}, _callee22, this, [[14, 19]]);
|
|
1870
1994
|
}));
|
|
1871
|
-
function getRemainingOrderAmountWithInputAsync(
|
|
1995
|
+
function getRemainingOrderAmountWithInputAsync(_x27, _x28) {
|
|
1872
1996
|
return _getRemainingOrderAmountWithInputAsync.apply(this, arguments);
|
|
1873
1997
|
}
|
|
1874
1998
|
return getRemainingOrderAmountWithInputAsync;
|
|
@@ -1891,9 +2015,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1891
2015
|
// 计算有效支付金额:支付金额 + 抹零金额的绝对值
|
|
1892
2016
|
// 当 rounding_amount 为负数时,表示抹掉的金额,按绝对值计算有效支付
|
|
1893
2017
|
// 例如:amount=15, rounding_amount=-0.2,有效支付=15.2(抹掉0.2元零头)
|
|
2018
|
+
// 例2:amount=15,rounding_amount=0.2,有效支付 14.8
|
|
1894
2019
|
var paymentAmount = new Decimal(payment.amount || 0);
|
|
1895
2020
|
var roundingAmount = new Decimal(payment.rounding_amount || 0);
|
|
1896
|
-
var effectiveAmount = paymentAmount.
|
|
2021
|
+
var effectiveAmount = paymentAmount.minus(roundingAmount);
|
|
1897
2022
|
return sum.plus(effectiveAmount);
|
|
1898
2023
|
} catch (error) {
|
|
1899
2024
|
console.warn("[PaymentModule] \u65E0\u6548\u7684\u652F\u4ED8\u91D1\u989D: amount=".concat(payment.amount, ", rounding_amount=").concat(payment.rounding_amount, "\uFF0C\u8DF3\u8FC7\u8BA1\u7B97"));
|
|
@@ -1921,7 +2046,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1921
2046
|
code: p.code,
|
|
1922
2047
|
amount: p.amount,
|
|
1923
2048
|
rounding_amount: p.rounding_amount || '0.00',
|
|
1924
|
-
effective_amount: new Decimal(p.amount || 0).
|
|
2049
|
+
effective_amount: new Decimal(p.amount || 0).minus(new Decimal(p.rounding_amount || 0)).toFixed(2)
|
|
1925
2050
|
};
|
|
1926
2051
|
}),
|
|
1927
2052
|
说明: '有效支付金额包含抹零计算(amount + |rounding_amount|)'
|
|
@@ -1934,29 +2059,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1934
2059
|
}, {
|
|
1935
2060
|
key: "getCashPaymentMethod",
|
|
1936
2061
|
value: (function () {
|
|
1937
|
-
var _getCashPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2062
|
+
var _getCashPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
1938
2063
|
var payMethods;
|
|
1939
|
-
return _regeneratorRuntime().wrap(function
|
|
1940
|
-
while (1) switch (
|
|
2064
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2065
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1941
2066
|
case 0:
|
|
1942
|
-
|
|
1943
|
-
|
|
2067
|
+
_context23.prev = 0;
|
|
2068
|
+
_context23.next = 3;
|
|
1944
2069
|
return this.dbManager.getAll('pay_method');
|
|
1945
2070
|
case 3:
|
|
1946
|
-
payMethods =
|
|
1947
|
-
return
|
|
2071
|
+
payMethods = _context23.sent;
|
|
2072
|
+
return _context23.abrupt("return", payMethods.find(function (method) {
|
|
1948
2073
|
return method.code === PaymentMethodType.Cash;
|
|
1949
2074
|
}) || null);
|
|
1950
2075
|
case 7:
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
console.error('[PaymentModule] 获取现金支付方式失败',
|
|
1954
|
-
return
|
|
2076
|
+
_context23.prev = 7;
|
|
2077
|
+
_context23.t0 = _context23["catch"](0);
|
|
2078
|
+
console.error('[PaymentModule] 获取现金支付方式失败', _context23.t0);
|
|
2079
|
+
return _context23.abrupt("return", null);
|
|
1955
2080
|
case 11:
|
|
1956
2081
|
case "end":
|
|
1957
|
-
return
|
|
2082
|
+
return _context23.stop();
|
|
1958
2083
|
}
|
|
1959
|
-
},
|
|
2084
|
+
}, _callee23, this, [[0, 7]]);
|
|
1960
2085
|
}));
|
|
1961
2086
|
function getCashPaymentMethod() {
|
|
1962
2087
|
return _getCashPaymentMethod.apply(this, arguments);
|
|
@@ -1970,29 +2095,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1970
2095
|
}, {
|
|
1971
2096
|
key: "getEftposPaymentMethod",
|
|
1972
2097
|
value: (function () {
|
|
1973
|
-
var _getEftposPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2098
|
+
var _getEftposPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
1974
2099
|
var payMethods;
|
|
1975
|
-
return _regeneratorRuntime().wrap(function
|
|
1976
|
-
while (1) switch (
|
|
2100
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2101
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1977
2102
|
case 0:
|
|
1978
|
-
|
|
1979
|
-
|
|
2103
|
+
_context24.prev = 0;
|
|
2104
|
+
_context24.next = 3;
|
|
1980
2105
|
return this.dbManager.getAll('pay_method');
|
|
1981
2106
|
case 3:
|
|
1982
|
-
payMethods =
|
|
1983
|
-
return
|
|
2107
|
+
payMethods = _context24.sent;
|
|
2108
|
+
return _context24.abrupt("return", payMethods.find(function (method) {
|
|
1984
2109
|
return method.code === PaymentMethodType.Eftpos;
|
|
1985
2110
|
}) || null);
|
|
1986
2111
|
case 7:
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
console.error('[PaymentModule] 获取Eftpos支付方式失败',
|
|
1990
|
-
return
|
|
2112
|
+
_context24.prev = 7;
|
|
2113
|
+
_context24.t0 = _context24["catch"](0);
|
|
2114
|
+
console.error('[PaymentModule] 获取Eftpos支付方式失败', _context24.t0);
|
|
2115
|
+
return _context24.abrupt("return", null);
|
|
1991
2116
|
case 11:
|
|
1992
2117
|
case "end":
|
|
1993
|
-
return
|
|
2118
|
+
return _context24.stop();
|
|
1994
2119
|
}
|
|
1995
|
-
},
|
|
2120
|
+
}, _callee24, this, [[0, 7]]);
|
|
1996
2121
|
}));
|
|
1997
2122
|
function getEftposPaymentMethod() {
|
|
1998
2123
|
return _getEftposPaymentMethod.apply(this, arguments);
|
|
@@ -2006,29 +2131,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2006
2131
|
}, {
|
|
2007
2132
|
key: "getWalletPaymentMethod",
|
|
2008
2133
|
value: (function () {
|
|
2009
|
-
var _getWalletPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2134
|
+
var _getWalletPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
2010
2135
|
var payMethods;
|
|
2011
|
-
return _regeneratorRuntime().wrap(function
|
|
2012
|
-
while (1) switch (
|
|
2136
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2137
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2013
2138
|
case 0:
|
|
2014
|
-
|
|
2015
|
-
|
|
2139
|
+
_context25.prev = 0;
|
|
2140
|
+
_context25.next = 3;
|
|
2016
2141
|
return this.dbManager.getAll('pay_method');
|
|
2017
2142
|
case 3:
|
|
2018
|
-
payMethods =
|
|
2019
|
-
return
|
|
2143
|
+
payMethods = _context25.sent;
|
|
2144
|
+
return _context25.abrupt("return", payMethods.find(function (method) {
|
|
2020
2145
|
return method.code === PaymentMethodType.Wallet;
|
|
2021
2146
|
}) || null);
|
|
2022
2147
|
case 7:
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
console.error('[PaymentModule] 获取钱包支付方式失败',
|
|
2026
|
-
return
|
|
2148
|
+
_context25.prev = 7;
|
|
2149
|
+
_context25.t0 = _context25["catch"](0);
|
|
2150
|
+
console.error('[PaymentModule] 获取钱包支付方式失败', _context25.t0);
|
|
2151
|
+
return _context25.abrupt("return", null);
|
|
2027
2152
|
case 11:
|
|
2028
2153
|
case "end":
|
|
2029
|
-
return
|
|
2154
|
+
return _context25.stop();
|
|
2030
2155
|
}
|
|
2031
|
-
},
|
|
2156
|
+
}, _callee25, this, [[0, 7]]);
|
|
2032
2157
|
}));
|
|
2033
2158
|
function getWalletPaymentMethod() {
|
|
2034
2159
|
return _getWalletPaymentMethod.apply(this, arguments);
|
|
@@ -2042,38 +2167,38 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2042
2167
|
}, {
|
|
2043
2168
|
key: "ensurePaymentTables",
|
|
2044
2169
|
value: (function () {
|
|
2045
|
-
var _ensurePaymentTables = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2046
|
-
return _regeneratorRuntime().wrap(function
|
|
2047
|
-
while (1) switch (
|
|
2170
|
+
var _ensurePaymentTables = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
2171
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2172
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2048
2173
|
case 0:
|
|
2049
|
-
|
|
2050
|
-
|
|
2174
|
+
_context26.prev = 0;
|
|
2175
|
+
_context26.next = 3;
|
|
2051
2176
|
return this.dbManager.getAll('pay_method');
|
|
2052
2177
|
case 3:
|
|
2053
|
-
|
|
2178
|
+
_context26.next = 9;
|
|
2054
2179
|
break;
|
|
2055
2180
|
case 5:
|
|
2056
|
-
|
|
2057
|
-
|
|
2181
|
+
_context26.prev = 5;
|
|
2182
|
+
_context26.t0 = _context26["catch"](0);
|
|
2058
2183
|
console.warn('[PaymentModule] pay_method 表不存在,请在数据库配置中添加以下配置:');
|
|
2059
2184
|
console.warn('{ name: "pay_method", keyPath: "id" }');
|
|
2060
2185
|
case 9:
|
|
2061
|
-
|
|
2062
|
-
|
|
2186
|
+
_context26.prev = 9;
|
|
2187
|
+
_context26.next = 12;
|
|
2063
2188
|
return this.dbManager.getAll('order');
|
|
2064
2189
|
case 12:
|
|
2065
|
-
|
|
2190
|
+
_context26.next = 18;
|
|
2066
2191
|
break;
|
|
2067
2192
|
case 14:
|
|
2068
|
-
|
|
2069
|
-
|
|
2193
|
+
_context26.prev = 14;
|
|
2194
|
+
_context26.t1 = _context26["catch"](9);
|
|
2070
2195
|
console.warn('[PaymentModule] order 表不存在,请在数据库配置中添加以下配置:');
|
|
2071
2196
|
console.warn('{ name: "order", keyPath: "uuid" }');
|
|
2072
2197
|
case 18:
|
|
2073
2198
|
case "end":
|
|
2074
|
-
return
|
|
2199
|
+
return _context26.stop();
|
|
2075
2200
|
}
|
|
2076
|
-
},
|
|
2201
|
+
}, _callee26, this, [[0, 5], [9, 14]]);
|
|
2077
2202
|
}));
|
|
2078
2203
|
function ensurePaymentTables() {
|
|
2079
2204
|
return _ensurePaymentTables.apply(this, arguments);
|
|
@@ -2087,29 +2212,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2087
2212
|
}, {
|
|
2088
2213
|
key: "getPartiallyPaidOrdersAsync",
|
|
2089
2214
|
value: (function () {
|
|
2090
|
-
var _getPartiallyPaidOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2215
|
+
var _getPartiallyPaidOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
2091
2216
|
var allOrders;
|
|
2092
|
-
return _regeneratorRuntime().wrap(function
|
|
2093
|
-
while (1) switch (
|
|
2217
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2218
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2094
2219
|
case 0:
|
|
2095
|
-
|
|
2096
|
-
|
|
2220
|
+
_context27.prev = 0;
|
|
2221
|
+
_context27.next = 3;
|
|
2097
2222
|
return this.dbManager.getAll('order');
|
|
2098
2223
|
case 3:
|
|
2099
|
-
allOrders =
|
|
2100
|
-
return
|
|
2224
|
+
allOrders = _context27.sent;
|
|
2225
|
+
return _context27.abrupt("return", allOrders.filter(function (order) {
|
|
2101
2226
|
return order.payment_status === PaymentStatus.PartiallyPaid;
|
|
2102
2227
|
}));
|
|
2103
2228
|
case 7:
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
console.error('[PaymentModule] 获取部分支付订单失败',
|
|
2107
|
-
return
|
|
2229
|
+
_context27.prev = 7;
|
|
2230
|
+
_context27.t0 = _context27["catch"](0);
|
|
2231
|
+
console.error('[PaymentModule] 获取部分支付订单失败', _context27.t0);
|
|
2232
|
+
return _context27.abrupt("return", []);
|
|
2108
2233
|
case 11:
|
|
2109
2234
|
case "end":
|
|
2110
|
-
return
|
|
2235
|
+
return _context27.stop();
|
|
2111
2236
|
}
|
|
2112
|
-
},
|
|
2237
|
+
}, _callee27, this, [[0, 7]]);
|
|
2113
2238
|
}));
|
|
2114
2239
|
function getPartiallyPaidOrdersAsync() {
|
|
2115
2240
|
return _getPartiallyPaidOrdersAsync.apply(this, arguments);
|
|
@@ -2130,17 +2255,17 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2130
2255
|
}, {
|
|
2131
2256
|
key: "roundAmountAsync",
|
|
2132
2257
|
value: function () {
|
|
2133
|
-
var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2258
|
+
var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(originalAmount, interval, rule) {
|
|
2134
2259
|
var amount, roundingInterval, supportedIntervals, intervalValue, baseValue, roundedValue, finalAmount, originalAmountStr, roundedAmountStr, roundingDifference, roundingDifferenceStr;
|
|
2135
|
-
return _regeneratorRuntime().wrap(function
|
|
2136
|
-
while (1) switch (
|
|
2260
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2261
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2137
2262
|
case 0:
|
|
2138
|
-
|
|
2263
|
+
_context28.prev = 0;
|
|
2139
2264
|
// 参数验证
|
|
2140
2265
|
amount = new Decimal(originalAmount);
|
|
2141
2266
|
roundingInterval = new Decimal(interval);
|
|
2142
2267
|
if (!roundingInterval.lte(0)) {
|
|
2143
|
-
|
|
2268
|
+
_context28.next = 5;
|
|
2144
2269
|
break;
|
|
2145
2270
|
}
|
|
2146
2271
|
throw new Error('舍入间隔必须大于 0');
|
|
@@ -2155,25 +2280,25 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2155
2280
|
// 计算基础值:x / interval
|
|
2156
2281
|
baseValue = amount.div(roundingInterval);
|
|
2157
2282
|
console.log("[PaymentModule] \u820D\u5165\u8BA1\u7B97 - \u539F\u59CB\u91D1\u989D: ".concat(amount.toString(), ", \u95F4\u9694: ").concat(intervalValue, ", \u57FA\u7840\u503C: ").concat(baseValue.toString(), ", \u89C4\u5219: ").concat(rule));
|
|
2158
|
-
|
|
2159
|
-
|
|
2283
|
+
_context28.t0 = rule;
|
|
2284
|
+
_context28.next = _context28.t0 === RoundingRule.Standard ? 13 : _context28.t0 === 'standard' ? 13 : _context28.t0 === RoundingRule.StandardDown ? 15 : _context28.t0 === 'standard_down' ? 15 : _context28.t0 === RoundingRule.AlwaysUp ? 17 : _context28.t0 === 'always_up' ? 17 : _context28.t0 === RoundingRule.AlwaysDown ? 19 : _context28.t0 === 'always_down' ? 19 : 21;
|
|
2160
2285
|
break;
|
|
2161
2286
|
case 13:
|
|
2162
2287
|
// 标准舍入(中点向上)
|
|
2163
2288
|
roundedValue = this.standardRound(baseValue, true);
|
|
2164
|
-
return
|
|
2289
|
+
return _context28.abrupt("break", 22);
|
|
2165
2290
|
case 15:
|
|
2166
2291
|
// 标准舍入(中点向下)
|
|
2167
2292
|
roundedValue = this.standardRound(baseValue, false);
|
|
2168
|
-
return
|
|
2293
|
+
return _context28.abrupt("break", 22);
|
|
2169
2294
|
case 17:
|
|
2170
2295
|
// 总是向上舍入
|
|
2171
2296
|
roundedValue = baseValue.ceil();
|
|
2172
|
-
return
|
|
2297
|
+
return _context28.abrupt("break", 22);
|
|
2173
2298
|
case 19:
|
|
2174
2299
|
// 总是向下舍入
|
|
2175
2300
|
roundedValue = baseValue.floor();
|
|
2176
|
-
return
|
|
2301
|
+
return _context28.abrupt("break", 22);
|
|
2177
2302
|
case 21:
|
|
2178
2303
|
throw new Error("\u4E0D\u652F\u6301\u7684\u820D\u5165\u89C4\u5219: ".concat(rule));
|
|
2179
2304
|
case 22:
|
|
@@ -2181,11 +2306,11 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2181
2306
|
finalAmount = roundedValue.mul(roundingInterval);
|
|
2182
2307
|
originalAmountStr = amount.toFixed(2); // 如果最终金额是 0 元,则不采用舍入金额,返回原始金额
|
|
2183
2308
|
if (!finalAmount.eq(0)) {
|
|
2184
|
-
|
|
2309
|
+
_context28.next = 27;
|
|
2185
2310
|
break;
|
|
2186
2311
|
}
|
|
2187
2312
|
console.log("[PaymentModule] \u6700\u7EC8\u91D1\u989D\u4E3A0\uFF0C\u8FD4\u56DE\u539F\u59CB\u91D1\u989D: ".concat(originalAmountStr));
|
|
2188
|
-
return
|
|
2313
|
+
return _context28.abrupt("return", {
|
|
2189
2314
|
originalAmount: originalAmountStr,
|
|
2190
2315
|
roundedAmount: originalAmountStr,
|
|
2191
2316
|
roundingDifference: '0.00'
|
|
@@ -2195,23 +2320,23 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2195
2320
|
roundingDifference = finalAmount.sub(amount);
|
|
2196
2321
|
roundingDifferenceStr = roundingDifference.toFixed(2);
|
|
2197
2322
|
console.log("[PaymentModule] \u820D\u5165\u7ED3\u679C - \u539F\u59CB\u91D1\u989D: ".concat(originalAmountStr, ", \u820D\u5165\u540E\u91D1\u989D: ").concat(roundedAmountStr, ", \u820D\u5165\u5DEE\u989D: ").concat(roundingDifferenceStr));
|
|
2198
|
-
return
|
|
2323
|
+
return _context28.abrupt("return", {
|
|
2199
2324
|
originalAmount: originalAmountStr,
|
|
2200
2325
|
roundedAmount: roundedAmountStr,
|
|
2201
2326
|
roundingDifference: roundingDifferenceStr
|
|
2202
2327
|
});
|
|
2203
2328
|
case 34:
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
console.error('[PaymentModule] 金额舍入失败:',
|
|
2207
|
-
throw new Error("\u91D1\u989D\u820D\u5165\u5931\u8D25: ".concat(
|
|
2329
|
+
_context28.prev = 34;
|
|
2330
|
+
_context28.t1 = _context28["catch"](0);
|
|
2331
|
+
console.error('[PaymentModule] 金额舍入失败:', _context28.t1);
|
|
2332
|
+
throw new Error("\u91D1\u989D\u820D\u5165\u5931\u8D25: ".concat(_context28.t1 instanceof Error ? _context28.t1.message : String(_context28.t1)));
|
|
2208
2333
|
case 38:
|
|
2209
2334
|
case "end":
|
|
2210
|
-
return
|
|
2335
|
+
return _context28.stop();
|
|
2211
2336
|
}
|
|
2212
|
-
},
|
|
2337
|
+
}, _callee28, this, [[0, 34]]);
|
|
2213
2338
|
}));
|
|
2214
|
-
function roundAmountAsync(
|
|
2339
|
+
function roundAmountAsync(_x29, _x30, _x31) {
|
|
2215
2340
|
return _roundAmountAsync.apply(this, arguments);
|
|
2216
2341
|
}
|
|
2217
2342
|
return roundAmountAsync;
|