@pisell/pisellos 2.2.191 → 2.2.192
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/server/modules/order/index.d.ts +1 -68
- package/dist/server/modules/order/index.js +334 -761
- package/dist/server/modules/products/index.d.ts +0 -57
- package/dist/server/modules/products/index.js +347 -706
- package/lib/server/modules/order/index.d.ts +1 -68
- package/lib/server/modules/order/index.js +6 -376
- package/lib/server/modules/products/index.d.ts +0 -57
- package/lib/server/modules/products/index.js +0 -333
- package/package.json +1 -1
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
1
|
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; }
|
|
3
2
|
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; }
|
|
4
|
-
function
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
5
4
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
5
|
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."); }
|
|
7
6
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
7
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
9
|
-
function
|
|
10
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
+
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; } } }; }
|
|
11
9
|
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); }
|
|
12
10
|
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 _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
14
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
11
|
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
12
|
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
13
|
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); }); }; }
|
|
@@ -42,11 +38,6 @@ var INDEXDB_STORE_NAME = 'orders';
|
|
|
42
38
|
var ORDER_LAST_FULL_FETCH_AT_STORAGE_KEY = 'server_order_last_full_fetch_at';
|
|
43
39
|
var ORDER_SYNC_THROTTLE_MS_STORAGE_KEY = 'order_sync_throttle_ms';
|
|
44
40
|
var DEFAULT_ORDER_SYNC_THROTTLE_MS = 2000;
|
|
45
|
-
/** window 上挂载的订单流程调试日志 key */
|
|
46
|
-
var ORDER_FLOW_LOG_WINDOW_KEY = '__orderModuleFlowLogs';
|
|
47
|
-
/** window 上按订单聚合的 SQLite 写入统计 key */
|
|
48
|
-
var ORDER_WRITE_STATS_WINDOW_KEY = '__orderModuleWriteStats';
|
|
49
|
-
var ORDER_FLOW_LOG_MAX_LENGTH = 1000;
|
|
50
41
|
/** pubsub 回声写入去重窗口:业务 API 刚写入后,跳过同单 SQLite patch */
|
|
51
42
|
var ORDER_SQLITE_DEDUPE_MS = 15000;
|
|
52
43
|
/** silentRefresh 最小间隔,避免 preload 后立即全量重拉 */
|
|
@@ -54,10 +45,6 @@ var ORDER_SILENT_REFRESH_MIN_INTERVAL_MS = 30000;
|
|
|
54
45
|
/** 视为「业务侧刚写入」的来源,pubsub 回声可跳过 SQLite */
|
|
55
46
|
var ORDER_BUSINESS_WRITE_SOURCES = new Set(['upsertOrdersFromRemote', 'overwriteExistingOrder']);
|
|
56
47
|
|
|
57
|
-
/** 订单模块流程调试日志条目 */
|
|
58
|
-
|
|
59
|
-
/** 单笔订单 SQLite 写入记录 */
|
|
60
|
-
|
|
61
48
|
/**
|
|
62
49
|
* Order 模块 - 基础框架
|
|
63
50
|
*/
|
|
@@ -83,8 +70,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
83
70
|
// LoggerManager 实例
|
|
84
71
|
_defineProperty(_assertThisInitialized(_this), "storage", void 0);
|
|
85
72
|
_defineProperty(_assertThisInitialized(_this), "orderSQLiteSaveQueue", Promise.resolve());
|
|
86
|
-
/** 全局递增的 SQLite 写入序号,便于日志关联同一次操作 */
|
|
87
|
-
_defineProperty(_assertThisInitialized(_this), "orderFlowWriteSeq", 0);
|
|
88
73
|
/** 按 storageKey 记录最近一次 SQLite 写入来源与时间,用于去重 */
|
|
89
74
|
_defineProperty(_assertThisInitialized(_this), "recentSqliteWriteByStorageKey", new Map());
|
|
90
75
|
/** 最近一次 SSE 全量拉取完成时间 */
|
|
@@ -151,21 +136,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
151
136
|
this.store.list = [];
|
|
152
137
|
this.store.map = new Map();
|
|
153
138
|
}
|
|
154
|
-
this.initOrderFlowLogs();
|
|
155
139
|
this.initOrderDataSource();
|
|
156
140
|
this.setupOrderSync();
|
|
157
|
-
this.pushOrderFlowLog('initialize.complete', {
|
|
158
|
-
hasDbManager: !!this.dbManager,
|
|
159
|
-
hasLogger: !!this.logger,
|
|
160
|
-
initialOrderCount: this.store.list.length,
|
|
161
|
-
createdAtQuery: this.store.createdAtQuery || null
|
|
162
|
-
});
|
|
163
141
|
this.logInfo('OrderServer模块初始化完成', {
|
|
164
142
|
hasDbManager: !!this.dbManager,
|
|
165
143
|
hasLogger: !!this.logger,
|
|
166
144
|
initialOrderCount: this.store.list.length
|
|
167
145
|
});
|
|
168
|
-
case
|
|
146
|
+
case 10:
|
|
169
147
|
case "end":
|
|
170
148
|
return _context.stop();
|
|
171
149
|
}
|
|
@@ -216,171 +194,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
216
194
|
} catch (_unused2) {
|
|
217
195
|
// 日志记录失败不影响主流程
|
|
218
196
|
}
|
|
219
|
-
this.pushOrderFlowLog("error.".concat(title), metadata);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* 初始化 window 上的订单流程调试日志数组及辅助方法。
|
|
224
|
-
*
|
|
225
|
-
* @example
|
|
226
|
-
* window.clearOrderModuleFlowLogs()
|
|
227
|
-
* // 操作完成后:
|
|
228
|
-
* copy(window.exportOrderModuleFlowLogs?.() || '[]')
|
|
229
|
-
*/
|
|
230
|
-
}, {
|
|
231
|
-
key: "initOrderFlowLogs",
|
|
232
|
-
value: function initOrderFlowLogs() {
|
|
233
|
-
var _this2 = this;
|
|
234
|
-
try {
|
|
235
|
-
var win = typeof globalThis !== 'undefined' ? globalThis.window : undefined;
|
|
236
|
-
if (!win) return;
|
|
237
|
-
win[ORDER_FLOW_LOG_WINDOW_KEY] = [];
|
|
238
|
-
win[ORDER_WRITE_STATS_WINDOW_KEY] = {};
|
|
239
|
-
win.clearOrderModuleFlowLogs = function () {
|
|
240
|
-
win[ORDER_FLOW_LOG_WINDOW_KEY] = [];
|
|
241
|
-
win[ORDER_WRITE_STATS_WINDOW_KEY] = {};
|
|
242
|
-
_this2.orderFlowWriteSeq = 0;
|
|
243
|
-
_this2.recentSqliteWriteByStorageKey.clear();
|
|
244
|
-
_this2.lastServerFullFetchAtMs = 0;
|
|
245
|
-
_this2.pushOrderFlowLog('debug.clear', {});
|
|
246
|
-
};
|
|
247
|
-
win.exportOrderModuleFlowLogs = function () {
|
|
248
|
-
var logs = win[ORDER_FLOW_LOG_WINDOW_KEY] || [];
|
|
249
|
-
return JSON.stringify(logs, null, 2);
|
|
250
|
-
};
|
|
251
|
-
win.exportOrderModuleWriteStats = function () {
|
|
252
|
-
var stats = win[ORDER_WRITE_STATS_WINDOW_KEY] || {};
|
|
253
|
-
return JSON.stringify(stats, null, 2);
|
|
254
|
-
};
|
|
255
|
-
win.summarizeOrderModuleWrites = function () {
|
|
256
|
-
var topN = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 20;
|
|
257
|
-
var stats = win[ORDER_WRITE_STATS_WINDOW_KEY] || {};
|
|
258
|
-
return Object.entries(stats).map(function (_ref) {
|
|
259
|
-
var _last$orderId;
|
|
260
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
261
|
-
storageKey = _ref2[0],
|
|
262
|
-
entries = _ref2[1];
|
|
263
|
-
var list = entries || [];
|
|
264
|
-
var sources = _toConsumableArray(new Set(list.map(function (item) {
|
|
265
|
-
return item.source;
|
|
266
|
-
})));
|
|
267
|
-
var last = list[list.length - 1];
|
|
268
|
-
return {
|
|
269
|
-
storageKey: storageKey,
|
|
270
|
-
orderId: (_last$orderId = last === null || last === void 0 ? void 0 : last.orderId) !== null && _last$orderId !== void 0 ? _last$orderId : null,
|
|
271
|
-
writeCount: list.length,
|
|
272
|
-
sources: sources,
|
|
273
|
-
lastWriteAt: (last === null || last === void 0 ? void 0 : last.ts) || ''
|
|
274
|
-
};
|
|
275
|
-
}).sort(function (a, b) {
|
|
276
|
-
return b.writeCount - a.writeCount;
|
|
277
|
-
}).slice(0, topN);
|
|
278
|
-
};
|
|
279
|
-
this.pushOrderFlowLog('debug.init', {
|
|
280
|
-
logKey: ORDER_FLOW_LOG_WINDOW_KEY,
|
|
281
|
-
writeStatsKey: ORDER_WRITE_STATS_WINDOW_KEY,
|
|
282
|
-
helpers: ['clearOrderModuleFlowLogs', 'exportOrderModuleFlowLogs', 'exportOrderModuleWriteStats', 'summarizeOrderModuleWrites']
|
|
283
|
-
});
|
|
284
|
-
} catch (_unused3) {
|
|
285
|
-
// window 不可用时忽略
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* 写入 window 订单流程调试日志。
|
|
291
|
-
*
|
|
292
|
-
* @example
|
|
293
|
-
* this.pushOrderFlowLog('mergeOrdersToStore.start', { count: 3 })
|
|
294
|
-
*/
|
|
295
|
-
}, {
|
|
296
|
-
key: "pushOrderFlowLog",
|
|
297
|
-
value: function pushOrderFlowLog(step, metadata) {
|
|
298
|
-
try {
|
|
299
|
-
var win = typeof globalThis !== 'undefined' ? globalThis.window : undefined;
|
|
300
|
-
if (!win) return;
|
|
301
|
-
if (!Array.isArray(win[ORDER_FLOW_LOG_WINDOW_KEY])) {
|
|
302
|
-
win[ORDER_FLOW_LOG_WINDOW_KEY] = [];
|
|
303
|
-
}
|
|
304
|
-
var entry = {
|
|
305
|
-
ts: new Date().toISOString(),
|
|
306
|
-
step: step,
|
|
307
|
-
metadata: metadata || {}
|
|
308
|
-
};
|
|
309
|
-
win[ORDER_FLOW_LOG_WINDOW_KEY].push(entry);
|
|
310
|
-
var logs = win[ORDER_FLOW_LOG_WINDOW_KEY];
|
|
311
|
-
if (logs.length > ORDER_FLOW_LOG_MAX_LENGTH) {
|
|
312
|
-
logs.splice(0, logs.length - ORDER_FLOW_LOG_MAX_LENGTH);
|
|
313
|
-
}
|
|
314
|
-
console.log("[OrderFlow] ".concat(step), metadata || {});
|
|
315
|
-
} catch (_unused4) {
|
|
316
|
-
// 调试日志失败不影响主流程
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
/** 当前内存 store 快照信息,供流程日志使用 */
|
|
321
|
-
}, {
|
|
322
|
-
key: "getOrderStoreSnapshot",
|
|
323
|
-
value: function getOrderStoreSnapshot() {
|
|
324
|
-
return {
|
|
325
|
-
storeListCount: this.store.list.length,
|
|
326
|
-
storeMapCount: this.store.map.size,
|
|
327
|
-
pendingSyncCount: this.pendingSyncMessages.length,
|
|
328
|
-
isProcessingSyncBatch: this.isProcessingSyncBatch,
|
|
329
|
-
isIdlePhase: this.isIdlePhase
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* 记录一次 SQLite 写入到 window 统计,用于排查同一订单被多次写入的原因。
|
|
335
|
-
*
|
|
336
|
-
* @example
|
|
337
|
-
* this.trackOrderWrite('upsertOrdersFromRemote', 'bulkUpdate', orders, 'insert')
|
|
338
|
-
*/
|
|
339
|
-
}, {
|
|
340
|
-
key: "trackOrderWrite",
|
|
341
|
-
value: function trackOrderWrite(source, writeMethod, orders) {
|
|
342
|
-
var mergeActions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
343
|
-
var defaultMergeAction = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'update';
|
|
344
|
-
this.orderFlowWriteSeq += 1;
|
|
345
|
-
var writeSeq = this.orderFlowWriteSeq;
|
|
346
|
-
try {
|
|
347
|
-
var win = typeof globalThis !== 'undefined' ? globalThis.window : undefined;
|
|
348
|
-
if (!win) return writeSeq;
|
|
349
|
-
if (!win[ORDER_WRITE_STATS_WINDOW_KEY]) {
|
|
350
|
-
win[ORDER_WRITE_STATS_WINDOW_KEY] = {};
|
|
351
|
-
}
|
|
352
|
-
var stats = win[ORDER_WRITE_STATS_WINDOW_KEY];
|
|
353
|
-
var _iterator = _createForOfIteratorHelper(orders),
|
|
354
|
-
_step;
|
|
355
|
-
try {
|
|
356
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
357
|
-
var _order$order_id;
|
|
358
|
-
var order = _step.value;
|
|
359
|
-
var storageKey = this.getOrderStorageKey(order);
|
|
360
|
-
if (!storageKey) continue;
|
|
361
|
-
var orderKey = order.order_id !== undefined && order.order_id !== null ? this.getIdKey(order.order_id) : '';
|
|
362
|
-
var mergeAction = orderKey && mergeActions[orderKey] || defaultMergeAction;
|
|
363
|
-
var entry = {
|
|
364
|
-
ts: new Date().toISOString(),
|
|
365
|
-
writeSeq: writeSeq,
|
|
366
|
-
source: source,
|
|
367
|
-
writeMethod: writeMethod,
|
|
368
|
-
orderId: (_order$order_id = order.order_id) !== null && _order$order_id !== void 0 ? _order$order_id : null,
|
|
369
|
-
storageKey: storageKey,
|
|
370
|
-
mergeAction: mergeAction
|
|
371
|
-
};
|
|
372
|
-
if (!stats[storageKey]) stats[storageKey] = [];
|
|
373
|
-
stats[storageKey].push(entry);
|
|
374
|
-
}
|
|
375
|
-
} catch (err) {
|
|
376
|
-
_iterator.e(err);
|
|
377
|
-
} finally {
|
|
378
|
-
_iterator.f();
|
|
379
|
-
}
|
|
380
|
-
} catch (_unused5) {
|
|
381
|
-
// 统计失败不影响主流程
|
|
382
|
-
}
|
|
383
|
-
return writeSeq;
|
|
384
197
|
}
|
|
385
198
|
|
|
386
199
|
/**
|
|
@@ -393,11 +206,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
393
206
|
key: "recordRecentSqliteWrite",
|
|
394
207
|
value: function recordRecentSqliteWrite(source, orders) {
|
|
395
208
|
var now = Date.now();
|
|
396
|
-
var
|
|
397
|
-
|
|
209
|
+
var _iterator = _createForOfIteratorHelper(orders),
|
|
210
|
+
_step;
|
|
398
211
|
try {
|
|
399
|
-
for (
|
|
400
|
-
var order =
|
|
212
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
213
|
+
var order = _step.value;
|
|
401
214
|
var storageKey = this.getOrderStorageKey(order);
|
|
402
215
|
if (!storageKey) continue;
|
|
403
216
|
this.recentSqliteWriteByStorageKey.set(storageKey, {
|
|
@@ -406,9 +219,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
406
219
|
});
|
|
407
220
|
}
|
|
408
221
|
} catch (err) {
|
|
409
|
-
|
|
222
|
+
_iterator.e(err);
|
|
410
223
|
} finally {
|
|
411
|
-
|
|
224
|
+
_iterator.f();
|
|
412
225
|
}
|
|
413
226
|
}
|
|
414
227
|
|
|
@@ -431,11 +244,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
431
244
|
var now = Date.now();
|
|
432
245
|
var toWrite = [];
|
|
433
246
|
var skipped = [];
|
|
434
|
-
var
|
|
435
|
-
|
|
247
|
+
var _iterator2 = _createForOfIteratorHelper(orders),
|
|
248
|
+
_step2;
|
|
436
249
|
try {
|
|
437
|
-
for (
|
|
438
|
-
var order =
|
|
250
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
251
|
+
var order = _step2.value;
|
|
439
252
|
var storageKey = this.getOrderStorageKey(order);
|
|
440
253
|
if (!storageKey) {
|
|
441
254
|
toWrite.push(order);
|
|
@@ -451,9 +264,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
451
264
|
}
|
|
452
265
|
var recent = this.recentSqliteWriteByStorageKey.get(storageKey);
|
|
453
266
|
if (recent && ORDER_BUSINESS_WRITE_SOURCES.has(recent.source) && now - recent.ts < ORDER_SQLITE_DEDUPE_MS) {
|
|
454
|
-
var _order$
|
|
267
|
+
var _order$order_id;
|
|
455
268
|
skipped.push({
|
|
456
|
-
orderId: (_order$
|
|
269
|
+
orderId: (_order$order_id = order.order_id) !== null && _order$order_id !== void 0 ? _order$order_id : null,
|
|
457
270
|
storageKey: storageKey,
|
|
458
271
|
reason: 'skip_pubsub_echo_after_business_write',
|
|
459
272
|
lastSource: recent.source,
|
|
@@ -464,9 +277,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
464
277
|
toWrite.push(order);
|
|
465
278
|
}
|
|
466
279
|
} catch (err) {
|
|
467
|
-
|
|
280
|
+
_iterator2.e(err);
|
|
468
281
|
} finally {
|
|
469
|
-
|
|
282
|
+
_iterator2.f();
|
|
470
283
|
}
|
|
471
284
|
return {
|
|
472
285
|
toWrite: toWrite,
|
|
@@ -486,11 +299,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
486
299
|
var now = Date.now();
|
|
487
300
|
var toFetch = [];
|
|
488
301
|
var skipped = [];
|
|
489
|
-
var
|
|
490
|
-
|
|
302
|
+
var _iterator3 = _createForOfIteratorHelper(ids),
|
|
303
|
+
_step3;
|
|
491
304
|
try {
|
|
492
|
-
for (
|
|
493
|
-
var id =
|
|
305
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
306
|
+
var id = _step3.value;
|
|
494
307
|
var existing = this.getOrderByOrderId(id);
|
|
495
308
|
if (!existing) {
|
|
496
309
|
toFetch.push(id);
|
|
@@ -509,9 +322,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
509
322
|
toFetch.push(id);
|
|
510
323
|
}
|
|
511
324
|
} catch (err) {
|
|
512
|
-
|
|
325
|
+
_iterator3.e(err);
|
|
513
326
|
} finally {
|
|
514
|
-
|
|
327
|
+
_iterator3.f();
|
|
515
328
|
}
|
|
516
329
|
return {
|
|
517
330
|
toFetch: toFetch,
|
|
@@ -606,12 +419,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
606
419
|
key: "preload",
|
|
607
420
|
value: function () {
|
|
608
421
|
var _preload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
609
|
-
var
|
|
422
|
+
var _this2 = this;
|
|
610
423
|
var getData;
|
|
611
424
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
612
425
|
while (1) switch (_context3.prev = _context3.next) {
|
|
613
426
|
case 0:
|
|
614
|
-
this.pushOrderFlowLog('preload.start', this.getOrderStoreSnapshot());
|
|
615
427
|
// const hasPulledInCurrentWindow = this.hasPulledOrdersToday()
|
|
616
428
|
// // 仅当缓存属于当前统计窗口时才直接复用,避免跨天/跨营业日窗口继续使用旧数据
|
|
617
429
|
// if (cachedOrders.length > 0 && hasPulledInCurrentWindow) {
|
|
@@ -620,7 +432,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
620
432
|
// this.core.effects.emit(OrderHooks.onOrdersChanged, this.store.list)
|
|
621
433
|
// return
|
|
622
434
|
// }
|
|
623
|
-
|
|
624
435
|
// if (hasPulledInCurrentWindow) {
|
|
625
436
|
// this.logInfo('当天已完成全量订单拉取,跳过本次全量拉取', {
|
|
626
437
|
// lastFullFetchAt: this.getStorageItem(ORDER_LAST_FULL_FETCH_AT_STORAGE_KEY),
|
|
@@ -628,45 +439,41 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
628
439
|
// return
|
|
629
440
|
// }
|
|
630
441
|
getData = /*#__PURE__*/function () {
|
|
631
|
-
var
|
|
442
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
632
443
|
var orders;
|
|
633
444
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
634
445
|
while (1) switch (_context2.prev = _context2.next) {
|
|
635
446
|
case 0:
|
|
636
447
|
_context2.next = 2;
|
|
637
|
-
return
|
|
448
|
+
return _this2.loadOrdersByServer();
|
|
638
449
|
case 2:
|
|
639
450
|
orders = _context2.sent;
|
|
640
451
|
if (!(orders.length === 0)) {
|
|
641
|
-
_context2.next =
|
|
452
|
+
_context2.next = 5;
|
|
642
453
|
break;
|
|
643
454
|
}
|
|
644
|
-
_this3.pushOrderFlowLog('preload.empty', _this3.getOrderStoreSnapshot());
|
|
645
455
|
return _context2.abrupt("return");
|
|
646
|
-
case
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
loadedCount: orders.length
|
|
653
|
-
}));
|
|
654
|
-
case 11:
|
|
456
|
+
case 5:
|
|
457
|
+
_this2.store.list = cloneDeep(orders);
|
|
458
|
+
_this2.syncOrdersMap();
|
|
459
|
+
_this2.core.effects.emit(OrderHooks.onOrdersChanged, _this2.store.list);
|
|
460
|
+
_this2.core.effects.emit(OrderHooks.onOrdersSyncCompleted, null);
|
|
461
|
+
case 9:
|
|
655
462
|
case "end":
|
|
656
463
|
return _context2.stop();
|
|
657
464
|
}
|
|
658
465
|
}, _callee2);
|
|
659
466
|
}));
|
|
660
467
|
return function getData() {
|
|
661
|
-
return
|
|
468
|
+
return _ref.apply(this, arguments);
|
|
662
469
|
};
|
|
663
470
|
}();
|
|
664
471
|
getData();
|
|
665
|
-
case
|
|
472
|
+
case 2:
|
|
666
473
|
case "end":
|
|
667
474
|
return _context3.stop();
|
|
668
475
|
}
|
|
669
|
-
}, _callee3
|
|
476
|
+
}, _callee3);
|
|
670
477
|
}));
|
|
671
478
|
function preload() {
|
|
672
479
|
return _preload.apply(this, arguments);
|
|
@@ -694,7 +501,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
694
501
|
key: "getLocalOrderByOrderId",
|
|
695
502
|
value: function () {
|
|
696
503
|
var _getLocalOrderByOrderId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(orderId) {
|
|
697
|
-
var
|
|
504
|
+
var _this3 = this;
|
|
698
505
|
var key, memoryOrder, orders, localOrder;
|
|
699
506
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
700
507
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -702,40 +509,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
702
509
|
key = this.getIdKey(orderId);
|
|
703
510
|
memoryOrder = this.store.map.get(key);
|
|
704
511
|
if (!memoryOrder) {
|
|
705
|
-
_context4.next =
|
|
512
|
+
_context4.next = 4;
|
|
706
513
|
break;
|
|
707
514
|
}
|
|
708
|
-
this.pushOrderFlowLog('getLocalOrderByOrderId.hitMemory', {
|
|
709
|
-
orderId: orderId,
|
|
710
|
-
key: key
|
|
711
|
-
});
|
|
712
515
|
return _context4.abrupt("return", memoryOrder);
|
|
713
|
-
case
|
|
714
|
-
|
|
715
|
-
orderId: orderId,
|
|
716
|
-
key: key
|
|
717
|
-
});
|
|
718
|
-
_context4.next = 8;
|
|
516
|
+
case 4:
|
|
517
|
+
_context4.next = 6;
|
|
719
518
|
return this.loadOrdersFromSQLite();
|
|
720
|
-
case
|
|
519
|
+
case 6:
|
|
721
520
|
orders = _context4.sent;
|
|
722
521
|
localOrder = orders.find(function (order) {
|
|
723
522
|
var shopOrderNumber = order === null || order === void 0 ? void 0 : order.shop_order_number;
|
|
724
|
-
if (shopOrderNumber &&
|
|
523
|
+
if (shopOrderNumber && _this3.getIdKey(shopOrderNumber) === key) return true;
|
|
725
524
|
var id = order === null || order === void 0 ? void 0 : order.order_id;
|
|
726
525
|
if (id === undefined || id === null) return false;
|
|
727
|
-
return
|
|
526
|
+
return _this3.getIdKey(id) === key;
|
|
728
527
|
});
|
|
729
528
|
if (localOrder) {
|
|
730
|
-
_context4.next =
|
|
529
|
+
_context4.next = 10;
|
|
731
530
|
break;
|
|
732
531
|
}
|
|
733
532
|
return _context4.abrupt("return", null);
|
|
734
|
-
case
|
|
533
|
+
case 10:
|
|
735
534
|
this.store.list = orders;
|
|
736
535
|
this.syncOrdersMap();
|
|
737
536
|
return _context4.abrupt("return", localOrder);
|
|
738
|
-
case
|
|
537
|
+
case 13:
|
|
739
538
|
case "end":
|
|
740
539
|
return _context4.stop();
|
|
741
540
|
}
|
|
@@ -750,69 +549,58 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
750
549
|
key: "loadOrdersByServer",
|
|
751
550
|
value: function () {
|
|
752
551
|
var _loadOrdersByServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
753
|
-
var _this$store
|
|
552
|
+
var _this$store;
|
|
754
553
|
var orderList, data;
|
|
755
554
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
756
555
|
while (1) switch (_context5.prev = _context5.next) {
|
|
757
556
|
case 0:
|
|
758
557
|
orderList = [];
|
|
759
|
-
this.pushOrderFlowLog('loadOrdersByServer.start', _objectSpread(_objectSpread({}, this.getOrderStoreSnapshot()), {}, {
|
|
760
|
-
query: ((_this$store = this.store) === null || _this$store === void 0 ? void 0 : _this$store.createdAtQuery) || null,
|
|
761
|
-
hasOrderDataSource: !!this.orderDataSource
|
|
762
|
-
}));
|
|
763
558
|
this.logInfo('loadOrdersByServer-开始', {
|
|
764
559
|
hasOrderDataSource: !!this.orderDataSource,
|
|
765
|
-
query: ((_this$
|
|
560
|
+
query: ((_this$store = this.store) === null || _this$store === void 0 ? void 0 : _this$store.createdAtQuery) || null
|
|
766
561
|
});
|
|
767
562
|
if (!this.orderDataSource) {
|
|
768
|
-
_context5.next =
|
|
563
|
+
_context5.next = 17;
|
|
769
564
|
break;
|
|
770
565
|
}
|
|
771
|
-
_context5.prev =
|
|
772
|
-
_context5.next =
|
|
566
|
+
_context5.prev = 3;
|
|
567
|
+
_context5.next = 6;
|
|
773
568
|
return this.orderDataSource.run({
|
|
774
569
|
sse: {
|
|
775
570
|
query: this.store.createdAtQuery
|
|
776
571
|
}
|
|
777
572
|
});
|
|
778
|
-
case
|
|
573
|
+
case 6:
|
|
779
574
|
data = _context5.sent;
|
|
780
575
|
orderList = data || [];
|
|
781
|
-
this.pushOrderFlowLog('loadOrdersByServer.sseSuccess', {
|
|
782
|
-
count: orderList.length
|
|
783
|
-
});
|
|
784
576
|
this.logInfo('loadOrdersByServer-SSE拉取成功', {
|
|
785
577
|
count: orderList.length
|
|
786
578
|
});
|
|
787
579
|
this.markOrderPulledAtNow();
|
|
788
580
|
this.lastServerFullFetchAtMs = Date.now();
|
|
789
|
-
_context5.next =
|
|
581
|
+
_context5.next = 17;
|
|
790
582
|
break;
|
|
791
|
-
case
|
|
792
|
-
_context5.prev =
|
|
793
|
-
_context5.t0 = _context5["catch"](
|
|
583
|
+
case 13:
|
|
584
|
+
_context5.prev = 13;
|
|
585
|
+
_context5.t0 = _context5["catch"](3);
|
|
794
586
|
orderList = [];
|
|
795
|
-
this.pushOrderFlowLog('loadOrdersByServer.sseFailed', {});
|
|
796
587
|
this.logInfo('loadOrdersByServer-SSE拉取失败,回退为空数组');
|
|
797
|
-
case
|
|
798
|
-
_context5.next =
|
|
588
|
+
case 17:
|
|
589
|
+
_context5.next = 19;
|
|
799
590
|
return this.replaceOrdersSnapshotInSQLite(orderList, 'loadOrdersByServer');
|
|
800
|
-
case
|
|
801
|
-
this.pushOrderFlowLog('loadOrdersByServer.done', _objectSpread({
|
|
802
|
-
count: orderList.length
|
|
803
|
-
}, this.getOrderStoreSnapshot()));
|
|
591
|
+
case 19:
|
|
804
592
|
this.logInfo('loadOrdersByServer-结束', {
|
|
805
593
|
count: orderList.length
|
|
806
594
|
});
|
|
807
|
-
_context5.next =
|
|
595
|
+
_context5.next = 22;
|
|
808
596
|
return this.core.effects.emit(OrderHooks.onOrdersLoaded, orderList);
|
|
809
|
-
case
|
|
597
|
+
case 22:
|
|
810
598
|
return _context5.abrupt("return", orderList);
|
|
811
|
-
case
|
|
599
|
+
case 23:
|
|
812
600
|
case "end":
|
|
813
601
|
return _context5.stop();
|
|
814
602
|
}
|
|
815
|
-
}, _callee5, this, [[
|
|
603
|
+
}, _callee5, this, [[3, 13]]);
|
|
816
604
|
}));
|
|
817
605
|
function loadOrdersByServer() {
|
|
818
606
|
return _loadOrdersByServer.apply(this, arguments);
|
|
@@ -835,65 +623,51 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
835
623
|
startTime = Date.now();
|
|
836
624
|
elapsedSinceFullFetch = Date.now() - this.lastServerFullFetchAtMs;
|
|
837
625
|
if (!(this.lastServerFullFetchAtMs > 0 && elapsedSinceFullFetch < ORDER_SILENT_REFRESH_MIN_INTERVAL_MS)) {
|
|
838
|
-
_context6.next =
|
|
626
|
+
_context6.next = 4;
|
|
839
627
|
break;
|
|
840
628
|
}
|
|
841
|
-
this.pushOrderFlowLog('silentRefresh.skipped', _objectSpread({
|
|
842
|
-
elapsedMs: elapsedSinceFullFetch,
|
|
843
|
-
minIntervalMs: ORDER_SILENT_REFRESH_MIN_INTERVAL_MS
|
|
844
|
-
}, this.getOrderStoreSnapshot()));
|
|
845
629
|
return _context6.abrupt("return", this.store.list);
|
|
846
|
-
case
|
|
847
|
-
this.pushOrderFlowLog('silentRefresh.start', _objectSpread(_objectSpread({}, this.getOrderStoreSnapshot()), {}, {
|
|
848
|
-
callerHint: 'Server.refreshOrdersInBackground 或其他调用方'
|
|
849
|
-
}));
|
|
630
|
+
case 4:
|
|
850
631
|
this.logInfo('silentRefresh 开始');
|
|
851
|
-
_context6.prev =
|
|
852
|
-
_context6.next =
|
|
632
|
+
_context6.prev = 5;
|
|
633
|
+
_context6.next = 8;
|
|
853
634
|
return this.loadOrdersByServer();
|
|
854
|
-
case
|
|
635
|
+
case 8:
|
|
855
636
|
orders = _context6.sent;
|
|
856
637
|
if (!(orders.length > 0)) {
|
|
857
|
-
_context6.next =
|
|
638
|
+
_context6.next = 18;
|
|
858
639
|
break;
|
|
859
640
|
}
|
|
860
641
|
this.store.list = cloneDeep(orders);
|
|
861
642
|
this.syncOrdersMap();
|
|
862
643
|
this.core.effects.emit(OrderHooks.onOrdersChanged, this.store.list);
|
|
863
|
-
_context6.next =
|
|
644
|
+
_context6.next = 15;
|
|
864
645
|
return this.core.effects.emit(OrderHooks.onOrdersSyncCompleted, null);
|
|
865
|
-
case
|
|
866
|
-
this.pushOrderFlowLog('silentRefresh.done', _objectSpread({
|
|
867
|
-
orderCount: orders.length,
|
|
868
|
-
durationMs: Date.now() - startTime
|
|
869
|
-
}, this.getOrderStoreSnapshot()));
|
|
646
|
+
case 15:
|
|
870
647
|
this.logInfo('silentRefresh 完成', {
|
|
871
648
|
orderCount: orders.length,
|
|
872
649
|
duration: "".concat(Date.now() - startTime, "ms")
|
|
873
650
|
});
|
|
874
|
-
_context6.next =
|
|
651
|
+
_context6.next = 19;
|
|
875
652
|
break;
|
|
876
|
-
case
|
|
877
|
-
this.pushOrderFlowLog('silentRefresh.empty', {
|
|
878
|
-
durationMs: Date.now() - startTime
|
|
879
|
-
});
|
|
653
|
+
case 18:
|
|
880
654
|
this.logInfo('silentRefresh: 服务器未返回数据');
|
|
881
|
-
case
|
|
655
|
+
case 19:
|
|
882
656
|
return _context6.abrupt("return", this.store.list);
|
|
883
|
-
case
|
|
884
|
-
_context6.prev =
|
|
885
|
-
_context6.t0 = _context6["catch"](
|
|
657
|
+
case 22:
|
|
658
|
+
_context6.prev = 22;
|
|
659
|
+
_context6.t0 = _context6["catch"](5);
|
|
886
660
|
errorMessage = _context6.t0 instanceof Error ? _context6.t0.message : String(_context6.t0);
|
|
887
661
|
this.logError('silentRefresh 失败', {
|
|
888
662
|
duration: "".concat(Date.now() - startTime, "ms"),
|
|
889
663
|
error: errorMessage
|
|
890
664
|
});
|
|
891
665
|
return _context6.abrupt("return", this.store.list);
|
|
892
|
-
case
|
|
666
|
+
case 27:
|
|
893
667
|
case "end":
|
|
894
668
|
return _context6.stop();
|
|
895
669
|
}
|
|
896
|
-
}, _callee6, this, [[
|
|
670
|
+
}, _callee6, this, [[5, 22]]);
|
|
897
671
|
}));
|
|
898
672
|
function silentRefresh() {
|
|
899
673
|
return _silentRefresh.apply(this, arguments);
|
|
@@ -903,10 +677,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
903
677
|
}, {
|
|
904
678
|
key: "getOrdersByResourceId",
|
|
905
679
|
value: function getOrdersByResourceId(resourceId) {
|
|
906
|
-
var
|
|
680
|
+
var _this4 = this;
|
|
907
681
|
var ids = this.resourceIdIndex.get(String(resourceId)) || [];
|
|
908
682
|
return ids.map(function (id) {
|
|
909
|
-
return
|
|
683
|
+
return _this4.store.map.get(id);
|
|
910
684
|
}).filter(function (order) {
|
|
911
685
|
return !!order;
|
|
912
686
|
});
|
|
@@ -920,7 +694,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
920
694
|
key: "overwriteExistingOrder",
|
|
921
695
|
value: (function () {
|
|
922
696
|
var _overwriteExistingOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(fresh) {
|
|
923
|
-
var
|
|
697
|
+
var _this5 = this;
|
|
924
698
|
var orderId, key;
|
|
925
699
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
926
700
|
while (1) switch (_context7.prev = _context7.next) {
|
|
@@ -947,12 +721,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
947
721
|
overwritten: false
|
|
948
722
|
});
|
|
949
723
|
case 8:
|
|
950
|
-
this.pushOrderFlowLog('overwriteExistingOrder.start', _objectSpread(_objectSpread({
|
|
951
|
-
orderId: orderId,
|
|
952
|
-
storageKey: this.getOrderStorageKey(fresh)
|
|
953
|
-
}, this.getOrderStoreSnapshot()), {}, {
|
|
954
|
-
callerHint: 'Server.handleUpdateLocalOrder 本地已存在时'
|
|
955
|
-
}));
|
|
956
724
|
this.logInfo('overwriteExistingOrder-开始覆盖', {
|
|
957
725
|
orderId: orderId,
|
|
958
726
|
storeOrderCountBefore: this.store.list.length
|
|
@@ -960,26 +728,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
960
728
|
this.store.list = this.store.list.map(function (order) {
|
|
961
729
|
var id = order === null || order === void 0 ? void 0 : order.order_id;
|
|
962
730
|
if (id === undefined || id === null) return order;
|
|
963
|
-
return
|
|
731
|
+
return _this5.getIdKey(id) === key ? fresh : order;
|
|
964
732
|
});
|
|
965
733
|
this.syncOrdersMap();
|
|
966
|
-
_context7.next =
|
|
734
|
+
_context7.next = 13;
|
|
967
735
|
return this.updateOrderInSQLite(fresh, 'overwriteExistingOrder');
|
|
968
|
-
case
|
|
969
|
-
this.pushOrderFlowLog('overwriteExistingOrder.done', _objectSpread({
|
|
970
|
-
orderId: orderId
|
|
971
|
-
}, this.getOrderStoreSnapshot()));
|
|
736
|
+
case 13:
|
|
972
737
|
this.logInfo('overwriteExistingOrder-结束', {
|
|
973
738
|
orderId: orderId,
|
|
974
739
|
storeOrderCountAfter: this.store.list.length
|
|
975
740
|
});
|
|
976
|
-
_context7.next =
|
|
741
|
+
_context7.next = 16;
|
|
977
742
|
return this.core.effects.emit(OrderHooks.onOrdersChanged, this.store.list);
|
|
978
|
-
case
|
|
743
|
+
case 16:
|
|
979
744
|
return _context7.abrupt("return", {
|
|
980
745
|
overwritten: true
|
|
981
746
|
});
|
|
982
|
-
case
|
|
747
|
+
case 17:
|
|
983
748
|
case "end":
|
|
984
749
|
return _context7.stop();
|
|
985
750
|
}
|
|
@@ -1009,21 +774,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1009
774
|
this.logInfo('upsertOrdersFromRemote-订单列表为空', {});
|
|
1010
775
|
return _context8.abrupt("return");
|
|
1011
776
|
case 3:
|
|
1012
|
-
this.pushOrderFlowLog('upsertOrdersFromRemote.start', {
|
|
1013
|
-
count: freshOrders.length,
|
|
1014
|
-
orderIds: freshOrders.map(function (o) {
|
|
1015
|
-
return o.order_id;
|
|
1016
|
-
}).filter(function (id) {
|
|
1017
|
-
return id !== undefined && id !== null;
|
|
1018
|
-
}),
|
|
1019
|
-
callerHint: 'Server.handleUpdateLocalOrder / handleOrderSalesDetail / handleUpdateLocalOrdersBatch'
|
|
1020
|
-
});
|
|
1021
777
|
this.logInfo('upsertOrdersFromRemote-开始', {
|
|
1022
778
|
count: freshOrders.length
|
|
1023
779
|
});
|
|
1024
|
-
_context8.next =
|
|
780
|
+
_context8.next = 6;
|
|
1025
781
|
return this.mergeOrdersToStore(freshOrders, 'upsertOrdersFromRemote');
|
|
1026
|
-
case
|
|
782
|
+
case 6:
|
|
1027
783
|
case "end":
|
|
1028
784
|
return _context8.stop();
|
|
1029
785
|
}
|
|
@@ -1104,44 +860,44 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1104
860
|
}, {
|
|
1105
861
|
key: "syncOrdersMap",
|
|
1106
862
|
value: function syncOrdersMap() {
|
|
1107
|
-
var
|
|
863
|
+
var _this6 = this;
|
|
1108
864
|
this.store.map.clear();
|
|
1109
865
|
this.resourceIdIndex.clear();
|
|
1110
|
-
var
|
|
1111
|
-
|
|
866
|
+
var _iterator4 = _createForOfIteratorHelper(this.store.list),
|
|
867
|
+
_step4;
|
|
1112
868
|
try {
|
|
1113
869
|
var _loop = function _loop() {
|
|
1114
|
-
var order =
|
|
870
|
+
var order = _step4.value;
|
|
1115
871
|
var id = order.order_id;
|
|
1116
872
|
if (id === undefined || id === null) return 1; // continue
|
|
1117
|
-
|
|
1118
|
-
var resourceIds =
|
|
1119
|
-
var
|
|
1120
|
-
|
|
873
|
+
_this6.store.map.set(_this6.getIdKey(id), order);
|
|
874
|
+
var resourceIds = _this6.extractResourceIds(order);
|
|
875
|
+
var _iterator5 = _createForOfIteratorHelper(resourceIds),
|
|
876
|
+
_step5;
|
|
1121
877
|
try {
|
|
1122
|
-
for (
|
|
1123
|
-
var resourceId =
|
|
878
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
879
|
+
var resourceId = _step5.value;
|
|
1124
880
|
var key = String(resourceId);
|
|
1125
|
-
var existing =
|
|
881
|
+
var existing = _this6.resourceIdIndex.get(key) || [];
|
|
1126
882
|
if (existing.some(function (eid) {
|
|
1127
|
-
return
|
|
883
|
+
return _this6.getIdKey(eid) === _this6.getIdKey(id);
|
|
1128
884
|
})) continue;
|
|
1129
885
|
existing.push(id);
|
|
1130
|
-
|
|
886
|
+
_this6.resourceIdIndex.set(key, existing);
|
|
1131
887
|
}
|
|
1132
888
|
} catch (err) {
|
|
1133
|
-
|
|
889
|
+
_iterator5.e(err);
|
|
1134
890
|
} finally {
|
|
1135
|
-
|
|
891
|
+
_iterator5.f();
|
|
1136
892
|
}
|
|
1137
893
|
};
|
|
1138
|
-
for (
|
|
894
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
1139
895
|
if (_loop()) continue;
|
|
1140
896
|
}
|
|
1141
897
|
} catch (err) {
|
|
1142
|
-
|
|
898
|
+
_iterator4.e(err);
|
|
1143
899
|
} finally {
|
|
1144
|
-
|
|
900
|
+
_iterator4.f();
|
|
1145
901
|
}
|
|
1146
902
|
}
|
|
1147
903
|
}, {
|
|
@@ -1196,38 +952,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1196
952
|
}, {
|
|
1197
953
|
key: "setupOrderSync",
|
|
1198
954
|
value: function setupOrderSync() {
|
|
1199
|
-
var
|
|
955
|
+
var _this7 = this;
|
|
1200
956
|
if (!this.orderDataSource) return;
|
|
1201
957
|
this.orderDataSource.run({
|
|
1202
958
|
pubsub: {
|
|
1203
959
|
callback: function callback(res) {
|
|
1204
|
-
var _message$id, _message$order_id, _message$type
|
|
960
|
+
var _message$id, _message$order_id, _message$type;
|
|
1205
961
|
console.log('orderDataSource', res);
|
|
1206
962
|
var pubsubReceivedAt = Date.now();
|
|
1207
|
-
var message =
|
|
963
|
+
var message = _this7.normalizeOrderSyncMessage(res);
|
|
1208
964
|
if (!message) return;
|
|
1209
965
|
message._pubsubReceivedAt = pubsubReceivedAt;
|
|
1210
|
-
|
|
1211
|
-
var throttleMs =
|
|
1212
|
-
var routeInfo =
|
|
1213
|
-
|
|
966
|
+
_this7.pendingSyncMessages.push(message);
|
|
967
|
+
var throttleMs = _this7.getOrderSyncThrottleMs();
|
|
968
|
+
var routeInfo = _this7.resolveSyncMessageRoute(message);
|
|
969
|
+
_this7.logInfo('orderSync-收到消息并入队', {
|
|
1214
970
|
id: (_message$id = message.id) !== null && _message$id !== void 0 ? _message$id : null,
|
|
1215
971
|
order_id: (_message$order_id = message.order_id) !== null && _message$order_id !== void 0 ? _message$order_id : null,
|
|
1216
972
|
type: (_message$type = message.type) !== null && _message$type !== void 0 ? _message$type : null,
|
|
1217
|
-
pendingCount:
|
|
1218
|
-
throttleMs: throttleMs
|
|
1219
|
-
}, routeInfo), {}, {
|
|
1220
|
-
duplicateRiskHint: routeInfo.route === 'httpRefresh.batchIds' && routeInfo.hasNormalizedBody ? '有 body 但被 ids 优先,会走 HTTP 重拉' : routeInfo.route === 'bodyUpsert' ? 'body 直写,可能与 upsertOrdersFromRemote 重复' : null
|
|
1221
|
-
}));
|
|
1222
|
-
_this8.logInfo('orderSync-收到消息并入队', {
|
|
1223
|
-
id: (_message$id2 = message.id) !== null && _message$id2 !== void 0 ? _message$id2 : null,
|
|
1224
|
-
order_id: (_message$order_id2 = message.order_id) !== null && _message$order_id2 !== void 0 ? _message$order_id2 : null,
|
|
1225
|
-
type: (_message$type2 = message.type) !== null && _message$type2 !== void 0 ? _message$type2 : null,
|
|
1226
|
-
pendingCount: _this8.pendingSyncMessages.length,
|
|
973
|
+
pendingCount: _this7.pendingSyncMessages.length,
|
|
1227
974
|
throttleMs: throttleMs,
|
|
1228
975
|
pubsubReceivedAt: new Date(pubsubReceivedAt).toISOString()
|
|
1229
976
|
});
|
|
1230
|
-
|
|
977
|
+
_this7.scheduleOrderSyncThrottle();
|
|
1231
978
|
}
|
|
1232
979
|
}
|
|
1233
980
|
}).catch(function () {
|
|
@@ -1244,26 +991,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1244
991
|
}, {
|
|
1245
992
|
key: "scheduleOrderSyncThrottle",
|
|
1246
993
|
value: function scheduleOrderSyncThrottle() {
|
|
1247
|
-
var
|
|
994
|
+
var _this8 = this;
|
|
1248
995
|
if (this.isProcessingSyncBatch) return;
|
|
1249
996
|
if (this.isIdlePhase) {
|
|
1250
997
|
this.isIdlePhase = false;
|
|
1251
|
-
this.pushOrderFlowLog('orderSync.flushImmediate', {
|
|
1252
|
-
pendingCount: this.pendingSyncMessages.length
|
|
1253
|
-
});
|
|
1254
998
|
this.logInfo('orderSync-首条消息立即触发处理');
|
|
1255
999
|
void this.flushOrderSyncMessagesByThrottle();
|
|
1256
1000
|
return;
|
|
1257
1001
|
}
|
|
1258
1002
|
if (this.syncTimer) return;
|
|
1259
1003
|
var throttleMs = this.getOrderSyncThrottleMs();
|
|
1260
|
-
this.pushOrderFlowLog('orderSync.flushScheduled', {
|
|
1261
|
-
pendingCount: this.pendingSyncMessages.length,
|
|
1262
|
-
throttleMs: throttleMs
|
|
1263
|
-
});
|
|
1264
1004
|
this.syncTimer = setTimeout(function () {
|
|
1265
|
-
|
|
1266
|
-
void
|
|
1005
|
+
_this8.syncTimer = undefined;
|
|
1006
|
+
void _this8.flushOrderSyncMessagesByThrottle();
|
|
1267
1007
|
}, throttleMs);
|
|
1268
1008
|
}
|
|
1269
1009
|
|
|
@@ -1292,26 +1032,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1292
1032
|
return _context10.abrupt("return");
|
|
1293
1033
|
case 5:
|
|
1294
1034
|
this.isProcessingSyncBatch = true;
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
});
|
|
1298
|
-
_context10.prev = 7;
|
|
1299
|
-
_context10.next = 10;
|
|
1035
|
+
_context10.prev = 6;
|
|
1036
|
+
_context10.next = 9;
|
|
1300
1037
|
return this.processOrderSyncMessages();
|
|
1301
|
-
case
|
|
1302
|
-
_context10.prev =
|
|
1038
|
+
case 9:
|
|
1039
|
+
_context10.prev = 9;
|
|
1303
1040
|
this.isProcessingSyncBatch = false;
|
|
1304
1041
|
if (this.pendingSyncMessages.length > 0) {
|
|
1305
1042
|
this.scheduleOrderSyncThrottle();
|
|
1306
1043
|
} else {
|
|
1307
1044
|
this.isIdlePhase = true;
|
|
1308
1045
|
}
|
|
1309
|
-
return _context10.finish(
|
|
1310
|
-
case
|
|
1046
|
+
return _context10.finish(9);
|
|
1047
|
+
case 13:
|
|
1311
1048
|
case "end":
|
|
1312
1049
|
return _context10.stop();
|
|
1313
1050
|
}
|
|
1314
|
-
}, _callee10, this, [[
|
|
1051
|
+
}, _callee10, this, [[6,, 9, 13]]);
|
|
1315
1052
|
}));
|
|
1316
1053
|
function flushOrderSyncMessagesByThrottle() {
|
|
1317
1054
|
return _flushOrderSyncMessagesByThrottle.apply(this, arguments);
|
|
@@ -1334,7 +1071,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1334
1071
|
key: "processOrderSyncMessages",
|
|
1335
1072
|
value: (function () {
|
|
1336
1073
|
var _processOrderSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
1337
|
-
var
|
|
1074
|
+
var _this9 = this;
|
|
1338
1075
|
var messages, batchProcessStartAt, earliestReceivedAt, upsertOrders, refreshIds, uniqueRefreshIds, upsertList, _this$filterRedundant, toFetch, skipped, freshOrders, batchProcessEndAt;
|
|
1339
1076
|
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
1340
1077
|
while (1) switch (_context11.prev = _context11.next) {
|
|
@@ -1348,9 +1085,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1348
1085
|
return _context11.abrupt("return");
|
|
1349
1086
|
case 4:
|
|
1350
1087
|
batchProcessStartAt = Date.now();
|
|
1351
|
-
this.pushOrderFlowLog('processOrderSyncMessages.start', _objectSpread({
|
|
1352
|
-
messageCount: messages.length
|
|
1353
|
-
}, this.getOrderStoreSnapshot()));
|
|
1354
1088
|
earliestReceivedAt = Math.min.apply(Math, _toConsumableArray(messages.map(function (m) {
|
|
1355
1089
|
var _m$_pubsubReceivedAt;
|
|
1356
1090
|
return (_m$_pubsubReceivedAt = m._pubsubReceivedAt) !== null && _m$_pubsubReceivedAt !== void 0 ? _m$_pubsubReceivedAt : batchProcessStartAt;
|
|
@@ -1364,100 +1098,70 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1364
1098
|
upsertOrders = new Map();
|
|
1365
1099
|
refreshIds = [];
|
|
1366
1100
|
messages.forEach(function (msg, msgIndex) {
|
|
1367
|
-
var routeInfo =
|
|
1368
|
-
_this10.pushOrderFlowLog('processOrderSyncMessages.messageRoute', _objectSpread({
|
|
1369
|
-
msgIndex: msgIndex
|
|
1370
|
-
}, routeInfo));
|
|
1101
|
+
var routeInfo = _this9.resolveSyncMessageRoute(msg);
|
|
1371
1102
|
var hasBatchIds = routeInfo.hasBatchIds;
|
|
1372
1103
|
var singleId = routeInfo.singleId;
|
|
1373
1104
|
var hasSingleId = routeInfo.hasSingleId;
|
|
1374
|
-
var normalizedBody =
|
|
1105
|
+
var normalizedBody = _this9.normalizeOrderSyncPayload(msg.body || msg.data);
|
|
1375
1106
|
if (routeInfo.route === 'bodyUpsert' && normalizedBody) {
|
|
1376
|
-
upsertOrders.set(
|
|
1107
|
+
upsertOrders.set(_this9.getIdKey(normalizedBody.order_id), normalizedBody);
|
|
1377
1108
|
return;
|
|
1378
1109
|
}
|
|
1379
1110
|
if (hasBatchIds) refreshIds.push.apply(refreshIds, _toConsumableArray(routeInfo.batchIds));else if (routeInfo.route === 'httpRefresh.singleId' && singleId !== null) refreshIds.push(singleId);else if (routeInfo.route === 'httpRefresh.relationIds') refreshIds.push.apply(refreshIds, _toConsumableArray(routeInfo.batchIds));
|
|
1380
1111
|
});
|
|
1381
1112
|
uniqueRefreshIds = this.uniqueOrderIds(refreshIds);
|
|
1382
1113
|
upsertList = _toConsumableArray(upsertOrders.values());
|
|
1383
|
-
this.pushOrderFlowLog('processOrderSyncMessages.deduped', {
|
|
1384
|
-
upsertCount: upsertList.length,
|
|
1385
|
-
upsertOrderIds: upsertList.map(function (o) {
|
|
1386
|
-
return o.order_id;
|
|
1387
|
-
}),
|
|
1388
|
-
refreshIdCount: uniqueRefreshIds.length,
|
|
1389
|
-
refreshIds: uniqueRefreshIds,
|
|
1390
|
-
willCallMergeTimes: (upsertList.length > 0 ? 1 : 0) + (uniqueRefreshIds.length > 0 ? 1 : 0)
|
|
1391
|
-
});
|
|
1392
1114
|
this.logInfo('processOrderSyncMessages-去重完成', {
|
|
1393
1115
|
upsertCount: upsertList.length,
|
|
1394
1116
|
refreshIdCount: uniqueRefreshIds.length
|
|
1395
1117
|
});
|
|
1396
1118
|
if (!(upsertList.length > 0)) {
|
|
1397
|
-
_context11.next =
|
|
1119
|
+
_context11.next = 16;
|
|
1398
1120
|
break;
|
|
1399
1121
|
}
|
|
1400
|
-
_context11.next =
|
|
1122
|
+
_context11.next = 16;
|
|
1401
1123
|
return this.mergeOrdersToStore(upsertList, 'pubsub.bodyUpsert');
|
|
1402
|
-
case
|
|
1124
|
+
case 16:
|
|
1403
1125
|
if (!(uniqueRefreshIds.length > 0)) {
|
|
1404
|
-
_context11.next =
|
|
1126
|
+
_context11.next = 28;
|
|
1405
1127
|
break;
|
|
1406
1128
|
}
|
|
1407
1129
|
_this$filterRedundant = this.filterRedundantHttpRefreshIds(uniqueRefreshIds), toFetch = _this$filterRedundant.toFetch, skipped = _this$filterRedundant.skipped;
|
|
1408
|
-
if (skipped.length > 0) {
|
|
1409
|
-
this.pushOrderFlowLog('processOrderSyncMessages.httpRefreshFiltered', {
|
|
1410
|
-
requestedIds: uniqueRefreshIds,
|
|
1411
|
-
skippedIds: skipped.map(function (item) {
|
|
1412
|
-
return item.orderId;
|
|
1413
|
-
}),
|
|
1414
|
-
skipped: skipped
|
|
1415
|
-
});
|
|
1416
|
-
}
|
|
1130
|
+
if (skipped.length > 0) {}
|
|
1417
1131
|
if (!(toFetch.length > 0)) {
|
|
1418
|
-
_context11.next =
|
|
1132
|
+
_context11.next = 28;
|
|
1419
1133
|
break;
|
|
1420
1134
|
}
|
|
1421
|
-
_context11.next =
|
|
1135
|
+
_context11.next = 22;
|
|
1422
1136
|
return this.fetchOrdersByHttp(toFetch);
|
|
1423
|
-
case
|
|
1137
|
+
case 22:
|
|
1424
1138
|
freshOrders = _context11.sent;
|
|
1425
1139
|
if (!(freshOrders.length > 0)) {
|
|
1426
|
-
_context11.next =
|
|
1140
|
+
_context11.next = 28;
|
|
1427
1141
|
break;
|
|
1428
1142
|
}
|
|
1429
|
-
_context11.next =
|
|
1143
|
+
_context11.next = 26;
|
|
1430
1144
|
return this.mergeOrdersToStore(freshOrders, 'pubsub.httpRefresh');
|
|
1431
|
-
case
|
|
1432
|
-
_context11.next =
|
|
1145
|
+
case 26:
|
|
1146
|
+
_context11.next = 28;
|
|
1433
1147
|
break;
|
|
1434
|
-
case
|
|
1435
|
-
this.pushOrderFlowLog('processOrderSyncMessages.httpRefreshEmpty', {
|
|
1436
|
-
refreshIds: toFetch
|
|
1437
|
-
});
|
|
1438
|
-
case 31:
|
|
1148
|
+
case 28:
|
|
1439
1149
|
if (!(upsertList.length === 0 && uniqueRefreshIds.length === 0)) {
|
|
1440
|
-
_context11.next =
|
|
1150
|
+
_context11.next = 30;
|
|
1441
1151
|
break;
|
|
1442
1152
|
}
|
|
1443
|
-
this.pushOrderFlowLog('processOrderSyncMessages.noop', {});
|
|
1444
1153
|
return _context11.abrupt("return");
|
|
1445
|
-
case
|
|
1154
|
+
case 30:
|
|
1446
1155
|
batchProcessEndAt = Date.now();
|
|
1447
|
-
this.pushOrderFlowLog('processOrderSyncMessages.done', _objectSpread({
|
|
1448
|
-
upsertCount: upsertList.length,
|
|
1449
|
-
refreshIdCount: uniqueRefreshIds.length,
|
|
1450
|
-
batchProcessDurationMs: batchProcessEndAt - batchProcessStartAt
|
|
1451
|
-
}, this.getOrderStoreSnapshot()));
|
|
1452
1156
|
this.logInfo('processOrderSyncMessages-结束', {
|
|
1453
1157
|
upsertCount: upsertList.length,
|
|
1454
1158
|
refreshIdCount: uniqueRefreshIds.length,
|
|
1455
1159
|
batchProcessDurationMs: batchProcessEndAt - batchProcessStartAt,
|
|
1456
1160
|
totalFromPubsubToProcessedMs: batchProcessEndAt - earliestReceivedAt
|
|
1457
1161
|
});
|
|
1458
|
-
_context11.next =
|
|
1162
|
+
_context11.next = 34;
|
|
1459
1163
|
return this.core.effects.emit(OrderHooks.onOrdersSyncCompleted, null);
|
|
1460
|
-
case
|
|
1164
|
+
case 34:
|
|
1461
1165
|
case "end":
|
|
1462
1166
|
return _context11.stop();
|
|
1463
1167
|
}
|
|
@@ -1493,27 +1197,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1493
1197
|
}
|
|
1494
1198
|
return _context12.abrupt("return", []);
|
|
1495
1199
|
case 2:
|
|
1496
|
-
|
|
1497
|
-
ids: ids,
|
|
1498
|
-
count: ids.length
|
|
1499
|
-
});
|
|
1500
|
-
_context12.prev = 3;
|
|
1200
|
+
_context12.prev = 2;
|
|
1501
1201
|
if (!(typeof this.orderDataSource.fetchOrdersByIds === 'function')) {
|
|
1502
|
-
_context12.next =
|
|
1202
|
+
_context12.next = 8;
|
|
1503
1203
|
break;
|
|
1504
1204
|
}
|
|
1505
|
-
_context12.next =
|
|
1205
|
+
_context12.next = 6;
|
|
1506
1206
|
return this.orderDataSource.fetchOrdersByIds(ids);
|
|
1507
|
-
case
|
|
1207
|
+
case 6:
|
|
1508
1208
|
_orderList = _context12.sent;
|
|
1509
|
-
this.pushOrderFlowLog('fetchOrdersByHttp.done', {
|
|
1510
|
-
ids: ids,
|
|
1511
|
-
count: (_orderList === null || _orderList === void 0 ? void 0 : _orderList.length) || 0,
|
|
1512
|
-
via: 'fetchOrdersByIds'
|
|
1513
|
-
});
|
|
1514
1209
|
return _context12.abrupt("return", _orderList || []);
|
|
1515
|
-
case
|
|
1516
|
-
_context12.next =
|
|
1210
|
+
case 8:
|
|
1211
|
+
_context12.next = 10;
|
|
1517
1212
|
return this.orderDataSource.run({
|
|
1518
1213
|
http: {
|
|
1519
1214
|
query: {
|
|
@@ -1521,26 +1216,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1521
1216
|
}
|
|
1522
1217
|
}
|
|
1523
1218
|
});
|
|
1524
|
-
case
|
|
1219
|
+
case 10:
|
|
1525
1220
|
orderList = _context12.sent;
|
|
1526
|
-
this.pushOrderFlowLog('fetchOrdersByHttp.done', {
|
|
1527
|
-
ids: ids,
|
|
1528
|
-
count: (orderList === null || orderList === void 0 ? void 0 : orderList.length) || 0,
|
|
1529
|
-
via: 'run.http'
|
|
1530
|
-
});
|
|
1531
1221
|
return _context12.abrupt("return", orderList || []);
|
|
1532
|
-
case
|
|
1533
|
-
_context12.prev =
|
|
1534
|
-
_context12.t0 = _context12["catch"](
|
|
1535
|
-
this.pushOrderFlowLog('fetchOrdersByHttp.failed', {
|
|
1536
|
-
ids: ids
|
|
1537
|
-
});
|
|
1222
|
+
case 14:
|
|
1223
|
+
_context12.prev = 14;
|
|
1224
|
+
_context12.t0 = _context12["catch"](2);
|
|
1538
1225
|
return _context12.abrupt("return", []);
|
|
1539
|
-
case
|
|
1226
|
+
case 17:
|
|
1540
1227
|
case "end":
|
|
1541
1228
|
return _context12.stop();
|
|
1542
1229
|
}
|
|
1543
|
-
}, _callee12, this, [[
|
|
1230
|
+
}, _callee12, this, [[2, 14]]);
|
|
1544
1231
|
}));
|
|
1545
1232
|
function fetchOrdersByHttp(_x6) {
|
|
1546
1233
|
return _fetchOrdersByHttp.apply(this, arguments);
|
|
@@ -1555,74 +1242,65 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1555
1242
|
key: "mergeOrdersToStore",
|
|
1556
1243
|
value: (function () {
|
|
1557
1244
|
var _mergeOrdersToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(freshOrders, source) {
|
|
1558
|
-
var
|
|
1559
|
-
var freshMap,
|
|
1245
|
+
var _this10 = this;
|
|
1246
|
+
var freshMap, _iterator6, _step6, order, id, uniqueFreshCount, patchedOrders, mergeActions, updatedList, _iterator7, _step7, _order, _id, insertCount, updateCount;
|
|
1560
1247
|
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1561
1248
|
while (1) switch (_context13.prev = _context13.next) {
|
|
1562
1249
|
case 0:
|
|
1563
|
-
this.pushOrderFlowLog('mergeOrdersToStore.start', _objectSpread({
|
|
1564
|
-
source: source,
|
|
1565
|
-
freshOrderCount: freshOrders.length,
|
|
1566
|
-
freshOrderIds: freshOrders.map(function (o) {
|
|
1567
|
-
return o.order_id;
|
|
1568
|
-
}).filter(function (id) {
|
|
1569
|
-
return id !== undefined && id !== null;
|
|
1570
|
-
})
|
|
1571
|
-
}, this.getOrderStoreSnapshot()));
|
|
1572
1250
|
this.logInfo('mergeOrdersToStore-开始', {
|
|
1573
1251
|
freshOrderCount: freshOrders.length,
|
|
1574
1252
|
storeOrderCountBefore: this.store.list.length
|
|
1575
1253
|
});
|
|
1576
1254
|
freshMap = new Map();
|
|
1577
|
-
|
|
1578
|
-
_context13.prev =
|
|
1579
|
-
|
|
1580
|
-
case
|
|
1581
|
-
if ((
|
|
1582
|
-
_context13.next =
|
|
1255
|
+
_iterator6 = _createForOfIteratorHelper(freshOrders);
|
|
1256
|
+
_context13.prev = 3;
|
|
1257
|
+
_iterator6.s();
|
|
1258
|
+
case 5:
|
|
1259
|
+
if ((_step6 = _iterator6.n()).done) {
|
|
1260
|
+
_context13.next = 13;
|
|
1583
1261
|
break;
|
|
1584
1262
|
}
|
|
1585
|
-
order =
|
|
1263
|
+
order = _step6.value;
|
|
1586
1264
|
id = order === null || order === void 0 ? void 0 : order.order_id;
|
|
1587
1265
|
if (!(id === undefined || id === null)) {
|
|
1588
|
-
_context13.next =
|
|
1266
|
+
_context13.next = 10;
|
|
1589
1267
|
break;
|
|
1590
1268
|
}
|
|
1591
|
-
return _context13.abrupt("continue",
|
|
1592
|
-
case
|
|
1269
|
+
return _context13.abrupt("continue", 11);
|
|
1270
|
+
case 10:
|
|
1593
1271
|
freshMap.set(this.getIdKey(id), order);
|
|
1594
|
-
case
|
|
1595
|
-
_context13.next =
|
|
1272
|
+
case 11:
|
|
1273
|
+
_context13.next = 5;
|
|
1596
1274
|
break;
|
|
1597
|
-
case
|
|
1598
|
-
_context13.next =
|
|
1275
|
+
case 13:
|
|
1276
|
+
_context13.next = 18;
|
|
1599
1277
|
break;
|
|
1600
|
-
case
|
|
1601
|
-
_context13.prev =
|
|
1602
|
-
_context13.t0 = _context13["catch"](
|
|
1603
|
-
|
|
1604
|
-
case
|
|
1605
|
-
_context13.prev =
|
|
1606
|
-
|
|
1607
|
-
return _context13.finish(
|
|
1608
|
-
case
|
|
1278
|
+
case 15:
|
|
1279
|
+
_context13.prev = 15;
|
|
1280
|
+
_context13.t0 = _context13["catch"](3);
|
|
1281
|
+
_iterator6.e(_context13.t0);
|
|
1282
|
+
case 18:
|
|
1283
|
+
_context13.prev = 18;
|
|
1284
|
+
_iterator6.f();
|
|
1285
|
+
return _context13.finish(18);
|
|
1286
|
+
case 21:
|
|
1609
1287
|
uniqueFreshCount = freshMap.size;
|
|
1610
1288
|
patchedOrders = _toConsumableArray(freshMap.values());
|
|
1611
1289
|
mergeActions = {};
|
|
1612
1290
|
updatedList = this.store.list.map(function (order) {
|
|
1613
1291
|
var id = order.order_id;
|
|
1614
1292
|
if (id === undefined || id === null) return order;
|
|
1615
|
-
var key =
|
|
1293
|
+
var key = _this10.getIdKey(id);
|
|
1616
1294
|
if (!freshMap.has(key)) return order;
|
|
1617
1295
|
var fresh = freshMap.get(key);
|
|
1618
1296
|
freshMap.delete(key);
|
|
1619
1297
|
mergeActions[key] = 'update';
|
|
1620
1298
|
return fresh;
|
|
1621
1299
|
});
|
|
1622
|
-
|
|
1300
|
+
_iterator7 = _createForOfIteratorHelper(freshMap.values());
|
|
1623
1301
|
try {
|
|
1624
|
-
for (
|
|
1625
|
-
_order =
|
|
1302
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
1303
|
+
_order = _step7.value;
|
|
1626
1304
|
_id = _order.order_id;
|
|
1627
1305
|
if (_id !== undefined && _id !== null) {
|
|
1628
1306
|
mergeActions[this.getIdKey(_id)] = 'insert';
|
|
@@ -1630,9 +1308,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1630
1308
|
updatedList.push(_order);
|
|
1631
1309
|
}
|
|
1632
1310
|
} catch (err) {
|
|
1633
|
-
|
|
1311
|
+
_iterator7.e(err);
|
|
1634
1312
|
} finally {
|
|
1635
|
-
|
|
1313
|
+
_iterator7.f();
|
|
1636
1314
|
}
|
|
1637
1315
|
insertCount = Object.values(mergeActions).filter(function (v) {
|
|
1638
1316
|
return v === 'insert';
|
|
@@ -1642,33 +1320,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1642
1320
|
}).length;
|
|
1643
1321
|
this.store.list = updatedList;
|
|
1644
1322
|
this.syncOrdersMap();
|
|
1645
|
-
_context13.next =
|
|
1323
|
+
_context13.next = 33;
|
|
1646
1324
|
return this.patchOrdersInSQLite(patchedOrders, source, mergeActions);
|
|
1647
|
-
case
|
|
1648
|
-
this.pushOrderFlowLog('mergeOrdersToStore.done', _objectSpread({
|
|
1649
|
-
source: source,
|
|
1650
|
-
uniqueFreshCount: uniqueFreshCount,
|
|
1651
|
-
insertCount: insertCount,
|
|
1652
|
-
updateCount: updateCount,
|
|
1653
|
-
patchedCount: patchedOrders.length,
|
|
1654
|
-
patchedOrderIds: patchedOrders.map(function (o) {
|
|
1655
|
-
return o.order_id;
|
|
1656
|
-
}),
|
|
1657
|
-
patchedStorageKeys: patchedOrders.map(function (o) {
|
|
1658
|
-
return _this11.getOrderStorageKey(o);
|
|
1659
|
-
}),
|
|
1660
|
-
mergeActions: mergeActions
|
|
1661
|
-
}, this.getOrderStoreSnapshot()));
|
|
1325
|
+
case 33:
|
|
1662
1326
|
this.logInfo('mergeOrdersToStore-结束', {
|
|
1663
1327
|
uniqueFreshCount: uniqueFreshCount,
|
|
1664
1328
|
storeOrderCountAfter: this.store.list.length
|
|
1665
1329
|
});
|
|
1666
1330
|
this.core.effects.emit(OrderHooks.onOrdersChanged, this.store.list);
|
|
1667
|
-
case
|
|
1331
|
+
case 35:
|
|
1668
1332
|
case "end":
|
|
1669
1333
|
return _context13.stop();
|
|
1670
1334
|
}
|
|
1671
|
-
}, _callee13, this, [[
|
|
1335
|
+
}, _callee13, this, [[3, 15, 18, 21]]);
|
|
1672
1336
|
}));
|
|
1673
1337
|
function mergeOrdersToStore(_x7, _x8) {
|
|
1674
1338
|
return _mergeOrdersToStore.apply(this, arguments);
|
|
@@ -1707,17 +1371,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1707
1371
|
key: "uniqueOrderIds",
|
|
1708
1372
|
value: function uniqueOrderIds(ids) {
|
|
1709
1373
|
var idMap = new Map();
|
|
1710
|
-
var
|
|
1711
|
-
|
|
1374
|
+
var _iterator8 = _createForOfIteratorHelper(ids),
|
|
1375
|
+
_step8;
|
|
1712
1376
|
try {
|
|
1713
|
-
for (
|
|
1714
|
-
var id =
|
|
1377
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
1378
|
+
var id = _step8.value;
|
|
1715
1379
|
idMap.set(this.getIdKey(id), id);
|
|
1716
1380
|
}
|
|
1717
1381
|
} catch (err) {
|
|
1718
|
-
|
|
1382
|
+
_iterator8.e(err);
|
|
1719
1383
|
} finally {
|
|
1720
|
-
|
|
1384
|
+
_iterator8.f();
|
|
1721
1385
|
}
|
|
1722
1386
|
return _toConsumableArray(idMap.values());
|
|
1723
1387
|
}
|
|
@@ -1756,9 +1420,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1756
1420
|
}, {
|
|
1757
1421
|
key: "getCurrentPullWindow",
|
|
1758
1422
|
value: function getCurrentPullWindow() {
|
|
1759
|
-
var _this$
|
|
1423
|
+
var _this$store2;
|
|
1760
1424
|
var now = dayjs();
|
|
1761
|
-
var range = (_this$
|
|
1425
|
+
var range = (_this$store2 = this.store) === null || _this$store2 === void 0 || (_this$store2 = _this$store2.createdAtQuery) === null || _this$store2 === void 0 ? void 0 : _this$store2.sales_time_between;
|
|
1762
1426
|
if (Array.isArray(range) && range.length >= 2) {
|
|
1763
1427
|
var _startAt = dayjs(range[0]);
|
|
1764
1428
|
var endExclusiveAt = dayjs(range[1]);
|
|
@@ -1804,7 +1468,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1804
1468
|
if (typeof globalThis !== 'undefined' && globalThis !== null && globalThis !== void 0 && globalThis.localStorage) {
|
|
1805
1469
|
return globalThis.localStorage.getItem(key);
|
|
1806
1470
|
}
|
|
1807
|
-
} catch (
|
|
1471
|
+
} catch (_unused5) {
|
|
1808
1472
|
// 忽略存储异常,避免影响主流程
|
|
1809
1473
|
}
|
|
1810
1474
|
return null;
|
|
@@ -1821,7 +1485,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1821
1485
|
if (typeof globalThis !== 'undefined' && globalThis !== null && globalThis !== void 0 && globalThis.localStorage) {
|
|
1822
1486
|
globalThis.localStorage.setItem(key, value);
|
|
1823
1487
|
}
|
|
1824
|
-
} catch (
|
|
1488
|
+
} catch (_unused6) {
|
|
1825
1489
|
// 忽略存储异常,避免影响主流程
|
|
1826
1490
|
}
|
|
1827
1491
|
}
|
|
@@ -1905,7 +1569,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1905
1569
|
key: "patchOrdersInSQLite",
|
|
1906
1570
|
value: (function () {
|
|
1907
1571
|
var _patchOrdersInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(orders, source) {
|
|
1908
|
-
var
|
|
1572
|
+
var _this11 = this;
|
|
1909
1573
|
var mergeActions,
|
|
1910
1574
|
ordersSnapshot,
|
|
1911
1575
|
_this$filterRedundant2,
|
|
@@ -1917,164 +1581,121 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1917
1581
|
case 0:
|
|
1918
1582
|
mergeActions = _args17.length > 2 && _args17[2] !== undefined ? _args17[2] : {};
|
|
1919
1583
|
if (!(!this.dbManager || orders.length === 0)) {
|
|
1920
|
-
_context17.next =
|
|
1584
|
+
_context17.next = 3;
|
|
1921
1585
|
break;
|
|
1922
1586
|
}
|
|
1923
|
-
this.pushOrderFlowLog('patchOrdersInSQLite.skip', {
|
|
1924
|
-
source: source,
|
|
1925
|
-
hasDbManager: !!this.dbManager,
|
|
1926
|
-
inputCount: orders.length
|
|
1927
|
-
});
|
|
1928
1587
|
return _context17.abrupt("return");
|
|
1929
|
-
case
|
|
1588
|
+
case 3:
|
|
1930
1589
|
ordersSnapshot = cloneDeep(orders).filter(function (order) {
|
|
1931
|
-
return
|
|
1590
|
+
return _this11.getOrderStorageKey(order);
|
|
1932
1591
|
});
|
|
1933
1592
|
if (!(ordersSnapshot.length === 0)) {
|
|
1934
|
-
_context17.next =
|
|
1593
|
+
_context17.next = 6;
|
|
1935
1594
|
break;
|
|
1936
1595
|
}
|
|
1937
|
-
this.pushOrderFlowLog('patchOrdersInSQLite.skipNoStorageKey', {
|
|
1938
|
-
source: source,
|
|
1939
|
-
inputCount: orders.length
|
|
1940
|
-
});
|
|
1941
1596
|
return _context17.abrupt("return");
|
|
1942
|
-
case
|
|
1597
|
+
case 6:
|
|
1943
1598
|
_this$filterRedundant2 = this.filterRedundantPatchOrders(source, ordersSnapshot, mergeActions), toWrite = _this$filterRedundant2.toWrite, skipped = _this$filterRedundant2.skipped;
|
|
1944
|
-
if (skipped.length > 0) {
|
|
1945
|
-
this.pushOrderFlowLog('patchOrdersInSQLite.dedupeSkipped', {
|
|
1946
|
-
source: source,
|
|
1947
|
-
skippedCount: skipped.length,
|
|
1948
|
-
skipped: skipped
|
|
1949
|
-
});
|
|
1950
|
-
}
|
|
1951
1599
|
if (!(toWrite.length === 0)) {
|
|
1952
|
-
_context17.next =
|
|
1600
|
+
_context17.next = 9;
|
|
1953
1601
|
break;
|
|
1954
1602
|
}
|
|
1955
|
-
this.pushOrderFlowLog('patchOrdersInSQLite.skipAllDeduped', {
|
|
1956
|
-
source: source,
|
|
1957
|
-
inputCount: ordersSnapshot.length,
|
|
1958
|
-
skipped: skipped
|
|
1959
|
-
});
|
|
1960
1603
|
return _context17.abrupt("return");
|
|
1961
|
-
case
|
|
1962
|
-
_context17.prev =
|
|
1963
|
-
_context17.next =
|
|
1604
|
+
case 9:
|
|
1605
|
+
_context17.prev = 9;
|
|
1606
|
+
_context17.next = 12;
|
|
1964
1607
|
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
1965
|
-
var writeMethod,
|
|
1608
|
+
var writeMethod, _iterator9, _step9, order;
|
|
1966
1609
|
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1967
1610
|
while (1) switch (_context16.prev = _context16.next) {
|
|
1968
1611
|
case 0:
|
|
1969
1612
|
writeMethod = 'none';
|
|
1970
|
-
|
|
1613
|
+
_this11.logInfo('patchOrdersInSQLite-开始', {
|
|
1971
1614
|
source: source,
|
|
1972
1615
|
count: toWrite.length,
|
|
1973
|
-
orderIds: toWrite.map(function (o) {
|
|
1974
|
-
return o.order_id;
|
|
1975
|
-
}),
|
|
1976
|
-
storageKeys: toWrite.map(function (o) {
|
|
1977
|
-
return _this12.getOrderStorageKey(o);
|
|
1978
|
-
}),
|
|
1979
1616
|
dedupedCount: skipped.length
|
|
1980
1617
|
});
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
count: toWrite.length
|
|
1984
|
-
});
|
|
1985
|
-
if (!(typeof _this12.dbManager.bulkUpdate === 'function')) {
|
|
1986
|
-
_context16.next = 9;
|
|
1618
|
+
if (!(typeof _this11.dbManager.bulkUpdate === 'function')) {
|
|
1619
|
+
_context16.next = 8;
|
|
1987
1620
|
break;
|
|
1988
1621
|
}
|
|
1989
1622
|
writeMethod = 'bulkUpdate';
|
|
1990
|
-
_context16.next =
|
|
1991
|
-
return
|
|
1992
|
-
case
|
|
1993
|
-
_context16.next =
|
|
1623
|
+
_context16.next = 6;
|
|
1624
|
+
return _this11.dbManager.bulkUpdate(INDEXDB_STORE_NAME, toWrite);
|
|
1625
|
+
case 6:
|
|
1626
|
+
_context16.next = 33;
|
|
1994
1627
|
break;
|
|
1995
|
-
case
|
|
1996
|
-
if (!(typeof
|
|
1997
|
-
_context16.next =
|
|
1628
|
+
case 8:
|
|
1629
|
+
if (!(typeof _this11.dbManager.bulkAdd === 'function')) {
|
|
1630
|
+
_context16.next = 14;
|
|
1998
1631
|
break;
|
|
1999
1632
|
}
|
|
2000
1633
|
writeMethod = 'bulkAdd';
|
|
2001
|
-
_context16.next =
|
|
2002
|
-
return
|
|
2003
|
-
case
|
|
2004
|
-
_context16.next =
|
|
1634
|
+
_context16.next = 12;
|
|
1635
|
+
return _this11.dbManager.bulkAdd(INDEXDB_STORE_NAME, toWrite);
|
|
1636
|
+
case 12:
|
|
1637
|
+
_context16.next = 33;
|
|
2005
1638
|
break;
|
|
2006
|
-
case
|
|
2007
|
-
if (!(typeof
|
|
2008
|
-
_context16.next =
|
|
1639
|
+
case 14:
|
|
1640
|
+
if (!(typeof _this11.dbManager.update === 'function')) {
|
|
1641
|
+
_context16.next = 33;
|
|
2009
1642
|
break;
|
|
2010
1643
|
}
|
|
2011
1644
|
writeMethod = 'update';
|
|
2012
|
-
|
|
2013
|
-
_context16.prev =
|
|
2014
|
-
|
|
2015
|
-
case
|
|
2016
|
-
if ((
|
|
2017
|
-
_context16.next =
|
|
1645
|
+
_iterator9 = _createForOfIteratorHelper(toWrite);
|
|
1646
|
+
_context16.prev = 17;
|
|
1647
|
+
_iterator9.s();
|
|
1648
|
+
case 19:
|
|
1649
|
+
if ((_step9 = _iterator9.n()).done) {
|
|
1650
|
+
_context16.next = 25;
|
|
2018
1651
|
break;
|
|
2019
1652
|
}
|
|
2020
|
-
order =
|
|
2021
|
-
_context16.next =
|
|
2022
|
-
return
|
|
2023
|
-
case
|
|
2024
|
-
_context16.next =
|
|
1653
|
+
order = _step9.value;
|
|
1654
|
+
_context16.next = 23;
|
|
1655
|
+
return _this11.dbManager.update(INDEXDB_STORE_NAME, order);
|
|
1656
|
+
case 23:
|
|
1657
|
+
_context16.next = 19;
|
|
2025
1658
|
break;
|
|
2026
|
-
case
|
|
2027
|
-
_context16.next =
|
|
1659
|
+
case 25:
|
|
1660
|
+
_context16.next = 30;
|
|
2028
1661
|
break;
|
|
2029
|
-
case
|
|
2030
|
-
_context16.prev =
|
|
2031
|
-
_context16.t0 = _context16["catch"](
|
|
2032
|
-
|
|
2033
|
-
case
|
|
2034
|
-
_context16.prev =
|
|
2035
|
-
|
|
2036
|
-
return _context16.finish(
|
|
2037
|
-
case
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
_this12.pushOrderFlowLog('patchOrdersInSQLite.done', {
|
|
1662
|
+
case 27:
|
|
1663
|
+
_context16.prev = 27;
|
|
1664
|
+
_context16.t0 = _context16["catch"](17);
|
|
1665
|
+
_iterator9.e(_context16.t0);
|
|
1666
|
+
case 30:
|
|
1667
|
+
_context16.prev = 30;
|
|
1668
|
+
_iterator9.f();
|
|
1669
|
+
return _context16.finish(30);
|
|
1670
|
+
case 33:
|
|
1671
|
+
_this11.recordRecentSqliteWrite(source, toWrite);
|
|
1672
|
+
_this11.logInfo('patchOrdersInSQLite-完成', {
|
|
2041
1673
|
source: source,
|
|
2042
|
-
writeSeq: writeSeq,
|
|
2043
1674
|
count: toWrite.length,
|
|
2044
1675
|
writeMethod: writeMethod,
|
|
2045
1676
|
dedupedCount: skipped.length
|
|
2046
1677
|
});
|
|
2047
|
-
|
|
2048
|
-
source: source,
|
|
2049
|
-
count: toWrite.length,
|
|
2050
|
-
dedupedCount: skipped.length
|
|
2051
|
-
});
|
|
2052
|
-
case 38:
|
|
1678
|
+
case 35:
|
|
2053
1679
|
case "end":
|
|
2054
1680
|
return _context16.stop();
|
|
2055
1681
|
}
|
|
2056
|
-
}, _callee16, null, [[
|
|
1682
|
+
}, _callee16, null, [[17, 27, 30, 33]]);
|
|
2057
1683
|
})));
|
|
2058
|
-
case
|
|
2059
|
-
_context17.next =
|
|
1684
|
+
case 12:
|
|
1685
|
+
_context17.next = 17;
|
|
2060
1686
|
break;
|
|
2061
|
-
case
|
|
2062
|
-
_context17.prev =
|
|
2063
|
-
_context17.t0 = _context17["catch"](
|
|
2064
|
-
this.pushOrderFlowLog('patchOrdersInSQLite.error', {
|
|
2065
|
-
source: source,
|
|
2066
|
-
error: _context17.t0 instanceof Error ? _context17.t0.message : String(_context17.t0),
|
|
2067
|
-
orderCount: ordersSnapshot.length
|
|
2068
|
-
});
|
|
1687
|
+
case 14:
|
|
1688
|
+
_context17.prev = 14;
|
|
1689
|
+
_context17.t0 = _context17["catch"](9);
|
|
2069
1690
|
this.logError('增量保存订单到 SQLite 失败', {
|
|
2070
1691
|
error: _context17.t0 instanceof Error ? _context17.t0.message : String(_context17.t0),
|
|
2071
1692
|
orderCount: ordersSnapshot.length
|
|
2072
1693
|
});
|
|
2073
|
-
case
|
|
1694
|
+
case 17:
|
|
2074
1695
|
case "end":
|
|
2075
1696
|
return _context17.stop();
|
|
2076
1697
|
}
|
|
2077
|
-
}, _callee17, this, [[
|
|
1698
|
+
}, _callee17, this, [[9, 14]]);
|
|
2078
1699
|
}));
|
|
2079
1700
|
function patchOrdersInSQLite(_x10, _x11) {
|
|
2080
1701
|
return _patchOrdersInSQLite.apply(this, arguments);
|
|
@@ -2092,110 +1713,89 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2092
1713
|
key: "updateOrderInSQLite",
|
|
2093
1714
|
value: (function () {
|
|
2094
1715
|
var _updateOrderInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(order, source) {
|
|
2095
|
-
var
|
|
2096
|
-
var
|
|
1716
|
+
var _this12 = this;
|
|
1717
|
+
var orderSnapshot, _orderSnapshot$order_3;
|
|
2097
1718
|
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
2098
1719
|
while (1) switch (_context19.prev = _context19.next) {
|
|
2099
1720
|
case 0:
|
|
2100
1721
|
if (!(!this.dbManager || !this.getOrderStorageKey(order))) {
|
|
2101
|
-
_context19.next =
|
|
1722
|
+
_context19.next = 2;
|
|
2102
1723
|
break;
|
|
2103
1724
|
}
|
|
2104
|
-
this.pushOrderFlowLog('updateOrderInSQLite.skip', {
|
|
2105
|
-
source: source,
|
|
2106
|
-
hasDbManager: !!this.dbManager,
|
|
2107
|
-
orderId: (_order$order_id3 = order === null || order === void 0 ? void 0 : order.order_id) !== null && _order$order_id3 !== void 0 ? _order$order_id3 : null
|
|
2108
|
-
});
|
|
2109
1725
|
return _context19.abrupt("return");
|
|
2110
|
-
case
|
|
1726
|
+
case 2:
|
|
2111
1727
|
orderSnapshot = cloneDeep(order);
|
|
2112
|
-
_context19.prev =
|
|
2113
|
-
_context19.next =
|
|
1728
|
+
_context19.prev = 3;
|
|
1729
|
+
_context19.next = 6;
|
|
2114
1730
|
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
2115
|
-
var _orderSnapshot$order_, _orderSnapshot$order_2
|
|
2116
|
-
var writeMethod
|
|
1731
|
+
var _orderSnapshot$order_, _orderSnapshot$order_2;
|
|
1732
|
+
var writeMethod;
|
|
2117
1733
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
2118
1734
|
while (1) switch (_context18.prev = _context18.next) {
|
|
2119
1735
|
case 0:
|
|
2120
1736
|
writeMethod = 'none';
|
|
2121
|
-
|
|
1737
|
+
_this12.logInfo('updateOrderInSQLite-开始', {
|
|
2122
1738
|
source: source,
|
|
2123
1739
|
orderId: (_orderSnapshot$order_ = orderSnapshot.order_id) !== null && _orderSnapshot$order_ !== void 0 ? _orderSnapshot$order_ : null,
|
|
2124
|
-
storageKey:
|
|
2125
|
-
});
|
|
2126
|
-
_this13.logInfo('updateOrderInSQLite-开始', {
|
|
2127
|
-
source: source,
|
|
2128
|
-
orderId: (_orderSnapshot$order_2 = orderSnapshot.order_id) !== null && _orderSnapshot$order_2 !== void 0 ? _orderSnapshot$order_2 : null,
|
|
2129
|
-
storageKey: _this13.getOrderStorageKey(orderSnapshot)
|
|
1740
|
+
storageKey: _this12.getOrderStorageKey(orderSnapshot)
|
|
2130
1741
|
});
|
|
2131
|
-
if (!(typeof
|
|
2132
|
-
_context18.next =
|
|
1742
|
+
if (!(typeof _this12.dbManager.update === 'function')) {
|
|
1743
|
+
_context18.next = 8;
|
|
2133
1744
|
break;
|
|
2134
1745
|
}
|
|
2135
1746
|
writeMethod = 'update';
|
|
2136
|
-
_context18.next =
|
|
2137
|
-
return
|
|
2138
|
-
case
|
|
2139
|
-
_context18.next =
|
|
1747
|
+
_context18.next = 6;
|
|
1748
|
+
return _this12.dbManager.update(INDEXDB_STORE_NAME, orderSnapshot);
|
|
1749
|
+
case 6:
|
|
1750
|
+
_context18.next = 18;
|
|
2140
1751
|
break;
|
|
2141
|
-
case
|
|
2142
|
-
if (!(typeof
|
|
2143
|
-
_context18.next =
|
|
1752
|
+
case 8:
|
|
1753
|
+
if (!(typeof _this12.dbManager.bulkUpdate === 'function')) {
|
|
1754
|
+
_context18.next = 14;
|
|
2144
1755
|
break;
|
|
2145
1756
|
}
|
|
2146
1757
|
writeMethod = 'bulkUpdate';
|
|
2147
|
-
_context18.next =
|
|
2148
|
-
return
|
|
2149
|
-
case
|
|
2150
|
-
_context18.next =
|
|
1758
|
+
_context18.next = 12;
|
|
1759
|
+
return _this12.dbManager.bulkUpdate(INDEXDB_STORE_NAME, [orderSnapshot]);
|
|
1760
|
+
case 12:
|
|
1761
|
+
_context18.next = 18;
|
|
2151
1762
|
break;
|
|
2152
|
-
case
|
|
2153
|
-
if (!(typeof
|
|
2154
|
-
_context18.next =
|
|
1763
|
+
case 14:
|
|
1764
|
+
if (!(typeof _this12.dbManager.bulkAdd === 'function')) {
|
|
1765
|
+
_context18.next = 18;
|
|
2155
1766
|
break;
|
|
2156
1767
|
}
|
|
2157
1768
|
writeMethod = 'bulkAdd';
|
|
2158
|
-
_context18.next =
|
|
2159
|
-
return
|
|
2160
|
-
case
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
_this13.pushOrderFlowLog('updateOrderInSQLite.done', {
|
|
1769
|
+
_context18.next = 18;
|
|
1770
|
+
return _this12.dbManager.bulkAdd(INDEXDB_STORE_NAME, [orderSnapshot]);
|
|
1771
|
+
case 18:
|
|
1772
|
+
_this12.recordRecentSqliteWrite(source, [orderSnapshot]);
|
|
1773
|
+
_this12.logInfo('updateOrderInSQLite-完成', {
|
|
2164
1774
|
source: source,
|
|
2165
|
-
|
|
2166
|
-
orderId: (_orderSnapshot$order_3 = orderSnapshot.order_id) !== null && _orderSnapshot$order_3 !== void 0 ? _orderSnapshot$order_3 : null,
|
|
2167
|
-
storageKey: _this13.getOrderStorageKey(orderSnapshot),
|
|
1775
|
+
orderId: (_orderSnapshot$order_2 = orderSnapshot.order_id) !== null && _orderSnapshot$order_2 !== void 0 ? _orderSnapshot$order_2 : null,
|
|
2168
1776
|
writeMethod: writeMethod
|
|
2169
1777
|
});
|
|
2170
|
-
|
|
2171
|
-
orderId: (_orderSnapshot$order_4 = orderSnapshot.order_id) !== null && _orderSnapshot$order_4 !== void 0 ? _orderSnapshot$order_4 : null
|
|
2172
|
-
});
|
|
2173
|
-
case 23:
|
|
1778
|
+
case 20:
|
|
2174
1779
|
case "end":
|
|
2175
1780
|
return _context18.stop();
|
|
2176
1781
|
}
|
|
2177
1782
|
}, _callee18);
|
|
2178
1783
|
})));
|
|
2179
|
-
case
|
|
2180
|
-
_context19.next =
|
|
1784
|
+
case 6:
|
|
1785
|
+
_context19.next = 11;
|
|
2181
1786
|
break;
|
|
2182
|
-
case
|
|
2183
|
-
_context19.prev =
|
|
2184
|
-
_context19.t0 = _context19["catch"](
|
|
2185
|
-
this.pushOrderFlowLog('updateOrderInSQLite.error', {
|
|
2186
|
-
source: source,
|
|
2187
|
-
error: _context19.t0 instanceof Error ? _context19.t0.message : String(_context19.t0),
|
|
2188
|
-
orderId: (_orderSnapshot$order_5 = orderSnapshot.order_id) !== null && _orderSnapshot$order_5 !== void 0 ? _orderSnapshot$order_5 : null
|
|
2189
|
-
});
|
|
1787
|
+
case 8:
|
|
1788
|
+
_context19.prev = 8;
|
|
1789
|
+
_context19.t0 = _context19["catch"](3);
|
|
2190
1790
|
this.logError('单条保存订单到 SQLite 失败', {
|
|
2191
1791
|
error: _context19.t0 instanceof Error ? _context19.t0.message : String(_context19.t0),
|
|
2192
|
-
orderId: (_orderSnapshot$
|
|
1792
|
+
orderId: (_orderSnapshot$order_3 = orderSnapshot.order_id) !== null && _orderSnapshot$order_3 !== void 0 ? _orderSnapshot$order_3 : null
|
|
2193
1793
|
});
|
|
2194
|
-
case
|
|
1794
|
+
case 11:
|
|
2195
1795
|
case "end":
|
|
2196
1796
|
return _context19.stop();
|
|
2197
1797
|
}
|
|
2198
|
-
}, _callee19, this, [[
|
|
1798
|
+
}, _callee19, this, [[3, 8]]);
|
|
2199
1799
|
}));
|
|
2200
1800
|
function updateOrderInSQLite(_x12, _x13) {
|
|
2201
1801
|
return _updateOrderInSQLite.apply(this, arguments);
|
|
@@ -2213,96 +1813,69 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2213
1813
|
key: "replaceOrdersSnapshotInSQLite",
|
|
2214
1814
|
value: (function () {
|
|
2215
1815
|
var _replaceOrdersSnapshotInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(orderList, source) {
|
|
2216
|
-
var
|
|
1816
|
+
var _this13 = this;
|
|
2217
1817
|
var orderListSnapshot;
|
|
2218
1818
|
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2219
1819
|
while (1) switch (_context21.prev = _context21.next) {
|
|
2220
1820
|
case 0:
|
|
2221
1821
|
if (this.dbManager) {
|
|
2222
|
-
_context21.next =
|
|
1822
|
+
_context21.next = 2;
|
|
2223
1823
|
break;
|
|
2224
1824
|
}
|
|
2225
|
-
this.pushOrderFlowLog('replaceOrdersSnapshotInSQLite.skip', {
|
|
2226
|
-
source: source,
|
|
2227
|
-
count: orderList.length
|
|
2228
|
-
});
|
|
2229
1825
|
return _context21.abrupt("return");
|
|
2230
|
-
case
|
|
1826
|
+
case 2:
|
|
2231
1827
|
orderListSnapshot = cloneDeep(orderList);
|
|
2232
|
-
_context21.prev =
|
|
2233
|
-
_context21.next =
|
|
1828
|
+
_context21.prev = 3;
|
|
1829
|
+
_context21.next = 6;
|
|
2234
1830
|
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
2235
|
-
var writeSeq;
|
|
2236
1831
|
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
2237
1832
|
while (1) switch (_context20.prev = _context20.next) {
|
|
2238
1833
|
case 0:
|
|
2239
|
-
|
|
2240
|
-
source: source,
|
|
2241
|
-
count: orderListSnapshot.length
|
|
2242
|
-
});
|
|
2243
|
-
_this14.logInfo('replaceOrdersSnapshotInSQLite-开始', {
|
|
1834
|
+
_this13.logInfo('replaceOrdersSnapshotInSQLite-开始', {
|
|
2244
1835
|
source: source,
|
|
2245
1836
|
count: orderListSnapshot.length
|
|
2246
1837
|
});
|
|
2247
|
-
_context20.next =
|
|
2248
|
-
return
|
|
2249
|
-
case
|
|
2250
|
-
|
|
2251
|
-
source: source,
|
|
2252
|
-
count: orderListSnapshot.length
|
|
2253
|
-
});
|
|
2254
|
-
_this14.logInfo('replaceOrdersSnapshotInSQLite-clear完成', {
|
|
1838
|
+
_context20.next = 3;
|
|
1839
|
+
return _this13.dbManager.clear(INDEXDB_STORE_NAME);
|
|
1840
|
+
case 3:
|
|
1841
|
+
_this13.logInfo('replaceOrdersSnapshotInSQLite-clear完成', {
|
|
2255
1842
|
count: orderListSnapshot.length
|
|
2256
1843
|
});
|
|
2257
1844
|
if (!(orderListSnapshot.length === 0)) {
|
|
2258
|
-
_context20.next =
|
|
1845
|
+
_context20.next = 6;
|
|
2259
1846
|
break;
|
|
2260
1847
|
}
|
|
2261
|
-
_this14.pushOrderFlowLog('replaceOrdersSnapshotInSQLite.doneEmpty', {
|
|
2262
|
-
source: source
|
|
2263
|
-
});
|
|
2264
1848
|
return _context20.abrupt("return");
|
|
2265
|
-
case
|
|
2266
|
-
_context20.next =
|
|
2267
|
-
return
|
|
2268
|
-
case
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
_this14.pushOrderFlowLog('replaceOrdersSnapshotInSQLite.done', {
|
|
1849
|
+
case 6:
|
|
1850
|
+
_context20.next = 8;
|
|
1851
|
+
return _this13.dbManager.bulkAdd(INDEXDB_STORE_NAME, orderListSnapshot);
|
|
1852
|
+
case 8:
|
|
1853
|
+
_this13.recordRecentSqliteWrite(source, orderListSnapshot);
|
|
1854
|
+
_this13.logInfo('replaceOrdersSnapshotInSQLite-bulkAdd完成', {
|
|
2272
1855
|
source: source,
|
|
2273
|
-
writeSeq: writeSeq,
|
|
2274
|
-
count: orderListSnapshot.length,
|
|
2275
|
-
writeMethod: 'clear+bulkAdd'
|
|
2276
|
-
});
|
|
2277
|
-
_this14.logInfo('replaceOrdersSnapshotInSQLite-bulkAdd完成', {
|
|
2278
1856
|
count: orderListSnapshot.length
|
|
2279
1857
|
});
|
|
2280
|
-
case
|
|
1858
|
+
case 10:
|
|
2281
1859
|
case "end":
|
|
2282
1860
|
return _context20.stop();
|
|
2283
1861
|
}
|
|
2284
1862
|
}, _callee20);
|
|
2285
1863
|
})));
|
|
2286
|
-
case
|
|
2287
|
-
_context21.next =
|
|
1864
|
+
case 6:
|
|
1865
|
+
_context21.next = 11;
|
|
2288
1866
|
break;
|
|
2289
|
-
case
|
|
2290
|
-
_context21.prev =
|
|
2291
|
-
_context21.t0 = _context21["catch"](
|
|
2292
|
-
this.pushOrderFlowLog('replaceOrdersSnapshotInSQLite.error', {
|
|
2293
|
-
source: source,
|
|
2294
|
-
error: _context21.t0 instanceof Error ? _context21.t0.message : String(_context21.t0),
|
|
2295
|
-
orderList: orderListSnapshot.length
|
|
2296
|
-
});
|
|
1867
|
+
case 8:
|
|
1868
|
+
_context21.prev = 8;
|
|
1869
|
+
_context21.t0 = _context21["catch"](3);
|
|
2297
1870
|
this.logError('全量保存订单到 SQLite 失败', {
|
|
2298
1871
|
error: _context21.t0 instanceof Error ? _context21.t0.message : String(_context21.t0),
|
|
2299
1872
|
orderList: orderListSnapshot.length
|
|
2300
1873
|
});
|
|
2301
|
-
case
|
|
1874
|
+
case 11:
|
|
2302
1875
|
case "end":
|
|
2303
1876
|
return _context21.stop();
|
|
2304
1877
|
}
|
|
2305
|
-
}, _callee21, this, [[
|
|
1878
|
+
}, _callee21, this, [[3, 8]]);
|
|
2306
1879
|
}));
|
|
2307
1880
|
function replaceOrdersSnapshotInSQLite(_x14, _x15) {
|
|
2308
1881
|
return _replaceOrdersSnapshotInSQLite.apply(this, arguments);
|
|
@@ -2320,7 +1893,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2320
1893
|
key: "clear",
|
|
2321
1894
|
value: (function () {
|
|
2322
1895
|
var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
2323
|
-
var
|
|
1896
|
+
var _this14 = this;
|
|
2324
1897
|
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2325
1898
|
while (1) switch (_context23.prev = _context23.next) {
|
|
2326
1899
|
case 0:
|
|
@@ -2337,7 +1910,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2337
1910
|
while (1) switch (_context22.prev = _context22.next) {
|
|
2338
1911
|
case 0:
|
|
2339
1912
|
_context22.next = 2;
|
|
2340
|
-
return
|
|
1913
|
+
return _this14.dbManager.clear(INDEXDB_STORE_NAME);
|
|
2341
1914
|
case 2:
|
|
2342
1915
|
case "end":
|
|
2343
1916
|
return _context22.stop();
|