@pisell/pisellos 2.2.147 → 2.2.149

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.
Files changed (247) hide show
  1. package/dist/apis/picoding.d.ts +0 -0
  2. package/dist/apis/picoding.js +1 -0
  3. package/dist/model/strategy/adapter/index.d.ts +2 -0
  4. package/dist/model/strategy/adapter/index.js +3 -1
  5. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
  6. package/dist/model/strategy/adapter/itemRule/adapter.js +483 -0
  7. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
  8. package/dist/model/strategy/adapter/itemRule/evaluator.js +169 -0
  9. package/dist/model/strategy/adapter/itemRule/examples.d.ts +79 -0
  10. package/dist/model/strategy/adapter/itemRule/examples.js +382 -0
  11. package/dist/model/strategy/adapter/itemRule/index.d.ts +5 -0
  12. package/dist/model/strategy/adapter/itemRule/index.js +5 -0
  13. package/dist/model/strategy/adapter/itemRule/type.d.ts +225 -0
  14. package/dist/model/strategy/adapter/itemRule/type.js +101 -0
  15. package/dist/modules/Cart/types.d.ts +2 -0
  16. package/dist/modules/Cart/utils/cartProduct.js +22 -1
  17. package/dist/modules/Cart/utils/changePrice.js +6 -0
  18. package/dist/modules/Date/index.d.ts +1 -1
  19. package/dist/modules/Date/index.js +16 -8
  20. package/dist/modules/Date/types.d.ts +3 -1
  21. package/dist/modules/OpenData/index.d.ts +24 -0
  22. package/dist/modules/OpenData/index.js +173 -0
  23. package/dist/modules/OpenData/types.d.ts +73 -0
  24. package/dist/modules/OpenData/types.js +1 -0
  25. package/dist/modules/OpenData/utils.d.ts +2 -0
  26. package/dist/modules/OpenData/utils.js +75 -0
  27. package/dist/modules/Order/index.d.ts +171 -1
  28. package/dist/modules/Order/index.js +2052 -112
  29. package/dist/modules/Order/types.d.ts +441 -20
  30. package/dist/modules/Order/types.js +23 -0
  31. package/dist/modules/Order/utils.d.ts +120 -0
  32. package/dist/modules/Order/utils.js +653 -2
  33. package/dist/modules/Product/utils.js +2 -2
  34. package/dist/modules/ProductList/index.js +2 -1
  35. package/dist/modules/Quotation/index.d.ts +8 -1
  36. package/dist/modules/Quotation/index.js +40 -10
  37. package/dist/modules/Quotation/types.d.ts +5 -0
  38. package/dist/modules/Rules/index.d.ts +3 -1
  39. package/dist/modules/Rules/index.js +136 -50
  40. package/dist/modules/Rules/types.d.ts +6 -0
  41. package/dist/modules/Rules/types.js +8 -0
  42. package/dist/modules/SalesSummary/index.d.ts +70 -0
  43. package/dist/modules/SalesSummary/index.js +175 -0
  44. package/dist/modules/SalesSummary/types.d.ts +64 -0
  45. package/dist/modules/SalesSummary/types.js +1 -0
  46. package/dist/modules/SalesSummary/utils.d.ts +34 -0
  47. package/dist/modules/SalesSummary/utils.js +488 -0
  48. package/dist/modules/ScanOrderLogger/index.d.ts +21 -0
  49. package/dist/modules/ScanOrderLogger/index.js +161 -0
  50. package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  51. package/dist/modules/ScanOrderLogger/providers/feishu.js +203 -0
  52. package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  53. package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
  54. package/dist/modules/ScanOrderLogger/types.d.ts +52 -0
  55. package/dist/modules/ScanOrderLogger/types.js +1 -0
  56. package/dist/modules/Schedule/getDateIsInSchedule.js +7 -7
  57. package/dist/modules/Schedule/index.d.ts +4 -13
  58. package/dist/modules/Schedule/index.js +6 -23
  59. package/dist/modules/Schedule/utils.d.ts +1 -1
  60. package/dist/modules/Summary/index.d.ts +3 -0
  61. package/dist/modules/Summary/index.js +134 -15
  62. package/dist/modules/Summary/types.d.ts +7 -0
  63. package/dist/modules/Summary/utils.d.ts +104 -1
  64. package/dist/modules/Summary/utils.js +1116 -13
  65. package/dist/modules/index.d.ts +4 -0
  66. package/dist/modules/index.js +5 -1
  67. package/dist/server/index.d.ts +41 -4
  68. package/dist/server/index.js +900 -405
  69. package/dist/server/modules/order/index.d.ts +10 -2
  70. package/dist/server/modules/order/index.js +251 -196
  71. package/dist/server/modules/products/index.d.ts +26 -0
  72. package/dist/server/modules/products/index.js +618 -338
  73. package/dist/server/modules/products/types.d.ts +5 -1
  74. package/dist/solution/BaseSales/index.d.ts +175 -0
  75. package/dist/solution/BaseSales/index.js +1293 -0
  76. package/dist/solution/BaseSales/types.d.ts +305 -0
  77. package/dist/solution/BaseSales/types.js +38 -0
  78. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
  79. package/dist/solution/BaseSales/utils/parseSalesResponse.js +159 -0
  80. package/dist/solution/BaseSales/utils.d.ts +40 -0
  81. package/dist/solution/BaseSales/utils.js +222 -0
  82. package/dist/solution/BookingByStep/index.d.ts +14 -0
  83. package/dist/solution/BookingByStep/index.js +699 -212
  84. package/dist/solution/BookingByStep/types.d.ts +3 -1
  85. package/dist/solution/BookingByStep/types.js +5 -1
  86. package/dist/solution/BookingByStep/utils/capacity.js +1 -1
  87. package/dist/solution/BookingByStep/utils/resources.js +6 -1
  88. package/dist/solution/BookingTicket/index.d.ts +113 -15
  89. package/dist/solution/BookingTicket/index.js +534 -196
  90. package/dist/solution/BookingTicket/types.d.ts +69 -6
  91. package/dist/solution/BookingTicket/types.js +40 -9
  92. package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
  93. package/dist/solution/BookingTicket/utils/bookingStatus.js +66 -0
  94. package/dist/solution/BookingTicket/utils/cartView.d.ts +26 -0
  95. package/dist/solution/BookingTicket/utils/cartView.js +84 -0
  96. package/dist/solution/Sales/index.d.ts +1 -0
  97. package/dist/solution/Sales/index.js +1 -0
  98. package/dist/solution/ScanOrder/index.d.ts +146 -0
  99. package/dist/solution/ScanOrder/index.js +3029 -0
  100. package/dist/solution/ScanOrder/types.d.ts +305 -0
  101. package/dist/solution/ScanOrder/types.js +35 -0
  102. package/dist/solution/ScanOrder/utils.d.ts +167 -0
  103. package/dist/solution/ScanOrder/utils.js +768 -0
  104. package/dist/solution/ShopDiscount/index.d.ts +2 -0
  105. package/dist/solution/ShopDiscount/index.js +9 -5
  106. package/dist/solution/ShopDiscount/types.d.ts +4 -0
  107. package/dist/solution/VenueBooking/index.d.ts +197 -0
  108. package/dist/solution/VenueBooking/index.js +3411 -0
  109. package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
  110. package/dist/solution/VenueBooking/types.d.ts +153 -0
  111. package/dist/solution/VenueBooking/types.js +21 -0
  112. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
  113. package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
  114. package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
  115. package/dist/solution/VenueBooking/utils/resource.js +130 -0
  116. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
  117. package/dist/solution/VenueBooking/utils/slotMerge.js +224 -0
  118. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
  119. package/dist/solution/VenueBooking/utils/timeSlot.js +453 -0
  120. package/dist/solution/VenueBooking/utils.d.ts +1 -0
  121. package/dist/solution/VenueBooking/utils.js +1 -0
  122. package/dist/solution/index.d.ts +3 -0
  123. package/dist/solution/index.js +4 -1
  124. package/lib/apis/picoding.d.ts +0 -0
  125. package/lib/apis/picoding.js +0 -0
  126. package/lib/model/strategy/adapter/index.d.ts +2 -0
  127. package/lib/model/strategy/adapter/index.js +6 -0
  128. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
  129. package/lib/model/strategy/adapter/itemRule/adapter.js +377 -0
  130. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
  131. package/lib/model/strategy/adapter/itemRule/evaluator.js +124 -0
  132. package/lib/model/strategy/adapter/itemRule/examples.d.ts +79 -0
  133. package/lib/model/strategy/adapter/itemRule/examples.js +316 -0
  134. package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
  135. package/lib/model/strategy/adapter/itemRule/index.js +60 -0
  136. package/lib/model/strategy/adapter/itemRule/type.d.ts +225 -0
  137. package/lib/model/strategy/adapter/itemRule/type.js +46 -0
  138. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  139. package/lib/modules/Cart/types.d.ts +2 -0
  140. package/lib/modules/Cart/utils/cartProduct.js +17 -1
  141. package/lib/modules/Cart/utils/changePrice.js +5 -0
  142. package/lib/modules/Date/index.d.ts +1 -1
  143. package/lib/modules/Date/index.js +7 -1
  144. package/lib/modules/Date/types.d.ts +3 -1
  145. package/lib/modules/OpenData/index.d.ts +24 -0
  146. package/lib/modules/OpenData/index.js +119 -0
  147. package/lib/modules/OpenData/types.d.ts +73 -0
  148. package/lib/modules/OpenData/types.js +17 -0
  149. package/lib/modules/OpenData/utils.d.ts +2 -0
  150. package/lib/modules/OpenData/utils.js +111 -0
  151. package/lib/modules/Order/index.d.ts +171 -1
  152. package/lib/modules/Order/index.js +1396 -5
  153. package/lib/modules/Order/types.d.ts +441 -20
  154. package/lib/modules/Order/types.js +1 -0
  155. package/lib/modules/Order/utils.d.ts +120 -0
  156. package/lib/modules/Order/utils.js +562 -2
  157. package/lib/modules/Product/utils.js +2 -2
  158. package/lib/modules/ProductList/index.js +2 -1
  159. package/lib/modules/Quotation/index.d.ts +8 -1
  160. package/lib/modules/Quotation/index.js +33 -4
  161. package/lib/modules/Quotation/types.d.ts +5 -0
  162. package/lib/modules/Rules/index.d.ts +3 -1
  163. package/lib/modules/Rules/index.js +46 -6
  164. package/lib/modules/Rules/types.d.ts +6 -0
  165. package/lib/modules/Rules/types.js +11 -2
  166. package/lib/modules/SalesSummary/index.d.ts +70 -0
  167. package/lib/modules/SalesSummary/index.js +106 -0
  168. package/lib/modules/SalesSummary/types.d.ts +64 -0
  169. package/lib/modules/SalesSummary/types.js +17 -0
  170. package/lib/modules/SalesSummary/utils.d.ts +34 -0
  171. package/lib/modules/SalesSummary/utils.js +430 -0
  172. package/lib/modules/ScanOrderLogger/index.d.ts +21 -0
  173. package/lib/modules/ScanOrderLogger/index.js +135 -0
  174. package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  175. package/lib/modules/ScanOrderLogger/providers/feishu.js +148 -0
  176. package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  177. package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
  178. package/lib/modules/ScanOrderLogger/types.d.ts +52 -0
  179. package/lib/modules/ScanOrderLogger/types.js +17 -0
  180. package/lib/modules/Schedule/getDateIsInSchedule.js +5 -5
  181. package/lib/modules/Schedule/index.d.ts +4 -13
  182. package/lib/modules/Schedule/index.js +4 -15
  183. package/lib/modules/Schedule/utils.d.ts +1 -1
  184. package/lib/modules/Summary/index.d.ts +3 -0
  185. package/lib/modules/Summary/index.js +61 -2
  186. package/lib/modules/Summary/types.d.ts +7 -0
  187. package/lib/modules/Summary/utils.d.ts +104 -1
  188. package/lib/modules/Summary/utils.js +659 -8
  189. package/lib/modules/index.d.ts +4 -0
  190. package/lib/modules/index.js +9 -1
  191. package/lib/server/index.d.ts +41 -4
  192. package/lib/server/index.js +272 -10
  193. package/lib/server/modules/order/index.d.ts +10 -2
  194. package/lib/server/modules/order/index.js +31 -4
  195. package/lib/server/modules/products/index.d.ts +26 -0
  196. package/lib/server/modules/products/index.js +174 -22
  197. package/lib/server/modules/products/types.d.ts +5 -1
  198. package/lib/solution/BaseSales/index.d.ts +175 -0
  199. package/lib/solution/BaseSales/index.js +655 -0
  200. package/lib/solution/BaseSales/types.d.ts +305 -0
  201. package/lib/solution/BaseSales/types.js +40 -0
  202. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
  203. package/lib/solution/BaseSales/utils/parseSalesResponse.js +160 -0
  204. package/lib/solution/BaseSales/utils.d.ts +40 -0
  205. package/lib/solution/BaseSales/utils.js +200 -0
  206. package/lib/solution/BookingByStep/index.d.ts +14 -0
  207. package/lib/solution/BookingByStep/index.js +469 -91
  208. package/lib/solution/BookingByStep/types.d.ts +3 -1
  209. package/lib/solution/BookingByStep/types.js +10 -0
  210. package/lib/solution/BookingByStep/utils/capacity.js +1 -1
  211. package/lib/solution/BookingByStep/utils/resources.js +5 -2
  212. package/lib/solution/BookingTicket/index.d.ts +113 -15
  213. package/lib/solution/BookingTicket/index.js +253 -61
  214. package/lib/solution/BookingTicket/types.d.ts +69 -6
  215. package/lib/solution/BookingTicket/types.js +16 -14
  216. package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
  217. package/lib/solution/BookingTicket/utils/bookingStatus.js +65 -0
  218. package/lib/solution/BookingTicket/utils/cartView.d.ts +26 -0
  219. package/lib/solution/BookingTicket/utils/cartView.js +103 -0
  220. package/lib/solution/Sales/index.d.ts +1 -0
  221. package/lib/solution/ScanOrder/index.d.ts +146 -0
  222. package/lib/solution/ScanOrder/index.js +1820 -0
  223. package/lib/solution/ScanOrder/types.d.ts +305 -0
  224. package/lib/solution/ScanOrder/types.js +36 -0
  225. package/lib/solution/ScanOrder/utils.d.ts +167 -0
  226. package/lib/solution/ScanOrder/utils.js +639 -0
  227. package/lib/solution/ShopDiscount/index.d.ts +2 -0
  228. package/lib/solution/ShopDiscount/index.js +9 -4
  229. package/lib/solution/ShopDiscount/types.d.ts +4 -0
  230. package/lib/solution/VenueBooking/index.d.ts +197 -0
  231. package/lib/solution/VenueBooking/index.js +1892 -0
  232. package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
  233. package/lib/solution/VenueBooking/types.d.ts +153 -0
  234. package/lib/solution/VenueBooking/types.js +44 -0
  235. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
  236. package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
  237. package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
  238. package/lib/solution/VenueBooking/utils/resource.js +91 -0
  239. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
  240. package/lib/solution/VenueBooking/utils/slotMerge.js +225 -0
  241. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
  242. package/lib/solution/VenueBooking/utils/timeSlot.js +339 -0
  243. package/lib/solution/VenueBooking/utils.d.ts +1 -0
  244. package/lib/solution/VenueBooking/utils.js +69 -0
  245. package/lib/solution/index.d.ts +3 -0
  246. package/lib/solution/index.js +7 -1
  247. package/package.json +1 -1
@@ -70,7 +70,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
70
70
  value: function () {
71
71
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
72
72
  var _options$initialState;
73
- var appPlugin, app, _this$store$createdAt, coreData, today, operatingDayBoundary, boundaryTime, boundaryStart, boundaryEnd;
73
+ var appPlugin, app, _this$store$createdAt, coreData, today, operatingDayBoundary, boundaryTime, boundaryStart, isAfterBoundary, queryStart, queryEnd;
74
74
  return _regeneratorRuntime().wrap(function _callee$(_context) {
75
75
  while (1) switch (_context.prev = _context.next) {
76
76
  case 0:
@@ -91,10 +91,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
91
91
  if (operatingDayBoundary.type === 'start_time') {
92
92
  boundaryTime = String(operatingDayBoundary.time || '').trim();
93
93
  boundaryStart = dayjs("".concat(today.format('YYYY-MM-DD'), " ").concat(boundaryTime));
94
- boundaryEnd = boundaryStart.add(1, 'day');
95
94
  if (boundaryStart.isValid()) {
95
+ isAfterBoundary = today.isAfter(boundaryStart);
96
+ queryStart = isAfterBoundary ? today.startOf('day') : today.subtract(1, 'day').startOf('day');
97
+ queryEnd = isAfterBoundary ? today.add(1, 'day').endOf('day') : today.endOf('day');
96
98
  this.store.createdAtQuery = {
97
- sales_time_between: [boundaryStart.startOf('day').format('YYYY-MM-DD HH:mm:ss'), boundaryEnd.endOf('day').format('YYYY-MM-DD HH:mm:ss')]
99
+ sales_time_between: [queryStart.format('YYYY-MM-DD HH:mm:ss'), queryEnd.format('YYYY-MM-DD HH:mm:ss')]
98
100
  };
99
101
  } else {
100
102
  // 边界时间异常时回退到自然日,避免 createdAtQuery 为空导致后续查询异常
@@ -275,14 +277,60 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
275
277
  value: function getOrderByOrderId(orderId) {
276
278
  return this.store.map.get(this.getIdKey(orderId));
277
279
  }
280
+ }, {
281
+ key: "getLocalOrderByOrderId",
282
+ value: function () {
283
+ var _getLocalOrderByOrderId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(orderId) {
284
+ var _this3 = this;
285
+ var key, memoryOrder, orders, localOrder;
286
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
287
+ while (1) switch (_context4.prev = _context4.next) {
288
+ case 0:
289
+ key = this.getIdKey(orderId);
290
+ memoryOrder = this.store.map.get(key);
291
+ if (!memoryOrder) {
292
+ _context4.next = 4;
293
+ break;
294
+ }
295
+ return _context4.abrupt("return", memoryOrder);
296
+ case 4:
297
+ _context4.next = 6;
298
+ return this.loadOrdersFromSQLite();
299
+ case 6:
300
+ orders = _context4.sent;
301
+ localOrder = orders.find(function (order) {
302
+ var id = order === null || order === void 0 ? void 0 : order.order_id;
303
+ if (id === undefined || id === null) return false;
304
+ return _this3.getIdKey(id) === key;
305
+ });
306
+ if (localOrder) {
307
+ _context4.next = 10;
308
+ break;
309
+ }
310
+ return _context4.abrupt("return", null);
311
+ case 10:
312
+ this.store.list = orders;
313
+ this.syncOrdersMap();
314
+ return _context4.abrupt("return", localOrder);
315
+ case 13:
316
+ case "end":
317
+ return _context4.stop();
318
+ }
319
+ }, _callee4, this);
320
+ }));
321
+ function getLocalOrderByOrderId(_x3) {
322
+ return _getLocalOrderByOrderId.apply(this, arguments);
323
+ }
324
+ return getLocalOrderByOrderId;
325
+ }()
278
326
  }, {
279
327
  key: "loadOrdersByServer",
280
328
  value: function () {
281
- var _loadOrdersByServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
329
+ var _loadOrdersByServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
282
330
  var _this$store;
283
331
  var orderList, data;
284
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
285
- while (1) switch (_context4.prev = _context4.next) {
332
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
333
+ while (1) switch (_context5.prev = _context5.next) {
286
334
  case 0:
287
335
  orderList = [];
288
336
  this.logInfo('loadOrdersByServer-开始', {
@@ -290,46 +338,46 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
290
338
  query: ((_this$store = this.store) === null || _this$store === void 0 ? void 0 : _this$store.createdAtQuery) || null
291
339
  });
292
340
  if (!this.orderDataSource) {
293
- _context4.next = 16;
341
+ _context5.next = 16;
294
342
  break;
295
343
  }
296
- _context4.prev = 3;
297
- _context4.next = 6;
344
+ _context5.prev = 3;
345
+ _context5.next = 6;
298
346
  return this.orderDataSource.run({
299
347
  sse: {
300
348
  query: this.store.createdAtQuery
301
349
  }
302
350
  });
303
351
  case 6:
304
- data = _context4.sent;
352
+ data = _context5.sent;
305
353
  orderList = data || [];
306
354
  this.logInfo('loadOrdersByServer-SSE拉取成功', {
307
355
  count: orderList.length
308
356
  });
309
357
  this.markOrderPulledAtNow();
310
- _context4.next = 16;
358
+ _context5.next = 16;
311
359
  break;
312
360
  case 12:
313
- _context4.prev = 12;
314
- _context4.t0 = _context4["catch"](3);
361
+ _context5.prev = 12;
362
+ _context5.t0 = _context5["catch"](3);
315
363
  orderList = [];
316
364
  this.logInfo('loadOrdersByServer-SSE拉取失败,回退为空数组');
317
365
  case 16:
318
- _context4.next = 18;
366
+ _context5.next = 18;
319
367
  return this.saveOrdersToSQLite(orderList);
320
368
  case 18:
321
369
  this.logInfo('loadOrdersByServer-结束', {
322
370
  count: orderList.length
323
371
  });
324
- _context4.next = 21;
372
+ _context5.next = 21;
325
373
  return this.core.effects.emit(OrderHooks.onOrdersLoaded, orderList);
326
374
  case 21:
327
- return _context4.abrupt("return", orderList);
375
+ return _context5.abrupt("return", orderList);
328
376
  case 22:
329
377
  case "end":
330
- return _context4.stop();
378
+ return _context5.stop();
331
379
  }
332
- }, _callee4, this, [[3, 12]]);
380
+ }, _callee5, this, [[3, 12]]);
333
381
  }));
334
382
  function loadOrdersByServer() {
335
383
  return _loadOrdersByServer.apply(this, arguments);
@@ -339,10 +387,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
339
387
  }, {
340
388
  key: "getOrdersByResourceId",
341
389
  value: function getOrdersByResourceId(resourceId) {
342
- var _this3 = this;
390
+ var _this4 = this;
343
391
  var ids = this.resourceIdIndex.get(String(resourceId)) || [];
344
392
  return ids.map(function (id) {
345
- return _this3.store.map.get(id);
393
+ return _this4.store.map.get(id);
346
394
  }).filter(function (order) {
347
395
  return !!order;
348
396
  });
@@ -355,31 +403,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
355
403
  }, {
356
404
  key: "overwriteExistingOrder",
357
405
  value: (function () {
358
- var _overwriteExistingOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(fresh) {
359
- var _this4 = this;
406
+ var _overwriteExistingOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(fresh) {
407
+ var _this5 = this;
360
408
  var orderId, key;
361
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
362
- while (1) switch (_context5.prev = _context5.next) {
409
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
410
+ while (1) switch (_context6.prev = _context6.next) {
363
411
  case 0:
364
412
  orderId = fresh === null || fresh === void 0 ? void 0 : fresh.order_id;
365
413
  if (!(orderId === undefined || orderId === null)) {
366
- _context5.next = 4;
414
+ _context6.next = 4;
367
415
  break;
368
416
  }
369
417
  this.logError('overwriteExistingOrder-入参缺少 order_id');
370
- return _context5.abrupt("return", {
418
+ return _context6.abrupt("return", {
371
419
  overwritten: false
372
420
  });
373
421
  case 4:
374
422
  key = this.getIdKey(orderId);
375
423
  if (this.store.map.has(key)) {
376
- _context5.next = 8;
424
+ _context6.next = 8;
377
425
  break;
378
426
  }
379
427
  this.logInfo('overwriteExistingOrder-本地不存在该订单,跳过', {
380
428
  orderId: orderId
381
429
  });
382
- return _context5.abrupt("return", {
430
+ return _context6.abrupt("return", {
383
431
  overwritten: false
384
432
  });
385
433
  case 8:
@@ -390,29 +438,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
390
438
  this.store.list = this.store.list.map(function (order) {
391
439
  var id = order === null || order === void 0 ? void 0 : order.order_id;
392
440
  if (id === undefined || id === null) return order;
393
- return _this4.getIdKey(id) === key ? fresh : order;
441
+ return _this5.getIdKey(id) === key ? fresh : order;
394
442
  });
395
443
  this.syncOrdersMap();
396
- _context5.next = 13;
444
+ _context6.next = 13;
397
445
  return this.saveOrdersToSQLite(this.store.list);
398
446
  case 13:
399
447
  this.logInfo('overwriteExistingOrder-结束', {
400
448
  orderId: orderId,
401
449
  storeOrderCountAfter: this.store.list.length
402
450
  });
403
- _context5.next = 16;
451
+ _context6.next = 16;
404
452
  return this.core.effects.emit(OrderHooks.onOrdersChanged, this.store.list);
405
453
  case 16:
406
- return _context5.abrupt("return", {
454
+ return _context6.abrupt("return", {
407
455
  overwritten: true
408
456
  });
409
457
  case 17:
410
458
  case "end":
411
- return _context5.stop();
459
+ return _context6.stop();
412
460
  }
413
- }, _callee5, this);
461
+ }, _callee6, this);
414
462
  }));
415
- function overwriteExistingOrder(_x3) {
463
+ function overwriteExistingOrder(_x4) {
416
464
  return _overwriteExistingOrder.apply(this, arguments);
417
465
  }
418
466
  return overwriteExistingOrder;
@@ -425,29 +473,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
425
473
  }, {
426
474
  key: "upsertOrdersFromRemote",
427
475
  value: (function () {
428
- var _upsertOrdersFromRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(freshOrders) {
429
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
430
- while (1) switch (_context6.prev = _context6.next) {
476
+ var _upsertOrdersFromRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(freshOrders) {
477
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
478
+ while (1) switch (_context7.prev = _context7.next) {
431
479
  case 0:
432
480
  if (freshOrders !== null && freshOrders !== void 0 && freshOrders.length) {
433
- _context6.next = 3;
481
+ _context7.next = 3;
434
482
  break;
435
483
  }
436
484
  this.logInfo('upsertOrdersFromRemote-订单列表为空', {});
437
- return _context6.abrupt("return");
485
+ return _context7.abrupt("return");
438
486
  case 3:
439
487
  this.logInfo('upsertOrdersFromRemote-开始', {
440
488
  count: freshOrders.length
441
489
  });
442
- _context6.next = 6;
490
+ _context7.next = 6;
443
491
  return this.mergeOrdersToStore(freshOrders);
444
492
  case 6:
445
493
  case "end":
446
- return _context6.stop();
494
+ return _context7.stop();
447
495
  }
448
- }, _callee6, this);
496
+ }, _callee7, this);
449
497
  }));
450
- function upsertOrdersFromRemote(_x4) {
498
+ function upsertOrdersFromRemote(_x5) {
451
499
  return _upsertOrdersFromRemote.apply(this, arguments);
452
500
  }
453
501
  return upsertOrdersFromRemote;
@@ -459,42 +507,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
459
507
  }, {
460
508
  key: "fetchOrdersBySSE",
461
509
  value: (function () {
462
- var _fetchOrdersBySSE = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
510
+ var _fetchOrdersBySSE = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
463
511
  var query,
464
512
  data,
465
- _args7 = arguments;
466
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
467
- while (1) switch (_context7.prev = _context7.next) {
513
+ _args8 = arguments;
514
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
515
+ while (1) switch (_context8.prev = _context8.next) {
468
516
  case 0:
469
- query = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
517
+ query = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
470
518
  if (this.orderDataSource) {
471
- _context7.next = 3;
519
+ _context8.next = 3;
472
520
  break;
473
521
  }
474
- return _context7.abrupt("return", []);
522
+ return _context8.abrupt("return", []);
475
523
  case 3:
476
- _context7.prev = 3;
477
- _context7.next = 6;
524
+ _context8.prev = 3;
525
+ _context8.next = 6;
478
526
  return this.orderDataSource.run({
479
527
  sse: {
480
528
  query: query
481
529
  }
482
530
  });
483
531
  case 6:
484
- data = _context7.sent;
485
- return _context7.abrupt("return", data || []);
532
+ data = _context8.sent;
533
+ return _context8.abrupt("return", data || []);
486
534
  case 10:
487
- _context7.prev = 10;
488
- _context7.t0 = _context7["catch"](3);
535
+ _context8.prev = 10;
536
+ _context8.t0 = _context8["catch"](3);
489
537
  this.logError('fetchOrdersBySSE-失败', {
490
- error: _context7.t0 instanceof Error ? _context7.t0.message : String(_context7.t0)
538
+ error: _context8.t0 instanceof Error ? _context8.t0.message : String(_context8.t0)
491
539
  });
492
- return _context7.abrupt("return", []);
540
+ return _context8.abrupt("return", []);
493
541
  case 14:
494
542
  case "end":
495
- return _context7.stop();
543
+ return _context8.stop();
496
544
  }
497
- }, _callee7, this, [[3, 10]]);
545
+ }, _callee8, this, [[3, 10]]);
498
546
  }));
499
547
  function fetchOrdersBySSE() {
500
548
  return _fetchOrdersBySSE.apply(this, arguments);
@@ -522,7 +570,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
522
570
  }, {
523
571
  key: "syncOrdersMap",
524
572
  value: function syncOrdersMap() {
525
- var _this5 = this;
573
+ var _this6 = this;
526
574
  this.store.map.clear();
527
575
  this.resourceIdIndex.clear();
528
576
  var _iterator = _createForOfIteratorHelper(this.store.list),
@@ -532,20 +580,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
532
580
  var order = _step.value;
533
581
  var id = order.order_id;
534
582
  if (id === undefined || id === null) return 1; // continue
535
- _this5.store.map.set(_this5.getIdKey(id), order);
536
- var resourceIds = _this5.extractResourceIds(order);
583
+ _this6.store.map.set(_this6.getIdKey(id), order);
584
+ var resourceIds = _this6.extractResourceIds(order);
537
585
  var _iterator2 = _createForOfIteratorHelper(resourceIds),
538
586
  _step2;
539
587
  try {
540
588
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
541
589
  var resourceId = _step2.value;
542
590
  var key = String(resourceId);
543
- var existing = _this5.resourceIdIndex.get(key) || [];
591
+ var existing = _this6.resourceIdIndex.get(key) || [];
544
592
  if (existing.some(function (eid) {
545
- return _this5.getIdKey(eid) === _this5.getIdKey(id);
593
+ return _this6.getIdKey(eid) === _this6.getIdKey(id);
546
594
  })) continue;
547
595
  existing.push(id);
548
- _this5.resourceIdIndex.set(key, existing);
596
+ _this6.resourceIdIndex.set(key, existing);
549
597
  }
550
598
  } catch (err) {
551
599
  _iterator2.e(err);
@@ -614,7 +662,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
614
662
  }, {
615
663
  key: "setupOrderSync",
616
664
  value: function setupOrderSync() {
617
- var _this6 = this;
665
+ var _this7 = this;
618
666
  if (!this.orderDataSource) return;
619
667
  this.orderDataSource.run({
620
668
  pubsub: {
@@ -622,20 +670,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
622
670
  var _message$id, _message$order_id, _message$type;
623
671
  console.log('orderDataSource');
624
672
  var pubsubReceivedAt = Date.now();
625
- var message = _this6.normalizeOrderSyncMessage(res);
673
+ var message = _this7.normalizeOrderSyncMessage(res);
626
674
  if (!message) return;
627
675
  message._pubsubReceivedAt = pubsubReceivedAt;
628
- _this6.pendingSyncMessages.push(message);
629
- var throttleMs = _this6.getOrderSyncThrottleMs();
630
- _this6.logInfo('orderSync-收到消息并入队', {
676
+ _this7.pendingSyncMessages.push(message);
677
+ var throttleMs = _this7.getOrderSyncThrottleMs();
678
+ _this7.logInfo('orderSync-收到消息并入队', {
631
679
  id: (_message$id = message.id) !== null && _message$id !== void 0 ? _message$id : null,
632
680
  order_id: (_message$order_id = message.order_id) !== null && _message$order_id !== void 0 ? _message$order_id : null,
633
681
  type: (_message$type = message.type) !== null && _message$type !== void 0 ? _message$type : null,
634
- pendingCount: _this6.pendingSyncMessages.length,
682
+ pendingCount: _this7.pendingSyncMessages.length,
635
683
  throttleMs: throttleMs,
636
684
  pubsubReceivedAt: new Date(pubsubReceivedAt).toISOString()
637
685
  });
638
- _this6.scheduleOrderSyncThrottle();
686
+ _this7.scheduleOrderSyncThrottle();
639
687
  }
640
688
  }
641
689
  }).catch(function () {
@@ -652,7 +700,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
652
700
  }, {
653
701
  key: "scheduleOrderSyncThrottle",
654
702
  value: function scheduleOrderSyncThrottle() {
655
- var _this7 = this;
703
+ var _this8 = this;
656
704
  if (this.isProcessingSyncBatch) return;
657
705
  if (this.isIdlePhase) {
658
706
  this.isIdlePhase = false;
@@ -663,8 +711,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
663
711
  if (this.syncTimer) return;
664
712
  var throttleMs = this.getOrderSyncThrottleMs();
665
713
  this.syncTimer = setTimeout(function () {
666
- _this7.syncTimer = undefined;
667
- void _this7.flushOrderSyncMessagesByThrottle();
714
+ _this8.syncTimer = undefined;
715
+ void _this8.flushOrderSyncMessagesByThrottle();
668
716
  }, throttleMs);
669
717
  }
670
718
 
@@ -675,41 +723,41 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
675
723
  }, {
676
724
  key: "flushOrderSyncMessagesByThrottle",
677
725
  value: (function () {
678
- var _flushOrderSyncMessagesByThrottle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
679
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
680
- while (1) switch (_context8.prev = _context8.next) {
726
+ var _flushOrderSyncMessagesByThrottle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
727
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
728
+ while (1) switch (_context9.prev = _context9.next) {
681
729
  case 0:
682
730
  if (!this.isProcessingSyncBatch) {
683
- _context8.next = 2;
731
+ _context9.next = 2;
684
732
  break;
685
733
  }
686
- return _context8.abrupt("return");
734
+ return _context9.abrupt("return");
687
735
  case 2:
688
736
  if (!(this.pendingSyncMessages.length === 0)) {
689
- _context8.next = 5;
737
+ _context9.next = 5;
690
738
  break;
691
739
  }
692
740
  this.isIdlePhase = true;
693
- return _context8.abrupt("return");
741
+ return _context9.abrupt("return");
694
742
  case 5:
695
743
  this.isProcessingSyncBatch = true;
696
- _context8.prev = 6;
697
- _context8.next = 9;
744
+ _context9.prev = 6;
745
+ _context9.next = 9;
698
746
  return this.processOrderSyncMessages();
699
747
  case 9:
700
- _context8.prev = 9;
748
+ _context9.prev = 9;
701
749
  this.isProcessingSyncBatch = false;
702
750
  if (this.pendingSyncMessages.length > 0) {
703
751
  this.scheduleOrderSyncThrottle();
704
752
  } else {
705
753
  this.isIdlePhase = true;
706
754
  }
707
- return _context8.finish(9);
755
+ return _context9.finish(9);
708
756
  case 13:
709
757
  case "end":
710
- return _context8.stop();
758
+ return _context9.stop();
711
759
  }
712
- }, _callee8, this, [[6,, 9, 13]]);
760
+ }, _callee9, this, [[6,, 9, 13]]);
713
761
  }));
714
762
  function flushOrderSyncMessagesByThrottle() {
715
763
  return _flushOrderSyncMessagesByThrottle.apply(this, arguments);
@@ -731,18 +779,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
731
779
  }, {
732
780
  key: "processOrderSyncMessages",
733
781
  value: (function () {
734
- var _processOrderSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
782
+ var _processOrderSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
735
783
  var messages, batchProcessStartAt, earliestReceivedAt, upsertOrders, refreshIds, _iterator3, _step3, _msg$id, _msg$relation_order_i, msg, hasBatchIds, singleId, hasSingleId, rawBody, normalizedBody, uniqueRefreshIds, upsertList, freshOrders, batchProcessEndAt;
736
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
737
- while (1) switch (_context9.prev = _context9.next) {
784
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
785
+ while (1) switch (_context10.prev = _context10.next) {
738
786
  case 0:
739
787
  messages = _toConsumableArray(this.pendingSyncMessages);
740
788
  this.pendingSyncMessages = [];
741
789
  if (!(messages.length === 0)) {
742
- _context9.next = 4;
790
+ _context10.next = 4;
743
791
  break;
744
792
  }
745
- return _context9.abrupt("return");
793
+ return _context10.abrupt("return");
746
794
  case 4:
747
795
  batchProcessStartAt = Date.now();
748
796
  earliestReceivedAt = Math.min.apply(Math, _toConsumableArray(messages.map(function (m) {
@@ -758,11 +806,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
758
806
  upsertOrders = new Map();
759
807
  refreshIds = [];
760
808
  _iterator3 = _createForOfIteratorHelper(messages);
761
- _context9.prev = 10;
809
+ _context10.prev = 10;
762
810
  _iterator3.s();
763
811
  case 12:
764
812
  if ((_step3 = _iterator3.n()).done) {
765
- _context9.next = 25;
813
+ _context10.next = 25;
766
814
  break;
767
815
  }
768
816
  msg = _step3.value;
@@ -772,27 +820,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
772
820
  rawBody = msg.body || msg.data;
773
821
  normalizedBody = this.normalizeOrderSyncPayload(rawBody);
774
822
  if (!(hasSingleId && normalizedBody)) {
775
- _context9.next = 22;
823
+ _context10.next = 22;
776
824
  break;
777
825
  }
778
826
  upsertOrders.set(this.getIdKey(normalizedBody.order_id), normalizedBody);
779
- return _context9.abrupt("continue", 23);
827
+ return _context10.abrupt("continue", 23);
780
828
  case 22:
781
829
  if (hasBatchIds) refreshIds.push.apply(refreshIds, _toConsumableArray(msg.ids));else if (hasSingleId) refreshIds.push(singleId);else if ((_msg$relation_order_i = msg.relation_order_ids) !== null && _msg$relation_order_i !== void 0 && _msg$relation_order_i.length) refreshIds.push.apply(refreshIds, _toConsumableArray(msg.relation_order_ids));
782
830
  case 23:
783
- _context9.next = 12;
831
+ _context10.next = 12;
784
832
  break;
785
833
  case 25:
786
- _context9.next = 30;
834
+ _context10.next = 30;
787
835
  break;
788
836
  case 27:
789
- _context9.prev = 27;
790
- _context9.t0 = _context9["catch"](10);
791
- _iterator3.e(_context9.t0);
837
+ _context10.prev = 27;
838
+ _context10.t0 = _context10["catch"](10);
839
+ _iterator3.e(_context10.t0);
792
840
  case 30:
793
- _context9.prev = 30;
841
+ _context10.prev = 30;
794
842
  _iterator3.f();
795
- return _context9.finish(30);
843
+ return _context10.finish(30);
796
844
  case 33:
797
845
  uniqueRefreshIds = this.uniqueOrderIds(refreshIds);
798
846
  upsertList = _toConsumableArray(upsertOrders.values());
@@ -801,32 +849,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
801
849
  refreshIdCount: uniqueRefreshIds.length
802
850
  });
803
851
  if (!(upsertList.length > 0)) {
804
- _context9.next = 39;
852
+ _context10.next = 39;
805
853
  break;
806
854
  }
807
- _context9.next = 39;
855
+ _context10.next = 39;
808
856
  return this.mergeOrdersToStore(upsertList);
809
857
  case 39:
810
858
  if (!(uniqueRefreshIds.length > 0)) {
811
- _context9.next = 46;
859
+ _context10.next = 46;
812
860
  break;
813
861
  }
814
- _context9.next = 42;
862
+ _context10.next = 42;
815
863
  return this.fetchOrdersByHttp(uniqueRefreshIds);
816
864
  case 42:
817
- freshOrders = _context9.sent;
865
+ freshOrders = _context10.sent;
818
866
  if (!(freshOrders.length > 0)) {
819
- _context9.next = 46;
867
+ _context10.next = 46;
820
868
  break;
821
869
  }
822
- _context9.next = 46;
870
+ _context10.next = 46;
823
871
  return this.mergeOrdersToStore(freshOrders);
824
872
  case 46:
825
873
  if (!(upsertList.length === 0 && uniqueRefreshIds.length === 0)) {
826
- _context9.next = 48;
874
+ _context10.next = 48;
827
875
  break;
828
876
  }
829
- return _context9.abrupt("return");
877
+ return _context10.abrupt("return");
830
878
  case 48:
831
879
  batchProcessEndAt = Date.now();
832
880
  this.logInfo('processOrderSyncMessages-结束', {
@@ -835,13 +883,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
835
883
  batchProcessDurationMs: batchProcessEndAt - batchProcessStartAt,
836
884
  totalFromPubsubToProcessedMs: batchProcessEndAt - earliestReceivedAt
837
885
  });
838
- _context9.next = 52;
886
+ _context10.next = 52;
839
887
  return this.core.effects.emit(OrderHooks.onOrdersSyncCompleted, null);
840
888
  case 52:
841
889
  case "end":
842
- return _context9.stop();
890
+ return _context10.stop();
843
891
  }
844
- }, _callee9, this, [[10, 27, 30, 33]]);
892
+ }, _callee10, this, [[10, 27, 30, 33]]);
845
893
  }));
846
894
  function processOrderSyncMessages() {
847
895
  return _processOrderSyncMessages.apply(this, arguments);
@@ -849,35 +897,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
849
897
  return processOrderSyncMessages;
850
898
  }()
851
899
  /**
852
- * 通过 HTTP 按 ids 增量拉取订单
900
+ * 通过 HTTP 按 ids 批量拉取订单详情(走 orderDataSource)。
901
+ *
902
+ * - 优先使用 `orderDataSource.fetchOrdersByIds`(如适配器实现了该方法)
903
+ * - 否则回退到 `orderDataSource.run({ http: { query: { ids } } })`
904
+ * - 失败统一返回空数组(由调用方按"返回缺失的 id" 判断单笔失败)
905
+ *
906
+ * @example
907
+ * const fresh = await orderModule.fetchOrdersByHttp(['96971', '96972'])
853
908
  */
854
909
  )
855
910
  }, {
856
911
  key: "fetchOrdersByHttp",
857
912
  value: (function () {
858
- var _fetchOrdersByHttp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(ids) {
913
+ var _fetchOrdersByHttp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(ids) {
859
914
  var _orderList, orderList;
860
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
861
- while (1) switch (_context10.prev = _context10.next) {
915
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
916
+ while (1) switch (_context11.prev = _context11.next) {
862
917
  case 0:
863
918
  if (!(!this.orderDataSource || ids.length === 0)) {
864
- _context10.next = 2;
919
+ _context11.next = 2;
865
920
  break;
866
921
  }
867
- return _context10.abrupt("return", []);
922
+ return _context11.abrupt("return", []);
868
923
  case 2:
869
- _context10.prev = 2;
924
+ _context11.prev = 2;
870
925
  if (!(typeof this.orderDataSource.fetchOrdersByIds === 'function')) {
871
- _context10.next = 8;
926
+ _context11.next = 8;
872
927
  break;
873
928
  }
874
- _context10.next = 6;
929
+ _context11.next = 6;
875
930
  return this.orderDataSource.fetchOrdersByIds(ids);
876
931
  case 6:
877
- _orderList = _context10.sent;
878
- return _context10.abrupt("return", _orderList || []);
932
+ _orderList = _context11.sent;
933
+ return _context11.abrupt("return", _orderList || []);
879
934
  case 8:
880
- _context10.next = 10;
935
+ _context11.next = 10;
881
936
  return this.orderDataSource.run({
882
937
  http: {
883
938
  query: {
@@ -886,19 +941,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
886
941
  }
887
942
  });
888
943
  case 10:
889
- orderList = _context10.sent;
890
- return _context10.abrupt("return", orderList || []);
944
+ orderList = _context11.sent;
945
+ return _context11.abrupt("return", orderList || []);
891
946
  case 14:
892
- _context10.prev = 14;
893
- _context10.t0 = _context10["catch"](2);
894
- return _context10.abrupt("return", []);
947
+ _context11.prev = 14;
948
+ _context11.t0 = _context11["catch"](2);
949
+ return _context11.abrupt("return", []);
895
950
  case 17:
896
951
  case "end":
897
- return _context10.stop();
952
+ return _context11.stop();
898
953
  }
899
- }, _callee10, this, [[2, 14]]);
954
+ }, _callee11, this, [[2, 14]]);
900
955
  }));
901
- function fetchOrdersByHttp(_x5) {
956
+ function fetchOrdersByHttp(_x6) {
902
957
  return _fetchOrdersByHttp.apply(this, arguments);
903
958
  }
904
959
  return fetchOrdersByHttp;
@@ -910,11 +965,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
910
965
  }, {
911
966
  key: "mergeOrdersToStore",
912
967
  value: (function () {
913
- var _mergeOrdersToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(freshOrders) {
914
- var _this8 = this;
968
+ var _mergeOrdersToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(freshOrders) {
969
+ var _this9 = this;
915
970
  var freshMap, _iterator4, _step4, order, id, uniqueFreshCount, updatedList, _iterator5, _step5, _order;
916
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
917
- while (1) switch (_context11.prev = _context11.next) {
971
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
972
+ while (1) switch (_context12.prev = _context12.next) {
918
973
  case 0:
919
974
  this.logInfo('mergeOrdersToStore-开始', {
920
975
  freshOrderCount: freshOrders.length,
@@ -922,42 +977,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
922
977
  });
923
978
  freshMap = new Map();
924
979
  _iterator4 = _createForOfIteratorHelper(freshOrders);
925
- _context11.prev = 3;
980
+ _context12.prev = 3;
926
981
  _iterator4.s();
927
982
  case 5:
928
983
  if ((_step4 = _iterator4.n()).done) {
929
- _context11.next = 13;
984
+ _context12.next = 13;
930
985
  break;
931
986
  }
932
987
  order = _step4.value;
933
988
  id = order === null || order === void 0 ? void 0 : order.order_id;
934
989
  if (!(id === undefined || id === null)) {
935
- _context11.next = 10;
990
+ _context12.next = 10;
936
991
  break;
937
992
  }
938
- return _context11.abrupt("continue", 11);
993
+ return _context12.abrupt("continue", 11);
939
994
  case 10:
940
995
  freshMap.set(this.getIdKey(id), order);
941
996
  case 11:
942
- _context11.next = 5;
997
+ _context12.next = 5;
943
998
  break;
944
999
  case 13:
945
- _context11.next = 18;
1000
+ _context12.next = 18;
946
1001
  break;
947
1002
  case 15:
948
- _context11.prev = 15;
949
- _context11.t0 = _context11["catch"](3);
950
- _iterator4.e(_context11.t0);
1003
+ _context12.prev = 15;
1004
+ _context12.t0 = _context12["catch"](3);
1005
+ _iterator4.e(_context12.t0);
951
1006
  case 18:
952
- _context11.prev = 18;
1007
+ _context12.prev = 18;
953
1008
  _iterator4.f();
954
- return _context11.finish(18);
1009
+ return _context12.finish(18);
955
1010
  case 21:
956
1011
  uniqueFreshCount = freshMap.size;
957
1012
  updatedList = this.store.list.map(function (order) {
958
1013
  var id = order.order_id;
959
1014
  if (id === undefined || id === null) return order;
960
- var key = _this8.getIdKey(id);
1015
+ var key = _this9.getIdKey(id);
961
1016
  if (!freshMap.has(key)) return order;
962
1017
  var fresh = freshMap.get(key);
963
1018
  freshMap.delete(key);
@@ -976,7 +1031,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
976
1031
  }
977
1032
  this.store.list = updatedList;
978
1033
  this.syncOrdersMap();
979
- _context11.next = 29;
1034
+ _context12.next = 29;
980
1035
  return this.saveOrdersToSQLite(this.store.list);
981
1036
  case 29:
982
1037
  this.logInfo('mergeOrdersToStore-结束', {
@@ -986,11 +1041,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
986
1041
  this.core.effects.emit(OrderHooks.onOrdersChanged, this.store.list);
987
1042
  case 31:
988
1043
  case "end":
989
- return _context11.stop();
1044
+ return _context12.stop();
990
1045
  }
991
- }, _callee11, this, [[3, 15, 18, 21]]);
1046
+ }, _callee12, this, [[3, 15, 18, 21]]);
992
1047
  }));
993
- function mergeOrdersToStore(_x6) {
1048
+ function mergeOrdersToStore(_x7) {
994
1049
  return _mergeOrdersToStore.apply(this, arguments);
995
1050
  }
996
1051
  return mergeOrdersToStore;
@@ -1127,32 +1182,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1127
1182
  }, {
1128
1183
  key: "loadOrdersFromSQLite",
1129
1184
  value: function () {
1130
- var _loadOrdersFromSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1185
+ var _loadOrdersFromSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
1131
1186
  var orders;
1132
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1133
- while (1) switch (_context12.prev = _context12.next) {
1187
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1188
+ while (1) switch (_context13.prev = _context13.next) {
1134
1189
  case 0:
1135
1190
  if (this.dbManager) {
1136
- _context12.next = 2;
1191
+ _context13.next = 2;
1137
1192
  break;
1138
1193
  }
1139
- return _context12.abrupt("return", []);
1194
+ return _context13.abrupt("return", []);
1140
1195
  case 2:
1141
- _context12.prev = 2;
1142
- _context12.next = 5;
1196
+ _context13.prev = 2;
1197
+ _context13.next = 5;
1143
1198
  return this.dbManager.getAll(INDEXDB_STORE_NAME);
1144
1199
  case 5:
1145
- orders = _context12.sent;
1146
- return _context12.abrupt("return", orders || []);
1200
+ orders = _context13.sent;
1201
+ return _context13.abrupt("return", orders || []);
1147
1202
  case 9:
1148
- _context12.prev = 9;
1149
- _context12.t0 = _context12["catch"](2);
1150
- return _context12.abrupt("return", []);
1203
+ _context13.prev = 9;
1204
+ _context13.t0 = _context13["catch"](2);
1205
+ return _context13.abrupt("return", []);
1151
1206
  case 12:
1152
1207
  case "end":
1153
- return _context12.stop();
1208
+ return _context13.stop();
1154
1209
  }
1155
- }, _callee12, this, [[2, 9]]);
1210
+ }, _callee13, this, [[2, 9]]);
1156
1211
  }));
1157
1212
  function loadOrdersFromSQLite() {
1158
1213
  return _loadOrdersFromSQLite.apply(this, arguments);
@@ -1162,55 +1217,55 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1162
1217
  }, {
1163
1218
  key: "saveOrdersToSQLite",
1164
1219
  value: function () {
1165
- var _saveOrdersToSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderList) {
1166
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1167
- while (1) switch (_context13.prev = _context13.next) {
1220
+ var _saveOrdersToSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderList) {
1221
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1222
+ while (1) switch (_context14.prev = _context14.next) {
1168
1223
  case 0:
1169
1224
  if (this.dbManager) {
1170
- _context13.next = 2;
1225
+ _context14.next = 2;
1171
1226
  break;
1172
1227
  }
1173
- return _context13.abrupt("return");
1228
+ return _context14.abrupt("return");
1174
1229
  case 2:
1175
- _context13.prev = 2;
1230
+ _context14.prev = 2;
1176
1231
  this.logInfo('saveOrdersToSQLite-开始', {
1177
1232
  count: orderList.length
1178
1233
  });
1179
- _context13.next = 6;
1234
+ _context14.next = 6;
1180
1235
  return this.dbManager.clear(INDEXDB_STORE_NAME);
1181
1236
  case 6:
1182
1237
  this.logInfo('saveOrdersToSQLite-clear完成', {
1183
1238
  count: orderList.length
1184
1239
  });
1185
1240
  if (!(orderList.length === 0)) {
1186
- _context13.next = 9;
1241
+ _context14.next = 9;
1187
1242
  break;
1188
1243
  }
1189
- return _context13.abrupt("return");
1244
+ return _context14.abrupt("return");
1190
1245
  case 9:
1191
- _context13.next = 11;
1246
+ _context14.next = 11;
1192
1247
  return this.dbManager.bulkAdd(INDEXDB_STORE_NAME, orderList);
1193
1248
  case 11:
1194
1249
  this.logInfo('saveOrdersToSQLite-bulkAdd完成', {
1195
1250
  count: orderList.length
1196
1251
  });
1197
- _context13.next = 17;
1252
+ _context14.next = 17;
1198
1253
  break;
1199
1254
  case 14:
1200
- _context13.prev = 14;
1201
- _context13.t0 = _context13["catch"](2);
1255
+ _context14.prev = 14;
1256
+ _context14.t0 = _context14["catch"](2);
1202
1257
  // SQLite 异常,避免影响主流程
1203
1258
  this.logError('保存订单到 SQLite 失败', {
1204
- error: _context13.t0 instanceof Error ? _context13.t0.message : String(_context13.t0),
1259
+ error: _context14.t0 instanceof Error ? _context14.t0.message : String(_context14.t0),
1205
1260
  orderList: orderList.length
1206
1261
  });
1207
1262
  case 17:
1208
1263
  case "end":
1209
- return _context13.stop();
1264
+ return _context14.stop();
1210
1265
  }
1211
- }, _callee13, this, [[2, 14]]);
1266
+ }, _callee14, this, [[2, 14]]);
1212
1267
  }));
1213
- function saveOrdersToSQLite(_x7) {
1268
+ function saveOrdersToSQLite(_x8) {
1214
1269
  return _saveOrdersToSQLite.apply(this, arguments);
1215
1270
  }
1216
1271
  return saveOrdersToSQLite;
@@ -1218,27 +1273,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1218
1273
  }, {
1219
1274
  key: "clear",
1220
1275
  value: function () {
1221
- var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1222
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1223
- while (1) switch (_context14.prev = _context14.next) {
1276
+ var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1277
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1278
+ while (1) switch (_context15.prev = _context15.next) {
1224
1279
  case 0:
1225
1280
  this.store.list = [];
1226
1281
  this.store.map = new Map();
1227
1282
  this.resourceIdIndex.clear();
1228
1283
  if (!this.dbManager) {
1229
- _context14.next = 6;
1284
+ _context15.next = 6;
1230
1285
  break;
1231
1286
  }
1232
- _context14.next = 6;
1287
+ _context15.next = 6;
1233
1288
  return this.dbManager.clear(INDEXDB_STORE_NAME);
1234
1289
  case 6:
1235
1290
  this.setStorageItem(ORDER_LAST_FULL_FETCH_AT_STORAGE_KEY, '');
1236
1291
  this.core.effects.emit(OrderHooks.onOrdersChanged, this.store.list);
1237
1292
  case 8:
1238
1293
  case "end":
1239
- return _context14.stop();
1294
+ return _context15.stop();
1240
1295
  }
1241
- }, _callee14, this);
1296
+ }, _callee15, this);
1242
1297
  }));
1243
1298
  function clear() {
1244
1299
  return _clear.apply(this, arguments);