@pisell/pisellos 2.2.19 → 2.2.21
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/modules/Payment/index.d.ts +3 -0
- package/dist/modules/Payment/index.js +456 -368
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/ShopDiscount/index.js +11 -5
- package/lib/modules/Payment/index.d.ts +3 -0
- package/lib/modules/Payment/index.js +113 -60
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/ShopDiscount/index.js +5 -2
- 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; }
|
|
@@ -100,6 +100,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
100
100
|
// IndexDBManager 实例
|
|
101
101
|
_defineProperty(_assertThisInitialized(_this), "logger", void 0);
|
|
102
102
|
// LoggerManager 实例
|
|
103
|
+
_defineProperty(_assertThisInitialized(_this), "voucherUpdateLockByOrderUuid", new Map());
|
|
103
104
|
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
104
105
|
// 支付方式实例
|
|
105
106
|
_defineProperty(_assertThisInitialized(_this), "cash", void 0);
|
|
@@ -111,6 +112,50 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
111
112
|
return _this;
|
|
112
113
|
}
|
|
113
114
|
_createClass(PaymentModule, [{
|
|
115
|
+
key: "runVoucherUpdateLocked",
|
|
116
|
+
value: function runVoucherUpdateLocked(orderUuid, task) {
|
|
117
|
+
var _this2 = this;
|
|
118
|
+
var previous = this.voucherUpdateLockByOrderUuid.get(orderUuid) || Promise.resolve();
|
|
119
|
+
var next = previous.catch(function () {
|
|
120
|
+
return undefined;
|
|
121
|
+
}).then(task).finally(function () {
|
|
122
|
+
if (_this2.voucherUpdateLockByOrderUuid.get(orderUuid) === next) {
|
|
123
|
+
_this2.voucherUpdateLockByOrderUuid.delete(orderUuid);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
this.voucherUpdateLockByOrderUuid.set(orderUuid, next);
|
|
127
|
+
return next;
|
|
128
|
+
}
|
|
129
|
+
}, {
|
|
130
|
+
key: "normalizeVoucherPaymentItems",
|
|
131
|
+
value: function normalizeVoucherPaymentItems(voucherPaymentItems) {
|
|
132
|
+
var normalized = new Map();
|
|
133
|
+
var _iterator = _createForOfIteratorHelper(voucherPaymentItems || []),
|
|
134
|
+
_step;
|
|
135
|
+
try {
|
|
136
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
137
|
+
var item = _step.value;
|
|
138
|
+
if (!(item !== null && item !== void 0 && item.voucher_id)) {
|
|
139
|
+
throw new Error("\u4EE3\u91D1\u5238\u652F\u4ED8\u9879\u7F3A\u5C11 voucher_id: ".concat(JSON.stringify(item)));
|
|
140
|
+
}
|
|
141
|
+
var orderPaymentType = item.order_payment_type || 'normal';
|
|
142
|
+
var key = "".concat(item.voucher_id, "|").concat(orderPaymentType);
|
|
143
|
+
normalized.set(key, _objectSpread(_objectSpread({}, item), {}, {
|
|
144
|
+
order_payment_type: orderPaymentType
|
|
145
|
+
}));
|
|
146
|
+
}
|
|
147
|
+
} catch (err) {
|
|
148
|
+
_iterator.e(err);
|
|
149
|
+
} finally {
|
|
150
|
+
_iterator.f();
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
items: Array.from(normalized.values()),
|
|
154
|
+
originalCount: (voucherPaymentItems === null || voucherPaymentItems === void 0 ? void 0 : voucherPaymentItems.length) || 0,
|
|
155
|
+
normalizedCount: normalized.size
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
}, {
|
|
114
159
|
key: "initialize",
|
|
115
160
|
value: function () {
|
|
116
161
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
@@ -245,7 +290,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
245
290
|
}, {
|
|
246
291
|
key: "registerNetworkHandlers",
|
|
247
292
|
value: function registerNetworkHandlers() {
|
|
248
|
-
var
|
|
293
|
+
var _this3 = this;
|
|
249
294
|
var network = this.app.plugins.get('network');
|
|
250
295
|
this.logInfo('Registering network status listener');
|
|
251
296
|
network === null || network === void 0 || network.addListener('networkStatusChange', /*#__PURE__*/function () {
|
|
@@ -254,12 +299,12 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
254
299
|
while (1) switch (_context2.prev = _context2.next) {
|
|
255
300
|
case 0:
|
|
256
301
|
console.log('网络状态:', status.connected);
|
|
257
|
-
|
|
302
|
+
_this3.logInfo('Network status changed', {
|
|
258
303
|
connected: status.connected,
|
|
259
304
|
previousStatus: status.previousStatus
|
|
260
305
|
});
|
|
261
306
|
if (status.connected) {
|
|
262
|
-
|
|
307
|
+
_this3.logInfo('Network reconnected');
|
|
263
308
|
// 网络恢复时的处理逻辑可以在这里添加
|
|
264
309
|
}
|
|
265
310
|
case 3:
|
|
@@ -320,7 +365,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
320
365
|
key: "getPayMethodListAsync",
|
|
321
366
|
value: (function () {
|
|
322
367
|
var _getPayMethodListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
323
|
-
var cachedMethods, hasCache, response, payMethods,
|
|
368
|
+
var cachedMethods, hasCache, response, payMethods, _iterator2, _step2, method;
|
|
324
369
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
325
370
|
while (1) switch (_context4.prev = _context4.next) {
|
|
326
371
|
case 0:
|
|
@@ -357,15 +402,15 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
357
402
|
response.data = this.filterPayMethods(response.data);
|
|
358
403
|
payMethods = response.data || []; // 尝试缓存到 IndexDB
|
|
359
404
|
_context4.prev = 21;
|
|
360
|
-
|
|
405
|
+
_iterator2 = _createForOfIteratorHelper(payMethods);
|
|
361
406
|
_context4.prev = 23;
|
|
362
|
-
|
|
407
|
+
_iterator2.s();
|
|
363
408
|
case 25:
|
|
364
|
-
if ((
|
|
409
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
365
410
|
_context4.next = 31;
|
|
366
411
|
break;
|
|
367
412
|
}
|
|
368
|
-
method =
|
|
413
|
+
method = _step2.value;
|
|
369
414
|
_context4.next = 29;
|
|
370
415
|
return this.dbManager.update('pay_method', method);
|
|
371
416
|
case 29:
|
|
@@ -377,10 +422,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
377
422
|
case 33:
|
|
378
423
|
_context4.prev = 33;
|
|
379
424
|
_context4.t1 = _context4["catch"](23);
|
|
380
|
-
|
|
425
|
+
_iterator2.e(_context4.t1);
|
|
381
426
|
case 36:
|
|
382
427
|
_context4.prev = 36;
|
|
383
|
-
|
|
428
|
+
_iterator2.f();
|
|
384
429
|
return _context4.finish(36);
|
|
385
430
|
case 39:
|
|
386
431
|
_context4.next = 44;
|
|
@@ -424,7 +469,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
424
469
|
key: "refreshPaymentMethodsInBackground",
|
|
425
470
|
value: (function () {
|
|
426
471
|
var _refreshPaymentMethodsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(cachedMethods) {
|
|
427
|
-
var response, newPayMethods, hasChanges,
|
|
472
|
+
var response, newPayMethods, hasChanges, _iterator3, _step3, method, _iterator4, _step4, _method, eventData;
|
|
428
473
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
429
474
|
while (1) switch (_context5.prev = _context5.next) {
|
|
430
475
|
case 0:
|
|
@@ -455,15 +500,15 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
455
500
|
// 更新缓存
|
|
456
501
|
_context5.prev = 12;
|
|
457
502
|
// 先清除旧数据
|
|
458
|
-
|
|
503
|
+
_iterator3 = _createForOfIteratorHelper(cachedMethods);
|
|
459
504
|
_context5.prev = 14;
|
|
460
|
-
|
|
505
|
+
_iterator3.s();
|
|
461
506
|
case 16:
|
|
462
|
-
if ((
|
|
507
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
463
508
|
_context5.next = 22;
|
|
464
509
|
break;
|
|
465
510
|
}
|
|
466
|
-
method =
|
|
511
|
+
method = _step3.value;
|
|
467
512
|
_context5.next = 20;
|
|
468
513
|
return this.dbManager.delete('pay_method', method.id);
|
|
469
514
|
case 20:
|
|
@@ -475,22 +520,22 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
475
520
|
case 24:
|
|
476
521
|
_context5.prev = 24;
|
|
477
522
|
_context5.t0 = _context5["catch"](14);
|
|
478
|
-
|
|
523
|
+
_iterator3.e(_context5.t0);
|
|
479
524
|
case 27:
|
|
480
525
|
_context5.prev = 27;
|
|
481
|
-
|
|
526
|
+
_iterator3.f();
|
|
482
527
|
return _context5.finish(27);
|
|
483
528
|
case 30:
|
|
484
529
|
// 添加新数据
|
|
485
|
-
|
|
530
|
+
_iterator4 = _createForOfIteratorHelper(newPayMethods);
|
|
486
531
|
_context5.prev = 31;
|
|
487
|
-
|
|
532
|
+
_iterator4.s();
|
|
488
533
|
case 33:
|
|
489
|
-
if ((
|
|
534
|
+
if ((_step4 = _iterator4.n()).done) {
|
|
490
535
|
_context5.next = 39;
|
|
491
536
|
break;
|
|
492
537
|
}
|
|
493
|
-
_method =
|
|
538
|
+
_method = _step4.value;
|
|
494
539
|
_context5.next = 37;
|
|
495
540
|
return this.dbManager.update('pay_method', _method);
|
|
496
541
|
case 37:
|
|
@@ -502,10 +547,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
502
547
|
case 41:
|
|
503
548
|
_context5.prev = 41;
|
|
504
549
|
_context5.t1 = _context5["catch"](31);
|
|
505
|
-
|
|
550
|
+
_iterator4.e(_context5.t1);
|
|
506
551
|
case 44:
|
|
507
552
|
_context5.prev = 44;
|
|
508
|
-
|
|
553
|
+
_iterator4.f();
|
|
509
554
|
return _context5.finish(44);
|
|
510
555
|
case 47:
|
|
511
556
|
_context5.next = 52;
|
|
@@ -562,11 +607,11 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
562
607
|
}));
|
|
563
608
|
|
|
564
609
|
// 检查每个新方法是否与旧方法相同
|
|
565
|
-
var
|
|
566
|
-
|
|
610
|
+
var _iterator5 = _createForOfIteratorHelper(newMethods),
|
|
611
|
+
_step5;
|
|
567
612
|
try {
|
|
568
|
-
for (
|
|
569
|
-
var newMethod =
|
|
613
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
614
|
+
var newMethod = _step5.value;
|
|
570
615
|
var oldMethod = oldMethodsMap.get(newMethod.id);
|
|
571
616
|
if (!oldMethod) {
|
|
572
617
|
return true; // 新增方法
|
|
@@ -635,9 +680,9 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
635
680
|
}
|
|
636
681
|
}
|
|
637
682
|
} catch (err) {
|
|
638
|
-
|
|
683
|
+
_iterator5.e(err);
|
|
639
684
|
} finally {
|
|
640
|
-
|
|
685
|
+
_iterator5.f();
|
|
641
686
|
}
|
|
642
687
|
return false;
|
|
643
688
|
}
|
|
@@ -713,7 +758,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
713
758
|
key: "createPaymentOrderAsync",
|
|
714
759
|
value: (function () {
|
|
715
760
|
var _createPaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
|
|
716
|
-
var
|
|
761
|
+
var _this4 = this;
|
|
717
762
|
var newOrder, currentTime, dbAddStartTime, dbAddDuration;
|
|
718
763
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
719
764
|
while (1) switch (_context8.prev = _context8.next) {
|
|
@@ -821,7 +866,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
821
866
|
performance: dbAddDuration > 100 ? 'slow' : dbAddDuration > 50 ? 'medium' : 'fast'
|
|
822
867
|
});
|
|
823
868
|
setTimeout(function () {
|
|
824
|
-
|
|
869
|
+
_this4.core.effects.emit("".concat(_this4.name, ":onOrderAdded"), newOrder);
|
|
825
870
|
}, 0);
|
|
826
871
|
return _context8.abrupt("return", newOrder);
|
|
827
872
|
case 13:
|
|
@@ -1388,157 +1433,200 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1388
1433
|
}, {
|
|
1389
1434
|
key: "updateVoucherPaymentItemsAsync",
|
|
1390
1435
|
value: (function () {
|
|
1391
|
-
var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1392
|
-
var
|
|
1393
|
-
return _regeneratorRuntime().wrap(function
|
|
1394
|
-
while (1) switch (
|
|
1436
|
+
var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(orderUuid, voucherPaymentItems) {
|
|
1437
|
+
var _this5 = this;
|
|
1438
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1439
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1395
1440
|
case 0:
|
|
1396
|
-
this.
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
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
|
-
|
|
1441
|
+
return _context17.abrupt("return", this.runVoucherUpdateLocked(orderUuid, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
1442
|
+
var _this5$normalizeVouch, normalizedVoucherItems, originalCount, normalizedCount, order, existingVoucherItems, _iterator6, _step6, voucherItem, orderAfterDelete, existingActiveVoucherKeys, _iterator7, _step7, _voucherItem, orderPaymentType, key, updatedOrder;
|
|
1443
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1444
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1445
|
+
case 0:
|
|
1446
|
+
_this5$normalizeVouch = _this5.normalizeVoucherPaymentItems(voucherPaymentItems), normalizedVoucherItems = _this5$normalizeVouch.items, originalCount = _this5$normalizeVouch.originalCount, normalizedCount = _this5$normalizeVouch.normalizedCount;
|
|
1447
|
+
_this5.logInfo('Starting updateVoucherPaymentItemsAsync', {
|
|
1448
|
+
orderUuid: orderUuid,
|
|
1449
|
+
originalVoucherCount: originalCount,
|
|
1450
|
+
normalizedVoucherCount: normalizedCount,
|
|
1451
|
+
voucherItems: normalizedVoucherItems.map(function (item) {
|
|
1452
|
+
return {
|
|
1453
|
+
code: item.code,
|
|
1454
|
+
amount: item.amount,
|
|
1455
|
+
voucher_id: item.voucher_id,
|
|
1456
|
+
order_payment_type: item.order_payment_type
|
|
1457
|
+
};
|
|
1458
|
+
})
|
|
1459
|
+
});
|
|
1460
|
+
if (originalCount !== normalizedCount) {
|
|
1461
|
+
console.warn('[PaymentModule] voucherPaymentItems detected duplicates (deduped by voucher_id + order_payment_type)', {
|
|
1462
|
+
orderUuid: orderUuid,
|
|
1463
|
+
originalCount: originalCount,
|
|
1464
|
+
normalizedCount: normalizedCount
|
|
1465
|
+
});
|
|
1466
|
+
}
|
|
1467
|
+
_context16.prev = 3;
|
|
1468
|
+
_context16.next = 6;
|
|
1469
|
+
return _this5.getPaymentOrderByUuidAsync(orderUuid);
|
|
1470
|
+
case 6:
|
|
1471
|
+
order = _context16.sent;
|
|
1472
|
+
if (order) {
|
|
1473
|
+
_context16.next = 9;
|
|
1474
|
+
break;
|
|
1475
|
+
}
|
|
1476
|
+
throw new Error("\u8BA2\u5355\u4E0D\u5B58\u5728: ".concat(orderUuid));
|
|
1477
|
+
case 9:
|
|
1478
|
+
// 1. 查找所有现有的代金券类支付项(带 voucher_id 且状态不是 voided)并且还没有同步给后端
|
|
1479
|
+
// 如果同步给了后端的voucher 不允许删除
|
|
1480
|
+
existingVoucherItems = order.payment.filter(function (payment) {
|
|
1481
|
+
return payment.voucher_id && payment.status !== 'voided' && !payment.isSynced;
|
|
1482
|
+
});
|
|
1483
|
+
console.log('[PaymentModule] 发现现有代金券支付项:', {
|
|
1484
|
+
orderUuid: orderUuid,
|
|
1485
|
+
existingVoucherCount: existingVoucherItems.length,
|
|
1486
|
+
existingItems: existingVoucherItems.map(function (item) {
|
|
1487
|
+
return {
|
|
1488
|
+
uuid: item.uuid,
|
|
1489
|
+
code: item.code,
|
|
1490
|
+
amount: item.amount,
|
|
1491
|
+
voucher_id: item.voucher_id,
|
|
1492
|
+
isSynced: item.isSynced
|
|
1493
|
+
};
|
|
1494
|
+
})
|
|
1495
|
+
});
|
|
1437
1496
|
|
|
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
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1497
|
+
// 2. 删除所有现有的代金券支付项(仅删除未同步的)
|
|
1498
|
+
_iterator6 = _createForOfIteratorHelper(existingVoucherItems);
|
|
1499
|
+
_context16.prev = 12;
|
|
1500
|
+
_iterator6.s();
|
|
1501
|
+
case 14:
|
|
1502
|
+
if ((_step6 = _iterator6.n()).done) {
|
|
1503
|
+
_context16.next = 21;
|
|
1504
|
+
break;
|
|
1505
|
+
}
|
|
1506
|
+
voucherItem = _step6.value;
|
|
1507
|
+
console.log("[PaymentModule] \u5220\u9664\u73B0\u6709\u4EE3\u91D1\u5238\u652F\u4ED8\u9879: ".concat(voucherItem.uuid));
|
|
1508
|
+
_context16.next = 19;
|
|
1509
|
+
return _this5.deletePaymentAsync(orderUuid, voucherItem.uuid);
|
|
1510
|
+
case 19:
|
|
1511
|
+
_context16.next = 14;
|
|
1512
|
+
break;
|
|
1513
|
+
case 21:
|
|
1514
|
+
_context16.next = 26;
|
|
1515
|
+
break;
|
|
1516
|
+
case 23:
|
|
1517
|
+
_context16.prev = 23;
|
|
1518
|
+
_context16.t0 = _context16["catch"](12);
|
|
1519
|
+
_iterator6.e(_context16.t0);
|
|
1520
|
+
case 26:
|
|
1521
|
+
_context16.prev = 26;
|
|
1522
|
+
_iterator6.f();
|
|
1523
|
+
return _context16.finish(26);
|
|
1524
|
+
case 29:
|
|
1525
|
+
_context16.next = 31;
|
|
1526
|
+
return _this5.getPaymentOrderByUuidAsync(orderUuid);
|
|
1527
|
+
case 31:
|
|
1528
|
+
orderAfterDelete = _context16.sent;
|
|
1529
|
+
if (orderAfterDelete) {
|
|
1530
|
+
_context16.next = 34;
|
|
1531
|
+
break;
|
|
1532
|
+
}
|
|
1533
|
+
throw new Error("\u8BA2\u5355\u4E0D\u5B58\u5728: ".concat(orderUuid));
|
|
1534
|
+
case 34:
|
|
1535
|
+
existingActiveVoucherKeys = new Set(orderAfterDelete.payment.filter(function (p) {
|
|
1536
|
+
return p.voucher_id && p.status !== 'voided';
|
|
1537
|
+
}).map(function (p) {
|
|
1538
|
+
return "".concat(p.voucher_id, "|").concat(p.order_payment_type || 'normal');
|
|
1539
|
+
}));
|
|
1540
|
+
console.log('[PaymentModule] 添加新的代金券支付项:', {
|
|
1541
|
+
orderUuid: orderUuid,
|
|
1542
|
+
newItemCount: normalizedVoucherItems.length
|
|
1543
|
+
});
|
|
1544
|
+
_iterator7 = _createForOfIteratorHelper(normalizedVoucherItems);
|
|
1545
|
+
_context16.prev = 37;
|
|
1546
|
+
_iterator7.s();
|
|
1547
|
+
case 39:
|
|
1548
|
+
if ((_step7 = _iterator7.n()).done) {
|
|
1549
|
+
_context16.next = 52;
|
|
1550
|
+
break;
|
|
1551
|
+
}
|
|
1552
|
+
_voucherItem = _step7.value;
|
|
1553
|
+
orderPaymentType = _voucherItem.order_payment_type || 'normal';
|
|
1554
|
+
key = "".concat(_voucherItem.voucher_id, "|").concat(orderPaymentType);
|
|
1555
|
+
if (!existingActiveVoucherKeys.has(key)) {
|
|
1556
|
+
_context16.next = 46;
|
|
1557
|
+
break;
|
|
1558
|
+
}
|
|
1559
|
+
console.warn('[PaymentModule] Skip adding voucher payment item because it already exists (active)', {
|
|
1560
|
+
orderUuid: orderUuid,
|
|
1561
|
+
voucher_id: _voucherItem.voucher_id,
|
|
1562
|
+
order_payment_type: orderPaymentType
|
|
1563
|
+
});
|
|
1564
|
+
return _context16.abrupt("continue", 50);
|
|
1565
|
+
case 46:
|
|
1566
|
+
console.log("[PaymentModule] \u6DFB\u52A0\u4EE3\u91D1\u5238\u652F\u4ED8\u9879:", {
|
|
1567
|
+
code: _voucherItem.code,
|
|
1568
|
+
amount: _voucherItem.amount,
|
|
1569
|
+
voucher_id: _voucherItem.voucher_id,
|
|
1570
|
+
order_payment_type: orderPaymentType
|
|
1571
|
+
});
|
|
1572
|
+
_context16.next = 49;
|
|
1573
|
+
return _this5.addPaymentItemAsync(orderUuid, _voucherItem);
|
|
1574
|
+
case 49:
|
|
1575
|
+
existingActiveVoucherKeys.add(key);
|
|
1576
|
+
case 50:
|
|
1577
|
+
_context16.next = 39;
|
|
1578
|
+
break;
|
|
1579
|
+
case 52:
|
|
1580
|
+
_context16.next = 57;
|
|
1581
|
+
break;
|
|
1582
|
+
case 54:
|
|
1583
|
+
_context16.prev = 54;
|
|
1584
|
+
_context16.t1 = _context16["catch"](37);
|
|
1585
|
+
_iterator7.e(_context16.t1);
|
|
1586
|
+
case 57:
|
|
1587
|
+
_context16.prev = 57;
|
|
1588
|
+
_iterator7.f();
|
|
1589
|
+
return _context16.finish(57);
|
|
1590
|
+
case 60:
|
|
1591
|
+
_context16.next = 62;
|
|
1592
|
+
return _this5.getPaymentOrderByUuidAsync(orderUuid);
|
|
1593
|
+
case 62:
|
|
1594
|
+
updatedOrder = _context16.sent;
|
|
1595
|
+
_context16.next = 65;
|
|
1596
|
+
return _this5.core.effects.emit("".concat(_this5.name, ":onPaymentAdded"), {
|
|
1597
|
+
orderUuid: orderUuid,
|
|
1598
|
+
order: updatedOrder,
|
|
1599
|
+
payment: null // 批量操作不提供单个支付项
|
|
1600
|
+
});
|
|
1601
|
+
case 65:
|
|
1602
|
+
_this5.logInfo('updateVoucherPaymentItemsAsync completed successfully', {
|
|
1603
|
+
orderUuid: orderUuid,
|
|
1604
|
+
removedVoucherCount: existingVoucherItems.length,
|
|
1605
|
+
addedVoucherCount: normalizedVoucherItems.length,
|
|
1606
|
+
finalExpectAmount: updatedOrder === null || updatedOrder === void 0 ? void 0 : updatedOrder.expect_amount
|
|
1607
|
+
});
|
|
1608
|
+
_context16.next = 73;
|
|
1609
|
+
break;
|
|
1610
|
+
case 68:
|
|
1611
|
+
_context16.prev = 68;
|
|
1612
|
+
_context16.t2 = _context16["catch"](3);
|
|
1613
|
+
console.error('[PaymentModule] 批量更新代金券支付项失败:', _context16.t2);
|
|
1614
|
+
_this5.logError('updateVoucherPaymentItemsAsync failed', _context16.t2, {
|
|
1615
|
+
orderUuid: orderUuid,
|
|
1616
|
+
voucherPaymentItems: voucherPaymentItems
|
|
1617
|
+
});
|
|
1618
|
+
throw _context16.t2;
|
|
1619
|
+
case 73:
|
|
1620
|
+
case "end":
|
|
1621
|
+
return _context16.stop();
|
|
1622
|
+
}
|
|
1623
|
+
}, _callee16, null, [[3, 68], [12, 23, 26, 29], [37, 54, 57, 60]]);
|
|
1624
|
+
}))));
|
|
1625
|
+
case 1:
|
|
1538
1626
|
case "end":
|
|
1539
|
-
return
|
|
1627
|
+
return _context17.stop();
|
|
1540
1628
|
}
|
|
1541
|
-
},
|
|
1629
|
+
}, _callee17, this);
|
|
1542
1630
|
}));
|
|
1543
1631
|
function updateVoucherPaymentItemsAsync(_x19, _x20) {
|
|
1544
1632
|
return _updateVoucherPaymentItemsAsync.apply(this, arguments);
|
|
@@ -1552,18 +1640,18 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1552
1640
|
}, {
|
|
1553
1641
|
key: "updatePaymentAsync",
|
|
1554
1642
|
value: (function () {
|
|
1555
|
-
var _updatePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1643
|
+
var _updatePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(orderUuid, paymentUuid, params) {
|
|
1556
1644
|
var order, paymentItem, formattedParams;
|
|
1557
|
-
return _regeneratorRuntime().wrap(function
|
|
1558
|
-
while (1) switch (
|
|
1645
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1646
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1559
1647
|
case 0:
|
|
1560
|
-
|
|
1561
|
-
|
|
1648
|
+
_context18.prev = 0;
|
|
1649
|
+
_context18.next = 3;
|
|
1562
1650
|
return this.dbManager.get('order', orderUuid);
|
|
1563
1651
|
case 3:
|
|
1564
|
-
order =
|
|
1652
|
+
order = _context18.sent;
|
|
1565
1653
|
if (order) {
|
|
1566
|
-
|
|
1654
|
+
_context18.next = 6;
|
|
1567
1655
|
break;
|
|
1568
1656
|
}
|
|
1569
1657
|
throw new Error('订单不存在');
|
|
@@ -1572,7 +1660,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1572
1660
|
return payment.uuid === paymentUuid;
|
|
1573
1661
|
});
|
|
1574
1662
|
if (!paymentItem) {
|
|
1575
|
-
|
|
1663
|
+
_context18.next = 18;
|
|
1576
1664
|
break;
|
|
1577
1665
|
}
|
|
1578
1666
|
// 如果更新参数中包含 amount,先格式化
|
|
@@ -1586,34 +1674,34 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1586
1674
|
this.recalculateOrderAmount(order);
|
|
1587
1675
|
|
|
1588
1676
|
// 更新到 IndexDB
|
|
1589
|
-
|
|
1677
|
+
_context18.next = 14;
|
|
1590
1678
|
return this.dbManager.update('order', order);
|
|
1591
1679
|
case 14:
|
|
1592
|
-
|
|
1680
|
+
_context18.next = 16;
|
|
1593
1681
|
return this.core.effects.emit("".concat(this.name, ":onPaymentUpdated"), {
|
|
1594
1682
|
order: order,
|
|
1595
1683
|
paymentItem: paymentItem
|
|
1596
1684
|
});
|
|
1597
1685
|
case 16:
|
|
1598
|
-
|
|
1686
|
+
_context18.next = 18;
|
|
1599
1687
|
return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
|
|
1600
1688
|
action: 'payment_update',
|
|
1601
1689
|
order: order,
|
|
1602
1690
|
paymentItem: paymentItem
|
|
1603
1691
|
});
|
|
1604
1692
|
case 18:
|
|
1605
|
-
|
|
1693
|
+
_context18.next = 24;
|
|
1606
1694
|
break;
|
|
1607
1695
|
case 20:
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
console.error('[PaymentModule] 更新支付项失败',
|
|
1611
|
-
throw
|
|
1696
|
+
_context18.prev = 20;
|
|
1697
|
+
_context18.t0 = _context18["catch"](0);
|
|
1698
|
+
console.error('[PaymentModule] 更新支付项失败', _context18.t0);
|
|
1699
|
+
throw _context18.t0;
|
|
1612
1700
|
case 24:
|
|
1613
1701
|
case "end":
|
|
1614
|
-
return
|
|
1702
|
+
return _context18.stop();
|
|
1615
1703
|
}
|
|
1616
|
-
},
|
|
1704
|
+
}, _callee18, this, [[0, 20]]);
|
|
1617
1705
|
}));
|
|
1618
1706
|
function updatePaymentAsync(_x21, _x22, _x23) {
|
|
1619
1707
|
return _updatePaymentAsync.apply(this, arguments);
|
|
@@ -1627,61 +1715,61 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1627
1715
|
}, {
|
|
1628
1716
|
key: "submitPayAsync",
|
|
1629
1717
|
value: (function () {
|
|
1630
|
-
var _submitPayAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1631
|
-
var orderToSubmit, order, allOrders,
|
|
1632
|
-
return _regeneratorRuntime().wrap(function
|
|
1633
|
-
while (1) switch (
|
|
1718
|
+
var _submitPayAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(orderUuid) {
|
|
1719
|
+
var orderToSubmit, order, allOrders, _iterator8, _step8, _order, result;
|
|
1720
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1721
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1634
1722
|
case 0:
|
|
1635
1723
|
this.logInfo('Starting submitPayAsync', {
|
|
1636
1724
|
orderUuid: orderUuid
|
|
1637
1725
|
});
|
|
1638
|
-
|
|
1726
|
+
_context19.prev = 1;
|
|
1639
1727
|
if (!orderUuid) {
|
|
1640
|
-
|
|
1728
|
+
_context19.next = 9;
|
|
1641
1729
|
break;
|
|
1642
1730
|
}
|
|
1643
|
-
|
|
1731
|
+
_context19.next = 5;
|
|
1644
1732
|
return this.dbManager.get('order', orderUuid);
|
|
1645
1733
|
case 5:
|
|
1646
|
-
order =
|
|
1734
|
+
order = _context19.sent;
|
|
1647
1735
|
orderToSubmit = order ? [order] : [];
|
|
1648
|
-
|
|
1736
|
+
_context19.next = 13;
|
|
1649
1737
|
break;
|
|
1650
1738
|
case 9:
|
|
1651
|
-
|
|
1739
|
+
_context19.next = 11;
|
|
1652
1740
|
return this.dbManager.getAll('order');
|
|
1653
1741
|
case 11:
|
|
1654
|
-
allOrders =
|
|
1742
|
+
allOrders = _context19.sent;
|
|
1655
1743
|
// 包括正在处理中的订单和部分支付的订单(可能添加了新的支付项)
|
|
1656
1744
|
orderToSubmit = allOrders.filter(function (order) {
|
|
1657
1745
|
return order.payment_status === PaymentStatus.Processing || order.payment_status === PaymentStatus.PartiallyPaid;
|
|
1658
1746
|
});
|
|
1659
1747
|
case 13:
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1748
|
+
_iterator8 = _createForOfIteratorHelper(orderToSubmit);
|
|
1749
|
+
_context19.prev = 14;
|
|
1750
|
+
_iterator8.s();
|
|
1663
1751
|
case 16:
|
|
1664
|
-
if ((
|
|
1665
|
-
|
|
1752
|
+
if ((_step8 = _iterator8.n()).done) {
|
|
1753
|
+
_context19.next = 22;
|
|
1666
1754
|
break;
|
|
1667
1755
|
}
|
|
1668
|
-
_order =
|
|
1669
|
-
|
|
1756
|
+
_order = _step8.value;
|
|
1757
|
+
_context19.next = 20;
|
|
1670
1758
|
return this.submitSingleOrderPayment(_order);
|
|
1671
1759
|
case 20:
|
|
1672
|
-
|
|
1760
|
+
_context19.next = 16;
|
|
1673
1761
|
break;
|
|
1674
1762
|
case 22:
|
|
1675
|
-
|
|
1763
|
+
_context19.next = 27;
|
|
1676
1764
|
break;
|
|
1677
1765
|
case 24:
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1766
|
+
_context19.prev = 24;
|
|
1767
|
+
_context19.t0 = _context19["catch"](14);
|
|
1768
|
+
_iterator8.e(_context19.t0);
|
|
1681
1769
|
case 27:
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
return
|
|
1770
|
+
_context19.prev = 27;
|
|
1771
|
+
_iterator8.f();
|
|
1772
|
+
return _context19.finish(27);
|
|
1685
1773
|
case 30:
|
|
1686
1774
|
result = {
|
|
1687
1775
|
status: 'success'
|
|
@@ -1690,22 +1778,22 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1690
1778
|
result: result.status,
|
|
1691
1779
|
processedOrdersCount: orderToSubmit.length
|
|
1692
1780
|
});
|
|
1693
|
-
return
|
|
1781
|
+
return _context19.abrupt("return", result);
|
|
1694
1782
|
case 35:
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
console.error('[PaymentModule] 提交支付失败',
|
|
1698
|
-
this.logError('submitPayAsync failed',
|
|
1783
|
+
_context19.prev = 35;
|
|
1784
|
+
_context19.t1 = _context19["catch"](1);
|
|
1785
|
+
console.error('[PaymentModule] 提交支付失败', _context19.t1);
|
|
1786
|
+
this.logError('submitPayAsync failed', _context19.t1, {
|
|
1699
1787
|
orderUuid: orderUuid
|
|
1700
1788
|
});
|
|
1701
|
-
return
|
|
1789
|
+
return _context19.abrupt("return", {
|
|
1702
1790
|
status: 'failed'
|
|
1703
1791
|
});
|
|
1704
1792
|
case 40:
|
|
1705
1793
|
case "end":
|
|
1706
|
-
return
|
|
1794
|
+
return _context19.stop();
|
|
1707
1795
|
}
|
|
1708
|
-
},
|
|
1796
|
+
}, _callee19, this, [[1, 35], [14, 24, 27, 30]]);
|
|
1709
1797
|
}));
|
|
1710
1798
|
function submitPayAsync(_x24) {
|
|
1711
1799
|
return _submitPayAsync.apply(this, arguments);
|
|
@@ -1719,12 +1807,12 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1719
1807
|
}, {
|
|
1720
1808
|
key: "submitSingleOrderPayment",
|
|
1721
1809
|
value: (function () {
|
|
1722
|
-
var _submitSingleOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1810
|
+
var _submitSingleOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(order) {
|
|
1723
1811
|
var paymentData, totalPaidAmount, orderTotalAmount;
|
|
1724
|
-
return _regeneratorRuntime().wrap(function
|
|
1725
|
-
while (1) switch (
|
|
1812
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1813
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1726
1814
|
case 0:
|
|
1727
|
-
|
|
1815
|
+
_context20.prev = 0;
|
|
1728
1816
|
paymentData = {
|
|
1729
1817
|
payments: order.payment.map(function (payment) {
|
|
1730
1818
|
return {
|
|
@@ -1760,11 +1848,11 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1760
1848
|
paymentData.payment_status = order.payment_status === PaymentStatus.Finished ? 'paid' : 'partially_paid';
|
|
1761
1849
|
|
|
1762
1850
|
// 更新订单状态到数据库
|
|
1763
|
-
|
|
1851
|
+
_context20.next = 8;
|
|
1764
1852
|
return this.dbManager.update('order', order);
|
|
1765
1853
|
case 8:
|
|
1766
1854
|
if (!(paymentData.payments.length === 0)) {
|
|
1767
|
-
|
|
1855
|
+
_context20.next = 12;
|
|
1768
1856
|
break;
|
|
1769
1857
|
}
|
|
1770
1858
|
console.log("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u652F\u4ED8\u5217\u8868\u4E3A\u7A7A\uFF0C\u8DF3\u8FC7\u652F\u4ED8\u5904\u7406"));
|
|
@@ -1772,29 +1860,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1772
1860
|
orderUuid: order.uuid,
|
|
1773
1861
|
orderId: order.order_id
|
|
1774
1862
|
});
|
|
1775
|
-
return
|
|
1863
|
+
return _context20.abrupt("return");
|
|
1776
1864
|
case 12:
|
|
1777
|
-
|
|
1865
|
+
_context20.next = 14;
|
|
1778
1866
|
return this.core.effects.emit("".concat(this.name, ":onPaymentSubmitted"), order);
|
|
1779
1867
|
case 14:
|
|
1780
|
-
|
|
1868
|
+
_context20.next = 16;
|
|
1781
1869
|
return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
|
|
1782
1870
|
action: 'submit',
|
|
1783
1871
|
order: order
|
|
1784
1872
|
});
|
|
1785
1873
|
case 16:
|
|
1786
|
-
|
|
1874
|
+
_context20.next = 22;
|
|
1787
1875
|
break;
|
|
1788
1876
|
case 18:
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
console.error("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u652F\u4ED8\u63D0\u4EA4\u5931\u8D25"),
|
|
1792
|
-
throw
|
|
1877
|
+
_context20.prev = 18;
|
|
1878
|
+
_context20.t0 = _context20["catch"](0);
|
|
1879
|
+
console.error("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u652F\u4ED8\u63D0\u4EA4\u5931\u8D25"), _context20.t0);
|
|
1880
|
+
throw _context20.t0;
|
|
1793
1881
|
case 22:
|
|
1794
1882
|
case "end":
|
|
1795
|
-
return
|
|
1883
|
+
return _context20.stop();
|
|
1796
1884
|
}
|
|
1797
|
-
},
|
|
1885
|
+
}, _callee20, this, [[0, 18]]);
|
|
1798
1886
|
}));
|
|
1799
1887
|
function submitSingleOrderPayment(_x25) {
|
|
1800
1888
|
return _submitSingleOrderPayment.apply(this, arguments);
|
|
@@ -1808,27 +1896,27 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1808
1896
|
}, {
|
|
1809
1897
|
key: "getRemainingOrderAmountAsync",
|
|
1810
1898
|
value: (function () {
|
|
1811
|
-
var _getRemainingOrderAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1899
|
+
var _getRemainingOrderAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(orderUuid) {
|
|
1812
1900
|
var order;
|
|
1813
|
-
return _regeneratorRuntime().wrap(function
|
|
1814
|
-
while (1) switch (
|
|
1901
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1902
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1815
1903
|
case 0:
|
|
1816
|
-
|
|
1904
|
+
_context21.next = 2;
|
|
1817
1905
|
return this.getPaymentOrderByUuidAsync(orderUuid);
|
|
1818
1906
|
case 2:
|
|
1819
|
-
order =
|
|
1907
|
+
order = _context21.sent;
|
|
1820
1908
|
if (order) {
|
|
1821
|
-
|
|
1909
|
+
_context21.next = 5;
|
|
1822
1910
|
break;
|
|
1823
1911
|
}
|
|
1824
1912
|
throw new Error('订单不存在');
|
|
1825
1913
|
case 5:
|
|
1826
|
-
return
|
|
1914
|
+
return _context21.abrupt("return", new Decimal(order.expect_amount).toNumber());
|
|
1827
1915
|
case 6:
|
|
1828
1916
|
case "end":
|
|
1829
|
-
return
|
|
1917
|
+
return _context21.stop();
|
|
1830
1918
|
}
|
|
1831
|
-
},
|
|
1919
|
+
}, _callee21, this);
|
|
1832
1920
|
}));
|
|
1833
1921
|
function getRemainingOrderAmountAsync(_x26) {
|
|
1834
1922
|
return _getRemainingOrderAmountAsync.apply(this, arguments);
|
|
@@ -1842,63 +1930,63 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1842
1930
|
}, {
|
|
1843
1931
|
key: "getRemainingOrderAmountWithInputAsync",
|
|
1844
1932
|
value: (function () {
|
|
1845
|
-
var _getRemainingOrderAmountWithInputAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1933
|
+
var _getRemainingOrderAmountWithInputAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(inputAmount, orderUuid) {
|
|
1846
1934
|
var order, inputDecimal;
|
|
1847
|
-
return _regeneratorRuntime().wrap(function
|
|
1848
|
-
while (1) switch (
|
|
1935
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1936
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1849
1937
|
case 0:
|
|
1850
|
-
|
|
1938
|
+
_context22.next = 2;
|
|
1851
1939
|
return this.getPaymentOrderByUuidAsync(orderUuid);
|
|
1852
1940
|
case 2:
|
|
1853
|
-
order =
|
|
1941
|
+
order = _context22.sent;
|
|
1854
1942
|
if (order) {
|
|
1855
|
-
|
|
1943
|
+
_context22.next = 5;
|
|
1856
1944
|
break;
|
|
1857
1945
|
}
|
|
1858
1946
|
throw new Error('订单不存在');
|
|
1859
1947
|
case 5:
|
|
1860
1948
|
if (!(inputAmount === null || inputAmount === undefined)) {
|
|
1861
|
-
|
|
1949
|
+
_context22.next = 7;
|
|
1862
1950
|
break;
|
|
1863
1951
|
}
|
|
1864
|
-
return
|
|
1952
|
+
return _context22.abrupt("return", new Decimal(order.expect_amount).toNumber());
|
|
1865
1953
|
case 7:
|
|
1866
1954
|
if (!(typeof inputAmount === 'string')) {
|
|
1867
|
-
|
|
1955
|
+
_context22.next = 10;
|
|
1868
1956
|
break;
|
|
1869
1957
|
}
|
|
1870
1958
|
if (!(inputAmount.trim() === '')) {
|
|
1871
|
-
|
|
1959
|
+
_context22.next = 10;
|
|
1872
1960
|
break;
|
|
1873
1961
|
}
|
|
1874
|
-
return
|
|
1962
|
+
return _context22.abrupt("return", new Decimal(order.expect_amount).toNumber());
|
|
1875
1963
|
case 10:
|
|
1876
1964
|
if (!(typeof inputAmount === 'number')) {
|
|
1877
|
-
|
|
1965
|
+
_context22.next = 14;
|
|
1878
1966
|
break;
|
|
1879
1967
|
}
|
|
1880
1968
|
if (!(isNaN(inputAmount) || !isFinite(inputAmount))) {
|
|
1881
|
-
|
|
1969
|
+
_context22.next = 14;
|
|
1882
1970
|
break;
|
|
1883
1971
|
}
|
|
1884
1972
|
// 如果输入是 NaN 或无穷大,返回原始的待付金额
|
|
1885
1973
|
console.warn("[PaymentModule] \u8F93\u5165\u91D1\u989D\u4E0D\u662F\u6709\u6548\u6570\u5B57: ".concat(inputAmount, "\uFF0C\u8FD4\u56DE\u539F\u59CB\u5F85\u4ED8\u91D1\u989D"));
|
|
1886
|
-
return
|
|
1974
|
+
return _context22.abrupt("return", new Decimal(order.expect_amount).toNumber());
|
|
1887
1975
|
case 14:
|
|
1888
|
-
|
|
1976
|
+
_context22.prev = 14;
|
|
1889
1977
|
inputDecimal = new Decimal(inputAmount);
|
|
1890
|
-
return
|
|
1978
|
+
return _context22.abrupt("return", new Decimal(order.expect_amount).minus(inputDecimal).toNumber());
|
|
1891
1979
|
case 19:
|
|
1892
|
-
|
|
1893
|
-
|
|
1980
|
+
_context22.prev = 19;
|
|
1981
|
+
_context22.t0 = _context22["catch"](14);
|
|
1894
1982
|
// 如果输入不是有效的数字,返回原始的待付金额
|
|
1895
1983
|
console.warn("[PaymentModule] \u8F93\u5165\u91D1\u989D\u683C\u5F0F\u65E0\u6548: ".concat(inputAmount, "\uFF0C\u8FD4\u56DE\u539F\u59CB\u5F85\u4ED8\u91D1\u989D"));
|
|
1896
|
-
return
|
|
1984
|
+
return _context22.abrupt("return", new Decimal(order.expect_amount).toNumber());
|
|
1897
1985
|
case 23:
|
|
1898
1986
|
case "end":
|
|
1899
|
-
return
|
|
1987
|
+
return _context22.stop();
|
|
1900
1988
|
}
|
|
1901
|
-
},
|
|
1989
|
+
}, _callee22, this, [[14, 19]]);
|
|
1902
1990
|
}));
|
|
1903
1991
|
function getRemainingOrderAmountWithInputAsync(_x27, _x28) {
|
|
1904
1992
|
return _getRemainingOrderAmountWithInputAsync.apply(this, arguments);
|
|
@@ -1966,29 +2054,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1966
2054
|
}, {
|
|
1967
2055
|
key: "getCashPaymentMethod",
|
|
1968
2056
|
value: (function () {
|
|
1969
|
-
var _getCashPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2057
|
+
var _getCashPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
1970
2058
|
var payMethods;
|
|
1971
|
-
return _regeneratorRuntime().wrap(function
|
|
1972
|
-
while (1) switch (
|
|
2059
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2060
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1973
2061
|
case 0:
|
|
1974
|
-
|
|
1975
|
-
|
|
2062
|
+
_context23.prev = 0;
|
|
2063
|
+
_context23.next = 3;
|
|
1976
2064
|
return this.dbManager.getAll('pay_method');
|
|
1977
2065
|
case 3:
|
|
1978
|
-
payMethods =
|
|
1979
|
-
return
|
|
2066
|
+
payMethods = _context23.sent;
|
|
2067
|
+
return _context23.abrupt("return", payMethods.find(function (method) {
|
|
1980
2068
|
return method.code === PaymentMethodType.Cash;
|
|
1981
2069
|
}) || null);
|
|
1982
2070
|
case 7:
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
console.error('[PaymentModule] 获取现金支付方式失败',
|
|
1986
|
-
return
|
|
2071
|
+
_context23.prev = 7;
|
|
2072
|
+
_context23.t0 = _context23["catch"](0);
|
|
2073
|
+
console.error('[PaymentModule] 获取现金支付方式失败', _context23.t0);
|
|
2074
|
+
return _context23.abrupt("return", null);
|
|
1987
2075
|
case 11:
|
|
1988
2076
|
case "end":
|
|
1989
|
-
return
|
|
2077
|
+
return _context23.stop();
|
|
1990
2078
|
}
|
|
1991
|
-
},
|
|
2079
|
+
}, _callee23, this, [[0, 7]]);
|
|
1992
2080
|
}));
|
|
1993
2081
|
function getCashPaymentMethod() {
|
|
1994
2082
|
return _getCashPaymentMethod.apply(this, arguments);
|
|
@@ -2002,29 +2090,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2002
2090
|
}, {
|
|
2003
2091
|
key: "getEftposPaymentMethod",
|
|
2004
2092
|
value: (function () {
|
|
2005
|
-
var _getEftposPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2093
|
+
var _getEftposPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
2006
2094
|
var payMethods;
|
|
2007
|
-
return _regeneratorRuntime().wrap(function
|
|
2008
|
-
while (1) switch (
|
|
2095
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2096
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2009
2097
|
case 0:
|
|
2010
|
-
|
|
2011
|
-
|
|
2098
|
+
_context24.prev = 0;
|
|
2099
|
+
_context24.next = 3;
|
|
2012
2100
|
return this.dbManager.getAll('pay_method');
|
|
2013
2101
|
case 3:
|
|
2014
|
-
payMethods =
|
|
2015
|
-
return
|
|
2102
|
+
payMethods = _context24.sent;
|
|
2103
|
+
return _context24.abrupt("return", payMethods.find(function (method) {
|
|
2016
2104
|
return method.code === PaymentMethodType.Eftpos;
|
|
2017
2105
|
}) || null);
|
|
2018
2106
|
case 7:
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
console.error('[PaymentModule] 获取Eftpos支付方式失败',
|
|
2022
|
-
return
|
|
2107
|
+
_context24.prev = 7;
|
|
2108
|
+
_context24.t0 = _context24["catch"](0);
|
|
2109
|
+
console.error('[PaymentModule] 获取Eftpos支付方式失败', _context24.t0);
|
|
2110
|
+
return _context24.abrupt("return", null);
|
|
2023
2111
|
case 11:
|
|
2024
2112
|
case "end":
|
|
2025
|
-
return
|
|
2113
|
+
return _context24.stop();
|
|
2026
2114
|
}
|
|
2027
|
-
},
|
|
2115
|
+
}, _callee24, this, [[0, 7]]);
|
|
2028
2116
|
}));
|
|
2029
2117
|
function getEftposPaymentMethod() {
|
|
2030
2118
|
return _getEftposPaymentMethod.apply(this, arguments);
|
|
@@ -2038,29 +2126,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2038
2126
|
}, {
|
|
2039
2127
|
key: "getWalletPaymentMethod",
|
|
2040
2128
|
value: (function () {
|
|
2041
|
-
var _getWalletPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2129
|
+
var _getWalletPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
2042
2130
|
var payMethods;
|
|
2043
|
-
return _regeneratorRuntime().wrap(function
|
|
2044
|
-
while (1) switch (
|
|
2131
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2132
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2045
2133
|
case 0:
|
|
2046
|
-
|
|
2047
|
-
|
|
2134
|
+
_context25.prev = 0;
|
|
2135
|
+
_context25.next = 3;
|
|
2048
2136
|
return this.dbManager.getAll('pay_method');
|
|
2049
2137
|
case 3:
|
|
2050
|
-
payMethods =
|
|
2051
|
-
return
|
|
2138
|
+
payMethods = _context25.sent;
|
|
2139
|
+
return _context25.abrupt("return", payMethods.find(function (method) {
|
|
2052
2140
|
return method.code === PaymentMethodType.Wallet;
|
|
2053
2141
|
}) || null);
|
|
2054
2142
|
case 7:
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
console.error('[PaymentModule] 获取钱包支付方式失败',
|
|
2058
|
-
return
|
|
2143
|
+
_context25.prev = 7;
|
|
2144
|
+
_context25.t0 = _context25["catch"](0);
|
|
2145
|
+
console.error('[PaymentModule] 获取钱包支付方式失败', _context25.t0);
|
|
2146
|
+
return _context25.abrupt("return", null);
|
|
2059
2147
|
case 11:
|
|
2060
2148
|
case "end":
|
|
2061
|
-
return
|
|
2149
|
+
return _context25.stop();
|
|
2062
2150
|
}
|
|
2063
|
-
},
|
|
2151
|
+
}, _callee25, this, [[0, 7]]);
|
|
2064
2152
|
}));
|
|
2065
2153
|
function getWalletPaymentMethod() {
|
|
2066
2154
|
return _getWalletPaymentMethod.apply(this, arguments);
|
|
@@ -2074,38 +2162,38 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2074
2162
|
}, {
|
|
2075
2163
|
key: "ensurePaymentTables",
|
|
2076
2164
|
value: (function () {
|
|
2077
|
-
var _ensurePaymentTables = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2078
|
-
return _regeneratorRuntime().wrap(function
|
|
2079
|
-
while (1) switch (
|
|
2165
|
+
var _ensurePaymentTables = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
2166
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2167
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2080
2168
|
case 0:
|
|
2081
|
-
|
|
2082
|
-
|
|
2169
|
+
_context26.prev = 0;
|
|
2170
|
+
_context26.next = 3;
|
|
2083
2171
|
return this.dbManager.getAll('pay_method');
|
|
2084
2172
|
case 3:
|
|
2085
|
-
|
|
2173
|
+
_context26.next = 9;
|
|
2086
2174
|
break;
|
|
2087
2175
|
case 5:
|
|
2088
|
-
|
|
2089
|
-
|
|
2176
|
+
_context26.prev = 5;
|
|
2177
|
+
_context26.t0 = _context26["catch"](0);
|
|
2090
2178
|
console.warn('[PaymentModule] pay_method 表不存在,请在数据库配置中添加以下配置:');
|
|
2091
2179
|
console.warn('{ name: "pay_method", keyPath: "id" }');
|
|
2092
2180
|
case 9:
|
|
2093
|
-
|
|
2094
|
-
|
|
2181
|
+
_context26.prev = 9;
|
|
2182
|
+
_context26.next = 12;
|
|
2095
2183
|
return this.dbManager.getAll('order');
|
|
2096
2184
|
case 12:
|
|
2097
|
-
|
|
2185
|
+
_context26.next = 18;
|
|
2098
2186
|
break;
|
|
2099
2187
|
case 14:
|
|
2100
|
-
|
|
2101
|
-
|
|
2188
|
+
_context26.prev = 14;
|
|
2189
|
+
_context26.t1 = _context26["catch"](9);
|
|
2102
2190
|
console.warn('[PaymentModule] order 表不存在,请在数据库配置中添加以下配置:');
|
|
2103
2191
|
console.warn('{ name: "order", keyPath: "uuid" }');
|
|
2104
2192
|
case 18:
|
|
2105
2193
|
case "end":
|
|
2106
|
-
return
|
|
2194
|
+
return _context26.stop();
|
|
2107
2195
|
}
|
|
2108
|
-
},
|
|
2196
|
+
}, _callee26, this, [[0, 5], [9, 14]]);
|
|
2109
2197
|
}));
|
|
2110
2198
|
function ensurePaymentTables() {
|
|
2111
2199
|
return _ensurePaymentTables.apply(this, arguments);
|
|
@@ -2119,29 +2207,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2119
2207
|
}, {
|
|
2120
2208
|
key: "getPartiallyPaidOrdersAsync",
|
|
2121
2209
|
value: (function () {
|
|
2122
|
-
var _getPartiallyPaidOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2210
|
+
var _getPartiallyPaidOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
2123
2211
|
var allOrders;
|
|
2124
|
-
return _regeneratorRuntime().wrap(function
|
|
2125
|
-
while (1) switch (
|
|
2212
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2213
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2126
2214
|
case 0:
|
|
2127
|
-
|
|
2128
|
-
|
|
2215
|
+
_context27.prev = 0;
|
|
2216
|
+
_context27.next = 3;
|
|
2129
2217
|
return this.dbManager.getAll('order');
|
|
2130
2218
|
case 3:
|
|
2131
|
-
allOrders =
|
|
2132
|
-
return
|
|
2219
|
+
allOrders = _context27.sent;
|
|
2220
|
+
return _context27.abrupt("return", allOrders.filter(function (order) {
|
|
2133
2221
|
return order.payment_status === PaymentStatus.PartiallyPaid;
|
|
2134
2222
|
}));
|
|
2135
2223
|
case 7:
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
console.error('[PaymentModule] 获取部分支付订单失败',
|
|
2139
|
-
return
|
|
2224
|
+
_context27.prev = 7;
|
|
2225
|
+
_context27.t0 = _context27["catch"](0);
|
|
2226
|
+
console.error('[PaymentModule] 获取部分支付订单失败', _context27.t0);
|
|
2227
|
+
return _context27.abrupt("return", []);
|
|
2140
2228
|
case 11:
|
|
2141
2229
|
case "end":
|
|
2142
|
-
return
|
|
2230
|
+
return _context27.stop();
|
|
2143
2231
|
}
|
|
2144
|
-
},
|
|
2232
|
+
}, _callee27, this, [[0, 7]]);
|
|
2145
2233
|
}));
|
|
2146
2234
|
function getPartiallyPaidOrdersAsync() {
|
|
2147
2235
|
return _getPartiallyPaidOrdersAsync.apply(this, arguments);
|
|
@@ -2162,17 +2250,17 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2162
2250
|
}, {
|
|
2163
2251
|
key: "roundAmountAsync",
|
|
2164
2252
|
value: function () {
|
|
2165
|
-
var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2253
|
+
var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(originalAmount, interval, rule) {
|
|
2166
2254
|
var amount, roundingInterval, supportedIntervals, intervalValue, baseValue, roundedValue, finalAmount, originalAmountStr, roundedAmountStr, roundingDifference, roundingDifferenceStr;
|
|
2167
|
-
return _regeneratorRuntime().wrap(function
|
|
2168
|
-
while (1) switch (
|
|
2255
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2256
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2169
2257
|
case 0:
|
|
2170
|
-
|
|
2258
|
+
_context28.prev = 0;
|
|
2171
2259
|
// 参数验证
|
|
2172
2260
|
amount = new Decimal(originalAmount);
|
|
2173
2261
|
roundingInterval = new Decimal(interval);
|
|
2174
2262
|
if (!roundingInterval.lte(0)) {
|
|
2175
|
-
|
|
2263
|
+
_context28.next = 5;
|
|
2176
2264
|
break;
|
|
2177
2265
|
}
|
|
2178
2266
|
throw new Error('舍入间隔必须大于 0');
|
|
@@ -2187,25 +2275,25 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2187
2275
|
// 计算基础值:x / interval
|
|
2188
2276
|
baseValue = amount.div(roundingInterval);
|
|
2189
2277
|
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));
|
|
2190
|
-
|
|
2191
|
-
|
|
2278
|
+
_context28.t0 = rule;
|
|
2279
|
+
_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;
|
|
2192
2280
|
break;
|
|
2193
2281
|
case 13:
|
|
2194
2282
|
// 标准舍入(中点向上)
|
|
2195
2283
|
roundedValue = this.standardRound(baseValue, true);
|
|
2196
|
-
return
|
|
2284
|
+
return _context28.abrupt("break", 22);
|
|
2197
2285
|
case 15:
|
|
2198
2286
|
// 标准舍入(中点向下)
|
|
2199
2287
|
roundedValue = this.standardRound(baseValue, false);
|
|
2200
|
-
return
|
|
2288
|
+
return _context28.abrupt("break", 22);
|
|
2201
2289
|
case 17:
|
|
2202
2290
|
// 总是向上舍入
|
|
2203
2291
|
roundedValue = baseValue.ceil();
|
|
2204
|
-
return
|
|
2292
|
+
return _context28.abrupt("break", 22);
|
|
2205
2293
|
case 19:
|
|
2206
2294
|
// 总是向下舍入
|
|
2207
2295
|
roundedValue = baseValue.floor();
|
|
2208
|
-
return
|
|
2296
|
+
return _context28.abrupt("break", 22);
|
|
2209
2297
|
case 21:
|
|
2210
2298
|
throw new Error("\u4E0D\u652F\u6301\u7684\u820D\u5165\u89C4\u5219: ".concat(rule));
|
|
2211
2299
|
case 22:
|
|
@@ -2213,11 +2301,11 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2213
2301
|
finalAmount = roundedValue.mul(roundingInterval);
|
|
2214
2302
|
originalAmountStr = amount.toFixed(2); // 如果最终金额是 0 元,则不采用舍入金额,返回原始金额
|
|
2215
2303
|
if (!finalAmount.eq(0)) {
|
|
2216
|
-
|
|
2304
|
+
_context28.next = 27;
|
|
2217
2305
|
break;
|
|
2218
2306
|
}
|
|
2219
2307
|
console.log("[PaymentModule] \u6700\u7EC8\u91D1\u989D\u4E3A0\uFF0C\u8FD4\u56DE\u539F\u59CB\u91D1\u989D: ".concat(originalAmountStr));
|
|
2220
|
-
return
|
|
2308
|
+
return _context28.abrupt("return", {
|
|
2221
2309
|
originalAmount: originalAmountStr,
|
|
2222
2310
|
roundedAmount: originalAmountStr,
|
|
2223
2311
|
roundingDifference: '0.00'
|
|
@@ -2227,21 +2315,21 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2227
2315
|
roundingDifference = finalAmount.sub(amount);
|
|
2228
2316
|
roundingDifferenceStr = roundingDifference.toFixed(2);
|
|
2229
2317
|
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));
|
|
2230
|
-
return
|
|
2318
|
+
return _context28.abrupt("return", {
|
|
2231
2319
|
originalAmount: originalAmountStr,
|
|
2232
2320
|
roundedAmount: roundedAmountStr,
|
|
2233
2321
|
roundingDifference: roundingDifferenceStr
|
|
2234
2322
|
});
|
|
2235
2323
|
case 34:
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
console.error('[PaymentModule] 金额舍入失败:',
|
|
2239
|
-
throw new Error("\u91D1\u989D\u820D\u5165\u5931\u8D25: ".concat(
|
|
2324
|
+
_context28.prev = 34;
|
|
2325
|
+
_context28.t1 = _context28["catch"](0);
|
|
2326
|
+
console.error('[PaymentModule] 金额舍入失败:', _context28.t1);
|
|
2327
|
+
throw new Error("\u91D1\u989D\u820D\u5165\u5931\u8D25: ".concat(_context28.t1 instanceof Error ? _context28.t1.message : String(_context28.t1)));
|
|
2240
2328
|
case 38:
|
|
2241
2329
|
case "end":
|
|
2242
|
-
return
|
|
2330
|
+
return _context28.stop();
|
|
2243
2331
|
}
|
|
2244
|
-
},
|
|
2332
|
+
}, _callee28, this, [[0, 34]]);
|
|
2245
2333
|
}));
|
|
2246
2334
|
function roundAmountAsync(_x29, _x30, _x31) {
|
|
2247
2335
|
return _roundAmountAsync.apply(this, arguments);
|