@pisell/pisellos 2.3.49 → 2.3.50
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/Discount/index.d.ts +1 -0
- package/dist/modules/Discount/index.js +40 -11
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/modules/Holder/index.d.ts +48 -0
- package/dist/modules/Holder/index.js +640 -0
- package/dist/modules/Holder/types.d.ts +123 -0
- package/dist/modules/Holder/types.js +1 -0
- package/dist/modules/Holder/utils.d.ts +13 -0
- package/dist/modules/Holder/utils.js +34 -0
- package/dist/modules/OpenData/index.js +2 -2
- package/dist/modules/Order/index.d.ts +3 -1
- package/dist/modules/Order/index.js +54 -25
- package/dist/modules/Order/types.d.ts +9 -0
- package/dist/modules/Order/utils.d.ts +10 -0
- package/dist/modules/Order/utils.js +35 -3
- package/dist/modules/Payment/types.d.ts +0 -8
- package/dist/modules/Payment/walletpass.d.ts +1 -7
- package/dist/modules/Payment/walletpass.js +45 -155
- package/dist/modules/Product/types.d.ts +1 -0
- package/dist/modules/ProductList/index.js +33 -14
- package/dist/modules/Quotation/index.d.ts +1 -1
- package/dist/modules/Quotation/index.js +2 -2
- package/dist/modules/ResourcePlanner/index.d.ts +24 -0
- package/dist/modules/ResourcePlanner/index.js +181 -0
- package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
- package/dist/modules/ResourcePlanner/planner.js +1069 -0
- package/dist/modules/ResourcePlanner/types.d.ts +227 -0
- package/dist/modules/ResourcePlanner/types.js +1 -0
- package/dist/modules/Rules/index.js +47 -13
- package/dist/modules/SalesSummary/index.js +12 -13
- package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/index.js +15 -2
- package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
- package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
- package/dist/modules/Schedule/index.d.ts +3 -1
- package/dist/modules/Schedule/index.js +21 -16
- package/dist/modules/Summary/utils.js +38 -13
- package/dist/modules/index.d.ts +2 -0
- package/dist/modules/index.js +3 -1
- package/dist/plugins/window.d.ts +1 -0
- package/dist/server/index.d.ts +14 -0
- package/dist/server/index.js +907 -793
- package/dist/server/modules/index.d.ts +1 -1
- package/dist/server/modules/order/index.d.ts +0 -16
- package/dist/server/modules/order/index.js +776 -964
- package/dist/server/modules/order/types.d.ts +0 -14
- package/dist/server/modules/order/types.js +0 -6
- package/dist/solution/BaseSales/index.d.ts +8 -3
- package/dist/solution/BaseSales/index.js +64 -50
- package/dist/solution/BookingByStep/index.d.ts +17 -2
- package/dist/solution/BookingByStep/index.js +294 -215
- package/dist/solution/BookingByStep/types.d.ts +2 -1
- package/dist/solution/BookingByStep/types.js +3 -1
- package/dist/solution/BookingByStep/utils/capacity.js +17 -1
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +2 -2
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +10 -2
- package/dist/solution/ScanOrder/index.d.ts +26 -14
- package/dist/solution/ScanOrder/index.js +1142 -739
- package/dist/solution/ScanOrder/types.d.ts +21 -1
- package/dist/solution/ScanOrder/utils.d.ts +8 -0
- package/dist/solution/ScanOrder/utils.js +66 -25
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +125 -87
- package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/dist/solution/UnifiedBookingSales/index.js +1891 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/dist/solution/UnifiedBookingSales/types.js +11 -0
- package/dist/solution/VenueBooking/index.d.ts +39 -11
- package/dist/solution/VenueBooking/index.js +1167 -841
- package/dist/solution/VenueBooking/types.d.ts +3 -0
- package/dist/solution/VenueBooking/utils/resource.js +1 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +2 -1
- package/dist/types/index.d.ts +1 -0
- package/lib/model/strategy/adapter/promotion/index.js +51 -0
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Discount/index.js +9 -0
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/Holder/index.d.ts +48 -0
- package/lib/modules/Holder/index.js +402 -0
- package/lib/modules/Holder/types.d.ts +123 -0
- package/lib/modules/Holder/types.js +17 -0
- package/lib/modules/Holder/utils.d.ts +13 -0
- package/lib/modules/Holder/utils.js +71 -0
- package/lib/modules/OpenData/index.js +1 -1
- package/lib/modules/Order/index.d.ts +3 -1
- package/lib/modules/Order/index.js +26 -10
- package/lib/modules/Order/types.d.ts +9 -0
- package/lib/modules/Order/utils.d.ts +10 -0
- package/lib/modules/Order/utils.js +36 -5
- package/lib/modules/Payment/types.d.ts +0 -8
- package/lib/modules/Payment/walletpass.d.ts +1 -7
- package/lib/modules/Payment/walletpass.js +9 -107
- package/lib/modules/Product/types.d.ts +1 -0
- package/lib/modules/ProductList/index.js +40 -31
- package/lib/modules/Quotation/index.d.ts +1 -1
- package/lib/modules/Quotation/index.js +2 -2
- package/lib/modules/ResourcePlanner/index.d.ts +24 -0
- package/lib/modules/ResourcePlanner/index.js +148 -0
- package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
- package/lib/modules/ResourcePlanner/planner.js +933 -0
- package/lib/modules/ResourcePlanner/types.d.ts +227 -0
- package/lib/modules/ResourcePlanner/types.js +17 -0
- package/lib/modules/Rules/index.js +33 -16
- package/lib/modules/SalesSummary/index.js +6 -7
- package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/index.js +13 -1
- package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
- package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
- package/lib/modules/Schedule/index.d.ts +3 -1
- package/lib/modules/Schedule/index.js +10 -8
- package/lib/modules/Summary/utils.js +21 -1
- package/lib/modules/index.d.ts +2 -0
- package/lib/modules/index.js +5 -1
- package/lib/plugins/window.d.ts +1 -0
- package/lib/server/index.d.ts +14 -0
- package/lib/server/index.js +72 -15
- package/lib/server/modules/index.d.ts +1 -1
- package/lib/server/modules/order/index.d.ts +0 -16
- package/lib/server/modules/order/index.js +4 -140
- package/lib/server/modules/order/types.d.ts +0 -14
- package/lib/server/modules/order/types.js +0 -1
- package/lib/solution/BaseSales/index.d.ts +8 -3
- package/lib/solution/BaseSales/index.js +24 -14
- package/lib/solution/BookingByStep/index.d.ts +17 -2
- package/lib/solution/BookingByStep/index.js +60 -18
- package/lib/solution/BookingByStep/types.d.ts +2 -1
- package/lib/solution/BookingByStep/types.js +5 -0
- package/lib/solution/BookingByStep/utils/capacity.js +20 -1
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +10 -2
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
- package/lib/solution/ScanOrder/index.d.ts +26 -14
- package/lib/solution/ScanOrder/index.js +449 -182
- package/lib/solution/ScanOrder/types.d.ts +21 -1
- package/lib/solution/ScanOrder/utils.d.ts +8 -0
- package/lib/solution/ScanOrder/utils.js +31 -0
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +14 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/lib/solution/UnifiedBookingSales/index.js +1084 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/lib/solution/UnifiedBookingSales/types.js +33 -0
- package/lib/solution/VenueBooking/index.d.ts +39 -11
- package/lib/solution/VenueBooking/index.js +322 -110
- package/lib/solution/VenueBooking/types.d.ts +3 -0
- package/lib/solution/VenueBooking/utils/resource.js +1 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +3 -1
- package/lib/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -7,11 +7,11 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableTo
|
|
|
7
7
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
8
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
9
9
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
|
-
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; }
|
|
11
|
-
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; }
|
|
12
10
|
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; } } }; }
|
|
13
11
|
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); }
|
|
14
12
|
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; }
|
|
13
|
+
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; }
|
|
14
|
+
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; }
|
|
15
15
|
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; }
|
|
16
16
|
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); } }
|
|
17
17
|
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); }); }; }
|
|
@@ -135,77 +135,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
135
135
|
return _emitOrdersChanged.apply(this, arguments);
|
|
136
136
|
}
|
|
137
137
|
return emitOrdersChanged;
|
|
138
|
-
}()
|
|
139
|
-
/**
|
|
140
|
-
* 广播远端商品成员增删。监听器异常必须与订单落库和原有订单广播隔离。
|
|
141
|
-
*/
|
|
142
|
-
)
|
|
143
|
-
}, {
|
|
144
|
-
key: "emitRemoteProductMembershipChanges",
|
|
145
|
-
value: (function () {
|
|
146
|
-
var _emitRemoteProductMembershipChanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(changes) {
|
|
147
|
-
var _iterator, _step, payload;
|
|
148
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
149
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
150
|
-
case 0:
|
|
151
|
-
_iterator = _createForOfIteratorHelper(changes);
|
|
152
|
-
_context2.prev = 1;
|
|
153
|
-
_iterator.s();
|
|
154
|
-
case 3:
|
|
155
|
-
if ((_step = _iterator.n()).done) {
|
|
156
|
-
_context2.next = 15;
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
payload = _step.value;
|
|
160
|
-
_context2.prev = 5;
|
|
161
|
-
_context2.next = 8;
|
|
162
|
-
return this.core.effects.emit(OrderHooks.onRemoteProductMembershipChanged, payload);
|
|
163
|
-
case 8:
|
|
164
|
-
_context2.next = 13;
|
|
165
|
-
break;
|
|
166
|
-
case 10:
|
|
167
|
-
_context2.prev = 10;
|
|
168
|
-
_context2.t0 = _context2["catch"](5);
|
|
169
|
-
this.logError('广播远端订单商品成员变更失败', {
|
|
170
|
-
order_id: payload.order_id,
|
|
171
|
-
source: payload.source,
|
|
172
|
-
added_product_count: payload.added_product_keys.length,
|
|
173
|
-
removed_product_count: payload.removed_product_keys.length,
|
|
174
|
-
error: _context2.t0 instanceof Error ? _context2.t0.message : String(_context2.t0)
|
|
175
|
-
});
|
|
176
|
-
case 13:
|
|
177
|
-
_context2.next = 3;
|
|
178
|
-
break;
|
|
179
|
-
case 15:
|
|
180
|
-
_context2.next = 20;
|
|
181
|
-
break;
|
|
182
|
-
case 17:
|
|
183
|
-
_context2.prev = 17;
|
|
184
|
-
_context2.t1 = _context2["catch"](1);
|
|
185
|
-
_iterator.e(_context2.t1);
|
|
186
|
-
case 20:
|
|
187
|
-
_context2.prev = 20;
|
|
188
|
-
_iterator.f();
|
|
189
|
-
return _context2.finish(20);
|
|
190
|
-
case 23:
|
|
191
|
-
case "end":
|
|
192
|
-
return _context2.stop();
|
|
193
|
-
}
|
|
194
|
-
}, _callee2, this, [[1, 17, 20, 23], [5, 10]]);
|
|
195
|
-
}));
|
|
196
|
-
function emitRemoteProductMembershipChanges(_x) {
|
|
197
|
-
return _emitRemoteProductMembershipChanges.apply(this, arguments);
|
|
198
|
-
}
|
|
199
|
-
return emitRemoteProductMembershipChanges;
|
|
200
138
|
}())
|
|
201
139
|
}, {
|
|
202
140
|
key: "initialize",
|
|
203
141
|
value: function () {
|
|
204
|
-
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
142
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(core, options) {
|
|
205
143
|
var _options$initialState;
|
|
206
144
|
var appPlugin, app;
|
|
207
|
-
return _regeneratorRuntime().wrap(function
|
|
208
|
-
while (1) switch (
|
|
145
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
146
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
209
147
|
case 0:
|
|
210
148
|
this.core = core;
|
|
211
149
|
this.store = options === null || options === void 0 ? void 0 : options.store;
|
|
@@ -235,11 +173,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
235
173
|
});
|
|
236
174
|
case 10:
|
|
237
175
|
case "end":
|
|
238
|
-
return
|
|
176
|
+
return _context2.stop();
|
|
239
177
|
}
|
|
240
|
-
},
|
|
178
|
+
}, _callee2, this);
|
|
241
179
|
}));
|
|
242
|
-
function initialize(
|
|
180
|
+
function initialize(_x, _x2) {
|
|
243
181
|
return _initialize.apply(this, arguments);
|
|
244
182
|
}
|
|
245
183
|
return initialize;
|
|
@@ -392,11 +330,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
392
330
|
var mergedItem = mergeOrderCollectionItems(kind, existingItem, incomingItem);
|
|
393
331
|
var mergedUid = getOrderCollectionUid(kind, mergedItem);
|
|
394
332
|
if (mergedUid) {
|
|
395
|
-
var
|
|
396
|
-
|
|
333
|
+
var _iterator = _createForOfIteratorHelper(new Set([getOrderCollectionReferenceUid(kind, existingItem), getOrderCollectionReferenceUid(kind, incomingItem)])),
|
|
334
|
+
_step;
|
|
397
335
|
try {
|
|
398
|
-
for (
|
|
399
|
-
var from =
|
|
336
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
337
|
+
var from = _step.value;
|
|
400
338
|
if (!from || from === mergedUid) continue;
|
|
401
339
|
uidRemaps.push({
|
|
402
340
|
kind: kind,
|
|
@@ -406,9 +344,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
406
344
|
});
|
|
407
345
|
}
|
|
408
346
|
} catch (err) {
|
|
409
|
-
|
|
347
|
+
_iterator.e(err);
|
|
410
348
|
} finally {
|
|
411
|
-
|
|
349
|
+
_iterator.f();
|
|
412
350
|
}
|
|
413
351
|
}
|
|
414
352
|
return mergedItem;
|
|
@@ -439,11 +377,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
439
377
|
key: "recordRecentSqliteWrite",
|
|
440
378
|
value: function recordRecentSqliteWrite(source, orders) {
|
|
441
379
|
var now = Date.now();
|
|
442
|
-
var
|
|
443
|
-
|
|
380
|
+
var _iterator2 = _createForOfIteratorHelper(orders),
|
|
381
|
+
_step2;
|
|
444
382
|
try {
|
|
445
|
-
for (
|
|
446
|
-
var order =
|
|
383
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
384
|
+
var order = _step2.value;
|
|
447
385
|
var storageKey = this.getOrderStorageKey(order);
|
|
448
386
|
if (!storageKey) continue;
|
|
449
387
|
this.recentSqliteWriteByStorageKey.set(storageKey, {
|
|
@@ -452,9 +390,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
452
390
|
});
|
|
453
391
|
}
|
|
454
392
|
} catch (err) {
|
|
455
|
-
|
|
393
|
+
_iterator2.e(err);
|
|
456
394
|
} finally {
|
|
457
|
-
|
|
395
|
+
_iterator2.f();
|
|
458
396
|
}
|
|
459
397
|
}
|
|
460
398
|
|
|
@@ -467,7 +405,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
467
405
|
}, {
|
|
468
406
|
key: "filterRedundantPatchOrders",
|
|
469
407
|
value: function filterRedundantPatchOrders(source, orders, mergeActions) {
|
|
470
|
-
var forceWriteStorageKeys = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new Set();
|
|
471
408
|
var eligibleSkipSources = new Set(['pubsub.bodyUpsert', 'pubsub.httpRefresh']);
|
|
472
409
|
if (!eligibleSkipSources.has(source)) {
|
|
473
410
|
return {
|
|
@@ -478,11 +415,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
478
415
|
var now = Date.now();
|
|
479
416
|
var toWrite = [];
|
|
480
417
|
var skipped = [];
|
|
481
|
-
var
|
|
482
|
-
|
|
418
|
+
var _iterator3 = _createForOfIteratorHelper(orders),
|
|
419
|
+
_step3;
|
|
483
420
|
try {
|
|
484
|
-
for (
|
|
485
|
-
var order =
|
|
421
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
422
|
+
var order = _step3.value;
|
|
486
423
|
var storageKey = this.getOrderStorageKey(order);
|
|
487
424
|
if (!storageKey) {
|
|
488
425
|
toWrite.push(order);
|
|
@@ -496,12 +433,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
496
433
|
toWrite.push(order);
|
|
497
434
|
continue;
|
|
498
435
|
}
|
|
499
|
-
|
|
500
|
-
// 远端商品成员确实发生增删时必须落库,避免内存已更新但 SQLite 仍被回声窗口跳过。
|
|
501
|
-
if (forceWriteStorageKeys.has(storageKey)) {
|
|
502
|
-
toWrite.push(order);
|
|
503
|
-
continue;
|
|
504
|
-
}
|
|
505
436
|
var recent = this.recentSqliteWriteByStorageKey.get(storageKey);
|
|
506
437
|
if (recent && ORDER_BUSINESS_WRITE_SOURCES.has(recent.source) && now - recent.ts < ORDER_SQLITE_DEDUPE_MS) {
|
|
507
438
|
var _order$order_id2;
|
|
@@ -517,9 +448,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
517
448
|
toWrite.push(order);
|
|
518
449
|
}
|
|
519
450
|
} catch (err) {
|
|
520
|
-
|
|
451
|
+
_iterator3.e(err);
|
|
521
452
|
} finally {
|
|
522
|
-
|
|
453
|
+
_iterator3.f();
|
|
523
454
|
}
|
|
524
455
|
return {
|
|
525
456
|
toWrite: toWrite,
|
|
@@ -539,11 +470,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
539
470
|
var now = Date.now();
|
|
540
471
|
var toFetch = [];
|
|
541
472
|
var skipped = [];
|
|
542
|
-
var
|
|
543
|
-
|
|
473
|
+
var _iterator4 = _createForOfIteratorHelper(ids),
|
|
474
|
+
_step4;
|
|
544
475
|
try {
|
|
545
|
-
for (
|
|
546
|
-
var id =
|
|
476
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
477
|
+
var id = _step4.value;
|
|
547
478
|
var existing = this.getOrderByOrderId(id);
|
|
548
479
|
if (!existing) {
|
|
549
480
|
toFetch.push(id);
|
|
@@ -562,9 +493,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
562
493
|
toFetch.push(id);
|
|
563
494
|
}
|
|
564
495
|
} catch (err) {
|
|
565
|
-
|
|
496
|
+
_iterator4.e(err);
|
|
566
497
|
} finally {
|
|
567
|
-
|
|
498
|
+
_iterator4.f();
|
|
568
499
|
}
|
|
569
500
|
return {
|
|
570
501
|
toFetch: toFetch,
|
|
@@ -699,27 +630,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
699
630
|
}, {
|
|
700
631
|
key: "preload",
|
|
701
632
|
value: function () {
|
|
702
|
-
var _preload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
633
|
+
var _preload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
703
634
|
var orders;
|
|
704
|
-
return _regeneratorRuntime().wrap(function
|
|
705
|
-
while (1) switch (
|
|
635
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
636
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
706
637
|
case 0:
|
|
707
|
-
|
|
638
|
+
_context3.next = 2;
|
|
708
639
|
return this.loadOrdersByServer();
|
|
709
640
|
case 2:
|
|
710
|
-
orders =
|
|
641
|
+
orders = _context3.sent;
|
|
711
642
|
this.store.list = cloneDeep(orders);
|
|
712
643
|
this.syncOrdersMap();
|
|
713
|
-
|
|
644
|
+
_context3.next = 7;
|
|
714
645
|
return this.emitOrdersChanged([], 'preload');
|
|
715
646
|
case 7:
|
|
716
|
-
|
|
647
|
+
_context3.next = 9;
|
|
717
648
|
return this.core.effects.emit(OrderHooks.onOrdersSyncCompleted, null);
|
|
718
649
|
case 9:
|
|
719
650
|
case "end":
|
|
720
|
-
return
|
|
651
|
+
return _context3.stop();
|
|
721
652
|
}
|
|
722
|
-
},
|
|
653
|
+
}, _callee3, this);
|
|
723
654
|
}));
|
|
724
655
|
function preload() {
|
|
725
656
|
return _preload.apply(this, arguments);
|
|
@@ -781,7 +712,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
781
712
|
}, {
|
|
782
713
|
key: "getLocalOrderByLookup",
|
|
783
714
|
value: function () {
|
|
784
|
-
var _getLocalOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
715
|
+
var _getLocalOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(lookup) {
|
|
785
716
|
var _this4 = this;
|
|
786
717
|
var options,
|
|
787
718
|
key,
|
|
@@ -791,11 +722,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
791
722
|
orders,
|
|
792
723
|
localOrder,
|
|
793
724
|
normalizedOrder,
|
|
794
|
-
|
|
795
|
-
return _regeneratorRuntime().wrap(function
|
|
796
|
-
while (1) switch (
|
|
725
|
+
_args4 = arguments;
|
|
726
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
727
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
797
728
|
case 0:
|
|
798
|
-
options =
|
|
729
|
+
options = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
|
|
799
730
|
key = this.getIdKey(lookup);
|
|
800
731
|
logContext = {
|
|
801
732
|
operation_id: options.operationId,
|
|
@@ -807,38 +738,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
807
738
|
}
|
|
808
739
|
memoryOrderById = this.store.map.get(key);
|
|
809
740
|
if (!memoryOrderById) {
|
|
810
|
-
|
|
741
|
+
_context4.next = 8;
|
|
811
742
|
break;
|
|
812
743
|
}
|
|
813
744
|
if (options.operationId) {
|
|
814
745
|
this.logInfo('getLocalOrderByLookup-localPayment-命中内存映射', _objectSpread(_objectSpread({}, logContext), this.buildLocalPaymentOrderLogContext(memoryOrderById)));
|
|
815
746
|
}
|
|
816
|
-
return
|
|
747
|
+
return _context4.abrupt("return", memoryOrderById);
|
|
817
748
|
case 8:
|
|
818
749
|
memoryOrder = this.store.list.find(function (order) {
|
|
819
750
|
return _this4.isOrderLookupMatch(order, key);
|
|
820
751
|
});
|
|
821
752
|
if (!memoryOrder) {
|
|
822
|
-
|
|
753
|
+
_context4.next = 12;
|
|
823
754
|
break;
|
|
824
755
|
}
|
|
825
756
|
if (options.operationId) {
|
|
826
757
|
this.logInfo('getLocalOrderByLookup-localPayment-命中内存列表', _objectSpread(_objectSpread({}, logContext), this.buildLocalPaymentOrderLogContext(memoryOrder)));
|
|
827
758
|
}
|
|
828
|
-
return
|
|
759
|
+
return _context4.abrupt("return", memoryOrder);
|
|
829
760
|
case 12:
|
|
830
761
|
if (options.operationId) {
|
|
831
762
|
this.logInfo('getLocalOrderByLookup-localPayment-开始读取SQLite', logContext);
|
|
832
763
|
}
|
|
833
|
-
|
|
764
|
+
_context4.next = 15;
|
|
834
765
|
return this.loadOrdersFromSQLite();
|
|
835
766
|
case 15:
|
|
836
|
-
orders =
|
|
767
|
+
orders = _context4.sent;
|
|
837
768
|
localOrder = orders.find(function (order) {
|
|
838
769
|
return _this4.isOrderLookupMatch(order, key);
|
|
839
770
|
});
|
|
840
771
|
if (localOrder) {
|
|
841
|
-
|
|
772
|
+
_context4.next = 20;
|
|
842
773
|
break;
|
|
843
774
|
}
|
|
844
775
|
if (options.operationId) {
|
|
@@ -846,7 +777,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
846
777
|
sqlite_order_count: orders.length
|
|
847
778
|
}));
|
|
848
779
|
}
|
|
849
|
-
return
|
|
780
|
+
return _context4.abrupt("return", null);
|
|
850
781
|
case 20:
|
|
851
782
|
this.store.list = this.normalizeOrdersForMemoryList(orders, 'getLocalOrderByLookup.sqliteMemory');
|
|
852
783
|
this.syncOrdersMap();
|
|
@@ -856,14 +787,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
856
787
|
sqlite_order_count: orders.length
|
|
857
788
|
}, this.buildLocalPaymentOrderLogContext(normalizedOrder)));
|
|
858
789
|
}
|
|
859
|
-
return
|
|
790
|
+
return _context4.abrupt("return", normalizedOrder);
|
|
860
791
|
case 25:
|
|
861
792
|
case "end":
|
|
862
|
-
return
|
|
793
|
+
return _context4.stop();
|
|
863
794
|
}
|
|
864
|
-
},
|
|
795
|
+
}, _callee4, this);
|
|
865
796
|
}));
|
|
866
|
-
function getLocalOrderByLookup(
|
|
797
|
+
function getLocalOrderByLookup(_x3) {
|
|
867
798
|
return _getLocalOrderByLookup.apply(this, arguments);
|
|
868
799
|
}
|
|
869
800
|
return getLocalOrderByLookup;
|
|
@@ -871,10 +802,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
871
802
|
}, {
|
|
872
803
|
key: "getLocalPayment",
|
|
873
804
|
value: function () {
|
|
874
|
-
var _getLocalPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
805
|
+
var _getLocalPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
|
|
875
806
|
var logContext, order, payments, match;
|
|
876
|
-
return _regeneratorRuntime().wrap(function
|
|
877
|
-
while (1) switch (
|
|
807
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
808
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
878
809
|
case 0:
|
|
879
810
|
logContext = {
|
|
880
811
|
operation_id: params.operationId,
|
|
@@ -882,56 +813,56 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
882
813
|
payment_number: params.paymentNumber
|
|
883
814
|
};
|
|
884
815
|
this.logInfo('getLocalPayment-开始', logContext);
|
|
885
|
-
|
|
886
|
-
|
|
816
|
+
_context5.prev = 2;
|
|
817
|
+
_context5.next = 5;
|
|
887
818
|
return this.getLocalOrderByLookup(params.saleId, {
|
|
888
819
|
operationId: params.operationId
|
|
889
820
|
});
|
|
890
821
|
case 5:
|
|
891
|
-
order =
|
|
822
|
+
order = _context5.sent;
|
|
892
823
|
if (order) {
|
|
893
|
-
|
|
824
|
+
_context5.next = 9;
|
|
894
825
|
break;
|
|
895
826
|
}
|
|
896
827
|
this.logWarning('getLocalPayment-订单未命中', logContext);
|
|
897
|
-
return
|
|
828
|
+
return _context5.abrupt("return", null);
|
|
898
829
|
case 9:
|
|
899
830
|
payments = order.payments || [];
|
|
900
831
|
match = resolveOrderPaymentIdentity(payments, params.paymentNumber, 'compat');
|
|
901
832
|
if (match) {
|
|
902
|
-
|
|
833
|
+
_context5.next = 14;
|
|
903
834
|
break;
|
|
904
835
|
}
|
|
905
836
|
this.logWarning('getLocalPayment-支付项未命中', _objectSpread(_objectSpread(_objectSpread({}, logContext), this.buildLocalPaymentOrderLogContext(order)), {}, {
|
|
906
837
|
payments: payments
|
|
907
838
|
}));
|
|
908
|
-
return
|
|
839
|
+
return _context5.abrupt("return", null);
|
|
909
840
|
case 14:
|
|
910
841
|
this.logInfo('getLocalPayment-支付项命中', _objectSpread(_objectSpread(_objectSpread({}, logContext), this.buildLocalPaymentOrderLogContext(order)), {}, {
|
|
911
842
|
matched_by: match.matchedBy,
|
|
912
843
|
payment_index: match.index,
|
|
913
844
|
payment: match.payment
|
|
914
845
|
}));
|
|
915
|
-
return
|
|
846
|
+
return _context5.abrupt("return", {
|
|
916
847
|
order: order,
|
|
917
848
|
payment: match.payment,
|
|
918
849
|
paymentIndex: match.index,
|
|
919
850
|
matchedBy: match.matchedBy
|
|
920
851
|
});
|
|
921
852
|
case 18:
|
|
922
|
-
|
|
923
|
-
|
|
853
|
+
_context5.prev = 18;
|
|
854
|
+
_context5.t0 = _context5["catch"](2);
|
|
924
855
|
this.logError('getLocalPayment-查询失败', _objectSpread(_objectSpread({}, logContext), {}, {
|
|
925
|
-
error:
|
|
856
|
+
error: _context5.t0 instanceof Error ? _context5.t0.message : String(_context5.t0)
|
|
926
857
|
}));
|
|
927
|
-
throw
|
|
858
|
+
throw _context5.t0;
|
|
928
859
|
case 22:
|
|
929
860
|
case "end":
|
|
930
|
-
return
|
|
861
|
+
return _context5.stop();
|
|
931
862
|
}
|
|
932
|
-
},
|
|
863
|
+
}, _callee5, this, [[2, 18]]);
|
|
933
864
|
}));
|
|
934
|
-
function getLocalPayment(
|
|
865
|
+
function getLocalPayment(_x4) {
|
|
935
866
|
return _getLocalPayment.apply(this, arguments);
|
|
936
867
|
}
|
|
937
868
|
return getLocalPayment;
|
|
@@ -939,10 +870,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
939
870
|
}, {
|
|
940
871
|
key: "updateLocalPayment",
|
|
941
872
|
value: function () {
|
|
942
|
-
var _updateLocalPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
873
|
+
var _updateLocalPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
|
|
943
874
|
var logContext, found, previousPayment, nextPayment, nextOrder, paymentContext, targetIndex, shouldKeepInMemory, previousList, storageOrder, _storageOrder$order_i, _storageOrder$order_i2, _storageOrder$order_i3;
|
|
944
|
-
return _regeneratorRuntime().wrap(function
|
|
945
|
-
while (1) switch (
|
|
875
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
876
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
946
877
|
case 0:
|
|
947
878
|
logContext = {
|
|
948
879
|
operation_id: params.operationId,
|
|
@@ -951,16 +882,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
951
882
|
incoming_payment_update: params.updates
|
|
952
883
|
};
|
|
953
884
|
this.logInfo('updateLocalPayment-开始', logContext);
|
|
954
|
-
|
|
885
|
+
_context6.next = 4;
|
|
955
886
|
return this.getLocalPayment(params);
|
|
956
887
|
case 4:
|
|
957
|
-
found =
|
|
888
|
+
found = _context6.sent;
|
|
958
889
|
if (found) {
|
|
959
|
-
|
|
890
|
+
_context6.next = 8;
|
|
960
891
|
break;
|
|
961
892
|
}
|
|
962
893
|
this.logWarning('updateLocalPayment-支付项未命中', logContext);
|
|
963
|
-
return
|
|
894
|
+
return _context6.abrupt("return", null);
|
|
964
895
|
case 8:
|
|
965
896
|
previousPayment = cloneDeep(found.payment);
|
|
966
897
|
nextPayment = mergeOrderPaymentRecord(found.payment, _objectSpread(_objectSpread({}, params.updates), {}, {
|
|
@@ -983,11 +914,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
983
914
|
targetIndex = this.findOrderIndexByIdentity(this.store.list, found.order);
|
|
984
915
|
shouldKeepInMemory = this.shouldKeepOrderInMemory(nextOrder);
|
|
985
916
|
if (!(targetIndex < 0 && shouldKeepInMemory)) {
|
|
986
|
-
|
|
917
|
+
_context6.next = 18;
|
|
987
918
|
break;
|
|
988
919
|
}
|
|
989
920
|
this.logError('updateLocalPayment-订单Store索引未命中', paymentContext);
|
|
990
|
-
return
|
|
921
|
+
return _context6.abrupt("return", null);
|
|
991
922
|
case 18:
|
|
992
923
|
previousList = this.store.list;
|
|
993
924
|
this.store.list = shouldKeepInMemory ? this.store.list.map(function (order, index) {
|
|
@@ -997,11 +928,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
997
928
|
});
|
|
998
929
|
this.syncOrdersMap();
|
|
999
930
|
storageOrder = this.withoutSyntheticDraftOrderId(nextOrder);
|
|
1000
|
-
|
|
931
|
+
_context6.prev = 22;
|
|
1001
932
|
this.logInfo('updateLocalPayment-SQLite写入开始', _objectSpread(_objectSpread({}, paymentContext), {}, {
|
|
1002
933
|
storage_order_id: (_storageOrder$order_i = storageOrder.order_id) !== null && _storageOrder$order_i !== void 0 ? _storageOrder$order_i : null
|
|
1003
934
|
}));
|
|
1004
|
-
|
|
935
|
+
_context6.next = 26;
|
|
1005
936
|
return this.updateOrderInSQLite(storageOrder, 'updateLocalPayment', {
|
|
1006
937
|
throwOnError: true
|
|
1007
938
|
});
|
|
@@ -1009,39 +940,39 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1009
940
|
this.logInfo('updateLocalPayment-SQLite写入完成', _objectSpread(_objectSpread({}, paymentContext), {}, {
|
|
1010
941
|
storage_order_id: (_storageOrder$order_i2 = storageOrder.order_id) !== null && _storageOrder$order_i2 !== void 0 ? _storageOrder$order_i2 : null
|
|
1011
942
|
}));
|
|
1012
|
-
|
|
943
|
+
_context6.next = 35;
|
|
1013
944
|
break;
|
|
1014
945
|
case 29:
|
|
1015
|
-
|
|
1016
|
-
|
|
946
|
+
_context6.prev = 29;
|
|
947
|
+
_context6.t0 = _context6["catch"](22);
|
|
1017
948
|
this.store.list = previousList;
|
|
1018
949
|
this.syncOrdersMap();
|
|
1019
950
|
this.logError('updateLocalPayment-SQLite写入失败并回滚内存', _objectSpread(_objectSpread({}, paymentContext), {}, {
|
|
1020
951
|
storage_order_id: (_storageOrder$order_i3 = storageOrder.order_id) !== null && _storageOrder$order_i3 !== void 0 ? _storageOrder$order_i3 : null,
|
|
1021
|
-
error:
|
|
952
|
+
error: _context6.t0 instanceof Error ? _context6.t0.message : String(_context6.t0)
|
|
1022
953
|
}));
|
|
1023
|
-
throw
|
|
954
|
+
throw _context6.t0;
|
|
1024
955
|
case 35:
|
|
1025
956
|
if (!(shouldKeepInMemory || targetIndex >= 0)) {
|
|
1026
|
-
|
|
957
|
+
_context6.next = 38;
|
|
1027
958
|
break;
|
|
1028
959
|
}
|
|
1029
|
-
|
|
960
|
+
_context6.next = 38;
|
|
1030
961
|
return this.emitOrdersChanged(shouldKeepInMemory ? [nextOrder] : [], shouldKeepInMemory ? 'updateLocalPayment' : 'updateLocalPayment.sqliteOnlyDraft');
|
|
1031
962
|
case 38:
|
|
1032
963
|
this.logInfo('updateLocalPayment-变更事件完成', paymentContext);
|
|
1033
|
-
return
|
|
964
|
+
return _context6.abrupt("return", {
|
|
1034
965
|
order: nextOrder,
|
|
1035
966
|
payment: nextPayment,
|
|
1036
967
|
previousPayment: previousPayment
|
|
1037
968
|
});
|
|
1038
969
|
case 40:
|
|
1039
970
|
case "end":
|
|
1040
|
-
return
|
|
971
|
+
return _context6.stop();
|
|
1041
972
|
}
|
|
1042
|
-
},
|
|
973
|
+
}, _callee6, this, [[22, 29]]);
|
|
1043
974
|
}));
|
|
1044
|
-
function updateLocalPayment(
|
|
975
|
+
function updateLocalPayment(_x5) {
|
|
1045
976
|
return _updateLocalPayment.apply(this, arguments);
|
|
1046
977
|
}
|
|
1047
978
|
return updateLocalPayment;
|
|
@@ -1049,18 +980,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1049
980
|
}, {
|
|
1050
981
|
key: "loadOrdersByServer",
|
|
1051
982
|
value: function () {
|
|
1052
|
-
var _loadOrdersByServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
983
|
+
var _loadOrdersByServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
1053
984
|
var _this5 = this,
|
|
1054
985
|
_this$store;
|
|
1055
986
|
var orderList, protectedOrdersBeforeRemoteFetch, data, mergedOrders, memoryOrders;
|
|
1056
|
-
return _regeneratorRuntime().wrap(function
|
|
1057
|
-
while (1) switch (
|
|
987
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
988
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
1058
989
|
case 0:
|
|
1059
990
|
orderList = [];
|
|
1060
|
-
|
|
991
|
+
_context7.next = 3;
|
|
1061
992
|
return this.loadOrdersFromSQLite();
|
|
1062
993
|
case 3:
|
|
1063
|
-
protectedOrdersBeforeRemoteFetch =
|
|
994
|
+
protectedOrdersBeforeRemoteFetch = _context7.sent.filter(function (order) {
|
|
1064
995
|
return _this5.shouldProtectLocalOrderFromRemoteSnapshot(order);
|
|
1065
996
|
});
|
|
1066
997
|
this.logInfo('loadOrdersByServer-开始', {
|
|
@@ -1072,51 +1003,51 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1072
1003
|
}, 0)
|
|
1073
1004
|
});
|
|
1074
1005
|
if (!this.orderDataSource) {
|
|
1075
|
-
|
|
1006
|
+
_context7.next = 20;
|
|
1076
1007
|
break;
|
|
1077
1008
|
}
|
|
1078
|
-
|
|
1079
|
-
|
|
1009
|
+
_context7.prev = 6;
|
|
1010
|
+
_context7.next = 9;
|
|
1080
1011
|
return this.orderDataSource.run({
|
|
1081
1012
|
sse: {
|
|
1082
1013
|
query: this.store.createdAtQuery
|
|
1083
1014
|
}
|
|
1084
1015
|
});
|
|
1085
1016
|
case 9:
|
|
1086
|
-
data =
|
|
1017
|
+
data = _context7.sent;
|
|
1087
1018
|
orderList = data || [];
|
|
1088
1019
|
this.logInfo('loadOrdersByServer-SSE拉取成功', {
|
|
1089
1020
|
count: orderList.length
|
|
1090
1021
|
});
|
|
1091
1022
|
this.markOrderPulledAtNow();
|
|
1092
1023
|
this.lastServerFullFetchAtMs = Date.now();
|
|
1093
|
-
|
|
1024
|
+
_context7.next = 20;
|
|
1094
1025
|
break;
|
|
1095
1026
|
case 16:
|
|
1096
|
-
|
|
1097
|
-
|
|
1027
|
+
_context7.prev = 16;
|
|
1028
|
+
_context7.t0 = _context7["catch"](6);
|
|
1098
1029
|
this.logInfo('loadOrdersByServer-SSE拉取失败,保持当前内存订单');
|
|
1099
|
-
return
|
|
1030
|
+
return _context7.abrupt("return", this.store.list);
|
|
1100
1031
|
case 20:
|
|
1101
|
-
|
|
1032
|
+
_context7.next = 22;
|
|
1102
1033
|
return this.replaceOrdersSnapshotInSQLite(orderList, 'loadOrdersByServer', protectedOrdersBeforeRemoteFetch);
|
|
1103
1034
|
case 22:
|
|
1104
|
-
mergedOrders =
|
|
1035
|
+
mergedOrders = _context7.sent;
|
|
1105
1036
|
memoryOrders = this.normalizeOrdersForMemoryList(mergedOrders, 'loadOrdersByServer.memory');
|
|
1106
1037
|
this.logInfo('loadOrdersByServer-结束', {
|
|
1107
1038
|
count: memoryOrders.length,
|
|
1108
1039
|
persistedCount: mergedOrders.length,
|
|
1109
1040
|
sqliteOnlyDraftCount: mergedOrders.length - memoryOrders.length
|
|
1110
1041
|
});
|
|
1111
|
-
|
|
1042
|
+
_context7.next = 27;
|
|
1112
1043
|
return this.core.effects.emit(OrderHooks.onOrdersLoaded, memoryOrders);
|
|
1113
1044
|
case 27:
|
|
1114
|
-
return
|
|
1045
|
+
return _context7.abrupt("return", memoryOrders);
|
|
1115
1046
|
case 28:
|
|
1116
1047
|
case "end":
|
|
1117
|
-
return
|
|
1048
|
+
return _context7.stop();
|
|
1118
1049
|
}
|
|
1119
|
-
},
|
|
1050
|
+
}, _callee7, this, [[6, 16]]);
|
|
1120
1051
|
}));
|
|
1121
1052
|
function loadOrdersByServer() {
|
|
1122
1053
|
return _loadOrdersByServer.apply(this, arguments);
|
|
@@ -1131,54 +1062,54 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1131
1062
|
}, {
|
|
1132
1063
|
key: "silentRefresh",
|
|
1133
1064
|
value: (function () {
|
|
1134
|
-
var _silentRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1065
|
+
var _silentRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
1135
1066
|
var startTime, elapsedSinceFullFetch, orders, errorMessage;
|
|
1136
|
-
return _regeneratorRuntime().wrap(function
|
|
1137
|
-
while (1) switch (
|
|
1067
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
1068
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
1138
1069
|
case 0:
|
|
1139
1070
|
startTime = Date.now();
|
|
1140
1071
|
elapsedSinceFullFetch = Date.now() - this.lastServerFullFetchAtMs;
|
|
1141
1072
|
if (!(this.lastServerFullFetchAtMs > 0 && elapsedSinceFullFetch < ORDER_SILENT_REFRESH_MIN_INTERVAL_MS)) {
|
|
1142
|
-
|
|
1073
|
+
_context8.next = 4;
|
|
1143
1074
|
break;
|
|
1144
1075
|
}
|
|
1145
|
-
return
|
|
1076
|
+
return _context8.abrupt("return", this.store.list);
|
|
1146
1077
|
case 4:
|
|
1147
1078
|
this.logInfo('silentRefresh 开始');
|
|
1148
|
-
|
|
1079
|
+
_context8.prev = 5;
|
|
1149
1080
|
// 刷新前,需要更新当前营业日边界(store.createdAtQuery)
|
|
1150
1081
|
this.updateCreateStore();
|
|
1151
|
-
|
|
1082
|
+
_context8.next = 9;
|
|
1152
1083
|
return this.loadOrdersByServer();
|
|
1153
1084
|
case 9:
|
|
1154
|
-
orders =
|
|
1085
|
+
orders = _context8.sent;
|
|
1155
1086
|
this.store.list = cloneDeep(orders);
|
|
1156
1087
|
this.syncOrdersMap();
|
|
1157
|
-
|
|
1088
|
+
_context8.next = 14;
|
|
1158
1089
|
return this.emitOrdersChanged([], 'silentRefresh');
|
|
1159
1090
|
case 14:
|
|
1160
|
-
|
|
1091
|
+
_context8.next = 16;
|
|
1161
1092
|
return this.core.effects.emit(OrderHooks.onOrdersSyncCompleted, null);
|
|
1162
1093
|
case 16:
|
|
1163
1094
|
this.logInfo('silentRefresh 完成', {
|
|
1164
1095
|
orderCount: orders.length,
|
|
1165
1096
|
duration: "".concat(Date.now() - startTime, "ms")
|
|
1166
1097
|
});
|
|
1167
|
-
return
|
|
1098
|
+
return _context8.abrupt("return", this.store.list);
|
|
1168
1099
|
case 20:
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
errorMessage =
|
|
1100
|
+
_context8.prev = 20;
|
|
1101
|
+
_context8.t0 = _context8["catch"](5);
|
|
1102
|
+
errorMessage = _context8.t0 instanceof Error ? _context8.t0.message : String(_context8.t0);
|
|
1172
1103
|
this.logError('silentRefresh 失败', {
|
|
1173
1104
|
duration: "".concat(Date.now() - startTime, "ms"),
|
|
1174
1105
|
error: errorMessage
|
|
1175
1106
|
});
|
|
1176
|
-
return
|
|
1107
|
+
return _context8.abrupt("return", this.store.list);
|
|
1177
1108
|
case 25:
|
|
1178
1109
|
case "end":
|
|
1179
|
-
return
|
|
1110
|
+
return _context8.stop();
|
|
1180
1111
|
}
|
|
1181
|
-
},
|
|
1112
|
+
}, _callee8, this, [[5, 20]]);
|
|
1182
1113
|
}));
|
|
1183
1114
|
function silentRefresh() {
|
|
1184
1115
|
return _silentRefresh.apply(this, arguments);
|
|
@@ -1245,31 +1176,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1245
1176
|
}, {
|
|
1246
1177
|
key: "overwriteExistingOrder",
|
|
1247
1178
|
value: (function () {
|
|
1248
|
-
var _overwriteExistingOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1179
|
+
var _overwriteExistingOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(fresh) {
|
|
1249
1180
|
var _this7 = this;
|
|
1250
1181
|
var orderId, key, normalizedFresh, existingOrder, reconciledFresh;
|
|
1251
|
-
return _regeneratorRuntime().wrap(function
|
|
1252
|
-
while (1) switch (
|
|
1182
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
1183
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
1253
1184
|
case 0:
|
|
1254
1185
|
orderId = fresh === null || fresh === void 0 ? void 0 : fresh.order_id;
|
|
1255
1186
|
if (!(orderId === undefined || orderId === null)) {
|
|
1256
|
-
|
|
1187
|
+
_context9.next = 4;
|
|
1257
1188
|
break;
|
|
1258
1189
|
}
|
|
1259
1190
|
this.logError('overwriteExistingOrder-入参缺少 order_id');
|
|
1260
|
-
return
|
|
1191
|
+
return _context9.abrupt("return", {
|
|
1261
1192
|
overwritten: false
|
|
1262
1193
|
});
|
|
1263
1194
|
case 4:
|
|
1264
1195
|
key = this.getIdKey(orderId);
|
|
1265
1196
|
if (this.store.map.has(key)) {
|
|
1266
|
-
|
|
1197
|
+
_context9.next = 8;
|
|
1267
1198
|
break;
|
|
1268
1199
|
}
|
|
1269
1200
|
this.logInfo('overwriteExistingOrder-本地不存在该订单,跳过', {
|
|
1270
1201
|
orderId: orderId
|
|
1271
1202
|
});
|
|
1272
|
-
return
|
|
1203
|
+
return _context9.abrupt("return", {
|
|
1273
1204
|
overwritten: false
|
|
1274
1205
|
});
|
|
1275
1206
|
case 8:
|
|
@@ -1288,26 +1219,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1288
1219
|
return _this7.getIdKey(id) === key ? reconciledFresh : _this7.normalizeOrderForMemoryList(order, 'overwriteExistingOrder.existingMemory');
|
|
1289
1220
|
});
|
|
1290
1221
|
this.syncOrdersMap();
|
|
1291
|
-
|
|
1222
|
+
_context9.next = 16;
|
|
1292
1223
|
return this.updateOrderInSQLite(reconciledFresh, 'overwriteExistingOrder');
|
|
1293
1224
|
case 16:
|
|
1294
1225
|
this.logInfo('overwriteExistingOrder-结束', {
|
|
1295
1226
|
orderId: orderId,
|
|
1296
1227
|
storeOrderCountAfter: this.store.list.length
|
|
1297
1228
|
});
|
|
1298
|
-
|
|
1229
|
+
_context9.next = 19;
|
|
1299
1230
|
return this.emitOrdersChanged([reconciledFresh], 'overwriteExistingOrder');
|
|
1300
1231
|
case 19:
|
|
1301
|
-
return
|
|
1232
|
+
return _context9.abrupt("return", {
|
|
1302
1233
|
overwritten: true
|
|
1303
1234
|
});
|
|
1304
1235
|
case 20:
|
|
1305
1236
|
case "end":
|
|
1306
|
-
return
|
|
1237
|
+
return _context9.stop();
|
|
1307
1238
|
}
|
|
1308
|
-
},
|
|
1239
|
+
}, _callee9, this);
|
|
1309
1240
|
}));
|
|
1310
|
-
function overwriteExistingOrder(
|
|
1241
|
+
function overwriteExistingOrder(_x6) {
|
|
1311
1242
|
return _overwriteExistingOrder.apply(this, arguments);
|
|
1312
1243
|
}
|
|
1313
1244
|
return overwriteExistingOrder;
|
|
@@ -1320,33 +1251,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1320
1251
|
}, {
|
|
1321
1252
|
key: "upsertOrdersFromRemote",
|
|
1322
1253
|
value: (function () {
|
|
1323
|
-
var _upsertOrdersFromRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1254
|
+
var _upsertOrdersFromRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(freshOrders) {
|
|
1324
1255
|
var source,
|
|
1325
|
-
|
|
1326
|
-
return _regeneratorRuntime().wrap(function
|
|
1327
|
-
while (1) switch (
|
|
1256
|
+
_args10 = arguments;
|
|
1257
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1258
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1328
1259
|
case 0:
|
|
1329
|
-
source =
|
|
1260
|
+
source = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : 'upsertOrdersFromRemote';
|
|
1330
1261
|
if (freshOrders !== null && freshOrders !== void 0 && freshOrders.length) {
|
|
1331
|
-
|
|
1262
|
+
_context10.next = 4;
|
|
1332
1263
|
break;
|
|
1333
1264
|
}
|
|
1334
1265
|
this.logInfo('upsertOrdersFromRemote-订单列表为空', {});
|
|
1335
|
-
return
|
|
1266
|
+
return _context10.abrupt("return");
|
|
1336
1267
|
case 4:
|
|
1337
1268
|
this.logInfo('upsertOrdersFromRemote-开始', {
|
|
1338
1269
|
count: freshOrders.length,
|
|
1339
1270
|
source: source
|
|
1340
1271
|
});
|
|
1341
|
-
|
|
1272
|
+
_context10.next = 7;
|
|
1342
1273
|
return this.mergeOrdersToStore(freshOrders, source);
|
|
1343
1274
|
case 7:
|
|
1344
1275
|
case "end":
|
|
1345
|
-
return
|
|
1276
|
+
return _context10.stop();
|
|
1346
1277
|
}
|
|
1347
|
-
},
|
|
1278
|
+
}, _callee10, this);
|
|
1348
1279
|
}));
|
|
1349
|
-
function upsertOrdersFromRemote(
|
|
1280
|
+
function upsertOrdersFromRemote(_x7) {
|
|
1350
1281
|
return _upsertOrdersFromRemote.apply(this, arguments);
|
|
1351
1282
|
}
|
|
1352
1283
|
return upsertOrdersFromRemote;
|
|
@@ -1354,21 +1285,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1354
1285
|
}, {
|
|
1355
1286
|
key: "markOrderSyncedByExternalSaleNumber",
|
|
1356
1287
|
value: function () {
|
|
1357
|
-
var _markOrderSyncedByExternalSaleNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1288
|
+
var _markOrderSyncedByExternalSaleNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
|
|
1358
1289
|
var _this8 = this,
|
|
1359
1290
|
_existing$external_sa,
|
|
1360
1291
|
_nextOrder$order_id;
|
|
1361
1292
|
var externalSaleNumber, key, targetIndex, existing, nextOrder, storageKey;
|
|
1362
|
-
return _regeneratorRuntime().wrap(function
|
|
1363
|
-
while (1) switch (
|
|
1293
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
1294
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1364
1295
|
case 0:
|
|
1365
1296
|
externalSaleNumber = params.externalSaleNumber;
|
|
1366
1297
|
if (!(externalSaleNumber === undefined || externalSaleNumber === null || externalSaleNumber === '')) {
|
|
1367
|
-
|
|
1298
|
+
_context11.next = 4;
|
|
1368
1299
|
break;
|
|
1369
1300
|
}
|
|
1370
1301
|
this.logError('markOrderSyncedByExternalSaleNumber-缺少 external_sale_number');
|
|
1371
|
-
return
|
|
1302
|
+
return _context11.abrupt("return", {
|
|
1372
1303
|
updated: false
|
|
1373
1304
|
});
|
|
1374
1305
|
case 4:
|
|
@@ -1379,13 +1310,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1379
1310
|
return _this8.getIdKey(value) === key;
|
|
1380
1311
|
});
|
|
1381
1312
|
if (!(targetIndex < 0)) {
|
|
1382
|
-
|
|
1313
|
+
_context11.next = 9;
|
|
1383
1314
|
break;
|
|
1384
1315
|
}
|
|
1385
1316
|
this.logInfo('markOrderSyncedByExternalSaleNumber-本地订单不存在,跳过', {
|
|
1386
1317
|
external_sale_number: externalSaleNumber
|
|
1387
1318
|
});
|
|
1388
|
-
return
|
|
1319
|
+
return _context11.abrupt("return", {
|
|
1389
1320
|
updated: false
|
|
1390
1321
|
});
|
|
1391
1322
|
case 9:
|
|
@@ -1401,27 +1332,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1401
1332
|
return nextOrder;
|
|
1402
1333
|
});
|
|
1403
1334
|
this.syncOrdersMap();
|
|
1404
|
-
|
|
1335
|
+
_context11.next = 16;
|
|
1405
1336
|
return this.patchOrdersInSQLite([nextOrder], 'markOrderSyncedByExternalSaleNumber', _defineProperty({}, storageKey, 'update'));
|
|
1406
1337
|
case 16:
|
|
1407
1338
|
this.logInfo('markOrderSyncedByExternalSaleNumber-完成', {
|
|
1408
1339
|
external_sale_number: externalSaleNumber,
|
|
1409
1340
|
order_id: (_nextOrder$order_id = nextOrder.order_id) !== null && _nextOrder$order_id !== void 0 ? _nextOrder$order_id : null
|
|
1410
1341
|
});
|
|
1411
|
-
|
|
1342
|
+
_context11.next = 19;
|
|
1412
1343
|
return this.emitOrdersChanged([nextOrder], 'markOrderSyncedByExternalSaleNumber');
|
|
1413
1344
|
case 19:
|
|
1414
|
-
return
|
|
1345
|
+
return _context11.abrupt("return", {
|
|
1415
1346
|
updated: true,
|
|
1416
1347
|
order: nextOrder
|
|
1417
1348
|
});
|
|
1418
1349
|
case 20:
|
|
1419
1350
|
case "end":
|
|
1420
|
-
return
|
|
1351
|
+
return _context11.stop();
|
|
1421
1352
|
}
|
|
1422
|
-
},
|
|
1353
|
+
}, _callee11, this);
|
|
1423
1354
|
}));
|
|
1424
|
-
function markOrderSyncedByExternalSaleNumber(
|
|
1355
|
+
function markOrderSyncedByExternalSaleNumber(_x8) {
|
|
1425
1356
|
return _markOrderSyncedByExternalSaleNumber.apply(this, arguments);
|
|
1426
1357
|
}
|
|
1427
1358
|
return markOrderSyncedByExternalSaleNumber;
|
|
@@ -1433,13 +1364,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1433
1364
|
}, {
|
|
1434
1365
|
key: "upsertPendingSyncOrders",
|
|
1435
1366
|
value: (function () {
|
|
1436
|
-
var _upsertPendingSyncOrders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1367
|
+
var _upsertPendingSyncOrders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(pendingOrders) {
|
|
1437
1368
|
var _this9 = this;
|
|
1438
1369
|
var options,
|
|
1439
1370
|
pendingMap,
|
|
1440
1371
|
memoryPendingMap,
|
|
1441
|
-
|
|
1442
|
-
|
|
1372
|
+
_iterator5,
|
|
1373
|
+
_step5,
|
|
1443
1374
|
order,
|
|
1444
1375
|
normalizedOrder,
|
|
1445
1376
|
pendingOrder,
|
|
@@ -1448,12 +1379,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1448
1379
|
updatedList,
|
|
1449
1380
|
identityKeyToIndex,
|
|
1450
1381
|
index,
|
|
1382
|
+
_iterator6,
|
|
1383
|
+
_step6,
|
|
1384
|
+
key,
|
|
1451
1385
|
_iterator7,
|
|
1452
1386
|
_step7,
|
|
1453
|
-
|
|
1454
|
-
_iterator8,
|
|
1455
|
-
_step8,
|
|
1456
|
-
_step8$value,
|
|
1387
|
+
_step7$value,
|
|
1457
1388
|
_storageKey,
|
|
1458
1389
|
_pendingOrder,
|
|
1459
1390
|
matchIndex,
|
|
@@ -1464,29 +1395,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1464
1395
|
insertIndex,
|
|
1465
1396
|
patchedOrders,
|
|
1466
1397
|
previousList,
|
|
1467
|
-
|
|
1468
|
-
return _regeneratorRuntime().wrap(function
|
|
1469
|
-
while (1) switch (
|
|
1398
|
+
_args12 = arguments;
|
|
1399
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1400
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1470
1401
|
case 0:
|
|
1471
|
-
options =
|
|
1402
|
+
options = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : {};
|
|
1472
1403
|
if (pendingOrders !== null && pendingOrders !== void 0 && pendingOrders.length) {
|
|
1473
|
-
|
|
1404
|
+
_context12.next = 4;
|
|
1474
1405
|
break;
|
|
1475
1406
|
}
|
|
1476
1407
|
this.logInfo('upsertPendingSyncOrders-订单列表为空', {});
|
|
1477
|
-
return
|
|
1408
|
+
return _context12.abrupt("return");
|
|
1478
1409
|
case 4:
|
|
1479
1410
|
pendingMap = new Map();
|
|
1480
1411
|
memoryPendingMap = new Map();
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1412
|
+
_iterator5 = _createForOfIteratorHelper(pendingOrders);
|
|
1413
|
+
_context12.prev = 7;
|
|
1414
|
+
_iterator5.s();
|
|
1484
1415
|
case 9:
|
|
1485
|
-
if ((
|
|
1486
|
-
|
|
1416
|
+
if ((_step5 = _iterator5.n()).done) {
|
|
1417
|
+
_context12.next = 20;
|
|
1487
1418
|
break;
|
|
1488
1419
|
}
|
|
1489
|
-
order =
|
|
1420
|
+
order = _step5.value;
|
|
1490
1421
|
normalizedOrder = this.normalizeOrderCollectionsForIngress(order, 'upsertPendingSyncOrders.incoming');
|
|
1491
1422
|
pendingOrder = _objectSpread(_objectSpread({}, normalizedOrder), {}, {
|
|
1492
1423
|
need_sync: 1,
|
|
@@ -1494,36 +1425,36 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1494
1425
|
});
|
|
1495
1426
|
storageKey = this.getOrderStorageKey(pendingOrder);
|
|
1496
1427
|
if (storageKey) {
|
|
1497
|
-
|
|
1428
|
+
_context12.next = 16;
|
|
1498
1429
|
break;
|
|
1499
1430
|
}
|
|
1500
|
-
return
|
|
1431
|
+
return _context12.abrupt("continue", 18);
|
|
1501
1432
|
case 16:
|
|
1502
1433
|
pendingMap.set(storageKey, pendingOrder);
|
|
1503
1434
|
memoryPendingMap.set(storageKey, this.normalizeOrderForMemoryList(pendingOrder, 'upsertPendingSyncOrders.memory'));
|
|
1504
1435
|
case 18:
|
|
1505
|
-
|
|
1436
|
+
_context12.next = 9;
|
|
1506
1437
|
break;
|
|
1507
1438
|
case 20:
|
|
1508
|
-
|
|
1439
|
+
_context12.next = 25;
|
|
1509
1440
|
break;
|
|
1510
1441
|
case 22:
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1442
|
+
_context12.prev = 22;
|
|
1443
|
+
_context12.t0 = _context12["catch"](7);
|
|
1444
|
+
_iterator5.e(_context12.t0);
|
|
1514
1445
|
case 25:
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
return
|
|
1446
|
+
_context12.prev = 25;
|
|
1447
|
+
_iterator5.f();
|
|
1448
|
+
return _context12.finish(25);
|
|
1518
1449
|
case 28:
|
|
1519
1450
|
if (!(pendingMap.size === 0)) {
|
|
1520
|
-
|
|
1451
|
+
_context12.next = 31;
|
|
1521
1452
|
break;
|
|
1522
1453
|
}
|
|
1523
1454
|
this.logError('upsertPendingSyncOrders-订单缺少可落库标识', {
|
|
1524
1455
|
count: pendingOrders.length
|
|
1525
1456
|
});
|
|
1526
|
-
return
|
|
1457
|
+
return _context12.abrupt("return");
|
|
1527
1458
|
case 31:
|
|
1528
1459
|
this.logInfo('upsertPendingSyncOrders-开始', {
|
|
1529
1460
|
count: pendingMap.size
|
|
@@ -1535,31 +1466,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1535
1466
|
// 从 O(n) 线性扫描降为 O(1),整体复杂度由 O(n^2) 降为 O(n + m)。
|
|
1536
1467
|
identityKeyToIndex = new Map();
|
|
1537
1468
|
for (index = 0; index < updatedList.length; index += 1) {
|
|
1538
|
-
|
|
1469
|
+
_iterator6 = _createForOfIteratorHelper(this.getOrderIdentityMatchKeys(updatedList[index]));
|
|
1539
1470
|
try {
|
|
1540
|
-
for (
|
|
1541
|
-
key =
|
|
1471
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
1472
|
+
key = _step6.value;
|
|
1542
1473
|
// 同一 key 命中多张时保留最靠前的下标,与原 findIndex「取首个匹配」一致
|
|
1543
1474
|
if (!identityKeyToIndex.has(key)) identityKeyToIndex.set(key, index);
|
|
1544
1475
|
}
|
|
1545
1476
|
} catch (err) {
|
|
1546
|
-
|
|
1477
|
+
_iterator6.e(err);
|
|
1547
1478
|
} finally {
|
|
1548
|
-
|
|
1479
|
+
_iterator6.f();
|
|
1549
1480
|
}
|
|
1550
1481
|
}
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1482
|
+
_iterator7 = _createForOfIteratorHelper(memoryPendingMap.entries());
|
|
1483
|
+
_context12.prev = 37;
|
|
1484
|
+
_iterator7.s();
|
|
1554
1485
|
case 39:
|
|
1555
|
-
if ((
|
|
1556
|
-
|
|
1486
|
+
if ((_step7 = _iterator7.n()).done) {
|
|
1487
|
+
_context12.next = 58;
|
|
1557
1488
|
break;
|
|
1558
1489
|
}
|
|
1559
|
-
|
|
1490
|
+
_step7$value = _slicedToArray(_step7.value, 2), _storageKey = _step7$value[0], _pendingOrder = _step7$value[1];
|
|
1560
1491
|
matchIndex = this.lookupOrderIndexByIdentityKeys(identityKeyToIndex, this.getOrderIdentityMatchKeys(_pendingOrder));
|
|
1561
1492
|
if (!(matchIndex >= 0)) {
|
|
1562
|
-
|
|
1493
|
+
_context12.next = 52;
|
|
1563
1494
|
break;
|
|
1564
1495
|
}
|
|
1565
1496
|
existingOrder = updatedList[matchIndex];
|
|
@@ -1576,57 +1507,57 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1576
1507
|
// 合并后身份字段可能新增(如挂单拿到 order_id),同步登记,供同批后续 pending 命中同一槽位
|
|
1577
1508
|
this.registerOrderIdentityKeys(identityKeyToIndex, nextOrder, matchIndex);
|
|
1578
1509
|
mergeActions[_storageKey] = 'update';
|
|
1579
|
-
return
|
|
1510
|
+
return _context12.abrupt("continue", 56);
|
|
1580
1511
|
case 52:
|
|
1581
1512
|
insertIndex = updatedList.length;
|
|
1582
1513
|
updatedList.push(_pendingOrder);
|
|
1583
1514
|
this.registerOrderIdentityKeys(identityKeyToIndex, _pendingOrder, insertIndex);
|
|
1584
1515
|
mergeActions[_storageKey] = 'insert';
|
|
1585
1516
|
case 56:
|
|
1586
|
-
|
|
1517
|
+
_context12.next = 39;
|
|
1587
1518
|
break;
|
|
1588
1519
|
case 58:
|
|
1589
|
-
|
|
1520
|
+
_context12.next = 63;
|
|
1590
1521
|
break;
|
|
1591
1522
|
case 60:
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1523
|
+
_context12.prev = 60;
|
|
1524
|
+
_context12.t1 = _context12["catch"](37);
|
|
1525
|
+
_iterator7.e(_context12.t1);
|
|
1595
1526
|
case 63:
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
return
|
|
1527
|
+
_context12.prev = 63;
|
|
1528
|
+
_iterator7.f();
|
|
1529
|
+
return _context12.finish(63);
|
|
1599
1530
|
case 66:
|
|
1600
1531
|
patchedOrders = _toConsumableArray(pendingMap.values()); // 增量索引已保证 store 去重不变量,无需再对全表做 O(n^2) 压缩;仅自检开关开启时兜底。
|
|
1601
1532
|
previousList = this.store.list;
|
|
1602
1533
|
this.store.list = this.runOrderStoreSelfCheck(updatedList, 'upsertPendingSyncOrders.store');
|
|
1603
1534
|
this.syncOrdersMap();
|
|
1604
|
-
|
|
1605
|
-
|
|
1535
|
+
_context12.prev = 70;
|
|
1536
|
+
_context12.next = 73;
|
|
1606
1537
|
return this.patchOrdersInSQLite(patchedOrders, 'upsertPendingSyncOrders', mergeActions, options);
|
|
1607
1538
|
case 73:
|
|
1608
|
-
|
|
1539
|
+
_context12.next = 80;
|
|
1609
1540
|
break;
|
|
1610
1541
|
case 75:
|
|
1611
|
-
|
|
1612
|
-
|
|
1542
|
+
_context12.prev = 75;
|
|
1543
|
+
_context12.t2 = _context12["catch"](70);
|
|
1613
1544
|
this.store.list = previousList;
|
|
1614
1545
|
this.syncOrdersMap();
|
|
1615
|
-
throw
|
|
1546
|
+
throw _context12.t2;
|
|
1616
1547
|
case 80:
|
|
1617
1548
|
this.logInfo('upsertPendingSyncOrders-结束', {
|
|
1618
1549
|
count: patchedOrders.length,
|
|
1619
1550
|
storeOrderCountAfter: this.store.list.length
|
|
1620
1551
|
});
|
|
1621
|
-
|
|
1552
|
+
_context12.next = 83;
|
|
1622
1553
|
return this.emitOrdersChanged(patchedOrders, 'upsertPendingSyncOrders');
|
|
1623
1554
|
case 83:
|
|
1624
1555
|
case "end":
|
|
1625
|
-
return
|
|
1556
|
+
return _context12.stop();
|
|
1626
1557
|
}
|
|
1627
|
-
},
|
|
1558
|
+
}, _callee12, this, [[7, 22, 25, 28], [37, 60, 63, 66], [70, 75]]);
|
|
1628
1559
|
}));
|
|
1629
|
-
function upsertPendingSyncOrders(
|
|
1560
|
+
function upsertPendingSyncOrders(_x9) {
|
|
1630
1561
|
return _upsertPendingSyncOrders.apply(this, arguments);
|
|
1631
1562
|
}
|
|
1632
1563
|
return upsertPendingSyncOrders;
|
|
@@ -1639,40 +1570,40 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1639
1570
|
}, {
|
|
1640
1571
|
key: "upsertLocalDraftOrders",
|
|
1641
1572
|
value: (function () {
|
|
1642
|
-
var _upsertLocalDraftOrders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1573
|
+
var _upsertLocalDraftOrders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(draftOrders) {
|
|
1643
1574
|
var _this10 = this;
|
|
1644
|
-
var draftMap, memoryDraftMap,
|
|
1645
|
-
return _regeneratorRuntime().wrap(function
|
|
1646
|
-
while (1) switch (
|
|
1575
|
+
var draftMap, memoryDraftMap, _iterator8, _step8, order, draftOrder, storageKey, memoryDraftOrder, mergeActions, updatedList, identityKeyToIndex, index, _iterator9, _step9, key, _iterator10, _step10, _step10$value, _storageKey2, _draftOrder, matchIndex, existingOrder, reconciledDraftOrder, mergedOrder, nextOrder, insertIndex, patchedOrders, previousList, removedLegacyMemoryDraft;
|
|
1576
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1577
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1647
1578
|
case 0:
|
|
1648
1579
|
if (draftOrders !== null && draftOrders !== void 0 && draftOrders.length) {
|
|
1649
|
-
|
|
1580
|
+
_context13.next = 3;
|
|
1650
1581
|
break;
|
|
1651
1582
|
}
|
|
1652
1583
|
this.logInfo('upsertLocalDraftOrders-订单列表为空', {});
|
|
1653
|
-
return
|
|
1584
|
+
return _context13.abrupt("return");
|
|
1654
1585
|
case 3:
|
|
1655
1586
|
draftMap = new Map();
|
|
1656
1587
|
memoryDraftMap = new Map();
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1588
|
+
_iterator8 = _createForOfIteratorHelper(draftOrders);
|
|
1589
|
+
_context13.prev = 6;
|
|
1590
|
+
_iterator8.s();
|
|
1660
1591
|
case 8:
|
|
1661
|
-
if ((
|
|
1662
|
-
|
|
1592
|
+
if ((_step8 = _iterator8.n()).done) {
|
|
1593
|
+
_context13.next = 19;
|
|
1663
1594
|
break;
|
|
1664
1595
|
}
|
|
1665
|
-
order =
|
|
1596
|
+
order = _step8.value;
|
|
1666
1597
|
draftOrder = _objectSpread(_objectSpread({}, order), {}, {
|
|
1667
1598
|
need_sync: 0,
|
|
1668
1599
|
is_draft_order: 1
|
|
1669
1600
|
});
|
|
1670
1601
|
storageKey = this.getOrderStorageKey(draftOrder);
|
|
1671
1602
|
if (storageKey) {
|
|
1672
|
-
|
|
1603
|
+
_context13.next = 14;
|
|
1673
1604
|
break;
|
|
1674
1605
|
}
|
|
1675
|
-
return
|
|
1606
|
+
return _context13.abrupt("continue", 17);
|
|
1676
1607
|
case 14:
|
|
1677
1608
|
draftMap.set(storageKey, draftOrder);
|
|
1678
1609
|
memoryDraftOrder = this.normalizeOrderForMemoryList(draftOrder);
|
|
@@ -1680,28 +1611,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1680
1611
|
memoryDraftMap.set(storageKey, memoryDraftOrder);
|
|
1681
1612
|
}
|
|
1682
1613
|
case 17:
|
|
1683
|
-
|
|
1614
|
+
_context13.next = 8;
|
|
1684
1615
|
break;
|
|
1685
1616
|
case 19:
|
|
1686
|
-
|
|
1617
|
+
_context13.next = 24;
|
|
1687
1618
|
break;
|
|
1688
1619
|
case 21:
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1620
|
+
_context13.prev = 21;
|
|
1621
|
+
_context13.t0 = _context13["catch"](6);
|
|
1622
|
+
_iterator8.e(_context13.t0);
|
|
1692
1623
|
case 24:
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
return
|
|
1624
|
+
_context13.prev = 24;
|
|
1625
|
+
_iterator8.f();
|
|
1626
|
+
return _context13.finish(24);
|
|
1696
1627
|
case 27:
|
|
1697
1628
|
if (!(draftMap.size === 0)) {
|
|
1698
|
-
|
|
1629
|
+
_context13.next = 30;
|
|
1699
1630
|
break;
|
|
1700
1631
|
}
|
|
1701
1632
|
this.logError('upsertLocalDraftOrders-订单缺少可落库标识', {
|
|
1702
1633
|
count: draftOrders.length
|
|
1703
1634
|
});
|
|
1704
|
-
return
|
|
1635
|
+
return _context13.abrupt("return");
|
|
1705
1636
|
case 30:
|
|
1706
1637
|
this.logInfo('upsertLocalDraftOrders-开始', {
|
|
1707
1638
|
count: draftMap.size,
|
|
@@ -1714,30 +1645,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1714
1645
|
});
|
|
1715
1646
|
identityKeyToIndex = new Map();
|
|
1716
1647
|
for (index = 0; index < updatedList.length; index += 1) {
|
|
1717
|
-
|
|
1648
|
+
_iterator9 = _createForOfIteratorHelper(this.getOrderIdentityMatchKeys(updatedList[index]));
|
|
1718
1649
|
try {
|
|
1719
|
-
for (
|
|
1720
|
-
key =
|
|
1650
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
1651
|
+
key = _step9.value;
|
|
1721
1652
|
if (!identityKeyToIndex.has(key)) identityKeyToIndex.set(key, index);
|
|
1722
1653
|
}
|
|
1723
1654
|
} catch (err) {
|
|
1724
|
-
|
|
1655
|
+
_iterator9.e(err);
|
|
1725
1656
|
} finally {
|
|
1726
|
-
|
|
1657
|
+
_iterator9.f();
|
|
1727
1658
|
}
|
|
1728
1659
|
}
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1660
|
+
_iterator10 = _createForOfIteratorHelper(memoryDraftMap.entries());
|
|
1661
|
+
_context13.prev = 36;
|
|
1662
|
+
_iterator10.s();
|
|
1732
1663
|
case 38:
|
|
1733
|
-
if ((
|
|
1734
|
-
|
|
1664
|
+
if ((_step10 = _iterator10.n()).done) {
|
|
1665
|
+
_context13.next = 57;
|
|
1735
1666
|
break;
|
|
1736
1667
|
}
|
|
1737
|
-
|
|
1668
|
+
_step10$value = _slicedToArray(_step10.value, 2), _storageKey2 = _step10$value[0], _draftOrder = _step10$value[1];
|
|
1738
1669
|
matchIndex = this.lookupOrderIndexByIdentityKeys(identityKeyToIndex, this.getOrderIdentityMatchKeys(_draftOrder));
|
|
1739
1670
|
if (!(matchIndex >= 0)) {
|
|
1740
|
-
|
|
1671
|
+
_context13.next = 51;
|
|
1741
1672
|
break;
|
|
1742
1673
|
}
|
|
1743
1674
|
existingOrder = updatedList[matchIndex];
|
|
@@ -1752,45 +1683,45 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1752
1683
|
draftMap.set(_storageKey2, reconciledDraftOrder);
|
|
1753
1684
|
this.registerOrderIdentityKeys(identityKeyToIndex, nextOrder, matchIndex);
|
|
1754
1685
|
mergeActions[_storageKey2] = 'update';
|
|
1755
|
-
return
|
|
1686
|
+
return _context13.abrupt("continue", 55);
|
|
1756
1687
|
case 51:
|
|
1757
1688
|
insertIndex = updatedList.length;
|
|
1758
1689
|
updatedList.push(_draftOrder);
|
|
1759
1690
|
this.registerOrderIdentityKeys(identityKeyToIndex, _draftOrder, insertIndex);
|
|
1760
1691
|
mergeActions[_storageKey2] = 'insert';
|
|
1761
1692
|
case 55:
|
|
1762
|
-
|
|
1693
|
+
_context13.next = 38;
|
|
1763
1694
|
break;
|
|
1764
1695
|
case 57:
|
|
1765
|
-
|
|
1696
|
+
_context13.next = 62;
|
|
1766
1697
|
break;
|
|
1767
1698
|
case 59:
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1699
|
+
_context13.prev = 59;
|
|
1700
|
+
_context13.t1 = _context13["catch"](36);
|
|
1701
|
+
_iterator10.e(_context13.t1);
|
|
1771
1702
|
case 62:
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
return
|
|
1703
|
+
_context13.prev = 62;
|
|
1704
|
+
_iterator10.f();
|
|
1705
|
+
return _context13.finish(62);
|
|
1775
1706
|
case 65:
|
|
1776
1707
|
patchedOrders = _toConsumableArray(draftMap.values());
|
|
1777
1708
|
previousList = this.store.list;
|
|
1778
1709
|
this.store.list = this.runOrderStoreSelfCheck(updatedList, 'upsertLocalDraftOrders.store');
|
|
1779
1710
|
this.syncOrdersMap();
|
|
1780
|
-
|
|
1781
|
-
|
|
1711
|
+
_context13.prev = 69;
|
|
1712
|
+
_context13.next = 72;
|
|
1782
1713
|
return this.patchOrdersInSQLite(patchedOrders, 'upsertLocalDraftOrders', mergeActions, {
|
|
1783
1714
|
throwOnError: true
|
|
1784
1715
|
});
|
|
1785
1716
|
case 72:
|
|
1786
|
-
|
|
1717
|
+
_context13.next = 79;
|
|
1787
1718
|
break;
|
|
1788
1719
|
case 74:
|
|
1789
|
-
|
|
1790
|
-
|
|
1720
|
+
_context13.prev = 74;
|
|
1721
|
+
_context13.t2 = _context13["catch"](69);
|
|
1791
1722
|
this.store.list = previousList;
|
|
1792
1723
|
this.syncOrdersMap();
|
|
1793
|
-
throw
|
|
1724
|
+
throw _context13.t2;
|
|
1794
1725
|
case 79:
|
|
1795
1726
|
this.logInfo('upsertLocalDraftOrders-结束', {
|
|
1796
1727
|
count: patchedOrders.length,
|
|
@@ -1800,20 +1731,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1800
1731
|
return !_this10.shouldKeepOrderInMemory(order);
|
|
1801
1732
|
});
|
|
1802
1733
|
if (!(memoryDraftMap.size > 0 || removedLegacyMemoryDraft)) {
|
|
1803
|
-
|
|
1734
|
+
_context13.next = 84;
|
|
1804
1735
|
break;
|
|
1805
1736
|
}
|
|
1806
|
-
|
|
1737
|
+
_context13.next = 84;
|
|
1807
1738
|
return this.emitOrdersChanged(patchedOrders.filter(function (order) {
|
|
1808
1739
|
return _this10.shouldKeepOrderInMemory(order);
|
|
1809
1740
|
}), 'upsertLocalDraftOrders');
|
|
1810
1741
|
case 84:
|
|
1811
1742
|
case "end":
|
|
1812
|
-
return
|
|
1743
|
+
return _context13.stop();
|
|
1813
1744
|
}
|
|
1814
|
-
},
|
|
1745
|
+
}, _callee13, this, [[6, 21, 24, 27], [36, 59, 62, 65], [69, 74]]);
|
|
1815
1746
|
}));
|
|
1816
|
-
function upsertLocalDraftOrders(
|
|
1747
|
+
function upsertLocalDraftOrders(_x10) {
|
|
1817
1748
|
return _upsertLocalDraftOrders.apply(this, arguments);
|
|
1818
1749
|
}
|
|
1819
1750
|
return upsertLocalDraftOrders;
|
|
@@ -1825,42 +1756,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1825
1756
|
}, {
|
|
1826
1757
|
key: "fetchOrdersBySSE",
|
|
1827
1758
|
value: (function () {
|
|
1828
|
-
var _fetchOrdersBySSE = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1759
|
+
var _fetchOrdersBySSE = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
1829
1760
|
var query,
|
|
1830
1761
|
data,
|
|
1831
|
-
|
|
1832
|
-
return _regeneratorRuntime().wrap(function
|
|
1833
|
-
while (1) switch (
|
|
1762
|
+
_args14 = arguments;
|
|
1763
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1764
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1834
1765
|
case 0:
|
|
1835
|
-
query =
|
|
1766
|
+
query = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
|
|
1836
1767
|
if (this.orderDataSource) {
|
|
1837
|
-
|
|
1768
|
+
_context14.next = 3;
|
|
1838
1769
|
break;
|
|
1839
1770
|
}
|
|
1840
|
-
return
|
|
1771
|
+
return _context14.abrupt("return", []);
|
|
1841
1772
|
case 3:
|
|
1842
|
-
|
|
1843
|
-
|
|
1773
|
+
_context14.prev = 3;
|
|
1774
|
+
_context14.next = 6;
|
|
1844
1775
|
return this.orderDataSource.run({
|
|
1845
1776
|
sse: {
|
|
1846
1777
|
query: query
|
|
1847
1778
|
}
|
|
1848
1779
|
});
|
|
1849
1780
|
case 6:
|
|
1850
|
-
data =
|
|
1851
|
-
return
|
|
1781
|
+
data = _context14.sent;
|
|
1782
|
+
return _context14.abrupt("return", data || []);
|
|
1852
1783
|
case 10:
|
|
1853
|
-
|
|
1854
|
-
|
|
1784
|
+
_context14.prev = 10;
|
|
1785
|
+
_context14.t0 = _context14["catch"](3);
|
|
1855
1786
|
this.logError('fetchOrdersBySSE-失败', {
|
|
1856
|
-
error:
|
|
1787
|
+
error: _context14.t0 instanceof Error ? _context14.t0.message : String(_context14.t0)
|
|
1857
1788
|
});
|
|
1858
|
-
return
|
|
1789
|
+
return _context14.abrupt("return", []);
|
|
1859
1790
|
case 14:
|
|
1860
1791
|
case "end":
|
|
1861
|
-
return
|
|
1792
|
+
return _context14.stop();
|
|
1862
1793
|
}
|
|
1863
|
-
},
|
|
1794
|
+
}, _callee14, this, [[3, 10]]);
|
|
1864
1795
|
}));
|
|
1865
1796
|
function fetchOrdersBySSE() {
|
|
1866
1797
|
return _fetchOrdersBySSE.apply(this, arguments);
|
|
@@ -1893,19 +1824,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1893
1824
|
return _this11.shouldKeepOrderInMemory(order);
|
|
1894
1825
|
});
|
|
1895
1826
|
this.store.map.clear();
|
|
1896
|
-
var
|
|
1897
|
-
|
|
1827
|
+
var _iterator11 = _createForOfIteratorHelper(this.store.list),
|
|
1828
|
+
_step11;
|
|
1898
1829
|
try {
|
|
1899
|
-
for (
|
|
1900
|
-
var order =
|
|
1830
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
1831
|
+
var order = _step11.value;
|
|
1901
1832
|
var primaryIdentity = this.getOrderMapKey(order);
|
|
1902
1833
|
if (!primaryIdentity) continue;
|
|
1903
1834
|
this.store.map.set(primaryIdentity, order);
|
|
1904
1835
|
}
|
|
1905
1836
|
} catch (err) {
|
|
1906
|
-
|
|
1837
|
+
_iterator11.e(err);
|
|
1907
1838
|
} finally {
|
|
1908
|
-
|
|
1839
|
+
_iterator11.f();
|
|
1909
1840
|
}
|
|
1910
1841
|
}
|
|
1911
1842
|
}, {
|
|
@@ -1986,17 +1917,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1986
1917
|
key: "getOrderIdentityKeys",
|
|
1987
1918
|
value: function getOrderIdentityKeys(order) {
|
|
1988
1919
|
var keys = [];
|
|
1989
|
-
var
|
|
1990
|
-
|
|
1920
|
+
var _iterator12 = _createForOfIteratorHelper(this.getOrderIdentityEntries(order)),
|
|
1921
|
+
_step12;
|
|
1991
1922
|
try {
|
|
1992
|
-
for (
|
|
1993
|
-
var entry =
|
|
1923
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
1924
|
+
var entry = _step12.value;
|
|
1994
1925
|
if (!keys.includes(entry.key)) keys.push(entry.key);
|
|
1995
1926
|
}
|
|
1996
1927
|
} catch (err) {
|
|
1997
|
-
|
|
1928
|
+
_iterator12.e(err);
|
|
1998
1929
|
} finally {
|
|
1999
|
-
|
|
1930
|
+
_iterator12.f();
|
|
2000
1931
|
}
|
|
2001
1932
|
return keys;
|
|
2002
1933
|
}
|
|
@@ -2096,41 +2027,41 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2096
2027
|
}, {
|
|
2097
2028
|
key: "flushOrderSyncMessagesByThrottle",
|
|
2098
2029
|
value: (function () {
|
|
2099
|
-
var _flushOrderSyncMessagesByThrottle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2100
|
-
return _regeneratorRuntime().wrap(function
|
|
2101
|
-
while (1) switch (
|
|
2030
|
+
var _flushOrderSyncMessagesByThrottle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
2031
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
2032
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
2102
2033
|
case 0:
|
|
2103
2034
|
if (!this.isProcessingSyncBatch) {
|
|
2104
|
-
|
|
2035
|
+
_context15.next = 2;
|
|
2105
2036
|
break;
|
|
2106
2037
|
}
|
|
2107
|
-
return
|
|
2038
|
+
return _context15.abrupt("return");
|
|
2108
2039
|
case 2:
|
|
2109
2040
|
if (!(this.pendingSyncMessages.length === 0)) {
|
|
2110
|
-
|
|
2041
|
+
_context15.next = 5;
|
|
2111
2042
|
break;
|
|
2112
2043
|
}
|
|
2113
2044
|
this.isIdlePhase = true;
|
|
2114
|
-
return
|
|
2045
|
+
return _context15.abrupt("return");
|
|
2115
2046
|
case 5:
|
|
2116
2047
|
this.isProcessingSyncBatch = true;
|
|
2117
|
-
|
|
2118
|
-
|
|
2048
|
+
_context15.prev = 6;
|
|
2049
|
+
_context15.next = 9;
|
|
2119
2050
|
return this.processOrderSyncMessages();
|
|
2120
2051
|
case 9:
|
|
2121
|
-
|
|
2052
|
+
_context15.prev = 9;
|
|
2122
2053
|
this.isProcessingSyncBatch = false;
|
|
2123
2054
|
if (this.pendingSyncMessages.length > 0) {
|
|
2124
2055
|
this.scheduleOrderSyncThrottle();
|
|
2125
2056
|
} else {
|
|
2126
2057
|
this.isIdlePhase = true;
|
|
2127
2058
|
}
|
|
2128
|
-
return
|
|
2059
|
+
return _context15.finish(9);
|
|
2129
2060
|
case 13:
|
|
2130
2061
|
case "end":
|
|
2131
|
-
return
|
|
2062
|
+
return _context15.stop();
|
|
2132
2063
|
}
|
|
2133
|
-
},
|
|
2064
|
+
}, _callee15, this, [[6,, 9, 13]]);
|
|
2134
2065
|
}));
|
|
2135
2066
|
function flushOrderSyncMessagesByThrottle() {
|
|
2136
2067
|
return _flushOrderSyncMessagesByThrottle.apply(this, arguments);
|
|
@@ -2152,19 +2083,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2152
2083
|
}, {
|
|
2153
2084
|
key: "processOrderSyncMessages",
|
|
2154
2085
|
value: (function () {
|
|
2155
|
-
var _processOrderSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2086
|
+
var _processOrderSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
2156
2087
|
var _this15 = this;
|
|
2157
2088
|
var messages, batchProcessStartAt, earliestReceivedAt, upsertOrders, refreshIds, uniqueRefreshIds, upsertList, _this$filterRedundant, toFetch, skipped, freshOrders, batchProcessEndAt;
|
|
2158
|
-
return _regeneratorRuntime().wrap(function
|
|
2159
|
-
while (1) switch (
|
|
2089
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
2090
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
2160
2091
|
case 0:
|
|
2161
2092
|
messages = _toConsumableArray(this.pendingSyncMessages);
|
|
2162
2093
|
this.pendingSyncMessages = [];
|
|
2163
2094
|
if (!(messages.length === 0)) {
|
|
2164
|
-
|
|
2095
|
+
_context16.next = 4;
|
|
2165
2096
|
break;
|
|
2166
2097
|
}
|
|
2167
|
-
return
|
|
2098
|
+
return _context16.abrupt("return");
|
|
2168
2099
|
case 4:
|
|
2169
2100
|
batchProcessStartAt = Date.now();
|
|
2170
2101
|
earliestReceivedAt = Math.min.apply(Math, _toConsumableArray(messages.map(function (m) {
|
|
@@ -2198,41 +2129,41 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2198
2129
|
refreshIdCount: uniqueRefreshIds.length
|
|
2199
2130
|
});
|
|
2200
2131
|
if (!(upsertList.length > 0)) {
|
|
2201
|
-
|
|
2132
|
+
_context16.next = 16;
|
|
2202
2133
|
break;
|
|
2203
2134
|
}
|
|
2204
|
-
|
|
2135
|
+
_context16.next = 16;
|
|
2205
2136
|
return this.mergeOrdersToStore(upsertList, 'pubsub.bodyUpsert');
|
|
2206
2137
|
case 16:
|
|
2207
2138
|
if (!(uniqueRefreshIds.length > 0)) {
|
|
2208
|
-
|
|
2139
|
+
_context16.next = 28;
|
|
2209
2140
|
break;
|
|
2210
2141
|
}
|
|
2211
2142
|
_this$filterRedundant = this.filterRedundantHttpRefreshIds(uniqueRefreshIds), toFetch = _this$filterRedundant.toFetch, skipped = _this$filterRedundant.skipped;
|
|
2212
2143
|
if (skipped.length > 0) {}
|
|
2213
2144
|
if (!(toFetch.length > 0)) {
|
|
2214
|
-
|
|
2145
|
+
_context16.next = 28;
|
|
2215
2146
|
break;
|
|
2216
2147
|
}
|
|
2217
|
-
|
|
2148
|
+
_context16.next = 22;
|
|
2218
2149
|
return this.fetchOrdersByHttp(toFetch);
|
|
2219
2150
|
case 22:
|
|
2220
|
-
freshOrders =
|
|
2151
|
+
freshOrders = _context16.sent;
|
|
2221
2152
|
if (!(freshOrders.length > 0)) {
|
|
2222
|
-
|
|
2153
|
+
_context16.next = 28;
|
|
2223
2154
|
break;
|
|
2224
2155
|
}
|
|
2225
|
-
|
|
2156
|
+
_context16.next = 26;
|
|
2226
2157
|
return this.mergeOrdersToStore(freshOrders, 'pubsub.httpRefresh');
|
|
2227
2158
|
case 26:
|
|
2228
|
-
|
|
2159
|
+
_context16.next = 28;
|
|
2229
2160
|
break;
|
|
2230
2161
|
case 28:
|
|
2231
2162
|
if (!(upsertList.length === 0 && uniqueRefreshIds.length === 0)) {
|
|
2232
|
-
|
|
2163
|
+
_context16.next = 30;
|
|
2233
2164
|
break;
|
|
2234
2165
|
}
|
|
2235
|
-
return
|
|
2166
|
+
return _context16.abrupt("return");
|
|
2236
2167
|
case 30:
|
|
2237
2168
|
batchProcessEndAt = Date.now();
|
|
2238
2169
|
this.logInfo('processOrderSyncMessages-结束', {
|
|
@@ -2241,13 +2172,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2241
2172
|
batchProcessDurationMs: batchProcessEndAt - batchProcessStartAt,
|
|
2242
2173
|
totalFromPubsubToProcessedMs: batchProcessEndAt - earliestReceivedAt
|
|
2243
2174
|
});
|
|
2244
|
-
|
|
2175
|
+
_context16.next = 34;
|
|
2245
2176
|
return this.core.effects.emit(OrderHooks.onOrdersSyncCompleted, null);
|
|
2246
2177
|
case 34:
|
|
2247
2178
|
case "end":
|
|
2248
|
-
return
|
|
2179
|
+
return _context16.stop();
|
|
2249
2180
|
}
|
|
2250
|
-
},
|
|
2181
|
+
}, _callee16, this);
|
|
2251
2182
|
}));
|
|
2252
2183
|
function processOrderSyncMessages() {
|
|
2253
2184
|
return _processOrderSyncMessages.apply(this, arguments);
|
|
@@ -2268,29 +2199,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2268
2199
|
}, {
|
|
2269
2200
|
key: "fetchOrdersByHttp",
|
|
2270
2201
|
value: (function () {
|
|
2271
|
-
var _fetchOrdersByHttp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2202
|
+
var _fetchOrdersByHttp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(ids) {
|
|
2272
2203
|
var _orderList, orderList;
|
|
2273
|
-
return _regeneratorRuntime().wrap(function
|
|
2274
|
-
while (1) switch (
|
|
2204
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
2205
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
2275
2206
|
case 0:
|
|
2276
2207
|
if (!(!this.orderDataSource || ids.length === 0)) {
|
|
2277
|
-
|
|
2208
|
+
_context17.next = 2;
|
|
2278
2209
|
break;
|
|
2279
2210
|
}
|
|
2280
|
-
return
|
|
2211
|
+
return _context17.abrupt("return", []);
|
|
2281
2212
|
case 2:
|
|
2282
|
-
|
|
2213
|
+
_context17.prev = 2;
|
|
2283
2214
|
if (!(typeof this.orderDataSource.fetchOrdersByIds === 'function')) {
|
|
2284
|
-
|
|
2215
|
+
_context17.next = 8;
|
|
2285
2216
|
break;
|
|
2286
2217
|
}
|
|
2287
|
-
|
|
2218
|
+
_context17.next = 6;
|
|
2288
2219
|
return this.orderDataSource.fetchOrdersByIds(ids);
|
|
2289
2220
|
case 6:
|
|
2290
|
-
_orderList =
|
|
2291
|
-
return
|
|
2221
|
+
_orderList = _context17.sent;
|
|
2222
|
+
return _context17.abrupt("return", _orderList || []);
|
|
2292
2223
|
case 8:
|
|
2293
|
-
|
|
2224
|
+
_context17.next = 10;
|
|
2294
2225
|
return this.orderDataSource.run({
|
|
2295
2226
|
http: {
|
|
2296
2227
|
query: {
|
|
@@ -2299,19 +2230,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2299
2230
|
}
|
|
2300
2231
|
});
|
|
2301
2232
|
case 10:
|
|
2302
|
-
orderList =
|
|
2303
|
-
return
|
|
2233
|
+
orderList = _context17.sent;
|
|
2234
|
+
return _context17.abrupt("return", orderList || []);
|
|
2304
2235
|
case 14:
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
return
|
|
2236
|
+
_context17.prev = 14;
|
|
2237
|
+
_context17.t0 = _context17["catch"](2);
|
|
2238
|
+
return _context17.abrupt("return", []);
|
|
2308
2239
|
case 17:
|
|
2309
2240
|
case "end":
|
|
2310
|
-
return
|
|
2241
|
+
return _context17.stop();
|
|
2311
2242
|
}
|
|
2312
|
-
},
|
|
2243
|
+
}, _callee17, this, [[2, 14]]);
|
|
2313
2244
|
}));
|
|
2314
|
-
function fetchOrdersByHttp(
|
|
2245
|
+
function fetchOrdersByHttp(_x11) {
|
|
2315
2246
|
return _fetchOrdersByHttp.apply(this, arguments);
|
|
2316
2247
|
}
|
|
2317
2248
|
return fetchOrdersByHttp;
|
|
@@ -2323,11 +2254,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2323
2254
|
}, {
|
|
2324
2255
|
key: "mergeOrdersToStore",
|
|
2325
2256
|
value: (function () {
|
|
2326
|
-
var _mergeOrdersToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2257
|
+
var _mergeOrdersToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(freshOrders, source) {
|
|
2327
2258
|
var _this16 = this;
|
|
2328
|
-
var storeOrderCountBefore, normalizedFreshOrders,
|
|
2329
|
-
return _regeneratorRuntime().wrap(function
|
|
2330
|
-
while (1) switch (
|
|
2259
|
+
var storeOrderCountBefore, normalizedFreshOrders, _iterator13, _step13, order, id, uniqueFreshOrders, uniqueFreshCount, patchedOrders, mergeActions, updatedList, identityKeyToIndex, index, identityKeys, _iterator14, _step14, key, _iterator15, _step15, fresh, freshIdentityKeys, matchIndex, storageKey, mergeKey, existingOrder, _ref, _existingOrder$order_, _ref2, _external_sale_number2, _existingOrder$paymen, _fresh$payment_status, _existingOrder$need_s, _fresh$need_sync, _ref3, _existingOrder$order_2, _ref4, _external_sale_number3, _existingOrder$is_dra, _fresh$is_draft_order, mergedOrder, adjustedMatchIndex, duplicateIndexes, _iterator16, _step16, _key2, _duplicateIndex, _iterator17, _step17, duplicateIndex, _index, _iterator18, _step18, _key, insertIndex, insertCount, updateCount;
|
|
2260
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
2261
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
2331
2262
|
case 0:
|
|
2332
2263
|
storeOrderCountBefore = this.store.list.length;
|
|
2333
2264
|
this.logInfo('mergeOrdersToStore-开始', {
|
|
@@ -2337,55 +2268,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2337
2268
|
});
|
|
2338
2269
|
this.logDuplicateOrders("".concat(source, ".beforeMerge"), this.store.list);
|
|
2339
2270
|
normalizedFreshOrders = [];
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
_context19.next = 18;
|
|
2271
|
+
_iterator13 = _createForOfIteratorHelper(freshOrders);
|
|
2272
|
+
_context18.prev = 5;
|
|
2273
|
+
_iterator13.s();
|
|
2274
|
+
case 7:
|
|
2275
|
+
if ((_step13 = _iterator13.n()).done) {
|
|
2276
|
+
_context18.next = 15;
|
|
2347
2277
|
break;
|
|
2348
2278
|
}
|
|
2349
|
-
order =
|
|
2279
|
+
order = _step13.value;
|
|
2350
2280
|
id = order === null || order === void 0 ? void 0 : order.order_id;
|
|
2351
2281
|
if (!(id === undefined || id === null)) {
|
|
2352
|
-
|
|
2282
|
+
_context18.next = 12;
|
|
2353
2283
|
break;
|
|
2354
2284
|
}
|
|
2355
|
-
return
|
|
2356
|
-
case
|
|
2357
|
-
rawProducts = order.products;
|
|
2358
|
-
if (Array.isArray(rawProducts)) {
|
|
2359
|
-
allProductsHaveStableIdentity = this.doProductsHaveStableMembershipIdentity(rawProducts);
|
|
2360
|
-
orderIdKey = this.getIdKey(id);
|
|
2361
|
-
incomingProductsHaveStableIdentity.set(orderIdKey, ((_incomingProductsHave = incomingProductsHaveStableIdentity.get(orderIdKey)) !== null && _incomingProductsHave !== void 0 ? _incomingProductsHave : true) && allProductsHaveStableIdentity);
|
|
2362
|
-
}
|
|
2285
|
+
return _context18.abrupt("continue", 13);
|
|
2286
|
+
case 12:
|
|
2363
2287
|
normalizedFreshOrders.push(this.normalizeRemoteSyncedOrder(order));
|
|
2364
|
-
case
|
|
2365
|
-
|
|
2288
|
+
case 13:
|
|
2289
|
+
_context18.next = 7;
|
|
2366
2290
|
break;
|
|
2367
|
-
case
|
|
2368
|
-
|
|
2291
|
+
case 15:
|
|
2292
|
+
_context18.next = 20;
|
|
2369
2293
|
break;
|
|
2294
|
+
case 17:
|
|
2295
|
+
_context18.prev = 17;
|
|
2296
|
+
_context18.t0 = _context18["catch"](5);
|
|
2297
|
+
_iterator13.e(_context18.t0);
|
|
2370
2298
|
case 20:
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2299
|
+
_context18.prev = 20;
|
|
2300
|
+
_iterator13.f();
|
|
2301
|
+
return _context18.finish(20);
|
|
2374
2302
|
case 23:
|
|
2375
|
-
_context19.prev = 23;
|
|
2376
|
-
_iterator14.f();
|
|
2377
|
-
return _context19.finish(23);
|
|
2378
|
-
case 26:
|
|
2379
2303
|
// 先对本批新单做去重(批内规模 m 很小),保证每条 fresh 身份唯一
|
|
2380
2304
|
uniqueFreshOrders = this.compactOrderListByIdentity(normalizedFreshOrders, "".concat(source, ".incoming")).list;
|
|
2381
2305
|
uniqueFreshCount = uniqueFreshOrders.length;
|
|
2382
2306
|
patchedOrders = [];
|
|
2383
|
-
remoteProductMembershipChanges = [];
|
|
2384
|
-
forceWriteStorageKeys = new Set();
|
|
2385
2307
|
mergeActions = {};
|
|
2386
|
-
existingProductsHaveStableIdentity = this.store.list.map(function (order) {
|
|
2387
|
-
return _this16.doProductsHaveStableMembershipIdentity(order.products);
|
|
2388
|
-
});
|
|
2389
2308
|
updatedList = this.store.list.map(function (order) {
|
|
2390
2309
|
return _this16.normalizeOrderForMemoryList(order, "".concat(source, ".existingMemory"));
|
|
2391
2310
|
}); // 基于身份键(field:value)建立索引,把「查找已存在订单」从 O(n) 线性扫描降为 O(1),
|
|
@@ -2394,39 +2313,39 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2394
2313
|
identityKeyToIndex = new Map();
|
|
2395
2314
|
for (index = 0; index < updatedList.length; index += 1) {
|
|
2396
2315
|
identityKeys = this.getOrderIdentityMatchKeys(updatedList[index]);
|
|
2397
|
-
|
|
2316
|
+
_iterator14 = _createForOfIteratorHelper(identityKeys);
|
|
2398
2317
|
try {
|
|
2399
|
-
for (
|
|
2400
|
-
key =
|
|
2318
|
+
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
2319
|
+
key = _step14.value;
|
|
2401
2320
|
// 同一 key 命中多张时保留最靠前的下标,与原 findIndex「取首个匹配」一致
|
|
2402
2321
|
if (!identityKeyToIndex.has(key)) identityKeyToIndex.set(key, index);
|
|
2403
2322
|
}
|
|
2404
2323
|
} catch (err) {
|
|
2405
|
-
|
|
2324
|
+
_iterator14.e(err);
|
|
2406
2325
|
} finally {
|
|
2407
|
-
|
|
2326
|
+
_iterator14.f();
|
|
2408
2327
|
}
|
|
2409
2328
|
}
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
case
|
|
2414
|
-
if ((
|
|
2415
|
-
|
|
2329
|
+
_iterator15 = _createForOfIteratorHelper(uniqueFreshOrders);
|
|
2330
|
+
_context18.prev = 31;
|
|
2331
|
+
_iterator15.s();
|
|
2332
|
+
case 33:
|
|
2333
|
+
if ((_step15 = _iterator15.n()).done) {
|
|
2334
|
+
_context18.next = 82;
|
|
2416
2335
|
break;
|
|
2417
2336
|
}
|
|
2418
|
-
fresh =
|
|
2337
|
+
fresh = _step15.value;
|
|
2419
2338
|
freshIdentityKeys = this.getOrderIdentityMatchKeys(fresh);
|
|
2420
2339
|
matchIndex = this.lookupOrderIndexByIdentityKeys(identityKeyToIndex, freshIdentityKeys);
|
|
2421
2340
|
storageKey = this.getOrderStorageKey(fresh);
|
|
2422
2341
|
mergeKey = storageKey || (fresh.order_id !== undefined && fresh.order_id !== null ? this.getIdKey(fresh.order_id) : '');
|
|
2423
2342
|
if (!(matchIndex >= 0)) {
|
|
2424
|
-
|
|
2343
|
+
_context18.next = 75;
|
|
2425
2344
|
break;
|
|
2426
2345
|
}
|
|
2427
2346
|
existingOrder = updatedList[matchIndex];
|
|
2428
2347
|
if (!(this.isPendingSyncOrder(existingOrder) && this.isRemoteEchoMergeSource(source))) {
|
|
2429
|
-
|
|
2348
|
+
_context18.next = 44;
|
|
2430
2349
|
break;
|
|
2431
2350
|
}
|
|
2432
2351
|
this.logInfo('mergeOrdersToStore-跳过 pending 订单远端覆盖', {
|
|
@@ -2439,10 +2358,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2439
2358
|
remote_need_sync: (_fresh$need_sync = fresh.need_sync) !== null && _fresh$need_sync !== void 0 ? _fresh$need_sync : null,
|
|
2440
2359
|
reason: 'protect_pending_sync_order_from_remote_echo'
|
|
2441
2360
|
});
|
|
2442
|
-
return
|
|
2443
|
-
case
|
|
2361
|
+
return _context18.abrupt("continue", 80);
|
|
2362
|
+
case 44:
|
|
2444
2363
|
if (!(this.isDraftOrder(existingOrder) && this.shouldProtectDraftOrderFromIncoming(source))) {
|
|
2445
|
-
|
|
2364
|
+
_context18.next = 47;
|
|
2446
2365
|
break;
|
|
2447
2366
|
}
|
|
2448
2367
|
this.logInfo('mergeOrdersToStore-跳过 draft 订单远端覆盖', {
|
|
@@ -2453,118 +2372,102 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2453
2372
|
remote_is_draft_order: (_fresh$is_draft_order = fresh.is_draft_order) !== null && _fresh$is_draft_order !== void 0 ? _fresh$is_draft_order : null,
|
|
2454
2373
|
reason: 'protect_draft_order_from_remote_echo'
|
|
2455
2374
|
});
|
|
2456
|
-
return
|
|
2457
|
-
case
|
|
2375
|
+
return _context18.abrupt("continue", 80);
|
|
2376
|
+
case 47:
|
|
2458
2377
|
mergedOrder = this.mergeOrderRecords(existingOrder, fresh);
|
|
2459
|
-
freshOrderId = fresh.order_id;
|
|
2460
|
-
incomingProductsAreStable = freshOrderId !== undefined && freshOrderId !== null && incomingProductsHaveStableIdentity.get(this.getIdKey(freshOrderId)) !== false;
|
|
2461
|
-
membershipChange = null;
|
|
2462
|
-
if (Array.isArray(fresh.products) && freshOrderId !== undefined && freshOrderId !== null && existingProductsHaveStableIdentity[matchIndex] !== false && incomingProductsAreStable) {
|
|
2463
|
-
membershipChange = this.getRemoteProductMembershipChange(existingOrder, mergedOrder, source);
|
|
2464
|
-
}
|
|
2465
|
-
mergedProductsHaveStableIdentity = existingProductsHaveStableIdentity[matchIndex] !== false && incomingProductsAreStable;
|
|
2466
2378
|
adjustedMatchIndex = matchIndex;
|
|
2467
2379
|
duplicateIndexes = new Set();
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
case
|
|
2472
|
-
if ((
|
|
2473
|
-
|
|
2380
|
+
_iterator16 = _createForOfIteratorHelper(freshIdentityKeys);
|
|
2381
|
+
_context18.prev = 51;
|
|
2382
|
+
_iterator16.s();
|
|
2383
|
+
case 53:
|
|
2384
|
+
if ((_step16 = _iterator16.n()).done) {
|
|
2385
|
+
_context18.next = 61;
|
|
2474
2386
|
break;
|
|
2475
2387
|
}
|
|
2476
|
-
_key2 =
|
|
2388
|
+
_key2 = _step16.value;
|
|
2477
2389
|
_duplicateIndex = identityKeyToIndex.get(_key2);
|
|
2478
2390
|
if (!(_duplicateIndex === undefined || _duplicateIndex === matchIndex)) {
|
|
2479
|
-
|
|
2391
|
+
_context18.next = 58;
|
|
2480
2392
|
break;
|
|
2481
2393
|
}
|
|
2482
|
-
return
|
|
2483
|
-
case
|
|
2394
|
+
return _context18.abrupt("continue", 59);
|
|
2395
|
+
case 58:
|
|
2484
2396
|
duplicateIndexes.add(_duplicateIndex);
|
|
2485
|
-
case
|
|
2486
|
-
|
|
2397
|
+
case 59:
|
|
2398
|
+
_context18.next = 53;
|
|
2487
2399
|
break;
|
|
2488
|
-
case
|
|
2489
|
-
|
|
2400
|
+
case 61:
|
|
2401
|
+
_context18.next = 66;
|
|
2490
2402
|
break;
|
|
2491
|
-
case
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
case
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
return
|
|
2499
|
-
case
|
|
2403
|
+
case 63:
|
|
2404
|
+
_context18.prev = 63;
|
|
2405
|
+
_context18.t1 = _context18["catch"](51);
|
|
2406
|
+
_iterator16.e(_context18.t1);
|
|
2407
|
+
case 66:
|
|
2408
|
+
_context18.prev = 66;
|
|
2409
|
+
_iterator16.f();
|
|
2410
|
+
return _context18.finish(66);
|
|
2411
|
+
case 69:
|
|
2500
2412
|
if (duplicateIndexes.size > 0) {
|
|
2501
|
-
|
|
2413
|
+
_iterator17 = _createForOfIteratorHelper(_toConsumableArray(duplicateIndexes).sort(function (left, right) {
|
|
2502
2414
|
return right - left;
|
|
2503
2415
|
}));
|
|
2504
2416
|
try {
|
|
2505
|
-
for (
|
|
2506
|
-
duplicateIndex =
|
|
2417
|
+
for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
|
|
2418
|
+
duplicateIndex = _step17.value;
|
|
2507
2419
|
mergedOrder = this.mergeOrderRecords(mergedOrder, updatedList[duplicateIndex]);
|
|
2508
|
-
mergedProductsHaveStableIdentity = mergedProductsHaveStableIdentity && existingProductsHaveStableIdentity[duplicateIndex] !== false;
|
|
2509
2420
|
updatedList.splice(duplicateIndex, 1);
|
|
2510
|
-
existingProductsHaveStableIdentity.splice(duplicateIndex, 1);
|
|
2511
2421
|
if (duplicateIndex < adjustedMatchIndex) adjustedMatchIndex -= 1;
|
|
2512
2422
|
}
|
|
2513
2423
|
} catch (err) {
|
|
2514
|
-
|
|
2424
|
+
_iterator17.e(err);
|
|
2515
2425
|
} finally {
|
|
2516
|
-
|
|
2426
|
+
_iterator17.f();
|
|
2517
2427
|
}
|
|
2518
2428
|
identityKeyToIndex.clear();
|
|
2519
2429
|
for (_index = 0; _index < updatedList.length; _index += 1) {
|
|
2520
|
-
|
|
2430
|
+
_iterator18 = _createForOfIteratorHelper(this.getOrderIdentityMatchKeys(updatedList[_index]));
|
|
2521
2431
|
try {
|
|
2522
|
-
for (
|
|
2523
|
-
_key =
|
|
2432
|
+
for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
|
|
2433
|
+
_key = _step18.value;
|
|
2524
2434
|
if (!identityKeyToIndex.has(_key)) identityKeyToIndex.set(_key, _index);
|
|
2525
2435
|
}
|
|
2526
2436
|
} catch (err) {
|
|
2527
|
-
|
|
2437
|
+
_iterator18.e(err);
|
|
2528
2438
|
} finally {
|
|
2529
|
-
|
|
2439
|
+
_iterator18.f();
|
|
2530
2440
|
}
|
|
2531
2441
|
}
|
|
2532
2442
|
}
|
|
2533
2443
|
updatedList[adjustedMatchIndex] = mergedOrder;
|
|
2534
|
-
existingProductsHaveStableIdentity[adjustedMatchIndex] = mergedProductsHaveStableIdentity;
|
|
2535
|
-
if (membershipChange) {
|
|
2536
|
-
remoteProductMembershipChanges.push(membershipChange);
|
|
2537
|
-
mergedStorageKey = this.getOrderStorageKey(mergedOrder);
|
|
2538
|
-
if (mergedStorageKey) forceWriteStorageKeys.add(mergedStorageKey);
|
|
2539
|
-
}
|
|
2540
2444
|
// 合并后身份字段可能新增(如挂单拿到 order_id),同步登记到索引,
|
|
2541
2445
|
// 供同批后续 fresh 命中同一槽位,避免重复插入
|
|
2542
2446
|
this.registerOrderIdentityKeys(identityKeyToIndex, mergedOrder, adjustedMatchIndex);
|
|
2543
2447
|
patchedOrders.push(mergedOrder);
|
|
2544
2448
|
if (mergeKey) mergeActions[mergeKey] = 'update';
|
|
2545
|
-
return
|
|
2546
|
-
case
|
|
2449
|
+
return _context18.abrupt("continue", 80);
|
|
2450
|
+
case 75:
|
|
2547
2451
|
insertIndex = updatedList.length;
|
|
2548
2452
|
updatedList.push(fresh);
|
|
2549
|
-
existingProductsHaveStableIdentity.push(fresh.order_id !== undefined && fresh.order_id !== null && incomingProductsHaveStableIdentity.get(this.getIdKey(fresh.order_id)) !== false);
|
|
2550
2453
|
this.registerOrderIdentityKeys(identityKeyToIndex, fresh, insertIndex);
|
|
2551
2454
|
patchedOrders.push(fresh);
|
|
2552
2455
|
if (mergeKey) mergeActions[mergeKey] = 'insert';
|
|
2553
|
-
case
|
|
2554
|
-
|
|
2456
|
+
case 80:
|
|
2457
|
+
_context18.next = 33;
|
|
2555
2458
|
break;
|
|
2556
|
-
case
|
|
2557
|
-
|
|
2459
|
+
case 82:
|
|
2460
|
+
_context18.next = 87;
|
|
2558
2461
|
break;
|
|
2559
|
-
case
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
case
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
return
|
|
2567
|
-
case
|
|
2462
|
+
case 84:
|
|
2463
|
+
_context18.prev = 84;
|
|
2464
|
+
_context18.t2 = _context18["catch"](31);
|
|
2465
|
+
_iterator15.e(_context18.t2);
|
|
2466
|
+
case 87:
|
|
2467
|
+
_context18.prev = 87;
|
|
2468
|
+
_iterator15.f();
|
|
2469
|
+
return _context18.finish(87);
|
|
2470
|
+
case 90:
|
|
2568
2471
|
insertCount = Object.values(mergeActions).filter(function (v) {
|
|
2569
2472
|
return v === 'insert';
|
|
2570
2473
|
}).length;
|
|
@@ -2580,27 +2483,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2580
2483
|
// 仅在自检开关开启时做一次兜底校验。
|
|
2581
2484
|
this.store.list = this.runOrderStoreSelfCheck(updatedList, "".concat(source, ".store"));
|
|
2582
2485
|
this.syncOrdersMap();
|
|
2583
|
-
|
|
2584
|
-
return this.patchOrdersInSQLite(patchedOrders, source, mergeActions
|
|
2585
|
-
case
|
|
2486
|
+
_context18.next = 97;
|
|
2487
|
+
return this.patchOrdersInSQLite(patchedOrders, source, mergeActions);
|
|
2488
|
+
case 97:
|
|
2586
2489
|
this.logInfo('mergeOrdersToStore-结束', {
|
|
2587
2490
|
uniqueFreshCount: uniqueFreshCount,
|
|
2588
2491
|
storeOrderCountAfter: this.store.list.length,
|
|
2589
2492
|
insertCount: insertCount,
|
|
2590
2493
|
updateCount: updateCount
|
|
2591
2494
|
});
|
|
2592
|
-
|
|
2593
|
-
return this.emitRemoteProductMembershipChanges(remoteProductMembershipChanges);
|
|
2594
|
-
case 114:
|
|
2595
|
-
_context19.next = 116;
|
|
2495
|
+
_context18.next = 100;
|
|
2596
2496
|
return this.emitOrdersChanged(patchedOrders, source);
|
|
2597
|
-
case
|
|
2497
|
+
case 100:
|
|
2598
2498
|
case "end":
|
|
2599
|
-
return
|
|
2499
|
+
return _context18.stop();
|
|
2600
2500
|
}
|
|
2601
|
-
},
|
|
2501
|
+
}, _callee18, this, [[5, 17, 20, 23], [31, 84, 87, 90], [51, 63, 66, 69]]);
|
|
2602
2502
|
}));
|
|
2603
|
-
function mergeOrdersToStore(
|
|
2503
|
+
function mergeOrdersToStore(_x12, _x13) {
|
|
2604
2504
|
return _mergeOrdersToStore.apply(this, arguments);
|
|
2605
2505
|
}
|
|
2606
2506
|
return mergeOrdersToStore;
|
|
@@ -2617,19 +2517,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2617
2517
|
key: "lookupOrderIndexByIdentityKeys",
|
|
2618
2518
|
value: function lookupOrderIndexByIdentityKeys(identityKeyToIndex, identityKeys) {
|
|
2619
2519
|
var matchIndex = -1;
|
|
2620
|
-
var
|
|
2621
|
-
|
|
2520
|
+
var _iterator19 = _createForOfIteratorHelper(identityKeys),
|
|
2521
|
+
_step19;
|
|
2622
2522
|
try {
|
|
2623
|
-
for (
|
|
2624
|
-
var key =
|
|
2523
|
+
for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {
|
|
2524
|
+
var key = _step19.value;
|
|
2625
2525
|
var index = identityKeyToIndex.get(key);
|
|
2626
2526
|
if (index === undefined) continue;
|
|
2627
2527
|
if (matchIndex < 0 || index < matchIndex) matchIndex = index;
|
|
2628
2528
|
}
|
|
2629
2529
|
} catch (err) {
|
|
2630
|
-
|
|
2530
|
+
_iterator19.e(err);
|
|
2631
2531
|
} finally {
|
|
2632
|
-
|
|
2532
|
+
_iterator19.f();
|
|
2633
2533
|
}
|
|
2634
2534
|
return matchIndex;
|
|
2635
2535
|
}
|
|
@@ -2638,92 +2538,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2638
2538
|
value: function isRemoteEchoMergeSource(source) {
|
|
2639
2539
|
return source === 'pubsub.bodyUpsert' || source === 'pubsub.httpRefresh';
|
|
2640
2540
|
}
|
|
2641
|
-
}, {
|
|
2642
|
-
key: "getProductMembershipKey",
|
|
2643
|
-
value: function getProductMembershipKey(product) {
|
|
2644
|
-
var persistentId = getOrderCollectionPersistentId('product', product);
|
|
2645
|
-
if (persistentId) return "order_detail_id:".concat(persistentId);
|
|
2646
|
-
var uid = getOrderCollectionUid('product', product);
|
|
2647
|
-
return uid ? "unique_identification_number:".concat(uid) : '';
|
|
2648
|
-
}
|
|
2649
|
-
}, {
|
|
2650
|
-
key: "doProductsHaveStableMembershipIdentity",
|
|
2651
|
-
value: function doProductsHaveStableMembershipIdentity(products) {
|
|
2652
|
-
if (!Array.isArray(products)) return true;
|
|
2653
|
-
return products.every(function (product) {
|
|
2654
|
-
return Boolean(getOrderCollectionPersistentId('product', product) || getOrderCollectionUid('product', product));
|
|
2655
|
-
});
|
|
2656
|
-
}
|
|
2657
|
-
|
|
2658
|
-
/**
|
|
2659
|
-
* 冲突提示关注逻辑商品行,而不是服务端 checkout 过程中可能被重建的 detail 记录。
|
|
2660
|
-
* 通用集合合并仍以 order_detail_id 为事实主键;这里只允许相同稳定 UID 跨 detail id 对齐,
|
|
2661
|
-
* 避免本机 checkout 回声被误判成“一删一增”。
|
|
2662
|
-
*/
|
|
2663
|
-
}, {
|
|
2664
|
-
key: "isSameProductMembershipItem",
|
|
2665
|
-
value: function isSameProductMembershipItem(left, right) {
|
|
2666
|
-
if (isSameOrderCollectionItem('product', left, right)) return true;
|
|
2667
|
-
var leftUid = getOrderCollectionUid('product', left);
|
|
2668
|
-
var rightUid = getOrderCollectionUid('product', right);
|
|
2669
|
-
return Boolean(leftUid && rightUid && leftUid === rightUid);
|
|
2670
|
-
}
|
|
2671
|
-
|
|
2672
|
-
/**
|
|
2673
|
-
* 对比合并前后的商品成员集合。商品字段修改与数组重排不会产生 diff。
|
|
2674
|
-
*/
|
|
2675
|
-
}, {
|
|
2676
|
-
key: "getRemoteProductMembershipChange",
|
|
2677
|
-
value: function getRemoteProductMembershipChange(existingOrder, mergedOrder, source) {
|
|
2678
|
-
var _this17 = this,
|
|
2679
|
-
_mergedOrder$order_id;
|
|
2680
|
-
if (!this.isRemoteEchoMergeSource(source)) return null;
|
|
2681
|
-
var previousProducts = Array.isArray(existingOrder.products) ? existingOrder.products : [];
|
|
2682
|
-
var currentProducts = Array.isArray(mergedOrder.products) ? mergedOrder.products : [];
|
|
2683
|
-
var unmatchedCurrentIndexes = new Set(currentProducts.map(function (_, index) {
|
|
2684
|
-
return index;
|
|
2685
|
-
}));
|
|
2686
|
-
var removedProductKeys = [];
|
|
2687
|
-
var _iterator21 = _createForOfIteratorHelper(previousProducts),
|
|
2688
|
-
_step21;
|
|
2689
|
-
try {
|
|
2690
|
-
var _loop2 = function _loop2() {
|
|
2691
|
-
var previousProduct = _step21.value;
|
|
2692
|
-
var matchedIndex = currentProducts.findIndex(function (currentProduct, index) {
|
|
2693
|
-
return unmatchedCurrentIndexes.has(index) && _this17.isSameProductMembershipItem(previousProduct, currentProduct);
|
|
2694
|
-
});
|
|
2695
|
-
if (matchedIndex >= 0) {
|
|
2696
|
-
unmatchedCurrentIndexes.delete(matchedIndex);
|
|
2697
|
-
return 1; // continue
|
|
2698
|
-
}
|
|
2699
|
-
var productKey = _this17.getProductMembershipKey(previousProduct);
|
|
2700
|
-
if (productKey) removedProductKeys.push(productKey);
|
|
2701
|
-
};
|
|
2702
|
-
for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
|
|
2703
|
-
if (_loop2()) continue;
|
|
2704
|
-
}
|
|
2705
|
-
} catch (err) {
|
|
2706
|
-
_iterator21.e(err);
|
|
2707
|
-
} finally {
|
|
2708
|
-
_iterator21.f();
|
|
2709
|
-
}
|
|
2710
|
-
var addedProductKeys = _toConsumableArray(unmatchedCurrentIndexes).map(function (index) {
|
|
2711
|
-
return _this17.getProductMembershipKey(currentProducts[index]);
|
|
2712
|
-
}).filter(Boolean);
|
|
2713
|
-
if (addedProductKeys.length === 0 && removedProductKeys.length === 0) {
|
|
2714
|
-
return null;
|
|
2715
|
-
}
|
|
2716
|
-
var orderId = (_mergedOrder$order_id = mergedOrder.order_id) !== null && _mergedOrder$order_id !== void 0 ? _mergedOrder$order_id : existingOrder.order_id;
|
|
2717
|
-
if (orderId === undefined || orderId === null) return null;
|
|
2718
|
-
return {
|
|
2719
|
-
order_id: orderId,
|
|
2720
|
-
source: source,
|
|
2721
|
-
added_product_keys: addedProductKeys,
|
|
2722
|
-
removed_product_keys: removedProductKeys,
|
|
2723
|
-
previous_product_count: previousProducts.length,
|
|
2724
|
-
current_product_count: currentProducts.length
|
|
2725
|
-
};
|
|
2726
|
-
}
|
|
2727
2541
|
|
|
2728
2542
|
/**
|
|
2729
2543
|
* 将订单的全部身份键登记到索引并指向其在列表中的下标。
|
|
@@ -2736,17 +2550,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2736
2550
|
key: "registerOrderIdentityKeys",
|
|
2737
2551
|
value: function registerOrderIdentityKeys(identityKeyToIndex, order, index) {
|
|
2738
2552
|
var identityKeys = this.getOrderIdentityMatchKeys(order);
|
|
2739
|
-
var
|
|
2740
|
-
|
|
2553
|
+
var _iterator20 = _createForOfIteratorHelper(identityKeys),
|
|
2554
|
+
_step20;
|
|
2741
2555
|
try {
|
|
2742
|
-
for (
|
|
2743
|
-
var key =
|
|
2556
|
+
for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {
|
|
2557
|
+
var key = _step20.value;
|
|
2744
2558
|
identityKeyToIndex.set(key, index);
|
|
2745
2559
|
}
|
|
2746
2560
|
} catch (err) {
|
|
2747
|
-
|
|
2561
|
+
_iterator20.e(err);
|
|
2748
2562
|
} finally {
|
|
2749
|
-
|
|
2563
|
+
_iterator20.f();
|
|
2750
2564
|
}
|
|
2751
2565
|
}
|
|
2752
2566
|
|
|
@@ -2801,17 +2615,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2801
2615
|
key: "uniqueOrderIds",
|
|
2802
2616
|
value: function uniqueOrderIds(ids) {
|
|
2803
2617
|
var idMap = new Map();
|
|
2804
|
-
var
|
|
2805
|
-
|
|
2618
|
+
var _iterator21 = _createForOfIteratorHelper(ids),
|
|
2619
|
+
_step21;
|
|
2806
2620
|
try {
|
|
2807
|
-
for (
|
|
2808
|
-
var id =
|
|
2621
|
+
for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
|
|
2622
|
+
var id = _step21.value;
|
|
2809
2623
|
idMap.set(this.getIdKey(id), id);
|
|
2810
2624
|
}
|
|
2811
2625
|
} catch (err) {
|
|
2812
|
-
|
|
2626
|
+
_iterator21.e(err);
|
|
2813
2627
|
} finally {
|
|
2814
|
-
|
|
2628
|
+
_iterator21.f();
|
|
2815
2629
|
}
|
|
2816
2630
|
return _toConsumableArray(idMap.values());
|
|
2817
2631
|
}
|
|
@@ -2823,12 +2637,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2823
2637
|
}, {
|
|
2824
2638
|
key: "isOrderLookupMatch",
|
|
2825
2639
|
value: function isOrderLookupMatch(order, lookupKey) {
|
|
2826
|
-
var
|
|
2640
|
+
var _this17 = this;
|
|
2827
2641
|
if (!order || !lookupKey) return false;
|
|
2828
2642
|
var candidates = [order.order_id, order.external_sale_number, order.order_number, order.shop_order_number, order.shop_full_order_number];
|
|
2829
2643
|
return candidates.some(function (value) {
|
|
2830
2644
|
if (value === undefined || value === null || value === '') return false;
|
|
2831
|
-
return
|
|
2645
|
+
return _this17.getIdKey(value) === lookupKey;
|
|
2832
2646
|
});
|
|
2833
2647
|
}
|
|
2834
2648
|
|
|
@@ -2871,10 +2685,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2871
2685
|
}, {
|
|
2872
2686
|
key: "findOrderIndexByIdentity",
|
|
2873
2687
|
value: function findOrderIndexByIdentity(orders, target) {
|
|
2874
|
-
var
|
|
2688
|
+
var _this18 = this;
|
|
2875
2689
|
if (this.getOrderIdentityMatchKeys(target).length === 0) return -1;
|
|
2876
2690
|
return orders.findIndex(function (order) {
|
|
2877
|
-
return
|
|
2691
|
+
return _this18.doOrdersShareIdentity(order, target);
|
|
2878
2692
|
});
|
|
2879
2693
|
}
|
|
2880
2694
|
}, {
|
|
@@ -2923,58 +2737,58 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2923
2737
|
if (secondaryList.length === 0) return preferredList;
|
|
2924
2738
|
if (preferredList.length === 0) return secondaryList;
|
|
2925
2739
|
var seenKeys = new Set();
|
|
2926
|
-
var
|
|
2927
|
-
|
|
2740
|
+
var _iterator22 = _createForOfIteratorHelper(preferredList),
|
|
2741
|
+
_step22;
|
|
2928
2742
|
try {
|
|
2929
|
-
for (
|
|
2930
|
-
var item =
|
|
2743
|
+
for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
|
|
2744
|
+
var item = _step22.value;
|
|
2931
2745
|
var keys = this.getProductIdentityKeys(item);
|
|
2932
|
-
var
|
|
2933
|
-
|
|
2746
|
+
var _iterator24 = _createForOfIteratorHelper(keys),
|
|
2747
|
+
_step24;
|
|
2934
2748
|
try {
|
|
2935
|
-
for (
|
|
2936
|
-
var key =
|
|
2749
|
+
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
2750
|
+
var key = _step24.value;
|
|
2937
2751
|
seenKeys.add(key);
|
|
2938
2752
|
}
|
|
2939
2753
|
} catch (err) {
|
|
2940
|
-
|
|
2754
|
+
_iterator24.e(err);
|
|
2941
2755
|
} finally {
|
|
2942
|
-
|
|
2756
|
+
_iterator24.f();
|
|
2943
2757
|
}
|
|
2944
2758
|
}
|
|
2945
2759
|
} catch (err) {
|
|
2946
|
-
|
|
2760
|
+
_iterator22.e(err);
|
|
2947
2761
|
} finally {
|
|
2948
|
-
|
|
2762
|
+
_iterator22.f();
|
|
2949
2763
|
}
|
|
2950
2764
|
var result = _toConsumableArray(preferredList);
|
|
2951
|
-
var
|
|
2952
|
-
|
|
2765
|
+
var _iterator23 = _createForOfIteratorHelper(secondaryList),
|
|
2766
|
+
_step23;
|
|
2953
2767
|
try {
|
|
2954
|
-
for (
|
|
2955
|
-
var _item =
|
|
2768
|
+
for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
|
|
2769
|
+
var _item = _step23.value;
|
|
2956
2770
|
var _keys = this.getProductIdentityKeys(_item);
|
|
2957
2771
|
if (_keys.length === 0 || _keys.some(function (key) {
|
|
2958
2772
|
return seenKeys.has(key);
|
|
2959
2773
|
})) continue;
|
|
2960
|
-
var
|
|
2961
|
-
|
|
2774
|
+
var _iterator25 = _createForOfIteratorHelper(_keys),
|
|
2775
|
+
_step25;
|
|
2962
2776
|
try {
|
|
2963
|
-
for (
|
|
2964
|
-
var _key3 =
|
|
2777
|
+
for (_iterator25.s(); !(_step25 = _iterator25.n()).done;) {
|
|
2778
|
+
var _key3 = _step25.value;
|
|
2965
2779
|
seenKeys.add(_key3);
|
|
2966
2780
|
}
|
|
2967
2781
|
} catch (err) {
|
|
2968
|
-
|
|
2782
|
+
_iterator25.e(err);
|
|
2969
2783
|
} finally {
|
|
2970
|
-
|
|
2784
|
+
_iterator25.f();
|
|
2971
2785
|
}
|
|
2972
2786
|
result.push(cloneDeep(_item));
|
|
2973
2787
|
}
|
|
2974
2788
|
} catch (err) {
|
|
2975
|
-
|
|
2789
|
+
_iterator23.e(err);
|
|
2976
2790
|
} finally {
|
|
2977
|
-
|
|
2791
|
+
_iterator23.f();
|
|
2978
2792
|
}
|
|
2979
2793
|
return result;
|
|
2980
2794
|
}
|
|
@@ -3084,30 +2898,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3084
2898
|
key: "summarizeDuplicateOrders",
|
|
3085
2899
|
value: function summarizeDuplicateOrders(orders) {
|
|
3086
2900
|
var groups = new Map();
|
|
3087
|
-
var
|
|
3088
|
-
|
|
2901
|
+
var _iterator26 = _createForOfIteratorHelper(orders),
|
|
2902
|
+
_step26;
|
|
3089
2903
|
try {
|
|
3090
|
-
for (
|
|
3091
|
-
var order =
|
|
3092
|
-
var
|
|
3093
|
-
|
|
2904
|
+
for (_iterator26.s(); !(_step26 = _iterator26.n()).done;) {
|
|
2905
|
+
var order = _step26.value;
|
|
2906
|
+
var _iterator27 = _createForOfIteratorHelper(this.getOrderIdentityMatchKeys(order)),
|
|
2907
|
+
_step27;
|
|
3094
2908
|
try {
|
|
3095
|
-
for (
|
|
3096
|
-
var key =
|
|
2909
|
+
for (_iterator27.s(); !(_step27 = _iterator27.n()).done;) {
|
|
2910
|
+
var key = _step27.value;
|
|
3097
2911
|
var group = groups.get(key) || [];
|
|
3098
2912
|
group.push(order);
|
|
3099
2913
|
groups.set(key, group);
|
|
3100
2914
|
}
|
|
3101
2915
|
} catch (err) {
|
|
3102
|
-
|
|
2916
|
+
_iterator27.e(err);
|
|
3103
2917
|
} finally {
|
|
3104
|
-
|
|
2918
|
+
_iterator27.f();
|
|
3105
2919
|
}
|
|
3106
2920
|
}
|
|
3107
2921
|
} catch (err) {
|
|
3108
|
-
|
|
2922
|
+
_iterator26.e(err);
|
|
3109
2923
|
} finally {
|
|
3110
|
-
|
|
2924
|
+
_iterator26.f();
|
|
3111
2925
|
}
|
|
3112
2926
|
return _toConsumableArray(groups.entries()).filter(function (_ref7) {
|
|
3113
2927
|
var _ref8 = _slicedToArray(_ref7, 2),
|
|
@@ -3150,11 +2964,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3150
2964
|
value: function compactOrderListByIdentity(orders, source) {
|
|
3151
2965
|
var list = [];
|
|
3152
2966
|
var removedCount = 0;
|
|
3153
|
-
var
|
|
3154
|
-
|
|
2967
|
+
var _iterator28 = _createForOfIteratorHelper(orders),
|
|
2968
|
+
_step28;
|
|
3155
2969
|
try {
|
|
3156
|
-
for (
|
|
3157
|
-
var order =
|
|
2970
|
+
for (_iterator28.s(); !(_step28 = _iterator28.n()).done;) {
|
|
2971
|
+
var order = _step28.value;
|
|
3158
2972
|
var normalizedOrder = this.normalizeOrderCollectionsForIngress(order, "".concat(source, ".order"));
|
|
3159
2973
|
var matchIndex = this.findOrderIndexByIdentity(list, normalizedOrder);
|
|
3160
2974
|
if (matchIndex < 0) {
|
|
@@ -3165,9 +2979,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3165
2979
|
removedCount += 1;
|
|
3166
2980
|
}
|
|
3167
2981
|
} catch (err) {
|
|
3168
|
-
|
|
2982
|
+
_iterator28.e(err);
|
|
3169
2983
|
} finally {
|
|
3170
|
-
|
|
2984
|
+
_iterator28.f();
|
|
3171
2985
|
}
|
|
3172
2986
|
if (removedCount > 0) {
|
|
3173
2987
|
this.logWarning('订单列表重复项已压缩', {
|
|
@@ -3265,35 +3079,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3265
3079
|
}, {
|
|
3266
3080
|
key: "loadOrdersFromSQLite",
|
|
3267
3081
|
value: function () {
|
|
3268
|
-
var _loadOrdersFromSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3269
|
-
var
|
|
3082
|
+
var _loadOrdersFromSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
3083
|
+
var _this19 = this;
|
|
3270
3084
|
var orders;
|
|
3271
|
-
return _regeneratorRuntime().wrap(function
|
|
3272
|
-
while (1) switch (
|
|
3085
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
3086
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
3273
3087
|
case 0:
|
|
3274
3088
|
if (this.dbManager) {
|
|
3275
|
-
|
|
3089
|
+
_context19.next = 2;
|
|
3276
3090
|
break;
|
|
3277
3091
|
}
|
|
3278
|
-
return
|
|
3092
|
+
return _context19.abrupt("return", []);
|
|
3279
3093
|
case 2:
|
|
3280
|
-
|
|
3281
|
-
|
|
3094
|
+
_context19.prev = 2;
|
|
3095
|
+
_context19.next = 5;
|
|
3282
3096
|
return this.dbManager.getAll(INDEXDB_STORE_NAME);
|
|
3283
3097
|
case 5:
|
|
3284
|
-
orders =
|
|
3285
|
-
return
|
|
3286
|
-
return
|
|
3098
|
+
orders = _context19.sent;
|
|
3099
|
+
return _context19.abrupt("return", (orders || []).map(function (order) {
|
|
3100
|
+
return _this19.normalizeOrderCollectionsForIngress(order, 'loadOrdersFromSQLite');
|
|
3287
3101
|
}));
|
|
3288
3102
|
case 9:
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
return
|
|
3103
|
+
_context19.prev = 9;
|
|
3104
|
+
_context19.t0 = _context19["catch"](2);
|
|
3105
|
+
return _context19.abrupt("return", []);
|
|
3292
3106
|
case 12:
|
|
3293
3107
|
case "end":
|
|
3294
|
-
return
|
|
3108
|
+
return _context19.stop();
|
|
3295
3109
|
}
|
|
3296
|
-
},
|
|
3110
|
+
}, _callee19, this, [[2, 9]]);
|
|
3297
3111
|
}));
|
|
3298
3112
|
function loadOrdersFromSQLite() {
|
|
3299
3113
|
return _loadOrdersFromSQLite.apply(this, arguments);
|
|
@@ -3343,15 +3157,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3343
3157
|
}, {
|
|
3344
3158
|
key: "mergeRemoteSnapshotWithPendingOrders",
|
|
3345
3159
|
value: function mergeRemoteSnapshotWithPendingOrders(remoteOrders, existingOrders) {
|
|
3346
|
-
var
|
|
3160
|
+
var _this20 = this;
|
|
3347
3161
|
var merged = remoteOrders.map(function (order) {
|
|
3348
|
-
return
|
|
3162
|
+
return _this20.normalizeRemoteSyncedOrder(order);
|
|
3349
3163
|
});
|
|
3350
|
-
var
|
|
3351
|
-
|
|
3164
|
+
var _iterator29 = _createForOfIteratorHelper(existingOrders),
|
|
3165
|
+
_step29;
|
|
3352
3166
|
try {
|
|
3353
|
-
for (
|
|
3354
|
-
var rawOrder =
|
|
3167
|
+
for (_iterator29.s(); !(_step29 = _iterator29.n()).done;) {
|
|
3168
|
+
var rawOrder = _step29.value;
|
|
3355
3169
|
var order = this.normalizeOrderCollectionsForIngress(rawOrder, 'mergeRemoteSnapshotWithPendingOrders.existingSQLite');
|
|
3356
3170
|
if (!this.shouldProtectLocalOrderFromRemoteSnapshot(order)) continue;
|
|
3357
3171
|
var matchIndex = this.findOrderIndexByIdentity(merged, order);
|
|
@@ -3367,9 +3181,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3367
3181
|
merged.push(order);
|
|
3368
3182
|
}
|
|
3369
3183
|
} catch (err) {
|
|
3370
|
-
|
|
3184
|
+
_iterator29.e(err);
|
|
3371
3185
|
} finally {
|
|
3372
|
-
|
|
3186
|
+
_iterator29.f();
|
|
3373
3187
|
}
|
|
3374
3188
|
return this.compactOrderListByIdentity(merged, 'mergeRemoteSnapshotWithPendingOrders').list;
|
|
3375
3189
|
}
|
|
@@ -3385,10 +3199,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3385
3199
|
}, {
|
|
3386
3200
|
key: "runInOrderSQLiteSaveQueue",
|
|
3387
3201
|
value: (function () {
|
|
3388
|
-
var _runInOrderSQLiteSaveQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3202
|
+
var _runInOrderSQLiteSaveQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(task) {
|
|
3389
3203
|
var queuedTask;
|
|
3390
|
-
return _regeneratorRuntime().wrap(function
|
|
3391
|
-
while (1) switch (
|
|
3204
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
3205
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
3392
3206
|
case 0:
|
|
3393
3207
|
queuedTask = this.orderSQLiteSaveQueue.then(task, task);
|
|
3394
3208
|
this.orderSQLiteSaveQueue = queuedTask.then(function () {
|
|
@@ -3396,14 +3210,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3396
3210
|
}, function () {
|
|
3397
3211
|
return undefined;
|
|
3398
3212
|
});
|
|
3399
|
-
return
|
|
3213
|
+
return _context20.abrupt("return", queuedTask);
|
|
3400
3214
|
case 3:
|
|
3401
3215
|
case "end":
|
|
3402
|
-
return
|
|
3216
|
+
return _context20.stop();
|
|
3403
3217
|
}
|
|
3404
|
-
},
|
|
3218
|
+
}, _callee20, this);
|
|
3405
3219
|
}));
|
|
3406
|
-
function runInOrderSQLiteSaveQueue(
|
|
3220
|
+
function runInOrderSQLiteSaveQueue(_x14) {
|
|
3407
3221
|
return _runInOrderSQLiteSaveQueue.apply(this, arguments);
|
|
3408
3222
|
}
|
|
3409
3223
|
return runInOrderSQLiteSaveQueue;
|
|
@@ -3418,143 +3232,141 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3418
3232
|
}, {
|
|
3419
3233
|
key: "patchOrdersInSQLite",
|
|
3420
3234
|
value: (function () {
|
|
3421
|
-
var _patchOrdersInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3422
|
-
var
|
|
3235
|
+
var _patchOrdersInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(orders, source) {
|
|
3236
|
+
var _this21 = this;
|
|
3423
3237
|
var mergeActions,
|
|
3424
3238
|
options,
|
|
3425
|
-
forceWriteStorageKeys,
|
|
3426
3239
|
ordersSnapshot,
|
|
3427
3240
|
_this$filterRedundant2,
|
|
3428
3241
|
toWrite,
|
|
3429
3242
|
skipped,
|
|
3430
3243
|
compactedToWrite,
|
|
3431
|
-
|
|
3432
|
-
return _regeneratorRuntime().wrap(function
|
|
3433
|
-
while (1) switch (
|
|
3244
|
+
_args22 = arguments;
|
|
3245
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
3246
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
3434
3247
|
case 0:
|
|
3435
|
-
mergeActions =
|
|
3436
|
-
options =
|
|
3437
|
-
forceWriteStorageKeys = _args23.length > 4 && _args23[4] !== undefined ? _args23[4] : new Set();
|
|
3248
|
+
mergeActions = _args22.length > 2 && _args22[2] !== undefined ? _args22[2] : {};
|
|
3249
|
+
options = _args22.length > 3 && _args22[3] !== undefined ? _args22[3] : {};
|
|
3438
3250
|
if (!(orders.length === 0)) {
|
|
3439
|
-
|
|
3251
|
+
_context22.next = 4;
|
|
3440
3252
|
break;
|
|
3441
3253
|
}
|
|
3442
|
-
return
|
|
3443
|
-
case
|
|
3254
|
+
return _context22.abrupt("return");
|
|
3255
|
+
case 4:
|
|
3444
3256
|
if (this.dbManager) {
|
|
3445
|
-
|
|
3257
|
+
_context22.next = 8;
|
|
3446
3258
|
break;
|
|
3447
3259
|
}
|
|
3448
3260
|
if (!options.throwOnError) {
|
|
3449
|
-
|
|
3261
|
+
_context22.next = 7;
|
|
3450
3262
|
break;
|
|
3451
3263
|
}
|
|
3452
3264
|
throw new Error('订单 SQLite 数据库未初始化');
|
|
3265
|
+
case 7:
|
|
3266
|
+
return _context22.abrupt("return");
|
|
3453
3267
|
case 8:
|
|
3454
|
-
return _context23.abrupt("return");
|
|
3455
|
-
case 9:
|
|
3456
3268
|
ordersSnapshot = cloneDeep(orders).map(function (order) {
|
|
3457
|
-
return
|
|
3269
|
+
return _this21.normalizeOrderCollectionsForIngress(order, "".concat(source, ".sqliteIngress"));
|
|
3458
3270
|
}).filter(function (order) {
|
|
3459
|
-
return
|
|
3271
|
+
return _this21.getOrderStorageKey(order);
|
|
3460
3272
|
});
|
|
3461
3273
|
if (!(ordersSnapshot.length === 0)) {
|
|
3462
|
-
|
|
3274
|
+
_context22.next = 11;
|
|
3463
3275
|
break;
|
|
3464
3276
|
}
|
|
3465
|
-
return
|
|
3466
|
-
case
|
|
3467
|
-
_this$filterRedundant2 = this.filterRedundantPatchOrders(source, ordersSnapshot, mergeActions
|
|
3277
|
+
return _context22.abrupt("return");
|
|
3278
|
+
case 11:
|
|
3279
|
+
_this$filterRedundant2 = this.filterRedundantPatchOrders(source, ordersSnapshot, mergeActions), toWrite = _this$filterRedundant2.toWrite, skipped = _this$filterRedundant2.skipped;
|
|
3468
3280
|
if (!(toWrite.length === 0)) {
|
|
3469
|
-
|
|
3281
|
+
_context22.next = 14;
|
|
3470
3282
|
break;
|
|
3471
3283
|
}
|
|
3472
|
-
return
|
|
3473
|
-
case
|
|
3284
|
+
return _context22.abrupt("return");
|
|
3285
|
+
case 14:
|
|
3474
3286
|
compactedToWrite = this.compactOrderListByIdentity(toWrite, "".concat(source, ".sqlitePatch")).list;
|
|
3475
3287
|
if (!(compactedToWrite.length === 0)) {
|
|
3476
|
-
|
|
3288
|
+
_context22.next = 17;
|
|
3477
3289
|
break;
|
|
3478
3290
|
}
|
|
3479
|
-
return
|
|
3480
|
-
case
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3484
|
-
var writeMethod,
|
|
3485
|
-
return _regeneratorRuntime().wrap(function
|
|
3486
|
-
while (1) switch (
|
|
3291
|
+
return _context22.abrupt("return");
|
|
3292
|
+
case 17:
|
|
3293
|
+
_context22.prev = 17;
|
|
3294
|
+
_context22.next = 20;
|
|
3295
|
+
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
3296
|
+
var writeMethod, _iterator30, _step30, order;
|
|
3297
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
3298
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
3487
3299
|
case 0:
|
|
3488
3300
|
writeMethod = 'none';
|
|
3489
|
-
|
|
3301
|
+
_this21.logInfo('patchOrdersInSQLite-开始', {
|
|
3490
3302
|
source: source,
|
|
3491
3303
|
count: compactedToWrite.length,
|
|
3492
3304
|
dedupedCount: skipped.length
|
|
3493
3305
|
});
|
|
3494
|
-
if (!(typeof
|
|
3495
|
-
|
|
3306
|
+
if (!(typeof _this21.dbManager.bulkUpdate === 'function')) {
|
|
3307
|
+
_context21.next = 8;
|
|
3496
3308
|
break;
|
|
3497
3309
|
}
|
|
3498
3310
|
writeMethod = 'bulkUpdate';
|
|
3499
|
-
|
|
3500
|
-
return
|
|
3311
|
+
_context21.next = 6;
|
|
3312
|
+
return _this21.dbManager.bulkUpdate(INDEXDB_STORE_NAME, compactedToWrite);
|
|
3501
3313
|
case 6:
|
|
3502
|
-
|
|
3314
|
+
_context21.next = 37;
|
|
3503
3315
|
break;
|
|
3504
3316
|
case 8:
|
|
3505
|
-
if (!(typeof
|
|
3506
|
-
|
|
3317
|
+
if (!(typeof _this21.dbManager.bulkAdd === 'function')) {
|
|
3318
|
+
_context21.next = 14;
|
|
3507
3319
|
break;
|
|
3508
3320
|
}
|
|
3509
3321
|
writeMethod = 'bulkAdd';
|
|
3510
|
-
|
|
3511
|
-
return
|
|
3322
|
+
_context21.next = 12;
|
|
3323
|
+
return _this21.dbManager.bulkAdd(INDEXDB_STORE_NAME, compactedToWrite);
|
|
3512
3324
|
case 12:
|
|
3513
|
-
|
|
3325
|
+
_context21.next = 37;
|
|
3514
3326
|
break;
|
|
3515
3327
|
case 14:
|
|
3516
|
-
if (!(typeof
|
|
3517
|
-
|
|
3328
|
+
if (!(typeof _this21.dbManager.update === 'function')) {
|
|
3329
|
+
_context21.next = 35;
|
|
3518
3330
|
break;
|
|
3519
3331
|
}
|
|
3520
3332
|
writeMethod = 'update';
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3333
|
+
_iterator30 = _createForOfIteratorHelper(compactedToWrite);
|
|
3334
|
+
_context21.prev = 17;
|
|
3335
|
+
_iterator30.s();
|
|
3524
3336
|
case 19:
|
|
3525
|
-
if ((
|
|
3526
|
-
|
|
3337
|
+
if ((_step30 = _iterator30.n()).done) {
|
|
3338
|
+
_context21.next = 25;
|
|
3527
3339
|
break;
|
|
3528
3340
|
}
|
|
3529
|
-
order =
|
|
3530
|
-
|
|
3531
|
-
return
|
|
3341
|
+
order = _step30.value;
|
|
3342
|
+
_context21.next = 23;
|
|
3343
|
+
return _this21.dbManager.update(INDEXDB_STORE_NAME, order);
|
|
3532
3344
|
case 23:
|
|
3533
|
-
|
|
3345
|
+
_context21.next = 19;
|
|
3534
3346
|
break;
|
|
3535
3347
|
case 25:
|
|
3536
|
-
|
|
3348
|
+
_context21.next = 30;
|
|
3537
3349
|
break;
|
|
3538
3350
|
case 27:
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3351
|
+
_context21.prev = 27;
|
|
3352
|
+
_context21.t0 = _context21["catch"](17);
|
|
3353
|
+
_iterator30.e(_context21.t0);
|
|
3542
3354
|
case 30:
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
return
|
|
3355
|
+
_context21.prev = 30;
|
|
3356
|
+
_iterator30.f();
|
|
3357
|
+
return _context21.finish(30);
|
|
3546
3358
|
case 33:
|
|
3547
|
-
|
|
3359
|
+
_context21.next = 37;
|
|
3548
3360
|
break;
|
|
3549
3361
|
case 35:
|
|
3550
3362
|
if (!options.throwOnError) {
|
|
3551
|
-
|
|
3363
|
+
_context21.next = 37;
|
|
3552
3364
|
break;
|
|
3553
3365
|
}
|
|
3554
3366
|
throw new Error('订单 SQLite 数据库不支持写入');
|
|
3555
3367
|
case 37:
|
|
3556
|
-
|
|
3557
|
-
|
|
3368
|
+
_this21.recordRecentSqliteWrite(source, compactedToWrite);
|
|
3369
|
+
_this21.logInfo('patchOrdersInSQLite-完成', {
|
|
3558
3370
|
source: source,
|
|
3559
3371
|
count: compactedToWrite.length,
|
|
3560
3372
|
writeMethod: writeMethod,
|
|
@@ -3562,32 +3374,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3562
3374
|
});
|
|
3563
3375
|
case 39:
|
|
3564
3376
|
case "end":
|
|
3565
|
-
return
|
|
3377
|
+
return _context21.stop();
|
|
3566
3378
|
}
|
|
3567
|
-
},
|
|
3379
|
+
}, _callee21, null, [[17, 27, 30, 33]]);
|
|
3568
3380
|
})));
|
|
3569
|
-
case
|
|
3570
|
-
|
|
3381
|
+
case 20:
|
|
3382
|
+
_context22.next = 27;
|
|
3571
3383
|
break;
|
|
3572
|
-
case
|
|
3573
|
-
|
|
3574
|
-
|
|
3384
|
+
case 22:
|
|
3385
|
+
_context22.prev = 22;
|
|
3386
|
+
_context22.t0 = _context22["catch"](17);
|
|
3575
3387
|
this.logError('增量保存订单到 SQLite 失败', {
|
|
3576
|
-
error:
|
|
3388
|
+
error: _context22.t0 instanceof Error ? _context22.t0.message : String(_context22.t0),
|
|
3577
3389
|
orderCount: ordersSnapshot.length
|
|
3578
3390
|
});
|
|
3579
3391
|
if (!options.throwOnError) {
|
|
3580
|
-
|
|
3392
|
+
_context22.next = 27;
|
|
3581
3393
|
break;
|
|
3582
3394
|
}
|
|
3583
|
-
throw
|
|
3584
|
-
case
|
|
3395
|
+
throw _context22.t0;
|
|
3396
|
+
case 27:
|
|
3585
3397
|
case "end":
|
|
3586
|
-
return
|
|
3398
|
+
return _context22.stop();
|
|
3587
3399
|
}
|
|
3588
|
-
},
|
|
3400
|
+
}, _callee22, this, [[17, 22]]);
|
|
3589
3401
|
}));
|
|
3590
|
-
function patchOrdersInSQLite(
|
|
3402
|
+
function patchOrdersInSQLite(_x15, _x16) {
|
|
3591
3403
|
return _patchOrdersInSQLite.apply(this, arguments);
|
|
3592
3404
|
}
|
|
3593
3405
|
return patchOrdersInSQLite;
|
|
@@ -3602,128 +3414,128 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3602
3414
|
}, {
|
|
3603
3415
|
key: "updateOrderInSQLite",
|
|
3604
3416
|
value: (function () {
|
|
3605
|
-
var _updateOrderInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3606
|
-
var
|
|
3417
|
+
var _updateOrderInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(order, source) {
|
|
3418
|
+
var _this22 = this;
|
|
3607
3419
|
var options,
|
|
3608
3420
|
orderSnapshot,
|
|
3609
3421
|
_orderSnapshot$order_3,
|
|
3610
|
-
|
|
3611
|
-
return _regeneratorRuntime().wrap(function
|
|
3612
|
-
while (1) switch (
|
|
3422
|
+
_args24 = arguments;
|
|
3423
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
3424
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
3613
3425
|
case 0:
|
|
3614
|
-
options =
|
|
3426
|
+
options = _args24.length > 2 && _args24[2] !== undefined ? _args24[2] : {};
|
|
3615
3427
|
if (this.getOrderStorageKey(order)) {
|
|
3616
|
-
|
|
3428
|
+
_context24.next = 5;
|
|
3617
3429
|
break;
|
|
3618
3430
|
}
|
|
3619
3431
|
if (!options.throwOnError) {
|
|
3620
|
-
|
|
3432
|
+
_context24.next = 4;
|
|
3621
3433
|
break;
|
|
3622
3434
|
}
|
|
3623
3435
|
throw new Error('订单缺少可用的 SQLite 存储主键');
|
|
3624
3436
|
case 4:
|
|
3625
|
-
return
|
|
3437
|
+
return _context24.abrupt("return");
|
|
3626
3438
|
case 5:
|
|
3627
3439
|
if (this.dbManager) {
|
|
3628
|
-
|
|
3440
|
+
_context24.next = 9;
|
|
3629
3441
|
break;
|
|
3630
3442
|
}
|
|
3631
3443
|
if (!options.throwOnError) {
|
|
3632
|
-
|
|
3444
|
+
_context24.next = 8;
|
|
3633
3445
|
break;
|
|
3634
3446
|
}
|
|
3635
3447
|
throw new Error('订单 SQLite 数据库未初始化');
|
|
3636
3448
|
case 8:
|
|
3637
|
-
return
|
|
3449
|
+
return _context24.abrupt("return");
|
|
3638
3450
|
case 9:
|
|
3639
3451
|
orderSnapshot = this.normalizeOrderCollectionsForIngress(cloneDeep(order), "".concat(source, ".sqliteIngress"));
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3452
|
+
_context24.prev = 10;
|
|
3453
|
+
_context24.next = 13;
|
|
3454
|
+
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
3643
3455
|
var _orderSnapshot$order_, _orderSnapshot$order_2;
|
|
3644
3456
|
var writeMethod;
|
|
3645
|
-
return _regeneratorRuntime().wrap(function
|
|
3646
|
-
while (1) switch (
|
|
3457
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
3458
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
3647
3459
|
case 0:
|
|
3648
3460
|
writeMethod = 'none';
|
|
3649
|
-
|
|
3461
|
+
_this22.logInfo('updateOrderInSQLite-开始', {
|
|
3650
3462
|
source: source,
|
|
3651
3463
|
orderId: (_orderSnapshot$order_ = orderSnapshot.order_id) !== null && _orderSnapshot$order_ !== void 0 ? _orderSnapshot$order_ : null,
|
|
3652
|
-
storageKey:
|
|
3464
|
+
storageKey: _this22.getOrderStorageKey(orderSnapshot)
|
|
3653
3465
|
});
|
|
3654
|
-
if (!(typeof
|
|
3655
|
-
|
|
3466
|
+
if (!(typeof _this22.dbManager.update === 'function')) {
|
|
3467
|
+
_context23.next = 8;
|
|
3656
3468
|
break;
|
|
3657
3469
|
}
|
|
3658
3470
|
writeMethod = 'update';
|
|
3659
|
-
|
|
3660
|
-
return
|
|
3471
|
+
_context23.next = 6;
|
|
3472
|
+
return _this22.dbManager.update(INDEXDB_STORE_NAME, orderSnapshot);
|
|
3661
3473
|
case 6:
|
|
3662
|
-
|
|
3474
|
+
_context23.next = 22;
|
|
3663
3475
|
break;
|
|
3664
3476
|
case 8:
|
|
3665
|
-
if (!(typeof
|
|
3666
|
-
|
|
3477
|
+
if (!(typeof _this22.dbManager.bulkUpdate === 'function')) {
|
|
3478
|
+
_context23.next = 14;
|
|
3667
3479
|
break;
|
|
3668
3480
|
}
|
|
3669
3481
|
writeMethod = 'bulkUpdate';
|
|
3670
|
-
|
|
3671
|
-
return
|
|
3482
|
+
_context23.next = 12;
|
|
3483
|
+
return _this22.dbManager.bulkUpdate(INDEXDB_STORE_NAME, [orderSnapshot]);
|
|
3672
3484
|
case 12:
|
|
3673
|
-
|
|
3485
|
+
_context23.next = 22;
|
|
3674
3486
|
break;
|
|
3675
3487
|
case 14:
|
|
3676
|
-
if (!(typeof
|
|
3677
|
-
|
|
3488
|
+
if (!(typeof _this22.dbManager.bulkAdd === 'function')) {
|
|
3489
|
+
_context23.next = 20;
|
|
3678
3490
|
break;
|
|
3679
3491
|
}
|
|
3680
3492
|
writeMethod = 'bulkAdd';
|
|
3681
|
-
|
|
3682
|
-
return
|
|
3493
|
+
_context23.next = 18;
|
|
3494
|
+
return _this22.dbManager.bulkAdd(INDEXDB_STORE_NAME, [orderSnapshot]);
|
|
3683
3495
|
case 18:
|
|
3684
|
-
|
|
3496
|
+
_context23.next = 22;
|
|
3685
3497
|
break;
|
|
3686
3498
|
case 20:
|
|
3687
3499
|
if (!options.throwOnError) {
|
|
3688
|
-
|
|
3500
|
+
_context23.next = 22;
|
|
3689
3501
|
break;
|
|
3690
3502
|
}
|
|
3691
3503
|
throw new Error('订单 SQLite 数据库不支持写入');
|
|
3692
3504
|
case 22:
|
|
3693
|
-
|
|
3694
|
-
|
|
3505
|
+
_this22.recordRecentSqliteWrite(source, [orderSnapshot]);
|
|
3506
|
+
_this22.logInfo('updateOrderInSQLite-完成', {
|
|
3695
3507
|
source: source,
|
|
3696
3508
|
orderId: (_orderSnapshot$order_2 = orderSnapshot.order_id) !== null && _orderSnapshot$order_2 !== void 0 ? _orderSnapshot$order_2 : null,
|
|
3697
3509
|
writeMethod: writeMethod
|
|
3698
3510
|
});
|
|
3699
3511
|
case 24:
|
|
3700
3512
|
case "end":
|
|
3701
|
-
return
|
|
3513
|
+
return _context23.stop();
|
|
3702
3514
|
}
|
|
3703
|
-
},
|
|
3515
|
+
}, _callee23);
|
|
3704
3516
|
})));
|
|
3705
3517
|
case 13:
|
|
3706
|
-
|
|
3518
|
+
_context24.next = 20;
|
|
3707
3519
|
break;
|
|
3708
3520
|
case 15:
|
|
3709
|
-
|
|
3710
|
-
|
|
3521
|
+
_context24.prev = 15;
|
|
3522
|
+
_context24.t0 = _context24["catch"](10);
|
|
3711
3523
|
this.logError('单条保存订单到 SQLite 失败', {
|
|
3712
|
-
error:
|
|
3524
|
+
error: _context24.t0 instanceof Error ? _context24.t0.message : String(_context24.t0),
|
|
3713
3525
|
orderId: (_orderSnapshot$order_3 = orderSnapshot.order_id) !== null && _orderSnapshot$order_3 !== void 0 ? _orderSnapshot$order_3 : null
|
|
3714
3526
|
});
|
|
3715
3527
|
if (!options.throwOnError) {
|
|
3716
|
-
|
|
3528
|
+
_context24.next = 20;
|
|
3717
3529
|
break;
|
|
3718
3530
|
}
|
|
3719
|
-
throw
|
|
3531
|
+
throw _context24.t0;
|
|
3720
3532
|
case 20:
|
|
3721
3533
|
case "end":
|
|
3722
|
-
return
|
|
3534
|
+
return _context24.stop();
|
|
3723
3535
|
}
|
|
3724
|
-
},
|
|
3536
|
+
}, _callee24, this, [[10, 15]]);
|
|
3725
3537
|
}));
|
|
3726
|
-
function updateOrderInSQLite(
|
|
3538
|
+
function updateOrderInSQLite(_x17, _x18) {
|
|
3727
3539
|
return _updateOrderInSQLite.apply(this, arguments);
|
|
3728
3540
|
}
|
|
3729
3541
|
return updateOrderInSQLite;
|
|
@@ -3739,70 +3551,70 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3739
3551
|
}, {
|
|
3740
3552
|
key: "replaceOrdersSnapshotInSQLite",
|
|
3741
3553
|
value: (function () {
|
|
3742
|
-
var _replaceOrdersSnapshotInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3743
|
-
var
|
|
3554
|
+
var _replaceOrdersSnapshotInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(orderList, source) {
|
|
3555
|
+
var _this23 = this;
|
|
3744
3556
|
var protectedOrdersBeforeRemoteFetch,
|
|
3745
3557
|
remoteSnapshot,
|
|
3746
3558
|
mergedSnapshot,
|
|
3747
|
-
|
|
3748
|
-
return _regeneratorRuntime().wrap(function
|
|
3749
|
-
while (1) switch (
|
|
3559
|
+
_args26 = arguments;
|
|
3560
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
3561
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
3750
3562
|
case 0:
|
|
3751
|
-
protectedOrdersBeforeRemoteFetch =
|
|
3563
|
+
protectedOrdersBeforeRemoteFetch = _args26.length > 2 && _args26[2] !== undefined ? _args26[2] : [];
|
|
3752
3564
|
if (this.dbManager) {
|
|
3753
|
-
|
|
3565
|
+
_context26.next = 3;
|
|
3754
3566
|
break;
|
|
3755
3567
|
}
|
|
3756
|
-
return
|
|
3757
|
-
return
|
|
3568
|
+
return _context26.abrupt("return", this.compactOrderListByIdentity(orderList.map(function (order) {
|
|
3569
|
+
return _this23.normalizeRemoteSyncedOrder(order);
|
|
3758
3570
|
}), "".concat(source, ".snapshotNoDb")).list);
|
|
3759
3571
|
case 3:
|
|
3760
3572
|
remoteSnapshot = cloneDeep(orderList).map(function (order) {
|
|
3761
|
-
return
|
|
3573
|
+
return _this23.normalizeOrderCollectionsForIngress(order, "".concat(source, ".remoteIngress"));
|
|
3762
3574
|
});
|
|
3763
3575
|
mergedSnapshot = this.compactOrderListByIdentity(remoteSnapshot.map(function (order) {
|
|
3764
|
-
return
|
|
3576
|
+
return _this23.normalizeRemoteSyncedOrder(order);
|
|
3765
3577
|
}), "".concat(source, ".remoteSnapshot")).list;
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3769
|
-
var existingOrders, protectedLocalOrders,
|
|
3770
|
-
return _regeneratorRuntime().wrap(function
|
|
3771
|
-
while (1) switch (
|
|
3578
|
+
_context26.prev = 5;
|
|
3579
|
+
_context26.next = 8;
|
|
3580
|
+
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
3581
|
+
var existingOrders, protectedLocalOrders, _iterator31, _step31, rawCurrentOrder, currentOrder, protectedIndex, currentNeedsProtection, orderListSnapshot;
|
|
3582
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
3583
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
3772
3584
|
case 0:
|
|
3773
|
-
if (!(typeof
|
|
3774
|
-
|
|
3585
|
+
if (!(typeof _this23.dbManager.getAll === 'function')) {
|
|
3586
|
+
_context25.next = 6;
|
|
3775
3587
|
break;
|
|
3776
3588
|
}
|
|
3777
|
-
|
|
3778
|
-
return
|
|
3589
|
+
_context25.next = 3;
|
|
3590
|
+
return _this23.dbManager.getAll(INDEXDB_STORE_NAME);
|
|
3779
3591
|
case 3:
|
|
3780
|
-
|
|
3781
|
-
|
|
3592
|
+
_context25.t0 = _context25.sent;
|
|
3593
|
+
_context25.next = 7;
|
|
3782
3594
|
break;
|
|
3783
3595
|
case 6:
|
|
3784
|
-
|
|
3596
|
+
_context25.t0 = [];
|
|
3785
3597
|
case 7:
|
|
3786
|
-
existingOrders =
|
|
3598
|
+
existingOrders = _context25.t0;
|
|
3787
3599
|
protectedLocalOrders = protectedOrdersBeforeRemoteFetch.map(function (order) {
|
|
3788
|
-
return
|
|
3600
|
+
return _this23.normalizeOrderCollectionsForIngress(order, "".concat(source, ".protectedBeforeRemoteFetch"));
|
|
3789
3601
|
}).filter(function (order) {
|
|
3790
|
-
return
|
|
3602
|
+
return _this23.shouldProtectLocalOrderFromRemoteSnapshot(order);
|
|
3791
3603
|
});
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3604
|
+
_iterator31 = _createForOfIteratorHelper(existingOrders || []);
|
|
3605
|
+
_context25.prev = 10;
|
|
3606
|
+
_iterator31.s();
|
|
3795
3607
|
case 12:
|
|
3796
|
-
if ((
|
|
3797
|
-
|
|
3608
|
+
if ((_step31 = _iterator31.n()).done) {
|
|
3609
|
+
_context25.next = 23;
|
|
3798
3610
|
break;
|
|
3799
3611
|
}
|
|
3800
|
-
rawCurrentOrder =
|
|
3801
|
-
currentOrder =
|
|
3802
|
-
protectedIndex =
|
|
3803
|
-
currentNeedsProtection =
|
|
3612
|
+
rawCurrentOrder = _step31.value;
|
|
3613
|
+
currentOrder = _this23.normalizeOrderCollectionsForIngress(rawCurrentOrder, "".concat(source, ".currentSQLite"));
|
|
3614
|
+
protectedIndex = _this23.findOrderIndexByIdentity(protectedLocalOrders, currentOrder);
|
|
3615
|
+
currentNeedsProtection = _this23.shouldProtectLocalOrderFromRemoteSnapshot(currentOrder);
|
|
3804
3616
|
if (!(protectedIndex >= 0)) {
|
|
3805
|
-
|
|
3617
|
+
_context25.next = 20;
|
|
3806
3618
|
break;
|
|
3807
3619
|
}
|
|
3808
3620
|
if (currentNeedsProtection) {
|
|
@@ -3810,27 +3622,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3810
3622
|
} else {
|
|
3811
3623
|
protectedLocalOrders.splice(protectedIndex, 1);
|
|
3812
3624
|
}
|
|
3813
|
-
return
|
|
3625
|
+
return _context25.abrupt("continue", 21);
|
|
3814
3626
|
case 20:
|
|
3815
3627
|
if (currentNeedsProtection) protectedLocalOrders.push(currentOrder);
|
|
3816
3628
|
case 21:
|
|
3817
|
-
|
|
3629
|
+
_context25.next = 12;
|
|
3818
3630
|
break;
|
|
3819
3631
|
case 23:
|
|
3820
|
-
|
|
3632
|
+
_context25.next = 28;
|
|
3821
3633
|
break;
|
|
3822
3634
|
case 25:
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3635
|
+
_context25.prev = 25;
|
|
3636
|
+
_context25.t1 = _context25["catch"](10);
|
|
3637
|
+
_iterator31.e(_context25.t1);
|
|
3826
3638
|
case 28:
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
return
|
|
3639
|
+
_context25.prev = 28;
|
|
3640
|
+
_iterator31.f();
|
|
3641
|
+
return _context25.finish(28);
|
|
3830
3642
|
case 31:
|
|
3831
|
-
orderListSnapshot =
|
|
3832
|
-
mergedSnapshot =
|
|
3833
|
-
|
|
3643
|
+
orderListSnapshot = _this23.mergeRemoteSnapshotWithPendingOrders(remoteSnapshot, protectedLocalOrders);
|
|
3644
|
+
mergedSnapshot = _this23.compactOrderListByIdentity(orderListSnapshot, "".concat(source, ".sqliteSnapshot")).list;
|
|
3645
|
+
_this23.logInfo('replaceOrdersSnapshotInSQLite-开始', {
|
|
3834
3646
|
source: source,
|
|
3835
3647
|
count: mergedSnapshot.length,
|
|
3836
3648
|
remoteCount: remoteSnapshot.length,
|
|
@@ -3838,10 +3650,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3838
3650
|
protectedLocalOrderCount: protectedLocalOrders.length,
|
|
3839
3651
|
preservedLocalUnsyncedCount: mergedSnapshot.length - remoteSnapshot.length,
|
|
3840
3652
|
protectedPendingPaymentCount: protectedLocalOrders.reduce(function (count, order) {
|
|
3841
|
-
return count +
|
|
3653
|
+
return count + _this23.getIdentifiedPendingPayments(order).length;
|
|
3842
3654
|
}, 0),
|
|
3843
3655
|
protectedPendingPaymentIdentities: protectedLocalOrders.flatMap(function (order) {
|
|
3844
|
-
return
|
|
3656
|
+
return _this23.getIdentifiedPendingPayments(order).map(function (payment) {
|
|
3845
3657
|
var _order$order_id5, _external_sale_number5;
|
|
3846
3658
|
return {
|
|
3847
3659
|
order_id: (_order$order_id5 = order.order_id) !== null && _order$order_id5 !== void 0 ? _order$order_id5 : null,
|
|
@@ -3851,51 +3663,51 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3851
3663
|
});
|
|
3852
3664
|
})
|
|
3853
3665
|
});
|
|
3854
|
-
|
|
3855
|
-
return
|
|
3666
|
+
_context25.next = 36;
|
|
3667
|
+
return _this23.dbManager.clear(INDEXDB_STORE_NAME);
|
|
3856
3668
|
case 36:
|
|
3857
|
-
|
|
3669
|
+
_this23.logInfo('replaceOrdersSnapshotInSQLite-clear完成', {
|
|
3858
3670
|
count: mergedSnapshot.length
|
|
3859
3671
|
});
|
|
3860
3672
|
if (!(mergedSnapshot.length === 0)) {
|
|
3861
|
-
|
|
3673
|
+
_context25.next = 39;
|
|
3862
3674
|
break;
|
|
3863
3675
|
}
|
|
3864
|
-
return
|
|
3676
|
+
return _context25.abrupt("return");
|
|
3865
3677
|
case 39:
|
|
3866
|
-
|
|
3867
|
-
return
|
|
3678
|
+
_context25.next = 41;
|
|
3679
|
+
return _this23.dbManager.bulkAdd(INDEXDB_STORE_NAME, mergedSnapshot);
|
|
3868
3680
|
case 41:
|
|
3869
|
-
|
|
3870
|
-
|
|
3681
|
+
_this23.recordRecentSqliteWrite(source, mergedSnapshot);
|
|
3682
|
+
_this23.logInfo('replaceOrdersSnapshotInSQLite-bulkAdd完成', {
|
|
3871
3683
|
source: source,
|
|
3872
3684
|
count: mergedSnapshot.length
|
|
3873
3685
|
});
|
|
3874
3686
|
case 43:
|
|
3875
3687
|
case "end":
|
|
3876
|
-
return
|
|
3688
|
+
return _context25.stop();
|
|
3877
3689
|
}
|
|
3878
|
-
},
|
|
3690
|
+
}, _callee25, null, [[10, 25, 28, 31]]);
|
|
3879
3691
|
})));
|
|
3880
3692
|
case 8:
|
|
3881
|
-
|
|
3693
|
+
_context26.next = 13;
|
|
3882
3694
|
break;
|
|
3883
3695
|
case 10:
|
|
3884
|
-
|
|
3885
|
-
|
|
3696
|
+
_context26.prev = 10;
|
|
3697
|
+
_context26.t0 = _context26["catch"](5);
|
|
3886
3698
|
this.logError('全量保存订单到 SQLite 失败', {
|
|
3887
|
-
error:
|
|
3699
|
+
error: _context26.t0 instanceof Error ? _context26.t0.message : String(_context26.t0),
|
|
3888
3700
|
orderList: remoteSnapshot.length
|
|
3889
3701
|
});
|
|
3890
3702
|
case 13:
|
|
3891
|
-
return
|
|
3703
|
+
return _context26.abrupt("return", mergedSnapshot);
|
|
3892
3704
|
case 14:
|
|
3893
3705
|
case "end":
|
|
3894
|
-
return
|
|
3706
|
+
return _context26.stop();
|
|
3895
3707
|
}
|
|
3896
|
-
},
|
|
3708
|
+
}, _callee26, this, [[5, 10]]);
|
|
3897
3709
|
}));
|
|
3898
|
-
function replaceOrdersSnapshotInSQLite(
|
|
3710
|
+
function replaceOrdersSnapshotInSQLite(_x19, _x20) {
|
|
3899
3711
|
return _replaceOrdersSnapshotInSQLite.apply(this, arguments);
|
|
3900
3712
|
}
|
|
3901
3713
|
return replaceOrdersSnapshotInSQLite;
|
|
@@ -3910,38 +3722,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3910
3722
|
}, {
|
|
3911
3723
|
key: "clear",
|
|
3912
3724
|
value: (function () {
|
|
3913
|
-
var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3914
|
-
var
|
|
3915
|
-
return _regeneratorRuntime().wrap(function
|
|
3916
|
-
while (1) switch (
|
|
3725
|
+
var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
3726
|
+
var _this24 = this;
|
|
3727
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
3728
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
3917
3729
|
case 0:
|
|
3918
3730
|
this.store.list = [];
|
|
3919
3731
|
this.store.map = new Map();
|
|
3920
3732
|
if (!this.dbManager) {
|
|
3921
|
-
|
|
3733
|
+
_context28.next = 5;
|
|
3922
3734
|
break;
|
|
3923
3735
|
}
|
|
3924
|
-
|
|
3925
|
-
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3926
|
-
return _regeneratorRuntime().wrap(function
|
|
3927
|
-
while (1) switch (
|
|
3736
|
+
_context28.next = 5;
|
|
3737
|
+
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
3738
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
3739
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
3928
3740
|
case 0:
|
|
3929
|
-
|
|
3930
|
-
return
|
|
3741
|
+
_context27.next = 2;
|
|
3742
|
+
return _this24.dbManager.clear(INDEXDB_STORE_NAME);
|
|
3931
3743
|
case 2:
|
|
3932
3744
|
case "end":
|
|
3933
|
-
return
|
|
3745
|
+
return _context27.stop();
|
|
3934
3746
|
}
|
|
3935
|
-
},
|
|
3747
|
+
}, _callee27);
|
|
3936
3748
|
})));
|
|
3937
3749
|
case 5:
|
|
3938
3750
|
this.setStorageItem(ORDER_LAST_FULL_FETCH_AT_STORAGE_KEY, '');
|
|
3939
3751
|
this.emitOrdersChanged([], 'clear');
|
|
3940
3752
|
case 7:
|
|
3941
3753
|
case "end":
|
|
3942
|
-
return
|
|
3754
|
+
return _context28.stop();
|
|
3943
3755
|
}
|
|
3944
|
-
},
|
|
3756
|
+
}, _callee28, this);
|
|
3945
3757
|
}));
|
|
3946
3758
|
function clear() {
|
|
3947
3759
|
return _clear.apply(this, arguments);
|