@pisell/pisellos 2.2.263 → 2.2.264

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 (132) hide show
  1. package/dist/model/strategy/adapter/index.d.ts +0 -4
  2. package/dist/model/strategy/adapter/index.js +1 -5
  3. package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  4. package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
  5. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  6. package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
  7. package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
  8. package/dist/model/strategy/adapter/promotion/examples.js +99 -0
  9. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  10. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  11. package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
  12. package/dist/model/strategy/adapter/promotion/type.js +45 -0
  13. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +10 -16
  14. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -2
  15. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  16. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +1 -32
  17. package/dist/modules/Discount/index.d.ts +2 -5
  18. package/dist/modules/Discount/index.js +7 -30
  19. package/dist/modules/Discount/types.d.ts +0 -4
  20. package/dist/modules/Order/index.d.ts +2 -14
  21. package/dist/modules/Order/index.js +736 -1035
  22. package/dist/modules/Order/types.d.ts +0 -16
  23. package/dist/modules/Order/utils.d.ts +3 -4
  24. package/dist/modules/Order/utils.js +61 -54
  25. package/dist/modules/Product/types.d.ts +0 -22
  26. package/dist/modules/ProductList/index.d.ts +1 -1
  27. package/dist/modules/ProductList/index.js +2 -4
  28. package/dist/modules/ProductList/types.d.ts +0 -2
  29. package/dist/modules/Rules/index.d.ts +9 -2
  30. package/dist/modules/Rules/index.js +43 -69
  31. package/dist/modules/Rules/types.d.ts +1 -10
  32. package/dist/server/index.d.ts +0 -55
  33. package/dist/server/index.js +753 -1173
  34. package/dist/server/modules/order/index.d.ts +4 -10
  35. package/dist/server/modules/order/index.js +399 -404
  36. package/dist/server/modules/order/types.d.ts +0 -4
  37. package/dist/server/modules/products/index.d.ts +8 -31
  38. package/dist/server/modules/products/index.js +390 -549
  39. package/dist/server/modules/products/types.d.ts +0 -18
  40. package/dist/solution/BaseSales/index.d.ts +1 -21
  41. package/dist/solution/BaseSales/index.js +789 -1136
  42. package/dist/solution/BaseSales/types.d.ts +1 -6
  43. package/dist/solution/BaseSales/types.js +1 -1
  44. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  45. package/dist/solution/BaseSales/utils/cartPromotion.js +97 -50
  46. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
  47. package/dist/solution/BaseSales/utils/parseSalesResponse.js +8 -6
  48. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -14
  49. package/dist/solution/BookingByStep/index.d.ts +1 -1
  50. package/dist/solution/BookingTicket/index.js +25 -59
  51. package/dist/solution/BookingTicket/types.d.ts +0 -2
  52. package/dist/solution/ScanOrder/index.js +31 -20
  53. package/dist/solution/ShopDiscount/index.js +14 -15
  54. package/dist/solution/VenueBooking/index.js +30 -19
  55. package/lib/model/strategy/adapter/index.d.ts +0 -4
  56. package/lib/model/strategy/adapter/index.js +2 -13
  57. package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  58. package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
  59. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  60. package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
  61. package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
  62. package/lib/model/strategy/adapter/promotion/examples.js +91 -0
  63. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  64. package/lib/model/strategy/adapter/promotion/index.js +51 -0
  65. package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
  66. package/lib/model/strategy/adapter/promotion/type.js +2 -0
  67. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -5
  68. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -1
  69. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  70. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +2 -23
  71. package/lib/modules/Discount/index.d.ts +2 -5
  72. package/lib/modules/Discount/index.js +3 -23
  73. package/lib/modules/Discount/types.d.ts +0 -4
  74. package/lib/modules/Order/index.d.ts +2 -14
  75. package/lib/modules/Order/index.js +60 -326
  76. package/lib/modules/Order/types.d.ts +0 -16
  77. package/lib/modules/Order/utils.d.ts +3 -4
  78. package/lib/modules/Order/utils.js +23 -22
  79. package/lib/modules/Product/types.d.ts +0 -22
  80. package/lib/modules/ProductList/index.d.ts +1 -1
  81. package/lib/modules/ProductList/index.js +2 -4
  82. package/lib/modules/ProductList/types.d.ts +0 -2
  83. package/lib/modules/Rules/index.d.ts +9 -2
  84. package/lib/modules/Rules/index.js +29 -61
  85. package/lib/modules/Rules/types.d.ts +1 -10
  86. package/lib/server/index.d.ts +0 -55
  87. package/lib/server/index.js +34 -332
  88. package/lib/server/modules/order/index.d.ts +4 -10
  89. package/lib/server/modules/order/index.js +139 -198
  90. package/lib/server/modules/order/types.d.ts +0 -4
  91. package/lib/server/modules/products/index.d.ts +8 -31
  92. package/lib/server/modules/products/index.js +35 -134
  93. package/lib/server/modules/products/types.d.ts +0 -18
  94. package/lib/solution/BaseSales/index.d.ts +1 -21
  95. package/lib/solution/BaseSales/index.js +72 -313
  96. package/lib/solution/BaseSales/types.d.ts +1 -6
  97. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  98. package/lib/solution/BaseSales/utils/cartPromotion.js +64 -25
  99. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
  100. package/lib/solution/BaseSales/utils/parseSalesResponse.js +5 -4
  101. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +0 -8
  102. package/lib/solution/BookingByStep/index.d.ts +1 -1
  103. package/lib/solution/BookingTicket/index.js +8 -33
  104. package/lib/solution/BookingTicket/types.d.ts +0 -2
  105. package/lib/solution/ScanOrder/index.js +8 -0
  106. package/lib/solution/ShopDiscount/index.js +1 -2
  107. package/lib/solution/VenueBooking/index.js +8 -0
  108. package/package.json +1 -1
  109. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  110. package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
  111. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  112. package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -780
  113. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  114. package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
  115. package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  116. package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
  117. package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  118. package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
  119. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +0 -53
  120. package/dist/modules/Order/utils/orderCollectionIdentity.js +0 -405
  121. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  122. package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
  123. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  124. package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -583
  125. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  126. package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
  127. package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  128. package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
  129. package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  130. package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
  131. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +0 -53
  132. package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -415
@@ -93,8 +93,6 @@ var Server = /*#__PURE__*/function () {
93
93
  });
94
94
  // ---- 商品查询订阅者 ----
95
95
  _defineProperty(this, "productQuerySubscribers", new Map());
96
- /** subscriberId → 智能定价变价时间点定时器句柄(与 subscriber 分离存储,便于 clear) */
97
- _defineProperty(this, "productQueryScheduleTimers", new Map());
98
96
  // ---- 订单 / 预约列表查询订阅者 ----
99
97
  _defineProperty(this, "orderQuerySubscribers", new Map());
100
98
  _defineProperty(this, "bookingQuerySubscribers", new Map());
@@ -273,13 +271,13 @@ var Server = /*#__PURE__*/function () {
273
271
  */
274
272
  _defineProperty(this, "handleProductQuery", /*#__PURE__*/function () {
275
273
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref5) {
276
- var url, method, data, config, menu_list_ids, schedule_datetime, schedule_date, customer_id, ids, extension_type, strategy_context, _ref7, callback, subscriberId, result;
274
+ var url, method, data, config, menu_list_ids, schedule_datetime, schedule_date, customer_id, ids, extension_type, _ref7, callback, subscriberId;
277
275
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
278
276
  while (1) switch (_context3.prev = _context3.next) {
279
277
  case 0:
280
278
  url = _ref5.url, method = _ref5.method, data = _ref5.data, config = _ref5.config;
281
279
  console.log('[Server] handleProductQuery:', url, method, data, config);
282
- menu_list_ids = data.menu_list_ids, schedule_datetime = data.schedule_datetime, schedule_date = data.schedule_date, customer_id = data.customer_id, ids = data.ids, extension_type = data.extension_type, strategy_context = data.strategy_context;
280
+ menu_list_ids = data.menu_list_ids, schedule_datetime = data.schedule_datetime, schedule_date = data.schedule_date, customer_id = data.customer_id, ids = data.ids, extension_type = data.extension_type;
283
281
  _ref7 = config || {}, callback = _ref7.callback, subscriberId = _ref7.subscriberId;
284
282
  _this.logInfo('handleProductQuery: 开始处理商品查询请求', {
285
283
  menu_list_ids: menu_list_ids,
@@ -287,8 +285,7 @@ var Server = /*#__PURE__*/function () {
287
285
  schedule_datetime: schedule_datetime,
288
286
  schedule_date: schedule_date,
289
287
  customer_id: customer_id,
290
- extension_type: extension_type,
291
- strategyContextKeys: strategy_context ? Object.keys(strategy_context) : []
288
+ extension_type: extension_type
292
289
  });
293
290
 
294
291
  // 存储订阅者:后续 pubsub 数据变更时可通过 callback 推送最新结果
@@ -301,8 +298,7 @@ var Server = /*#__PURE__*/function () {
301
298
  schedule_date: schedule_date,
302
299
  schedule_datetime: schedule_datetime,
303
300
  customer_id: customer_id,
304
- extension_type: extension_type,
305
- strategy_context: strategy_context
301
+ extension_type: extension_type
306
302
  }
307
303
  });
308
304
  _this.logInfo('handleProductQuery: 已注册订阅者', {
@@ -310,23 +306,15 @@ var Server = /*#__PURE__*/function () {
310
306
  totalSubscribers: _this.productQuerySubscribers.size
311
307
  });
312
308
  }
313
- _context3.next = 8;
314
- return _this.computeProductQueryResult({
309
+ return _context3.abrupt("return", _this.computeProductQueryResult({
315
310
  menu_list_ids: menu_list_ids,
316
311
  ids: ids,
317
312
  schedule_date: schedule_date,
318
313
  schedule_datetime: schedule_datetime,
319
314
  customer_id: customer_id,
320
- extension_type: extension_type,
321
- strategy_context: strategy_context
322
- });
323
- case 8:
324
- result = _context3.sent;
325
- if (subscriberId && typeof callback === 'function') {
326
- _this.syncProductQueryScheduleTimers(subscriberId, strategy_context);
327
- }
328
- return _context3.abrupt("return", result);
329
- case 11:
315
+ extension_type: extension_type
316
+ }));
317
+ case 7:
330
318
  case "end":
331
319
  return _context3.stop();
332
320
  }
@@ -1213,7 +1201,7 @@ var Server = /*#__PURE__*/function () {
1213
1201
  _defineProperty(this, "handleOrderSalesDetail", /*#__PURE__*/function () {
1214
1202
  var _ref45 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(_ref44) {
1215
1203
  var _this$app3;
1216
- var url, data, path, requestPath, lookup, localOrder, enrichedOrder, backendPath, _response$data3, response, fresh, savedOrder, _enrichedOrder, errorMessage;
1204
+ var url, data, path, requestPath, lookup, localOrder, backendPath, _response$data3, response, fresh, savedOrder, errorMessage;
1217
1205
  return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1218
1206
  while (1) switch (_context18.prev = _context18.next) {
1219
1207
  case 0:
@@ -1253,7 +1241,7 @@ var Server = /*#__PURE__*/function () {
1253
1241
  });
1254
1242
  case 10:
1255
1243
  if (_this.shouldForceRemoteSalesDetail(data)) {
1256
- _context18.next = 20;
1244
+ _context18.next = 17;
1257
1245
  break;
1258
1246
  }
1259
1247
  _context18.next = 13;
@@ -1261,13 +1249,9 @@ var Server = /*#__PURE__*/function () {
1261
1249
  case 13:
1262
1250
  localOrder = _context18.sent;
1263
1251
  if (!localOrder) {
1264
- _context18.next = 20;
1252
+ _context18.next = 17;
1265
1253
  break;
1266
1254
  }
1267
- _context18.next = 17;
1268
- return _this.withSalesDetailProductSnapshots(localOrder);
1269
- case 17:
1270
- enrichedOrder = _context18.sent;
1271
1255
  _this.logInfo('handleOrderSalesDetail: 命中本地订单', {
1272
1256
  lookup: lookup
1273
1257
  });
@@ -1275,11 +1259,11 @@ var Server = /*#__PURE__*/function () {
1275
1259
  code: 200,
1276
1260
  status: true,
1277
1261
  message: '',
1278
- data: enrichedOrder
1262
+ data: localOrder
1279
1263
  });
1280
- case 20:
1264
+ case 17:
1281
1265
  if ((_this$app3 = _this.app) !== null && _this$app3 !== void 0 && _this$app3.request) {
1282
- _context18.next = 23;
1266
+ _context18.next = 20;
1283
1267
  break;
1284
1268
  }
1285
1269
  _this.logError('handleOrderSalesDetail: app.request 不可用');
@@ -1289,21 +1273,21 @@ var Server = /*#__PURE__*/function () {
1289
1273
  message: 'app.request 不可用',
1290
1274
  data: null
1291
1275
  });
1292
- case 23:
1276
+ case 20:
1293
1277
  backendPath = _this.buildOrderSalesDetailBackendPath(lookup, data);
1294
- _context18.prev = 24;
1295
- _context18.next = 27;
1278
+ _context18.prev = 21;
1279
+ _context18.next = 24;
1296
1280
  return _this.app.request.get(backendPath, {
1297
1281
  lookup_mode: 'multi'
1298
1282
  }, {
1299
1283
  isShopApi: true,
1300
1284
  customToast: function customToast() {}
1301
1285
  });
1302
- case 27:
1286
+ case 24:
1303
1287
  response = _context18.sent;
1304
1288
  fresh = (_response$data3 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data3 !== void 0 ? _response$data3 : response;
1305
1289
  if (!(!fresh || _typeof(fresh) !== 'object' || fresh.order_id == null)) {
1306
- _context18.next = 32;
1290
+ _context18.next = 29;
1307
1291
  break;
1308
1292
  }
1309
1293
  _this.logInfo('handleOrderSalesDetail: 后端返回订单为空', {
@@ -1316,16 +1300,16 @@ var Server = /*#__PURE__*/function () {
1316
1300
  message: '后端返回订单为空',
1317
1301
  data: null
1318
1302
  });
1319
- case 32:
1320
- _context18.next = 34;
1303
+ case 29:
1304
+ _context18.next = 31;
1321
1305
  return _this.order.upsertOrdersFromRemote([fresh]);
1322
- case 34:
1323
- _context18.next = 36;
1306
+ case 31:
1307
+ _context18.next = 33;
1324
1308
  return _this.order.getLocalOrderByLookup(lookup);
1325
- case 36:
1309
+ case 33:
1326
1310
  savedOrder = _context18.sent;
1327
1311
  if (savedOrder) {
1328
- _context18.next = 40;
1312
+ _context18.next = 37;
1329
1313
  break;
1330
1314
  }
1331
1315
  _this.logError('handleOrderSalesDetail: 订单写入后回读失败', {
@@ -1337,23 +1321,19 @@ var Server = /*#__PURE__*/function () {
1337
1321
  message: '订单写入后回读失败',
1338
1322
  data: null
1339
1323
  });
1340
- case 40:
1324
+ case 37:
1341
1325
  _this.logInfo('handleOrderSalesDetail: 远端订单已同步到本地', {
1342
1326
  lookup: lookup
1343
1327
  });
1344
- _context18.next = 43;
1345
- return _this.withSalesDetailProductSnapshots(savedOrder);
1346
- case 43:
1347
- _enrichedOrder = _context18.sent;
1348
1328
  return _context18.abrupt("return", {
1349
1329
  code: 200,
1350
1330
  status: true,
1351
1331
  message: '',
1352
- data: _enrichedOrder
1332
+ data: savedOrder
1353
1333
  });
1354
- case 47:
1355
- _context18.prev = 47;
1356
- _context18.t0 = _context18["catch"](24);
1334
+ case 41:
1335
+ _context18.prev = 41;
1336
+ _context18.t0 = _context18["catch"](21);
1357
1337
  errorMessage = _context18.t0 instanceof Error ? _context18.t0.message : String(_context18.t0);
1358
1338
  _this.logInfo('handleOrderSalesDetail: 请求失败', {
1359
1339
  lookup: lookup,
@@ -1366,11 +1346,11 @@ var Server = /*#__PURE__*/function () {
1366
1346
  message: errorMessage,
1367
1347
  data: null
1368
1348
  });
1369
- case 52:
1349
+ case 46:
1370
1350
  case "end":
1371
1351
  return _context18.stop();
1372
1352
  }
1373
- }, _callee18, null, [[24, 47]]);
1353
+ }, _callee18, null, [[21, 41]]);
1374
1354
  }));
1375
1355
  return function (_x18) {
1376
1356
  return _ref45.apply(this, arguments);
@@ -3128,7 +3108,6 @@ var Server = /*#__PURE__*/function () {
3128
3108
  key: "removeProductQuerySubscriber",
3129
3109
  value: function removeProductQuerySubscriber(subscriberId) {
3130
3110
  if (subscriberId) {
3131
- this.clearSubscriberScheduleTimers(subscriberId);
3132
3111
  this.productQuerySubscribers.delete(subscriberId);
3133
3112
  this.logInfo('removeProductQuerySubscriber: 已移除订阅者', {
3134
3113
  subscriberId: subscriberId,
@@ -3136,243 +3115,6 @@ var Server = /*#__PURE__*/function () {
3136
3115
  });
3137
3116
  }
3138
3117
  }
3139
-
3140
- /**
3141
- * 构建商品 query 响应 data 段,附带智能定价 schedule_time_points 元数据。
3142
- */
3143
- }, {
3144
- key: "buildProductQueryResultPayload",
3145
- value: function buildProductQueryResultPayload(list, count) {
3146
- var _this$products$getLas, _this$products, _this$products$getLas2;
3147
- return {
3148
- list: list,
3149
- count: count !== null && count !== void 0 ? count : list.length,
3150
- schedule_time_points: (_this$products$getLas = (_this$products = this.products) === null || _this$products === void 0 || (_this$products$getLas2 = _this$products.getLastScheduleTimePoints) === null || _this$products$getLas2 === void 0 ? void 0 : _this$products$getLas2.call(_this$products)) !== null && _this$products$getLas !== void 0 ? _this$products$getLas : []
3151
- };
3152
- }
3153
-
3154
- /**
3155
- * 是否启用商品 query 订阅的 schedule 时间点定时重算。
3156
- * strategy_context.enable_schedule_reload === false 时关闭。
3157
- */
3158
- }, {
3159
- key: "shouldScheduleProductQueryReload",
3160
- value: function shouldScheduleProductQueryReload(strategy_context) {
3161
- return (strategy_context === null || strategy_context === void 0 ? void 0 : strategy_context.enable_schedule_reload) !== false;
3162
- }
3163
-
3164
- /**
3165
- * 清除指定 subscriber 的全部 schedule 定时器,防止重复 query 或 unsubscribe 后泄漏。
3166
- */
3167
- }, {
3168
- key: "clearSubscriberScheduleTimers",
3169
- value: function clearSubscriberScheduleTimers(subscriberId) {
3170
- var timers = this.productQueryScheduleTimers.get(subscriberId);
3171
- if (timers !== null && timers !== void 0 && timers.length) {
3172
- timers.forEach(function (timerId) {
3173
- return clearTimeout(timerId);
3174
- });
3175
- }
3176
- this.productQueryScheduleTimers.delete(subscriberId);
3177
- var subscriber = this.productQuerySubscribers.get(subscriberId);
3178
- if (subscriber) {
3179
- subscriber.scheduleTimerIds = [];
3180
- }
3181
- }
3182
-
3183
- /**
3184
- * 从 productQueryScheduleTimers 移除已触发的 timer 引用。
3185
- */
3186
- }, {
3187
- key: "removeScheduleTimerRef",
3188
- value: function removeScheduleTimerRef(subscriberId, timerId) {
3189
- var timers = this.productQueryScheduleTimers.get(subscriberId);
3190
- if (!(timers !== null && timers !== void 0 && timers.length)) return;
3191
- var next = timers.filter(function (id) {
3192
- return id !== timerId;
3193
- });
3194
- if (next.length === 0) {
3195
- this.productQueryScheduleTimers.delete(subscriberId);
3196
- } else {
3197
- this.productQueryScheduleTimers.set(subscriberId, next);
3198
- }
3199
- var subscriber = this.productQuerySubscribers.get(subscriberId);
3200
- if (subscriber) {
3201
- subscriber.scheduleTimerIds = next;
3202
- }
3203
- }
3204
-
3205
- /**
3206
- * 计算 schedule 变价时间点到当前时刻的延迟(ms)。已过期返回 -1。
3207
- */
3208
- }, {
3209
- key: "computeScheduleTimePointDelayMs",
3210
- value: function computeScheduleTimePointDelayMs(scheduleDate, timePoint) {
3211
- var parts = timePoint.split(':');
3212
- if (parts.length < 2) return -1;
3213
- var hours = parseInt(parts[0], 10);
3214
- var minutes = parseInt(parts[1], 10);
3215
- if (!Number.isFinite(hours) || !Number.isFinite(minutes)) return -1;
3216
- var target = dayjs(scheduleDate).hour(hours).minute(minutes).second(4).millisecond(0);
3217
- var delayMs = target.diff(dayjs());
3218
- return delayMs >= 0 ? delayMs : -1;
3219
- }
3220
-
3221
- /**
3222
- * 定时重算前刷新 subscriber schedule 上下文:使用执行瞬间时间,禁止沿用首次 query 的 schedule_datetime。
3223
- */
3224
- }, {
3225
- key: "refreshSubscriberScheduleAtExecution",
3226
- value: function refreshSubscriberScheduleAtExecution(subscriber) {
3227
- var executedAt = dayjs();
3228
- var bookingDate = subscriber.context.schedule_date || executedAt.format('YYYY-MM-DD');
3229
- subscriber.context.schedule_date = bookingDate;
3230
- subscriber.context.schedule_datetime = "".concat(bookingDate, " ").concat(executedAt.format('HH:mm:ss'));
3231
- }
3232
-
3233
- /**
3234
- * 为 subscriber 注册智能定价 scheduleTimePoints 定时重算。
3235
- * 必须先 clearSubscriberScheduleTimers,再调用本方法。
3236
- */
3237
- }, {
3238
- key: "scheduleSubscriberTimePointReloads",
3239
- value: function scheduleSubscriberTimePointReloads(subscriberId, timePoints) {
3240
- var _this7 = this;
3241
- var subscriber = this.productQuerySubscribers.get(subscriberId);
3242
- if (!subscriber || !timePoints.length) return;
3243
- var scheduleDate = subscriber.context.schedule_date || dayjs().format('YYYY-MM-DD');
3244
- var timerIds = [];
3245
- var _iterator5 = _createForOfIteratorHelper(timePoints),
3246
- _step5;
3247
- try {
3248
- var _loop = function _loop() {
3249
- var timePoint = _step5.value;
3250
- var delayMs = _this7.computeScheduleTimePointDelayMs(scheduleDate, timePoint);
3251
- if (delayMs < 0) return 1; // continue
3252
- var timerId = setTimeout(function () {
3253
- void _this7.onScheduleTimePointTimerFire(subscriberId, timerId);
3254
- }, delayMs);
3255
- timerIds.push(timerId);
3256
- };
3257
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
3258
- if (_loop()) continue;
3259
- }
3260
- } catch (err) {
3261
- _iterator5.e(err);
3262
- } finally {
3263
- _iterator5.f();
3264
- }
3265
- if (timerIds.length > 0) {
3266
- this.productQueryScheduleTimers.set(subscriberId, timerIds);
3267
- subscriber.scheduleTimerIds = timerIds;
3268
- this.logInfo('scheduleSubscriberTimePointReloads: 已注册定时器', {
3269
- subscriberId: subscriberId,
3270
- timerCount: timerIds.length,
3271
- timePoints: timePoints
3272
- });
3273
- }
3274
- }
3275
-
3276
- /**
3277
- * schedule 变价时间点定时器触发:刷新 schedule_datetime 后重算并 callback。
3278
- */
3279
- }, {
3280
- key: "onScheduleTimePointTimerFire",
3281
- value: (function () {
3282
- var _onScheduleTimePointTimerFire = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(subscriberId, timerId) {
3283
- var subscriber;
3284
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3285
- while (1) switch (_context38.prev = _context38.next) {
3286
- case 0:
3287
- this.removeScheduleTimerRef(subscriberId, timerId);
3288
- if (this.productQuerySubscribers.has(subscriberId)) {
3289
- _context38.next = 3;
3290
- break;
3291
- }
3292
- return _context38.abrupt("return");
3293
- case 3:
3294
- subscriber = this.productQuerySubscribers.get(subscriberId);
3295
- this.refreshSubscriberScheduleAtExecution(subscriber);
3296
- _context38.next = 7;
3297
- return this.recomputeAndNotifySubscriber(subscriberId);
3298
- case 7:
3299
- case "end":
3300
- return _context38.stop();
3301
- }
3302
- }, _callee38, this);
3303
- }));
3304
- function onScheduleTimePointTimerFire(_x37, _x38) {
3305
- return _onScheduleTimePointTimerFire.apply(this, arguments);
3306
- }
3307
- return onScheduleTimePointTimerFire;
3308
- }()
3309
- /**
3310
- * 对单个商品 query 订阅者重算并推送(定时路径;不新建 schedule timer)。
3311
- */
3312
- )
3313
- }, {
3314
- key: "recomputeAndNotifySubscriber",
3315
- value: (function () {
3316
- var _recomputeAndNotifySubscriber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(subscriberId) {
3317
- var subscriber, result, errorMessage;
3318
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3319
- while (1) switch (_context39.prev = _context39.next) {
3320
- case 0:
3321
- subscriber = this.productQuerySubscribers.get(subscriberId);
3322
- if (subscriber) {
3323
- _context39.next = 3;
3324
- break;
3325
- }
3326
- return _context39.abrupt("return");
3327
- case 3:
3328
- _context39.prev = 3;
3329
- _context39.next = 6;
3330
- return this.computeProductQueryResult(subscriber.context);
3331
- case 6:
3332
- result = _context39.sent;
3333
- subscriber.callback(result);
3334
- this.logInfo('recomputeAndNotifySubscriber: 已推送', {
3335
- subscriberId: subscriberId,
3336
- schedule_datetime: subscriber.context.schedule_datetime
3337
- });
3338
- _context39.next = 15;
3339
- break;
3340
- case 11:
3341
- _context39.prev = 11;
3342
- _context39.t0 = _context39["catch"](3);
3343
- errorMessage = _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0);
3344
- this.logError('recomputeAndNotifySubscriber: 推送失败', {
3345
- subscriberId: subscriberId,
3346
- error: errorMessage
3347
- });
3348
- case 15:
3349
- case "end":
3350
- return _context39.stop();
3351
- }
3352
- }, _callee39, this, [[3, 11]]);
3353
- }));
3354
- function recomputeAndNotifySubscriber(_x39) {
3355
- return _recomputeAndNotifySubscriber.apply(this, arguments);
3356
- }
3357
- return recomputeAndNotifySubscriber;
3358
- }()
3359
- /**
3360
- * query 完成后为 subscriber 同步 schedule 定时器(先 clear 再 schedule)。
3361
- */
3362
- )
3363
- }, {
3364
- key: "syncProductQueryScheduleTimers",
3365
- value: function syncProductQueryScheduleTimers(subscriberId, strategy_context) {
3366
- var _this$products$getLas3, _this$products2, _this$products2$getLa;
3367
- this.clearSubscriberScheduleTimers(subscriberId);
3368
- if (!this.shouldScheduleProductQueryReload(strategy_context)) {
3369
- return;
3370
- }
3371
- var timePoints = (_this$products$getLas3 = (_this$products2 = this.products) === null || _this$products2 === void 0 || (_this$products2$getLa = _this$products2.getLastScheduleTimePoints) === null || _this$products2$getLa === void 0 ? void 0 : _this$products2$getLa.call(_this$products2)) !== null && _this$products$getLas3 !== void 0 ? _this$products$getLas3 : [];
3372
- if (timePoints.length > 0) {
3373
- this.scheduleSubscriberTimePointReloads(subscriberId, timePoints);
3374
- }
3375
- }
3376
3118
  }, {
3377
3119
  key: "handleSalesSearchRequest",
3378
3120
  value: (
@@ -3384,32 +3126,32 @@ var Server = /*#__PURE__*/function () {
3384
3126
  * const result = await this.handleSalesSearchRequest('single', '/shop/es/search/sales', { keyword: '1001' }, {})
3385
3127
  */
3386
3128
  function () {
3387
- var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(kind, backendPath, data, config) {
3388
- var queryPayload, result, _ref55, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator6, _step6, orderId;
3389
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3390
- while (1) switch (_context40.prev = _context40.next) {
3129
+ var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(kind, backendPath, data, config) {
3130
+ var queryPayload, result, _ref55, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator5, _step5, orderId;
3131
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3132
+ while (1) switch (_context38.prev = _context38.next) {
3391
3133
  case 0:
3392
3134
  queryPayload = data && _typeof(data) === 'object' ? _objectSpread({}, data) : {};
3393
- _context40.next = 3;
3135
+ _context38.next = 3;
3394
3136
  return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
3395
3137
  case 3:
3396
- result = _context40.sent;
3138
+ result = _context38.sent;
3397
3139
  _ref55 = config || {}, callback = _ref55.callback, subscriberId = _ref55.subscriberId, resetVisibleOrderIds = _ref55.resetVisibleOrderIds;
3398
3140
  if (subscriberId && typeof callback === 'function') {
3399
3141
  contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
3400
3142
  existing = this.salesSearchSubscribers.get(subscriberId);
3401
3143
  shouldReset = resetVisibleOrderIds === true || !existing || existing.kind !== kind || existing.contextSignature !== contextSignature;
3402
3144
  visibleOrderIds = shouldReset ? new Set() : new Set(existing.visibleOrderIds);
3403
- _iterator6 = _createForOfIteratorHelper(this.extractSalesSearchOrderIds(kind, result));
3145
+ _iterator5 = _createForOfIteratorHelper(this.extractSalesSearchOrderIds(kind, result));
3404
3146
  try {
3405
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
3406
- orderId = _step6.value;
3147
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
3148
+ orderId = _step5.value;
3407
3149
  visibleOrderIds.add(orderId);
3408
3150
  }
3409
3151
  } catch (err) {
3410
- _iterator6.e(err);
3152
+ _iterator5.e(err);
3411
3153
  } finally {
3412
- _iterator6.f();
3154
+ _iterator5.f();
3413
3155
  }
3414
3156
  this.salesSearchSubscribers.set(subscriberId, {
3415
3157
  callback: callback,
@@ -3425,14 +3167,14 @@ var Server = /*#__PURE__*/function () {
3425
3167
  visibleCount: visibleOrderIds.size
3426
3168
  });
3427
3169
  }
3428
- return _context40.abrupt("return", result);
3170
+ return _context38.abrupt("return", result);
3429
3171
  case 7:
3430
3172
  case "end":
3431
- return _context40.stop();
3173
+ return _context38.stop();
3432
3174
  }
3433
- }, _callee40, this);
3175
+ }, _callee38, this);
3434
3176
  }));
3435
- function handleSalesSearchRequest(_x40, _x41, _x42, _x43) {
3177
+ function handleSalesSearchRequest(_x37, _x38, _x39, _x40) {
3436
3178
  return _handleSalesSearchRequest.apply(this, arguments);
3437
3179
  }
3438
3180
  return handleSalesSearchRequest;
@@ -3447,20 +3189,20 @@ var Server = /*#__PURE__*/function () {
3447
3189
  }, {
3448
3190
  key: "fetchSalesSearchFromAPI",
3449
3191
  value: (function () {
3450
- var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(backendPath, data) {
3192
+ var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(backendPath, data) {
3451
3193
  var _this$app8;
3452
3194
  var _response$data4, _response$code2, _response$status2, _response$message2, response, _payload, errorMessage;
3453
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3454
- while (1) switch (_context41.prev = _context41.next) {
3195
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3196
+ while (1) switch (_context39.prev = _context39.next) {
3455
3197
  case 0:
3456
3198
  if ((_this$app8 = this.app) !== null && _this$app8 !== void 0 && _this$app8.request) {
3457
- _context41.next = 3;
3199
+ _context39.next = 3;
3458
3200
  break;
3459
3201
  }
3460
3202
  this.logError('fetchSalesSearchFromAPI: app.request 不可用', {
3461
3203
  backendPath: backendPath
3462
3204
  });
3463
- return _context41.abrupt("return", {
3205
+ return _context39.abrupt("return", {
3464
3206
  code: 500,
3465
3207
  message: 'app.request 不可用',
3466
3208
  data: backendPath === '/shop/es/search' ? {
@@ -3472,29 +3214,29 @@ var Server = /*#__PURE__*/function () {
3472
3214
  status: false
3473
3215
  });
3474
3216
  case 3:
3475
- _context41.prev = 3;
3476
- _context41.next = 6;
3217
+ _context39.prev = 3;
3218
+ _context39.next = 6;
3477
3219
  return this.app.request.post(backendPath, data, {
3478
3220
  isShopApi: true
3479
3221
  });
3480
3222
  case 6:
3481
- response = _context41.sent;
3223
+ response = _context39.sent;
3482
3224
  _payload = (_response$data4 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data4 !== void 0 ? _response$data4 : response;
3483
- return _context41.abrupt("return", {
3225
+ return _context39.abrupt("return", {
3484
3226
  code: (_response$code2 = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code2 !== void 0 ? _response$code2 : 200,
3485
3227
  status: (_response$status2 = response === null || response === void 0 ? void 0 : response.status) !== null && _response$status2 !== void 0 ? _response$status2 : true,
3486
3228
  message: (_response$message2 = response === null || response === void 0 ? void 0 : response.message) !== null && _response$message2 !== void 0 ? _response$message2 : '',
3487
3229
  data: _payload
3488
3230
  });
3489
3231
  case 11:
3490
- _context41.prev = 11;
3491
- _context41.t0 = _context41["catch"](3);
3492
- errorMessage = _context41.t0 instanceof Error ? _context41.t0.message : String(_context41.t0);
3232
+ _context39.prev = 11;
3233
+ _context39.t0 = _context39["catch"](3);
3234
+ errorMessage = _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0);
3493
3235
  this.logError('fetchSalesSearchFromAPI: 请求失败', {
3494
3236
  backendPath: backendPath,
3495
3237
  error: errorMessage
3496
3238
  });
3497
- return _context41.abrupt("return", {
3239
+ return _context39.abrupt("return", {
3498
3240
  code: 500,
3499
3241
  message: errorMessage,
3500
3242
  data: backendPath === '/shop/es/search' ? {
@@ -3507,11 +3249,11 @@ var Server = /*#__PURE__*/function () {
3507
3249
  });
3508
3250
  case 16:
3509
3251
  case "end":
3510
- return _context41.stop();
3252
+ return _context39.stop();
3511
3253
  }
3512
- }, _callee41, this, [[3, 11]]);
3254
+ }, _callee39, this, [[3, 11]]);
3513
3255
  }));
3514
- function fetchSalesSearchFromAPI(_x44, _x45) {
3256
+ function fetchSalesSearchFromAPI(_x41, _x42) {
3515
3257
  return _fetchSalesSearchFromAPI.apply(this, arguments);
3516
3258
  }
3517
3259
  return fetchSalesSearchFromAPI;
@@ -3541,10 +3283,10 @@ var Server = /*#__PURE__*/function () {
3541
3283
  }, {
3542
3284
  key: "stripSalesSearchPageParams",
3543
3285
  value: function stripSalesSearchPageParams(value) {
3544
- var _this8 = this;
3286
+ var _this7 = this;
3545
3287
  if (Array.isArray(value)) {
3546
3288
  return value.map(function (item) {
3547
- return _this8.stripSalesSearchPageParams(item);
3289
+ return _this7.stripSalesSearchPageParams(item);
3548
3290
  });
3549
3291
  }
3550
3292
  if (!value || _typeof(value) !== 'object') return value;
@@ -3582,12 +3324,12 @@ var Server = /*#__PURE__*/function () {
3582
3324
  key: "extractSalesSearchOrderIds",
3583
3325
  value: function extractSalesSearchOrderIds(kind, result) {
3584
3326
  var _this$findSalesSearch,
3585
- _this9 = this;
3327
+ _this8 = this;
3586
3328
  var data = this.extractSalesSearchResponseData(result);
3587
3329
  var list = kind === 'aggregate' ? (_this$findSalesSearch = this.findSalesSearchAggregateGroup(data)) === null || _this$findSalesSearch === void 0 ? void 0 : _this$findSalesSearch.list : data === null || data === void 0 ? void 0 : data.list;
3588
3330
  if (!Array.isArray(list)) return [];
3589
3331
  return list.map(function (item) {
3590
- return _this9.getSalesSearchOrderId(item);
3332
+ return _this8.getSalesSearchOrderId(item);
3591
3333
  }).filter(function (id) {
3592
3334
  return !!id;
3593
3335
  });
@@ -3754,11 +3496,11 @@ var Server = /*#__PURE__*/function () {
3754
3496
  }, {
3755
3497
  key: "stableSerialize",
3756
3498
  value: function stableSerialize(value) {
3757
- var _this10 = this;
3499
+ var _this9 = this;
3758
3500
  if (value === null || value === undefined) return 'null';
3759
3501
  if (Array.isArray(value)) {
3760
3502
  return "[".concat(value.map(function (item) {
3761
- return _this10.stableSerialize(item);
3503
+ return _this9.stableSerialize(item);
3762
3504
  }).join(','), "]");
3763
3505
  }
3764
3506
  if (_typeof(value) === 'object') {
@@ -3767,7 +3509,7 @@ var Server = /*#__PURE__*/function () {
3767
3509
  return obj[k] !== undefined;
3768
3510
  }).sort();
3769
3511
  return "{".concat(keys.map(function (k) {
3770
- return "".concat(JSON.stringify(k), ":").concat(_this10.stableSerialize(obj[k]));
3512
+ return "".concat(JSON.stringify(k), ":").concat(_this9.stableSerialize(obj[k]));
3771
3513
  }).join(','), "}");
3772
3514
  }
3773
3515
  return JSON.stringify(value);
@@ -3816,22 +3558,22 @@ var Server = /*#__PURE__*/function () {
3816
3558
  }
3817
3559
  var oldestKey = null;
3818
3560
  var oldestTime = Number.POSITIVE_INFINITY;
3819
- var _iterator7 = _createForOfIteratorHelper(this.bookingRemoteCache.entries()),
3820
- _step7;
3561
+ var _iterator6 = _createForOfIteratorHelper(this.bookingRemoteCache.entries()),
3562
+ _step6;
3821
3563
  try {
3822
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
3823
- var _step7$value = _slicedToArray(_step7.value, 2),
3824
- _key3 = _step7$value[0],
3825
- cache = _step7$value[1];
3564
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
3565
+ var _step6$value = _slicedToArray(_step6.value, 2),
3566
+ _key3 = _step6$value[0],
3567
+ cache = _step6$value[1];
3826
3568
  if (cache.updatedAt < oldestTime) {
3827
3569
  oldestTime = cache.updatedAt;
3828
3570
  oldestKey = _key3;
3829
3571
  }
3830
3572
  }
3831
3573
  } catch (err) {
3832
- _iterator7.e(err);
3574
+ _iterator6.e(err);
3833
3575
  } finally {
3834
- _iterator7.f();
3576
+ _iterator6.f();
3835
3577
  }
3836
3578
  if (oldestKey) this.bookingRemoteCache.delete(oldestKey);
3837
3579
  }
@@ -3847,17 +3589,17 @@ var Server = /*#__PURE__*/function () {
3847
3589
  key: "markBookingRemoteCacheAllStale",
3848
3590
  value: function markBookingRemoteCacheAllStale(reason) {
3849
3591
  if (this.bookingRemoteCache.size === 0) return;
3850
- var _iterator8 = _createForOfIteratorHelper(this.bookingRemoteCache.values()),
3851
- _step8;
3592
+ var _iterator7 = _createForOfIteratorHelper(this.bookingRemoteCache.values()),
3593
+ _step7;
3852
3594
  try {
3853
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
3854
- var entry = _step8.value;
3595
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
3596
+ var entry = _step7.value;
3855
3597
  entry.stale = true;
3856
3598
  }
3857
3599
  } catch (err) {
3858
- _iterator8.e(err);
3600
+ _iterator7.e(err);
3859
3601
  } finally {
3860
- _iterator8.f();
3602
+ _iterator7.f();
3861
3603
  }
3862
3604
  this.logWarning('bookingRemoteCache: 全量标记失效', {
3863
3605
  reason: reason,
@@ -3883,13 +3625,13 @@ var Server = /*#__PURE__*/function () {
3883
3625
  key: "notifyBookingRemoteSubscribersByCacheKey",
3884
3626
  value: function notifyBookingRemoteSubscribersByCacheKey(cacheKey, entry, reason) {
3885
3627
  if (this.bookingRemoteQuerySubscribers.size === 0) return;
3886
- var _iterator9 = _createForOfIteratorHelper(this.bookingRemoteQuerySubscribers.entries()),
3887
- _step9;
3628
+ var _iterator8 = _createForOfIteratorHelper(this.bookingRemoteQuerySubscribers.entries()),
3629
+ _step8;
3888
3630
  try {
3889
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
3890
- var _step9$value = _slicedToArray(_step9.value, 2),
3891
- subscriberId = _step9$value[0],
3892
- subscriber = _step9$value[1];
3631
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
3632
+ var _step8$value = _slicedToArray(_step8.value, 2),
3633
+ subscriberId = _step8$value[0],
3634
+ subscriber = _step8$value[1];
3893
3635
  if (subscriber.cacheKey !== cacheKey) continue;
3894
3636
  try {
3895
3637
  var callbackStartAt = Date.now();
@@ -3916,9 +3658,9 @@ var Server = /*#__PURE__*/function () {
3916
3658
  }
3917
3659
  }
3918
3660
  } catch (err) {
3919
- _iterator9.e(err);
3661
+ _iterator8.e(err);
3920
3662
  } finally {
3921
- _iterator9.f();
3663
+ _iterator8.f();
3922
3664
  }
3923
3665
  }
3924
3666
  }, {
@@ -3933,13 +3675,13 @@ var Server = /*#__PURE__*/function () {
3933
3675
  return;
3934
3676
  }
3935
3677
  var syncedEntryCount = 0;
3936
- var _iterator10 = _createForOfIteratorHelper(this.bookingRemoteCache.entries()),
3937
- _step10;
3678
+ var _iterator9 = _createForOfIteratorHelper(this.bookingRemoteCache.entries()),
3679
+ _step9;
3938
3680
  try {
3939
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
3940
- var _step10$value = _slicedToArray(_step10.value, 2),
3941
- cacheKey = _step10$value[0],
3942
- entry = _step10$value[1];
3681
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
3682
+ var _step9$value = _slicedToArray(_step9.value, 2),
3683
+ cacheKey = _step9$value[0],
3684
+ entry = _step9$value[1];
3943
3685
  if (entry.stale) {
3944
3686
  this.bookingRemoteCache.delete(cacheKey);
3945
3687
  continue;
@@ -3947,25 +3689,25 @@ var Server = /*#__PURE__*/function () {
3947
3689
  try {
3948
3690
  var queryPayload = entry.queryPayload;
3949
3691
  var orderMap = new Map();
3950
- var _iterator11 = _createForOfIteratorHelper(entry.rawOrders),
3951
- _step11;
3692
+ var _iterator10 = _createForOfIteratorHelper(entry.rawOrders),
3693
+ _step10;
3952
3694
  try {
3953
- for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
3954
- var order = _step11.value;
3695
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
3696
+ var order = _step10.value;
3955
3697
  var _key4 = this.toOrderIdKey(order);
3956
3698
  if (_key4) orderMap.set(_key4, order);
3957
3699
  }
3958
3700
  } catch (err) {
3959
- _iterator11.e(err);
3701
+ _iterator10.e(err);
3960
3702
  } finally {
3961
- _iterator11.f();
3703
+ _iterator10.f();
3962
3704
  }
3963
3705
  var changed = false;
3964
- var _iterator12 = _createForOfIteratorHelper(latestOrders),
3965
- _step12;
3706
+ var _iterator11 = _createForOfIteratorHelper(latestOrders),
3707
+ _step11;
3966
3708
  try {
3967
- for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
3968
- var latest = _step12.value;
3709
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
3710
+ var latest = _step11.value;
3969
3711
  var _key5 = this.toOrderIdKey(latest);
3970
3712
  if (!_key5) continue;
3971
3713
  if (orderMap.has(_key5)) {
@@ -3977,9 +3719,9 @@ var Server = /*#__PURE__*/function () {
3977
3719
  changed = true;
3978
3720
  }
3979
3721
  } catch (err) {
3980
- _iterator12.e(err);
3722
+ _iterator11.e(err);
3981
3723
  } finally {
3982
- _iterator12.f();
3724
+ _iterator11.f();
3983
3725
  }
3984
3726
  if (!changed) continue;
3985
3727
  var mergedOrders = _toConsumableArray(orderMap.values());
@@ -4012,9 +3754,9 @@ var Server = /*#__PURE__*/function () {
4012
3754
  }
4013
3755
  }
4014
3756
  } catch (err) {
4015
- _iterator10.e(err);
3757
+ _iterator9.e(err);
4016
3758
  } finally {
4017
- _iterator10.f();
3759
+ _iterator9.f();
4018
3760
  }
4019
3761
  var syncEndAt = Date.now();
4020
3762
  if (syncedEntryCount > 0) {
@@ -4032,18 +3774,18 @@ var Server = /*#__PURE__*/function () {
4032
3774
  }, {
4033
3775
  key: "fetchOrderListFromAPI",
4034
3776
  value: (function () {
4035
- var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(data) {
3777
+ var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(data) {
4036
3778
  var _this$app9;
4037
3779
  var _response$data5, response, _payload2, list, count, errorMessage;
4038
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
4039
- while (1) switch (_context42.prev = _context42.next) {
3780
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3781
+ while (1) switch (_context40.prev = _context40.next) {
4040
3782
  case 0:
4041
3783
  if ((_this$app9 = this.app) !== null && _this$app9 !== void 0 && _this$app9.request) {
4042
- _context42.next = 3;
3784
+ _context40.next = 3;
4043
3785
  break;
4044
3786
  }
4045
3787
  this.logError('fetchOrderListFromAPI: app.request 不可用');
4046
- return _context42.abrupt("return", {
3788
+ return _context40.abrupt("return", {
4047
3789
  code: 500,
4048
3790
  message: 'app.request 不可用',
4049
3791
  data: {
@@ -4053,17 +3795,17 @@ var Server = /*#__PURE__*/function () {
4053
3795
  status: false
4054
3796
  });
4055
3797
  case 3:
4056
- _context42.prev = 3;
4057
- _context42.next = 6;
3798
+ _context40.prev = 3;
3799
+ _context40.next = 6;
4058
3800
  return this.app.request.post('/shop/order/v2/list', data, {
4059
3801
  isShopApi: true
4060
3802
  });
4061
3803
  case 6:
4062
- response = _context42.sent;
3804
+ response = _context40.sent;
4063
3805
  _payload2 = (_response$data5 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data5 !== void 0 ? _response$data5 : response;
4064
3806
  list = Array.isArray(_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.list) ? _payload2.list : [];
4065
3807
  count = typeof (_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.count) === 'number' ? _payload2.count : list.length;
4066
- return _context42.abrupt("return", {
3808
+ return _context40.abrupt("return", {
4067
3809
  code: 200,
4068
3810
  data: _objectSpread(_objectSpread({}, _payload2), {}, {
4069
3811
  list: list,
@@ -4073,13 +3815,13 @@ var Server = /*#__PURE__*/function () {
4073
3815
  status: true
4074
3816
  });
4075
3817
  case 13:
4076
- _context42.prev = 13;
4077
- _context42.t0 = _context42["catch"](3);
4078
- errorMessage = _context42.t0 instanceof Error ? _context42.t0.message : String(_context42.t0);
3818
+ _context40.prev = 13;
3819
+ _context40.t0 = _context40["catch"](3);
3820
+ errorMessage = _context40.t0 instanceof Error ? _context40.t0.message : String(_context40.t0);
4079
3821
  this.logError('fetchOrderListFromAPI: 请求失败', {
4080
3822
  error: errorMessage
4081
3823
  });
4082
- return _context42.abrupt("return", {
3824
+ return _context40.abrupt("return", {
4083
3825
  code: 500,
4084
3826
  message: errorMessage,
4085
3827
  data: {
@@ -4090,11 +3832,11 @@ var Server = /*#__PURE__*/function () {
4090
3832
  });
4091
3833
  case 18:
4092
3834
  case "end":
4093
- return _context42.stop();
3835
+ return _context40.stop();
4094
3836
  }
4095
- }, _callee42, this, [[3, 13]]);
3837
+ }, _callee40, this, [[3, 13]]);
4096
3838
  }));
4097
- function fetchOrderListFromAPI(_x46) {
3839
+ function fetchOrderListFromAPI(_x43) {
4098
3840
  return _fetchOrderListFromAPI.apply(this, arguments);
4099
3841
  }
4100
3842
  return fetchOrderListFromAPI;
@@ -4106,17 +3848,17 @@ var Server = /*#__PURE__*/function () {
4106
3848
  }, {
4107
3849
  key: "fetchBookingListFromAPI",
4108
3850
  value: (function () {
4109
- var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(data) {
3851
+ var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(data) {
4110
3852
  var memoryCacheEnabled, withFields, requestPayload, cacheKey, cached, rawList, bookingResult, _bookingResult$list, errorMessage;
4111
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4112
- while (1) switch (_context43.prev = _context43.next) {
3853
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3854
+ while (1) switch (_context41.prev = _context41.next) {
4113
3855
  case 0:
4114
3856
  if (this.order) {
4115
- _context43.next = 3;
3857
+ _context41.next = 3;
4116
3858
  break;
4117
3859
  }
4118
3860
  this.logError('fetchBookingListFromAPI: Order 模块不可用');
4119
- return _context43.abrupt("return", {
3861
+ return _context41.abrupt("return", {
4120
3862
  code: 500,
4121
3863
  message: 'Order 模块不可用',
4122
3864
  data: {
@@ -4126,18 +3868,18 @@ var Server = /*#__PURE__*/function () {
4126
3868
  status: false
4127
3869
  });
4128
3870
  case 3:
4129
- _context43.prev = 3;
3871
+ _context41.prev = 3;
4130
3872
  memoryCacheEnabled = this.isBookingRemoteMemoryCacheEnabled(data);
4131
3873
  withFields = this.resolveBookingSalesWith(data);
4132
3874
  requestPayload = this.normalizeBookingRemoteQueryPayload(data, withFields);
4133
3875
  cacheKey = this.buildBookingRemoteCacheKey(requestPayload);
4134
3876
  if (!memoryCacheEnabled) {
4135
- _context43.next = 13;
3877
+ _context41.next = 13;
4136
3878
  break;
4137
3879
  }
4138
3880
  cached = this.readBookingRemoteCache(cacheKey);
4139
3881
  if (!cached) {
4140
- _context43.next = 13;
3882
+ _context41.next = 13;
4141
3883
  break;
4142
3884
  }
4143
3885
  this.logInfo('fetchBookingListFromAPI: 命中内存缓存', {
@@ -4145,14 +3887,14 @@ var Server = /*#__PURE__*/function () {
4145
3887
  listCount: cached.bookingResult.count,
4146
3888
  withFields: cached.withFields
4147
3889
  });
4148
- return _context43.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
3890
+ return _context41.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
4149
3891
  cache_hit: true
4150
3892
  }));
4151
3893
  case 13:
4152
- _context43.next = 15;
3894
+ _context41.next = 15;
4153
3895
  return this.order.fetchOrdersBySSE(requestPayload);
4154
3896
  case 15:
4155
- rawList = _context43.sent;
3897
+ rawList = _context41.sent;
4156
3898
  bookingResult = sortBookings(filterBookingsFromOrders(rawList, data), data); // DEBUG: 挂到 window 上方便排查 SSE → 日历数据丢失问题
4157
3899
  if (typeof globalThis !== 'undefined') {
4158
3900
  globalThis.__SSE_BOOKING_DEBUG__ = {
@@ -4199,15 +3941,15 @@ var Server = /*#__PURE__*/function () {
4199
3941
  cacheKey: cacheKey,
4200
3942
  withFields: withFields
4201
3943
  });
4202
- return _context43.abrupt("return", this.buildBookingResponse(bookingResult));
3944
+ return _context41.abrupt("return", this.buildBookingResponse(bookingResult));
4203
3945
  case 23:
4204
- _context43.prev = 23;
4205
- _context43.t0 = _context43["catch"](3);
4206
- errorMessage = _context43.t0 instanceof Error ? _context43.t0.message : String(_context43.t0);
3946
+ _context41.prev = 23;
3947
+ _context41.t0 = _context41["catch"](3);
3948
+ errorMessage = _context41.t0 instanceof Error ? _context41.t0.message : String(_context41.t0);
4207
3949
  this.logError('fetchBookingListFromAPI: SSE 请求失败', {
4208
3950
  error: errorMessage
4209
3951
  });
4210
- return _context43.abrupt("return", {
3952
+ return _context41.abrupt("return", {
4211
3953
  code: 500,
4212
3954
  message: errorMessage,
4213
3955
  data: {
@@ -4218,11 +3960,11 @@ var Server = /*#__PURE__*/function () {
4218
3960
  });
4219
3961
  case 28:
4220
3962
  case "end":
4221
- return _context43.stop();
3963
+ return _context41.stop();
4222
3964
  }
4223
- }, _callee43, this, [[3, 23]]);
3965
+ }, _callee41, this, [[3, 23]]);
4224
3966
  }));
4225
- function fetchBookingListFromAPI(_x47) {
3967
+ function fetchBookingListFromAPI(_x44) {
4226
3968
  return _fetchBookingListFromAPI.apply(this, arguments);
4227
3969
  }
4228
3970
  return fetchBookingListFromAPI;
@@ -4298,32 +4040,32 @@ var Server = /*#__PURE__*/function () {
4298
4040
  }, {
4299
4041
  key: "getShortNumberOrDeviceId",
4300
4042
  value: function () {
4301
- var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
4043
+ var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
4302
4044
  var getAsyncIotDeviceInfo, res;
4303
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4304
- while (1) switch (_context44.prev = _context44.next) {
4045
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
4046
+ while (1) switch (_context42.prev = _context42.next) {
4305
4047
  case 0:
4306
4048
  getAsyncIotDeviceInfo = this.getAppData('async_iot_device_info');
4307
4049
  if (!getAsyncIotDeviceInfo) {
4308
- _context44.next = 7;
4050
+ _context42.next = 7;
4309
4051
  break;
4310
4052
  }
4311
- _context44.next = 4;
4053
+ _context42.next = 4;
4312
4054
  return getAsyncIotDeviceInfo === null || getAsyncIotDeviceInfo === void 0 ? void 0 : getAsyncIotDeviceInfo();
4313
4055
  case 4:
4314
- res = _context44.sent;
4056
+ res = _context42.sent;
4315
4057
  if (!(res !== null && res !== void 0 && res.short_number)) {
4316
- _context44.next = 7;
4058
+ _context42.next = 7;
4317
4059
  break;
4318
4060
  }
4319
- return _context44.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
4061
+ return _context42.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
4320
4062
  case 7:
4321
- return _context44.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
4063
+ return _context42.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
4322
4064
  case 8:
4323
4065
  case "end":
4324
- return _context44.stop();
4066
+ return _context42.stop();
4325
4067
  }
4326
- }, _callee44, this);
4068
+ }, _callee42, this);
4327
4069
  }));
4328
4070
  function getShortNumberOrDeviceId() {
4329
4071
  return _getShortNumberOrDeviceId.apply(this, arguments);
@@ -4350,16 +4092,16 @@ var Server = /*#__PURE__*/function () {
4350
4092
  }, {
4351
4093
  key: "normalizeCheckoutSubmitData",
4352
4094
  value: function () {
4353
- var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(data, title) {
4095
+ var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(data, title) {
4354
4096
  var next, externalSaleNumber, shouldClearLocalOrderId, hasCheckoutOrderNumbers, localOrder;
4355
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4356
- while (1) switch (_context45.prev = _context45.next) {
4097
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4098
+ while (1) switch (_context43.prev = _context43.next) {
4357
4099
  case 0:
4358
4100
  if (!(!data || _typeof(data) !== 'object')) {
4359
- _context45.next = 2;
4101
+ _context43.next = 2;
4360
4102
  break;
4361
4103
  }
4362
- return _context45.abrupt("return", data);
4104
+ return _context43.abrupt("return", data);
4363
4105
  case 2:
4364
4106
  next = _objectSpread({}, data);
4365
4107
  externalSaleNumber = next.external_sale_number;
@@ -4369,7 +4111,7 @@ var Server = /*#__PURE__*/function () {
4369
4111
  delete next.vouchers;
4370
4112
  hasCheckoutOrderNumbers = !this.isBlankCheckoutValue(next.shop_order_number) && !this.isBlankCheckoutValue(next.shop_full_order_number);
4371
4113
  if (!hasCheckoutOrderNumbers) {
4372
- _context45.next = 11;
4114
+ _context43.next = 11;
4373
4115
  break;
4374
4116
  }
4375
4117
  this.logInfo("".concat(title, ": checkout \u5DF2\u643A\u5E26\u8BA2\u5355\u53F7\uFF0C\u8DF3\u8FC7\u67E5\u91CD"), {
@@ -4379,10 +4121,10 @@ var Server = /*#__PURE__*/function () {
4379
4121
  shop_order_number: next.shop_order_number,
4380
4122
  shop_full_order_number: next.shop_full_order_number
4381
4123
  });
4382
- return _context45.abrupt("return", next);
4124
+ return _context43.abrupt("return", next);
4383
4125
  case 11:
4384
4126
  if (!this.isBlankCheckoutValue(externalSaleNumber)) {
4385
- _context45.next = 14;
4127
+ _context43.next = 14;
4386
4128
  break;
4387
4129
  }
4388
4130
  if (shouldClearLocalOrderId) {
@@ -4391,10 +4133,10 @@ var Server = /*#__PURE__*/function () {
4391
4133
  order_id: next.order_id
4392
4134
  });
4393
4135
  }
4394
- return _context45.abrupt("return", next);
4136
+ return _context43.abrupt("return", next);
4395
4137
  case 14:
4396
4138
  if (!(!this.order || typeof this.order.getLocalOrderFromMemoryByLookup !== 'function')) {
4397
- _context45.next = 17;
4139
+ _context43.next = 17;
4398
4140
  break;
4399
4141
  }
4400
4142
  if (shouldClearLocalOrderId) {
@@ -4403,12 +4145,12 @@ var Server = /*#__PURE__*/function () {
4403
4145
  external_sale_number: externalSaleNumber
4404
4146
  });
4405
4147
  }
4406
- return _context45.abrupt("return", next);
4148
+ return _context43.abrupt("return", next);
4407
4149
  case 17:
4408
- _context45.prev = 17;
4150
+ _context43.prev = 17;
4409
4151
  localOrder = this.order.getLocalOrderFromMemoryByLookup(externalSaleNumber);
4410
4152
  if (localOrder) {
4411
- _context45.next = 22;
4153
+ _context43.next = 22;
4412
4154
  break;
4413
4155
  }
4414
4156
  if (shouldClearLocalOrderId) {
@@ -4418,7 +4160,7 @@ var Server = /*#__PURE__*/function () {
4418
4160
  localOrderFound: false
4419
4161
  });
4420
4162
  }
4421
- return _context45.abrupt("return", next);
4163
+ return _context43.abrupt("return", next);
4422
4164
  case 22:
4423
4165
  if (this.isBlankCheckoutValue(next.shop_order_number)) {
4424
4166
  next.shop_order_number = localOrder.shop_order_number;
@@ -4435,23 +4177,23 @@ var Server = /*#__PURE__*/function () {
4435
4177
  shop_full_order_number: next.shop_full_order_number
4436
4178
  });
4437
4179
  // 删除 数据体中的 vouchers,对小票和后端来说他们不需要,这个字段只是单向同步给前端用的,而且目前对订单来说还没什么用
4438
- return _context45.abrupt("return", next);
4180
+ return _context43.abrupt("return", next);
4439
4181
  case 28:
4440
- _context45.prev = 28;
4441
- _context45.t0 = _context45["catch"](17);
4182
+ _context43.prev = 28;
4183
+ _context43.t0 = _context43["catch"](17);
4442
4184
  this.logWarning("".concat(title, ": checkout \u67E5\u627E\u672C\u5730\u8BA2\u5355\u5931\u8D25"), {
4443
4185
  external_sale_number: externalSaleNumber,
4444
- error: this.getUnknownErrorMessage(_context45.t0),
4445
- error_detail: this.normalizeUnknownError(_context45.t0)
4186
+ error: this.getUnknownErrorMessage(_context43.t0),
4187
+ error_detail: this.normalizeUnknownError(_context43.t0)
4446
4188
  });
4447
- return _context45.abrupt("return", next);
4189
+ return _context43.abrupt("return", next);
4448
4190
  case 32:
4449
4191
  case "end":
4450
- return _context45.stop();
4192
+ return _context43.stop();
4451
4193
  }
4452
- }, _callee45, this, [[17, 28]]);
4194
+ }, _callee43, this, [[17, 28]]);
4453
4195
  }));
4454
- function normalizeCheckoutSubmitData(_x48, _x49) {
4196
+ function normalizeCheckoutSubmitData(_x45, _x46) {
4455
4197
  return _normalizeCheckoutSubmitData.apply(this, arguments);
4456
4198
  }
4457
4199
  return normalizeCheckoutSubmitData;
@@ -4459,81 +4201,81 @@ var Server = /*#__PURE__*/function () {
4459
4201
  }, {
4460
4202
  key: "ensureCheckoutOrderNumbers",
4461
4203
  value: function () {
4462
- var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(data, title) {
4204
+ var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(data, title) {
4463
4205
  var next, needsShopOrderNumber, needsShopFullOrderNumber, idGenerator;
4464
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4465
- while (1) switch (_context46.prev = _context46.next) {
4206
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4207
+ while (1) switch (_context44.prev = _context44.next) {
4466
4208
  case 0:
4467
4209
  if (!(!data || _typeof(data) !== 'object')) {
4468
- _context46.next = 2;
4210
+ _context44.next = 2;
4469
4211
  break;
4470
4212
  }
4471
- return _context46.abrupt("return", data);
4213
+ return _context44.abrupt("return", data);
4472
4214
  case 2:
4473
4215
  next = _objectSpread({}, data);
4474
4216
  needsShopOrderNumber = next.shop_order_number === undefined || next.shop_order_number === null || next.shop_order_number === '';
4475
4217
  needsShopFullOrderNumber = next.shop_full_order_number === undefined || next.shop_full_order_number === null || next.shop_full_order_number === '';
4476
4218
  if (!(!needsShopOrderNumber && !needsShopFullOrderNumber)) {
4477
- _context46.next = 7;
4219
+ _context44.next = 7;
4478
4220
  break;
4479
4221
  }
4480
- return _context46.abrupt("return", next);
4222
+ return _context44.abrupt("return", next);
4481
4223
  case 7:
4482
4224
  idGenerator = this.getIdGeneratorPlugin();
4483
4225
  if (idGenerator) {
4484
- _context46.next = 11;
4226
+ _context44.next = 11;
4485
4227
  break;
4486
4228
  }
4487
4229
  this.logWarning("".concat(title, ": idGenerator \u63D2\u4EF6\u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u751F\u6210\u8BA2\u5355\u53F7"), {
4488
4230
  needsShopOrderNumber: needsShopOrderNumber,
4489
4231
  needsShopFullOrderNumber: needsShopFullOrderNumber
4490
4232
  });
4491
- return _context46.abrupt("return", next);
4233
+ return _context44.abrupt("return", next);
4492
4234
  case 11:
4493
- _context46.prev = 11;
4235
+ _context44.prev = 11;
4494
4236
  if (!(needsShopOrderNumber && idGenerator.generateShopOrderNumber)) {
4495
- _context46.next = 16;
4237
+ _context44.next = 16;
4496
4238
  break;
4497
4239
  }
4498
- _context46.next = 15;
4240
+ _context44.next = 15;
4499
4241
  return idGenerator.generateShopOrderNumber({
4500
4242
  biz: next.business_code || 'ticket'
4501
4243
  });
4502
4244
  case 15:
4503
- next.shop_order_number = _context46.sent;
4245
+ next.shop_order_number = _context44.sent;
4504
4246
  case 16:
4505
4247
  if (!(needsShopFullOrderNumber && idGenerator.generateReceiptId)) {
4506
- _context46.next = 20;
4248
+ _context44.next = 20;
4507
4249
  break;
4508
4250
  }
4509
- _context46.next = 19;
4251
+ _context44.next = 19;
4510
4252
  return idGenerator.generateReceiptId({
4511
4253
  biz: next.business_code || 'ticket'
4512
4254
  });
4513
4255
  case 19:
4514
- next.shop_full_order_number = _context46.sent;
4256
+ next.shop_full_order_number = _context44.sent;
4515
4257
  case 20:
4516
4258
  this.logInfo("".concat(title, ": checkout \u8BA2\u5355\u53F7\u5DF2\u51C6\u5907"), {
4517
4259
  shop_order_number: next.shop_order_number,
4518
4260
  shop_full_order_number: next.shop_full_order_number
4519
4261
  });
4520
- _context46.next = 26;
4262
+ _context44.next = 26;
4521
4263
  break;
4522
4264
  case 23:
4523
- _context46.prev = 23;
4524
- _context46.t0 = _context46["catch"](11);
4265
+ _context44.prev = 23;
4266
+ _context44.t0 = _context44["catch"](11);
4525
4267
  this.logError("".concat(title, ": \u751F\u6210 checkout \u8BA2\u5355\u53F7\u5931\u8D25"), {
4526
- error: _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0)
4268
+ error: _context44.t0 instanceof Error ? _context44.t0.message : String(_context44.t0)
4527
4269
  });
4528
4270
  case 26:
4529
- return _context46.abrupt("return", next);
4271
+ return _context44.abrupt("return", next);
4530
4272
  case 27:
4531
4273
  case "end":
4532
- return _context46.stop();
4274
+ return _context44.stop();
4533
4275
  }
4534
- }, _callee46, this, [[11, 23]]);
4276
+ }, _callee44, this, [[11, 23]]);
4535
4277
  }));
4536
- function ensureCheckoutOrderNumbers(_x50, _x51) {
4278
+ function ensureCheckoutOrderNumbers(_x47, _x48) {
4537
4279
  return _ensureCheckoutOrderNumbers.apply(this, arguments);
4538
4280
  }
4539
4281
  return ensureCheckoutOrderNumbers;
@@ -4541,27 +4283,27 @@ var Server = /*#__PURE__*/function () {
4541
4283
  }, {
4542
4284
  key: "dispatchCheckoutSyncTask",
4543
4285
  value: function () {
4544
- var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
4286
+ var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
4545
4287
  var deviceTask, debugDeviceId, debugIdempotencyKey, _params$data, _params$data2, _params$data3, _params$data4, result;
4546
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4547
- while (1) switch (_context47.prev = _context47.next) {
4288
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4289
+ while (1) switch (_context45.prev = _context45.next) {
4548
4290
  case 0:
4549
4291
  this.registerDeviceTaskActions();
4550
4292
  deviceTask = this.getDeviceTaskPlugin();
4551
- _context47.next = 4;
4293
+ _context45.next = 4;
4552
4294
  return this.getShortNumberOrDeviceId();
4553
4295
  case 4:
4554
- debugDeviceId = _context47.sent;
4296
+ debugDeviceId = _context45.sent;
4555
4297
  debugIdempotencyKey = this.buildCheckoutTaskIdempotencyKey(params.data);
4556
4298
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
4557
- _context47.next = 9;
4299
+ _context45.next = 9;
4558
4300
  break;
4559
4301
  }
4560
4302
  this.logError("".concat(params.title, ": deviceTask.dispatch \u4E0D\u53EF\u7528"));
4561
- return _context47.abrupt("return");
4303
+ return _context45.abrupt("return");
4562
4304
  case 9:
4563
- _context47.prev = 9;
4564
- _context47.next = 12;
4305
+ _context45.prev = 9;
4306
+ _context45.next = 12;
4565
4307
  return deviceTask.dispatch({
4566
4308
  action: 'sync_sales',
4567
4309
  device_id: debugDeviceId,
@@ -4579,27 +4321,27 @@ var Server = /*#__PURE__*/function () {
4579
4321
  source_id: ((_params$data2 = params.data) === null || _params$data2 === void 0 ? void 0 : _params$data2.order_id) || ((_params$data3 = params.data) === null || _params$data3 === void 0 ? void 0 : _params$data3.external_sale_number) || ((_params$data4 = params.data) === null || _params$data4 === void 0 ? void 0 : _params$data4.shop_order_number)
4580
4322
  });
4581
4323
  case 12:
4582
- result = _context47.sent;
4324
+ result = _context45.sent;
4583
4325
  this.logInfo("".concat(params.title, ": sync_sales \u4EFB\u52A1\u5DF2\u6D3E\u53D1"), {
4584
4326
  uuid: result === null || result === void 0 ? void 0 : result.uuid,
4585
4327
  status: result === null || result === void 0 ? void 0 : result.status,
4586
4328
  reused: result === null || result === void 0 ? void 0 : result.reused
4587
4329
  });
4588
- _context47.next = 19;
4330
+ _context45.next = 19;
4589
4331
  break;
4590
4332
  case 16:
4591
- _context47.prev = 16;
4592
- _context47.t0 = _context47["catch"](9);
4333
+ _context45.prev = 16;
4334
+ _context45.t0 = _context45["catch"](9);
4593
4335
  this.logError("".concat(params.title, ": \u6D3E\u53D1 sync_sales \u4EFB\u52A1\u5931\u8D25"), {
4594
- error: _context47.t0 instanceof Error ? _context47.t0.message : String(_context47.t0)
4336
+ error: _context45.t0 instanceof Error ? _context45.t0.message : String(_context45.t0)
4595
4337
  });
4596
4338
  case 19:
4597
4339
  case "end":
4598
- return _context47.stop();
4340
+ return _context45.stop();
4599
4341
  }
4600
- }, _callee47, this, [[9, 16]]);
4342
+ }, _callee45, this, [[9, 16]]);
4601
4343
  }));
4602
- function dispatchCheckoutSyncTask(_x52) {
4344
+ function dispatchCheckoutSyncTask(_x49) {
4603
4345
  return _dispatchCheckoutSyncTask.apply(this, arguments);
4604
4346
  }
4605
4347
  return dispatchCheckoutSyncTask;
@@ -4607,26 +4349,26 @@ var Server = /*#__PURE__*/function () {
4607
4349
  }, {
4608
4350
  key: "dispatchPrintOtherReceiptTask",
4609
4351
  value: function () {
4610
- var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
4352
+ var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(params) {
4611
4353
  var deviceTask, _params$deviceId, _params$syncedOrder, _params$syncedOrder2, _params$syncedOrder3, printIdentity, deviceId;
4612
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4613
- while (1) switch (_context48.prev = _context48.next) {
4354
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4355
+ while (1) switch (_context46.prev = _context46.next) {
4614
4356
  case 0:
4615
4357
  deviceTask = this.getDeviceTaskPlugin();
4616
4358
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
4617
- _context48.next = 4;
4359
+ _context46.next = 4;
4618
4360
  break;
4619
4361
  }
4620
4362
  this.logWarning('dispatchPrintOtherReceiptTask: deviceTask.dispatch 不可用');
4621
- return _context48.abrupt("return");
4363
+ return _context46.abrupt("return");
4622
4364
  case 4:
4623
- _context48.prev = 4;
4365
+ _context46.prev = 4;
4624
4366
  printIdentity = this.getPrintOrderIdentity(params.syncedOrder);
4625
- _context48.next = 8;
4367
+ _context46.next = 8;
4626
4368
  return this.getShortNumberOrDeviceId();
4627
4369
  case 8:
4628
- deviceId = _context48.sent;
4629
- _context48.next = 11;
4370
+ deviceId = _context46.sent;
4371
+ _context46.next = 11;
4630
4372
  return deviceTask.dispatch({
4631
4373
  action: 'print_all',
4632
4374
  device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : deviceId,
@@ -4653,21 +4395,21 @@ var Server = /*#__PURE__*/function () {
4653
4395
  source_id: printIdentity
4654
4396
  });
4655
4397
  case 11:
4656
- _context48.next = 16;
4398
+ _context46.next = 16;
4657
4399
  break;
4658
4400
  case 13:
4659
- _context48.prev = 13;
4660
- _context48.t0 = _context48["catch"](4);
4401
+ _context46.prev = 13;
4402
+ _context46.t0 = _context46["catch"](4);
4661
4403
  this.logError('dispatchPrintOtherReceiptTask: 派发失败', {
4662
- error: _context48.t0 instanceof Error ? _context48.t0.message : String(_context48.t0)
4404
+ error: _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0)
4663
4405
  });
4664
4406
  case 16:
4665
4407
  case "end":
4666
- return _context48.stop();
4408
+ return _context46.stop();
4667
4409
  }
4668
- }, _callee48, this, [[4, 13]]);
4410
+ }, _callee46, this, [[4, 13]]);
4669
4411
  }));
4670
- function dispatchPrintOtherReceiptTask(_x53) {
4412
+ function dispatchPrintOtherReceiptTask(_x50) {
4671
4413
  return _dispatchPrintOtherReceiptTask.apply(this, arguments);
4672
4414
  }
4673
4415
  return dispatchPrintOtherReceiptTask;
@@ -4687,32 +4429,32 @@ var Server = /*#__PURE__*/function () {
4687
4429
  }, {
4688
4430
  key: "dispatchLocalReceiptPrint",
4689
4431
  value: function () {
4690
- var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
4432
+ var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
4691
4433
  var _payment_info;
4692
4434
  var printableOrder;
4693
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4694
- while (1) switch (_context49.prev = _context49.next) {
4435
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4436
+ while (1) switch (_context47.prev = _context47.next) {
4695
4437
  case 0:
4696
4438
  if (!(params.requireFullyPaid && !this.isSalesOrderFullyPaid(params.order))) {
4697
- _context49.next = 2;
4439
+ _context47.next = 2;
4698
4440
  break;
4699
4441
  }
4700
- return _context49.abrupt("return", {
4442
+ return _context47.abrupt("return", {
4701
4443
  printed: false,
4702
4444
  order: params.order
4703
4445
  });
4704
4446
  case 2:
4705
- _context49.next = 4;
4447
+ _context47.next = 4;
4706
4448
  return this.withLocalSmallTicketData(params.order, {
4707
4449
  requireFullyPaid: params.requireFullyPaid
4708
4450
  });
4709
4451
  case 4:
4710
- printableOrder = _context49.sent;
4452
+ printableOrder = _context47.sent;
4711
4453
  if (hasSmallTicketData((_payment_info = printableOrder.payment_info) === null || _payment_info === void 0 ? void 0 : _payment_info.small_ticket_data)) {
4712
- _context49.next = 7;
4454
+ _context47.next = 7;
4713
4455
  break;
4714
4456
  }
4715
- return _context49.abrupt("return", {
4457
+ return _context47.abrupt("return", {
4716
4458
  printed: false,
4717
4459
  order: printableOrder
4718
4460
  });
@@ -4722,7 +4464,7 @@ var Server = /*#__PURE__*/function () {
4722
4464
  printableOrder: printableOrder,
4723
4465
  response: params.response
4724
4466
  });
4725
- _context49.next = 10;
4467
+ _context47.next = 10;
4726
4468
  return this.dispatchPrintOtherReceiptTask({
4727
4469
  checkoutData: params.checkoutData,
4728
4470
  syncedOrder: printableOrder,
@@ -4731,17 +4473,17 @@ var Server = /*#__PURE__*/function () {
4731
4473
  isManualPrint: params.isManualPrint
4732
4474
  });
4733
4475
  case 10:
4734
- return _context49.abrupt("return", {
4476
+ return _context47.abrupt("return", {
4735
4477
  printed: true,
4736
4478
  order: printableOrder
4737
4479
  });
4738
4480
  case 11:
4739
4481
  case "end":
4740
- return _context49.stop();
4482
+ return _context47.stop();
4741
4483
  }
4742
- }, _callee49, this);
4484
+ }, _callee47, this);
4743
4485
  }));
4744
- function dispatchLocalReceiptPrint(_x54) {
4486
+ function dispatchLocalReceiptPrint(_x51) {
4745
4487
  return _dispatchLocalReceiptPrint.apply(this, arguments);
4746
4488
  }
4747
4489
  return dispatchLocalReceiptPrint;
@@ -4776,47 +4518,47 @@ var Server = /*#__PURE__*/function () {
4776
4518
  }, {
4777
4519
  key: "syncMachinecodeRedeemStatusToLocalOrder",
4778
4520
  value: function () {
4779
- var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(data, ids, status) {
4521
+ var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(data, ids, status) {
4780
4522
  var _this$order3;
4781
4523
  var title, lookup, localOrder, voucherIdSet, vouchers, hasUpdatedVoucher, nextVouchers;
4782
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4783
- while (1) switch (_context50.prev = _context50.next) {
4524
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4525
+ while (1) switch (_context48.prev = _context48.next) {
4784
4526
  case 0:
4785
4527
  title = 'handleMachinecodeBatchMetadata';
4786
4528
  lookup = this.resolveMachinecodeBatchMetadataLookup(data);
4787
4529
  if (!(lookup === undefined)) {
4788
- _context50.next = 5;
4530
+ _context48.next = 5;
4789
4531
  break;
4790
4532
  }
4791
4533
  this.logWarning("".concat(title, ": order lookup \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
4792
4534
  batchSize: ids.length,
4793
4535
  status: status
4794
4536
  });
4795
- return _context50.abrupt("return");
4537
+ return _context48.abrupt("return");
4796
4538
  case 5:
4797
4539
  if ((_this$order3 = this.order) !== null && _this$order3 !== void 0 && _this$order3.getLocalOrderByLookup) {
4798
- _context50.next = 8;
4540
+ _context48.next = 8;
4799
4541
  break;
4800
4542
  }
4801
4543
  this.logWarning("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
4802
4544
  lookup: lookup,
4803
4545
  status: status
4804
4546
  });
4805
- return _context50.abrupt("return");
4547
+ return _context48.abrupt("return");
4806
4548
  case 8:
4807
- _context50.next = 10;
4549
+ _context48.next = 10;
4808
4550
  return this.order.getLocalOrderByLookup(lookup);
4809
4551
  case 10:
4810
- localOrder = _context50.sent;
4552
+ localOrder = _context48.sent;
4811
4553
  if (localOrder) {
4812
- _context50.next = 14;
4554
+ _context48.next = 14;
4813
4555
  break;
4814
4556
  }
4815
4557
  this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
4816
4558
  lookup: lookup,
4817
4559
  status: status
4818
4560
  });
4819
- return _context50.abrupt("return");
4561
+ return _context48.abrupt("return");
4820
4562
  case 14:
4821
4563
  voucherIdSet = new Set(ids.filter(function (id) {
4822
4564
  return id !== undefined && id !== null && id !== '';
@@ -4824,14 +4566,14 @@ var Server = /*#__PURE__*/function () {
4824
4566
  return String(id);
4825
4567
  }));
4826
4568
  if (!(voucherIdSet.size === 0)) {
4827
- _context50.next = 18;
4569
+ _context48.next = 18;
4828
4570
  break;
4829
4571
  }
4830
4572
  this.logWarning("".concat(title, ": voucher ids \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
4831
4573
  lookup: lookup,
4832
4574
  status: status
4833
4575
  });
4834
- return _context50.abrupt("return");
4576
+ return _context48.abrupt("return");
4835
4577
  case 18:
4836
4578
  vouchers = Array.isArray(localOrder.vouchers) ? localOrder.vouchers : [];
4837
4579
  hasUpdatedVoucher = false;
@@ -4845,7 +4587,7 @@ var Server = /*#__PURE__*/function () {
4845
4587
  });
4846
4588
  });
4847
4589
  if (hasUpdatedVoucher) {
4848
- _context50.next = 24;
4590
+ _context48.next = 24;
4849
4591
  break;
4850
4592
  }
4851
4593
  this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u672A\u547D\u4E2D\u4EFB\u4F55 voucher\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
@@ -4853,13 +4595,13 @@ var Server = /*#__PURE__*/function () {
4853
4595
  voucher_ids: Array.from(voucherIdSet),
4854
4596
  status: status
4855
4597
  });
4856
- return _context50.abrupt("return");
4598
+ return _context48.abrupt("return");
4857
4599
  case 24:
4858
4600
  if (!(typeof this.order.overwriteExistingOrder === 'function')) {
4859
- _context50.next = 29;
4601
+ _context48.next = 29;
4860
4602
  break;
4861
4603
  }
4862
- _context50.next = 27;
4604
+ _context48.next = 27;
4863
4605
  return this.order.overwriteExistingOrder(_objectSpread(_objectSpread({}, localOrder), {}, {
4864
4606
  vouchers: nextVouchers
4865
4607
  }));
@@ -4869,13 +4611,13 @@ var Server = /*#__PURE__*/function () {
4869
4611
  updatedCount: voucherIdSet.size,
4870
4612
  status: status
4871
4613
  });
4872
- return _context50.abrupt("return");
4614
+ return _context48.abrupt("return");
4873
4615
  case 29:
4874
4616
  if (!(data !== null && data !== void 0 && data.external_sale_number && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
4875
- _context50.next = 34;
4617
+ _context48.next = 34;
4876
4618
  break;
4877
4619
  }
4878
- _context50.next = 32;
4620
+ _context48.next = 32;
4879
4621
  return this.order.markOrderSyncedByExternalSaleNumber({
4880
4622
  externalSaleNumber: data.external_sale_number,
4881
4623
  patch: {
@@ -4888,7 +4630,7 @@ var Server = /*#__PURE__*/function () {
4888
4630
  updatedCount: voucherIdSet.size,
4889
4631
  status: status
4890
4632
  });
4891
- return _context50.abrupt("return");
4633
+ return _context48.abrupt("return");
4892
4634
  case 34:
4893
4635
  this.logWarning("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8BA2\u5355\u8986\u76D6\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
4894
4636
  lookup: lookup,
@@ -4896,11 +4638,11 @@ var Server = /*#__PURE__*/function () {
4896
4638
  });
4897
4639
  case 35:
4898
4640
  case "end":
4899
- return _context50.stop();
4641
+ return _context48.stop();
4900
4642
  }
4901
- }, _callee50, this);
4643
+ }, _callee48, this);
4902
4644
  }));
4903
- function syncMachinecodeRedeemStatusToLocalOrder(_x55, _x56, _x57) {
4645
+ function syncMachinecodeRedeemStatusToLocalOrder(_x52, _x53, _x54) {
4904
4646
  return _syncMachinecodeRedeemStatusToLocalOrder.apply(this, arguments);
4905
4647
  }
4906
4648
  return syncMachinecodeRedeemStatusToLocalOrder;
@@ -4908,10 +4650,10 @@ var Server = /*#__PURE__*/function () {
4908
4650
  }, {
4909
4651
  key: "handleOrderCheckoutSubmit",
4910
4652
  value: function () {
4911
- var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
4912
- var backendPath, data, title, normalizedData, checkoutData, pendingResult, _this$core$context2, pendingOrder, platform, isAndroid;
4913
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4914
- while (1) switch (_context51.prev = _context51.next) {
4653
+ var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
4654
+ var backendPath, data, title, normalizedData, checkoutData, pendingResult, pendingOrder;
4655
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4656
+ while (1) switch (_context49.prev = _context49.next) {
4915
4657
  case 0:
4916
4658
  backendPath = params.backendPath, data = params.data, title = params.title;
4917
4659
  this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
@@ -4921,24 +4663,24 @@ var Server = /*#__PURE__*/function () {
4921
4663
  order_number: data === null || data === void 0 ? void 0 : data.order_number
4922
4664
  });
4923
4665
  if (!(data !== null && data !== void 0 && data.sync_mode || data !== null && data !== void 0 && data.syncMode)) {
4924
- _context51.next = 4;
4666
+ _context49.next = 4;
4925
4667
  break;
4926
4668
  }
4927
- return _context51.abrupt("return", this.handleSyncCheckoutSubmit({
4669
+ return _context49.abrupt("return", this.handleSyncCheckoutSubmit({
4928
4670
  backendPath: backendPath,
4929
4671
  data: data,
4930
4672
  title: title
4931
4673
  }));
4932
4674
  case 4:
4933
- _context51.next = 6;
4675
+ _context49.next = 6;
4934
4676
  return this.normalizeCheckoutSubmitData(data, title);
4935
4677
  case 6:
4936
- normalizedData = _context51.sent;
4937
- _context51.next = 9;
4678
+ normalizedData = _context49.sent;
4679
+ _context49.next = 9;
4938
4680
  return this.ensureCheckoutOrderNumbers(normalizedData, title);
4939
4681
  case 9:
4940
- checkoutData = _context51.sent;
4941
- _context51.next = 12;
4682
+ checkoutData = _context49.sent;
4683
+ _context49.next = 12;
4942
4684
  return this.handlePendingSyncCheckoutOrder({
4943
4685
  backendPath: backendPath,
4944
4686
  data: checkoutData,
@@ -4946,53 +4688,52 @@ var Server = /*#__PURE__*/function () {
4946
4688
  reason: 'checkout 已转入设备任务同步'
4947
4689
  });
4948
4690
  case 12:
4949
- pendingResult = _context51.sent;
4691
+ pendingResult = _context49.sent;
4950
4692
  if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
4951
- _context51.next = 22;
4693
+ _context49.next = 20;
4952
4694
  break;
4953
4695
  }
4954
4696
  pendingOrder = pendingResult.data;
4955
- platform = (_this$core$context2 = this.core.context) === null || _this$core$context2 === void 0 ? void 0 : _this$core$context2.getPlatform();
4956
- isAndroid = platform === 'android';
4957
- if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData) && this.isSalesOrderFullyPaid(pendingOrder) && (
4958
- // TODO 这里先加个兼容,如果是安卓,则需要 type=virtual 才走打印,如果是苹果则无限制
4959
- isAndroid ? checkoutData.type === 'virtual' : true))) {
4960
- _context51.next = 20;
4697
+ if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData) && this.isSalesOrderFullyPaid(pendingOrder) &&
4698
+ // TODO 这里先加个兼容,只有 type 为 virtual 才走打印
4699
+ // 后期需要迁移到 picoding ,根据工作流配置
4700
+ checkoutData.type === 'virtual')) {
4701
+ _context49.next = 18;
4961
4702
  break;
4962
4703
  }
4963
- _context51.next = 20;
4704
+ _context49.next = 18;
4964
4705
  return this.dispatchLocalReceiptPrint({
4965
4706
  checkoutData: checkoutData,
4966
4707
  order: pendingOrder,
4967
4708
  response: pendingResult,
4968
4709
  requireFullyPaid: true
4969
4710
  });
4970
- case 20:
4971
- _context51.next = 22;
4711
+ case 18:
4712
+ _context49.next = 20;
4972
4713
  return this.dispatchCheckoutSyncTask({
4973
4714
  backendPath: backendPath,
4974
4715
  data: checkoutData,
4975
4716
  title: title
4976
4717
  });
4977
- case 22:
4718
+ case 20:
4978
4719
  if (pendingResult.data.order_id) {
4979
- _context51.next = 24;
4720
+ _context49.next = 22;
4980
4721
  break;
4981
4722
  }
4982
- return _context51.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
4723
+ return _context49.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
4983
4724
  data: _objectSpread(_objectSpread({}, pendingResult.data), {}, {
4984
4725
  order_id: pendingResult.data.external_sale_number
4985
4726
  })
4986
4727
  }));
4987
- case 24:
4988
- return _context51.abrupt("return", pendingResult);
4989
- case 25:
4728
+ case 22:
4729
+ return _context49.abrupt("return", pendingResult);
4730
+ case 23:
4990
4731
  case "end":
4991
- return _context51.stop();
4732
+ return _context49.stop();
4992
4733
  }
4993
- }, _callee51, this);
4734
+ }, _callee49, this);
4994
4735
  }));
4995
- function handleOrderCheckoutSubmit(_x58) {
4736
+ function handleOrderCheckoutSubmit(_x55) {
4996
4737
  return _handleOrderCheckoutSubmit.apply(this, arguments);
4997
4738
  }
4998
4739
  return handleOrderCheckoutSubmit;
@@ -5000,27 +4741,27 @@ var Server = /*#__PURE__*/function () {
5000
4741
  }, {
5001
4742
  key: "handleSyncCheckoutSubmit",
5002
4743
  value: function () {
5003
- var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
4744
+ var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
5004
4745
  var _this$app16;
5005
4746
  var backendPath, data, title, syncResult, _normalized$data, normalized, backendError, _normalized$data2, _normalized, message;
5006
- return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5007
- while (1) switch (_context52.prev = _context52.next) {
4747
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4748
+ while (1) switch (_context50.prev = _context50.next) {
5008
4749
  case 0:
5009
4750
  backendPath = params.backendPath, data = params.data, title = params.title;
5010
4751
  if ((_this$app16 = this.app) !== null && _this$app16 !== void 0 && (_this$app16 = _this$app16.request) !== null && _this$app16 !== void 0 && _this$app16.post) {
5011
- _context52.next = 4;
4752
+ _context50.next = 4;
5012
4753
  break;
5013
4754
  }
5014
4755
  this.logError("".concat(title, ": sync checkout app.request \u4E0D\u53EF\u7528"));
5015
- return _context52.abrupt("return", {
4756
+ return _context50.abrupt("return", {
5016
4757
  code: 500,
5017
4758
  status: false,
5018
4759
  message: 'app.request 不可用',
5019
4760
  data: null
5020
4761
  });
5021
4762
  case 4:
5022
- _context52.prev = 4;
5023
- _context52.next = 7;
4763
+ _context50.prev = 4;
4764
+ _context50.next = 7;
5024
4765
  return this.runCheckoutSync({
5025
4766
  backendPath: backendPath,
5026
4767
  data: data,
@@ -5028,41 +4769,41 @@ var Server = /*#__PURE__*/function () {
5028
4769
  persistCheckoutDataWithResponse: true
5029
4770
  });
5030
4771
  case 7:
5031
- syncResult = _context52.sent;
4772
+ syncResult = _context50.sent;
5032
4773
  if (!syncResult.rejected) {
5033
- _context52.next = 11;
4774
+ _context50.next = 11;
5034
4775
  break;
5035
4776
  }
5036
4777
  normalized = this.normalizeCheckoutResponse(syncResult.errorResponse);
5037
- return _context52.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
4778
+ return _context50.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
5038
4779
  status: false,
5039
4780
  message: syncResult.message || (normalized === null || normalized === void 0 ? void 0 : normalized.message) || '后端明确拒绝 checkout',
5040
4781
  data: (_normalized$data = normalized === null || normalized === void 0 ? void 0 : normalized.data) !== null && _normalized$data !== void 0 ? _normalized$data : null
5041
4782
  }));
5042
4783
  case 11:
5043
- return _context52.abrupt("return", this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder));
4784
+ return _context50.abrupt("return", this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder));
5044
4785
  case 14:
5045
- _context52.prev = 14;
5046
- _context52.t0 = _context52["catch"](4);
5047
- backendError = this.extractBackendErrorResponse(_context52.t0);
4786
+ _context50.prev = 14;
4787
+ _context50.t0 = _context50["catch"](4);
4788
+ backendError = this.extractBackendErrorResponse(_context50.t0);
5048
4789
  if (!backendError) {
5049
- _context52.next = 20;
4790
+ _context50.next = 20;
5050
4791
  break;
5051
4792
  }
5052
4793
  _normalized = this.normalizeCheckoutResponse(backendError);
5053
- return _context52.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
4794
+ return _context50.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
5054
4795
  status: false,
5055
4796
  message: (backendError === null || backendError === void 0 ? void 0 : backendError.message) || (_normalized === null || _normalized === void 0 ? void 0 : _normalized.message) || '后端明确拒绝 checkout',
5056
4797
  data: (_normalized$data2 = _normalized === null || _normalized === void 0 ? void 0 : _normalized.data) !== null && _normalized$data2 !== void 0 ? _normalized$data2 : null
5057
4798
  }));
5058
4799
  case 20:
5059
- message = this.getUnknownErrorMessage(_context52.t0);
4800
+ message = this.getUnknownErrorMessage(_context50.t0);
5060
4801
  this.logError("".concat(title, ": sync checkout \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
5061
4802
  backendPath: backendPath,
5062
4803
  error: message,
5063
- error_detail: this.normalizeUnknownError(_context52.t0)
4804
+ error_detail: this.normalizeUnknownError(_context50.t0)
5064
4805
  });
5065
- return _context52.abrupt("return", {
4806
+ return _context50.abrupt("return", {
5066
4807
  code: 500,
5067
4808
  status: false,
5068
4809
  message: message,
@@ -5070,11 +4811,11 @@ var Server = /*#__PURE__*/function () {
5070
4811
  });
5071
4812
  case 23:
5072
4813
  case "end":
5073
- return _context52.stop();
4814
+ return _context50.stop();
5074
4815
  }
5075
- }, _callee52, this, [[4, 14]]);
4816
+ }, _callee50, this, [[4, 14]]);
5076
4817
  }));
5077
- function handleSyncCheckoutSubmit(_x59) {
4818
+ function handleSyncCheckoutSubmit(_x56) {
5078
4819
  return _handleSyncCheckoutSubmit.apply(this, arguments);
5079
4820
  }
5080
4821
  return handleSyncCheckoutSubmit;
@@ -5082,26 +4823,26 @@ var Server = /*#__PURE__*/function () {
5082
4823
  }, {
5083
4824
  key: "handlePendingSyncCheckoutOrder",
5084
4825
  value: function () {
5085
- var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
5086
- var _this11 = this;
4826
+ var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
4827
+ var _this10 = this;
5087
4828
  var backendPath, data, title, reason, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
5088
- return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5089
- while (1) switch (_context53.prev = _context53.next) {
4829
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4830
+ while (1) switch (_context51.prev = _context51.next) {
5090
4831
  case 0:
5091
4832
  backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason;
5092
- _context53.next = 3;
4833
+ _context51.next = 3;
5093
4834
  return this.buildPendingSyncCheckoutOrder(data);
5094
4835
  case 3:
5095
- pendingOrder = _context53.sent;
4836
+ pendingOrder = _context51.sent;
5096
4837
  if (pendingOrder) {
5097
- _context53.next = 7;
4838
+ _context51.next = 7;
5098
4839
  break;
5099
4840
  }
5100
4841
  this.logError("".concat(title, ": checkout \u5931\u8D25\u4E14\u8BA2\u5355\u7F3A\u5C11\u672C\u5730\u5B58\u50A8\u6807\u8BC6"), {
5101
4842
  backendPath: backendPath,
5102
4843
  reason: reason
5103
4844
  });
5104
- return _context53.abrupt("return", {
4845
+ return _context51.abrupt("return", {
5105
4846
  code: 500,
5106
4847
  status: false,
5107
4848
  message: '订单缺少本地存储标识,无法写入待同步队列',
@@ -5109,22 +4850,22 @@ var Server = /*#__PURE__*/function () {
5109
4850
  });
5110
4851
  case 7:
5111
4852
  if (!(!this.order || typeof this.order.upsertPendingSyncOrders !== 'function')) {
5112
- _context53.next = 10;
4853
+ _context51.next = 10;
5113
4854
  break;
5114
4855
  }
5115
4856
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u5F85\u540C\u6B65\u5199\u5165"), {
5116
4857
  backendPath: backendPath,
5117
4858
  reason: reason
5118
4859
  });
5119
- return _context53.abrupt("return", {
4860
+ return _context51.abrupt("return", {
5120
4861
  code: 500,
5121
4862
  status: false,
5122
4863
  message: 'Order 模块不支持本地待同步写入',
5123
4864
  data: null
5124
4865
  });
5125
4866
  case 10:
5126
- _context53.prev = 10;
5127
- _context53.next = 13;
4867
+ _context51.prev = 10;
4868
+ _context51.next = 13;
5128
4869
  return this.order.upsertPendingSyncOrders([pendingOrder]);
5129
4870
  case 13:
5130
4871
  this.logInfo("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
@@ -5136,9 +4877,9 @@ var Server = /*#__PURE__*/function () {
5136
4877
  });
5137
4878
  changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
5138
4879
  var _payment$metadata;
5139
- return sum + _this11.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
4880
+ return sum + _this10.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
5140
4881
  }, 0);
5141
- return _context53.abrupt("return", {
4882
+ return _context51.abrupt("return", {
5142
4883
  code: 200,
5143
4884
  status: true,
5144
4885
  message: '',
@@ -5153,15 +4894,15 @@ var Server = /*#__PURE__*/function () {
5153
4894
  })
5154
4895
  });
5155
4896
  case 18:
5156
- _context53.prev = 18;
5157
- _context53.t0 = _context53["catch"](10);
5158
- errorMessage = _context53.t0 instanceof Error ? _context53.t0.message : String(_context53.t0);
4897
+ _context51.prev = 18;
4898
+ _context51.t0 = _context51["catch"](10);
4899
+ errorMessage = _context51.t0 instanceof Error ? _context51.t0.message : String(_context51.t0);
5159
4900
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u5F85\u540C\u6B65\u8BA2\u5355\u5931\u8D25"), {
5160
4901
  backendPath: backendPath,
5161
4902
  reason: reason,
5162
4903
  error: errorMessage
5163
4904
  });
5164
- return _context53.abrupt("return", {
4905
+ return _context51.abrupt("return", {
5165
4906
  code: 500,
5166
4907
  status: false,
5167
4908
  message: errorMessage,
@@ -5169,11 +4910,11 @@ var Server = /*#__PURE__*/function () {
5169
4910
  });
5170
4911
  case 23:
5171
4912
  case "end":
5172
- return _context53.stop();
4913
+ return _context51.stop();
5173
4914
  }
5174
- }, _callee53, this, [[10, 18]]);
4915
+ }, _callee51, this, [[10, 18]]);
5175
4916
  }));
5176
- function handlePendingSyncCheckoutOrder(_x60) {
4917
+ function handlePendingSyncCheckoutOrder(_x57) {
5177
4918
  return _handlePendingSyncCheckoutOrder.apply(this, arguments);
5178
4919
  }
5179
4920
  return handlePendingSyncCheckoutOrder;
@@ -5181,43 +4922,43 @@ var Server = /*#__PURE__*/function () {
5181
4922
  }, {
5182
4923
  key: "buildPendingSyncCheckoutOrder",
5183
4924
  value: function () {
5184
- var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(data) {
4925
+ var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(data) {
5185
4926
  var hasStorageKey, pendingOrder, productMap, orderWithProductTitles;
5186
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5187
- while (1) switch (_context54.prev = _context54.next) {
4927
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4928
+ while (1) switch (_context52.prev = _context52.next) {
5188
4929
  case 0:
5189
4930
  if (!(!data || _typeof(data) !== 'object')) {
5190
- _context54.next = 2;
4931
+ _context52.next = 2;
5191
4932
  break;
5192
4933
  }
5193
- return _context54.abrupt("return", null);
4934
+ return _context52.abrupt("return", null);
5194
4935
  case 2:
5195
4936
  hasStorageKey = data.external_sale_number !== undefined && data.external_sale_number !== null && data.external_sale_number !== '' ? true : data.order_id !== undefined && data.order_id !== null && data.order_id !== '';
5196
4937
  if (hasStorageKey) {
5197
- _context54.next = 5;
4938
+ _context52.next = 5;
5198
4939
  break;
5199
4940
  }
5200
- return _context54.abrupt("return", null);
4941
+ return _context52.abrupt("return", null);
5201
4942
  case 5:
5202
4943
  pendingOrder = _objectSpread(_objectSpread({}, data), {}, {
5203
4944
  need_sync: 1
5204
4945
  });
5205
- _context54.next = 8;
4946
+ _context52.next = 8;
5206
4947
  return this.buildSmallTicketProductMap(pendingOrder);
5207
4948
  case 8:
5208
- productMap = _context54.sent;
4949
+ productMap = _context52.sent;
5209
4950
  orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
5210
- return _context54.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
4951
+ return _context52.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
5211
4952
  requireFullyPaid: true,
5212
4953
  productMap: productMap
5213
4954
  }));
5214
4955
  case 11:
5215
4956
  case "end":
5216
- return _context54.stop();
4957
+ return _context52.stop();
5217
4958
  }
5218
- }, _callee54, this);
4959
+ }, _callee52, this);
5219
4960
  }));
5220
- function buildPendingSyncCheckoutOrder(_x61) {
4961
+ function buildPendingSyncCheckoutOrder(_x58) {
5221
4962
  return _buildPendingSyncCheckoutOrder.apply(this, arguments);
5222
4963
  }
5223
4964
  return buildPendingSyncCheckoutOrder;
@@ -5265,13 +5006,13 @@ var Server = /*#__PURE__*/function () {
5265
5006
  }, {
5266
5007
  key: "sumPaidOrderPayments",
5267
5008
  value: function sumPaidOrderPayments(payments) {
5268
- var _this12 = this;
5009
+ var _this11 = this;
5269
5010
  if (!Array.isArray(payments)) return 0;
5270
5011
  return payments.reduce(function (sum, payment) {
5271
5012
  var _payment$amount;
5272
5013
  var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
5273
5014
  if (status === 'voided' || status === 'failed' || status === 'cancelled') return sum;
5274
- return sum + _this12.toAmountNumber((_payment$amount = payment === null || payment === void 0 ? void 0 : payment.amount) !== null && _payment$amount !== void 0 ? _payment$amount : payment === null || payment === void 0 ? void 0 : payment.origin_amount);
5015
+ return sum + _this11.toAmountNumber((_payment$amount = payment === null || payment === void 0 ? void 0 : payment.amount) !== null && _payment$amount !== void 0 ? _payment$amount : payment === null || payment === void 0 ? void 0 : payment.origin_amount);
5275
5016
  }, 0);
5276
5017
  }
5277
5018
  }, {
@@ -5285,12 +5026,12 @@ var Server = /*#__PURE__*/function () {
5285
5026
  }, {
5286
5027
  key: "buildSmallTicketProductMap",
5287
5028
  value: function () {
5288
- var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(order) {
5289
- var _this$products3,
5290
- _this13 = this;
5029
+ var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(order) {
5030
+ var _this$products,
5031
+ _this12 = this;
5291
5032
  var products, productIdSet, productIds, entries;
5292
- return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5293
- while (1) switch (_context56.prev = _context56.next) {
5033
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5034
+ while (1) switch (_context54.prev = _context54.next) {
5294
5035
  case 0:
5295
5036
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
5296
5037
  productIdSet = new Set();
@@ -5311,46 +5052,46 @@ var Server = /*#__PURE__*/function () {
5311
5052
  }
5312
5053
  });
5313
5054
  productIds = Array.from(productIdSet);
5314
- if (!(!productIds.length || typeof ((_this$products3 = this.products) === null || _this$products3 === void 0 ? void 0 : _this$products3.getProductById) !== 'function')) {
5315
- _context56.next = 6;
5055
+ if (!(!productIds.length || typeof ((_this$products = this.products) === null || _this$products === void 0 ? void 0 : _this$products.getProductById) !== 'function')) {
5056
+ _context54.next = 6;
5316
5057
  break;
5317
5058
  }
5318
- return _context56.abrupt("return", {});
5059
+ return _context54.abrupt("return", {});
5319
5060
  case 6:
5320
- _context56.next = 8;
5061
+ _context54.next = 8;
5321
5062
  return Promise.all(productIds.map( /*#__PURE__*/function () {
5322
- var _ref60 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(id) {
5323
- var _this13$products, _this13$products$getP, product;
5324
- return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5325
- while (1) switch (_context55.prev = _context55.next) {
5063
+ var _ref60 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(id) {
5064
+ var _this12$products, _this12$products$getP, product;
5065
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5066
+ while (1) switch (_context53.prev = _context53.next) {
5326
5067
  case 0:
5327
- _context55.prev = 0;
5328
- _context55.next = 3;
5329
- return (_this13$products = _this13.products) === null || _this13$products === void 0 || (_this13$products$getP = _this13$products.getProductById) === null || _this13$products$getP === void 0 ? void 0 : _this13$products$getP.call(_this13$products, Number(id));
5068
+ _context53.prev = 0;
5069
+ _context53.next = 3;
5070
+ return (_this12$products = _this12.products) === null || _this12$products === void 0 || (_this12$products$getP = _this12$products.getProductById) === null || _this12$products$getP === void 0 ? void 0 : _this12$products$getP.call(_this12$products, Number(id));
5330
5071
  case 3:
5331
- product = _context55.sent;
5332
- return _context55.abrupt("return", product ? [String(id), product] : null);
5072
+ product = _context53.sent;
5073
+ return _context53.abrupt("return", product ? [String(id), product] : null);
5333
5074
  case 7:
5334
- _context55.prev = 7;
5335
- _context55.t0 = _context55["catch"](0);
5336
- _this13.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
5075
+ _context53.prev = 7;
5076
+ _context53.t0 = _context53["catch"](0);
5077
+ _this12.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
5337
5078
  product_id: id,
5338
- error: _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0)
5079
+ error: _context53.t0 instanceof Error ? _context53.t0.message : String(_context53.t0)
5339
5080
  });
5340
- return _context55.abrupt("return", null);
5081
+ return _context53.abrupt("return", null);
5341
5082
  case 11:
5342
5083
  case "end":
5343
- return _context55.stop();
5084
+ return _context53.stop();
5344
5085
  }
5345
- }, _callee55, null, [[0, 7]]);
5086
+ }, _callee53, null, [[0, 7]]);
5346
5087
  }));
5347
- return function (_x63) {
5088
+ return function (_x60) {
5348
5089
  return _ref60.apply(this, arguments);
5349
5090
  };
5350
5091
  }()));
5351
5092
  case 8:
5352
- entries = _context56.sent;
5353
- return _context56.abrupt("return", entries.reduce(function (map, entry) {
5093
+ entries = _context54.sent;
5094
+ return _context54.abrupt("return", entries.reduce(function (map, entry) {
5354
5095
  if (!entry) return map;
5355
5096
  var _entry = _slicedToArray(entry, 2),
5356
5097
  id = _entry[0],
@@ -5360,190 +5101,25 @@ var Server = /*#__PURE__*/function () {
5360
5101
  }, {}));
5361
5102
  case 10:
5362
5103
  case "end":
5363
- return _context56.stop();
5104
+ return _context54.stop();
5364
5105
  }
5365
- }, _callee56, this);
5106
+ }, _callee54, this);
5366
5107
  }));
5367
- function buildSmallTicketProductMap(_x62) {
5108
+ function buildSmallTicketProductMap(_x59) {
5368
5109
  return _buildSmallTicketProductMap.apply(this, arguments);
5369
5110
  }
5370
5111
  return buildSmallTicketProductMap;
5371
5112
  }()
5372
- }, {
5373
- key: "collectSalesDetailProductIds",
5374
- value: function collectSalesDetailProductIds(order) {
5375
- var products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
5376
- var productIds = new Set();
5377
- var addProductId = function addProductId(rawProductId) {
5378
- if (rawProductId === undefined || rawProductId === null || rawProductId === '') return;
5379
- var productId = Number(rawProductId);
5380
- if (Number.isFinite(productId)) productIds.add(productId);
5381
- };
5382
- products.forEach(function (product) {
5383
- var _product$product_id2;
5384
- addProductId((_product$product_id2 = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : product === null || product === void 0 ? void 0 : product.id);
5385
- if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
5386
- product.product_bundle.forEach(function (bundle) {
5387
- var _ref61, _bundle$bundle_produc2;
5388
- addProductId((_ref61 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref61 !== void 0 ? _ref61 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
5389
- });
5390
- }
5391
- });
5392
- return Array.from(productIds);
5393
- }
5394
- }, {
5395
- key: "buildSalesDetailProductSnapshotMap",
5396
- value: function () {
5397
- var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(order) {
5398
- var _this$products4;
5399
- var productIds, getSnapshots;
5400
- return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5401
- while (1) switch (_context57.prev = _context57.next) {
5402
- case 0:
5403
- productIds = this.collectSalesDetailProductIds(order);
5404
- getSnapshots = (_this$products4 = this.products) === null || _this$products4 === void 0 ? void 0 : _this$products4.getProductSnapshotsByIds;
5405
- if (!(!productIds.length || typeof getSnapshots !== 'function')) {
5406
- _context57.next = 4;
5407
- break;
5408
- }
5409
- return _context57.abrupt("return", {});
5410
- case 4:
5411
- _context57.prev = 4;
5412
- _context57.next = 7;
5413
- return getSnapshots.call(this.products, productIds);
5414
- case 7:
5415
- return _context57.abrupt("return", _context57.sent);
5416
- case 10:
5417
- _context57.prev = 10;
5418
- _context57.t0 = _context57["catch"](4);
5419
- this.logWarning('buildSalesDetailProductSnapshotMap: 查询本地商品快照失败', {
5420
- product_ids: productIds,
5421
- error: _context57.t0 instanceof Error ? _context57.t0.message : String(_context57.t0)
5422
- });
5423
- return _context57.abrupt("return", {});
5424
- case 14:
5425
- case "end":
5426
- return _context57.stop();
5427
- }
5428
- }, _callee57, this, [[4, 10]]);
5429
- }));
5430
- function buildSalesDetailProductSnapshotMap(_x64) {
5431
- return _buildSalesDetailProductSnapshotMap.apply(this, arguments);
5432
- }
5433
- return buildSalesDetailProductSnapshotMap;
5434
- }()
5435
- }, {
5436
- key: "withProductCatalogSnapshots",
5437
- value: function withProductCatalogSnapshots(product, snapshotMap) {
5438
- var _product$product_id3;
5439
- if (!product || _typeof(product) !== 'object') return product;
5440
- var rawProductId = (_product$product_id3 = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id3 !== void 0 ? _product$product_id3 : product === null || product === void 0 ? void 0 : product.id;
5441
- if (rawProductId === undefined || rawProductId === null || rawProductId === '') return product;
5442
- var productId = Number(rawProductId);
5443
- if (!Number.isFinite(productId)) return product;
5444
- var snapshot = snapshotMap[String(productId)];
5445
- if (!snapshot) return product;
5446
- var shouldFillCover = (product.product_cover === undefined || product.product_cover === null || product.product_cover === '') && snapshot.cover !== undefined && snapshot.cover !== null && snapshot.cover !== '';
5447
- var metadata = product.metadata && _typeof(product.metadata) === 'object' ? product.metadata : {};
5448
- var shouldFillHolderConfig = (metadata.holder_config === undefined || metadata.holder_config === null) && snapshot.holder_config !== undefined && snapshot.holder_config !== null;
5449
- if (!shouldFillCover && !shouldFillHolderConfig) return product;
5450
- return _objectSpread(_objectSpread(_objectSpread({}, product), shouldFillCover ? {
5451
- product_cover: snapshot.cover
5452
- } : {}), shouldFillHolderConfig ? {
5453
- metadata: _objectSpread(_objectSpread({}, metadata), {}, {
5454
- holder_config: snapshot.holder_config
5455
- })
5456
- } : {});
5457
- }
5458
- }, {
5459
- key: "withBundleCatalogSnapshots",
5460
- value: function withBundleCatalogSnapshots(product, snapshotMap) {
5461
- if (!Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) return product;
5462
- var hasChanged = false;
5463
- var productBundle = product.product_bundle.map(function (bundle) {
5464
- var _ref62, _bundle$bundle_produc3;
5465
- if (!bundle || _typeof(bundle) !== 'object') return bundle;
5466
- var rawProductId = (_ref62 = (_bundle$bundle_produc3 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref62 !== void 0 ? _ref62 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
5467
- if (rawProductId === undefined || rawProductId === null || rawProductId === '') return bundle;
5468
- var productId = Number(rawProductId);
5469
- if (!Number.isFinite(productId)) return bundle;
5470
- var snapshot = snapshotMap[String(productId)];
5471
- var shouldFillCover = (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && (snapshot === null || snapshot === void 0 ? void 0 : snapshot.cover) !== undefined && snapshot.cover !== null && snapshot.cover !== '';
5472
- if (!shouldFillCover) return bundle;
5473
- hasChanged = true;
5474
- return _objectSpread(_objectSpread({}, bundle), {}, {
5475
- cover: snapshot.cover
5476
- });
5477
- });
5478
- if (!hasChanged) return product;
5479
- return _objectSpread(_objectSpread({}, product), {}, {
5480
- product_bundle: productBundle
5481
- });
5482
- }
5483
- }, {
5484
- key: "withSalesDetailProductSnapshots",
5485
- value: function () {
5486
- var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(order) {
5487
- var _this14 = this;
5488
- var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
5489
- return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5490
- while (1) switch (_context58.prev = _context58.next) {
5491
- case 0:
5492
- products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : null;
5493
- if (products !== null && products !== void 0 && products.length) {
5494
- _context58.next = 3;
5495
- break;
5496
- }
5497
- return _context58.abrupt("return", order);
5498
- case 3:
5499
- _context58.next = 5;
5500
- return this.buildSalesDetailProductSnapshotMap(order);
5501
- case 5:
5502
- snapshotMap = _context58.sent;
5503
- if (Object.keys(snapshotMap).length) {
5504
- _context58.next = 8;
5505
- break;
5506
- }
5507
- return _context58.abrupt("return", order);
5508
- case 8:
5509
- hasChanged = false;
5510
- enrichedProducts = products.map(function (product) {
5511
- var productWithBundleSnapshots = _this14.withBundleCatalogSnapshots(product, snapshotMap);
5512
- var nextProduct = _this14.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
5513
- if (nextProduct !== product) hasChanged = true;
5514
- return nextProduct;
5515
- });
5516
- if (hasChanged) {
5517
- _context58.next = 12;
5518
- break;
5519
- }
5520
- return _context58.abrupt("return", order);
5521
- case 12:
5522
- enrichedOrder = _objectSpread(_objectSpread({}, order), {}, {
5523
- products: enrichedProducts
5524
- });
5525
- return _context58.abrupt("return", enrichedOrder);
5526
- case 14:
5527
- case "end":
5528
- return _context58.stop();
5529
- }
5530
- }, _callee58, this);
5531
- }));
5532
- function withSalesDetailProductSnapshots(_x65) {
5533
- return _withSalesDetailProductSnapshots.apply(this, arguments);
5534
- }
5535
- return withSalesDetailProductSnapshots;
5536
- }()
5537
5113
  }, {
5538
5114
  key: "withPendingSyncProductTitles",
5539
5115
  value: function withPendingSyncProductTitles(order, productMap) {
5540
- var _this15 = this;
5116
+ var _this13 = this;
5541
5117
  var products = Array.isArray(order.products) ? order.products : null;
5542
5118
  if (!(products !== null && products !== void 0 && products.length)) return order;
5543
5119
  return _objectSpread(_objectSpread({}, order), {}, {
5544
5120
  products: products.map(function (product) {
5545
5121
  return _objectSpread(_objectSpread({}, product), {}, {
5546
- product_title: _this15.buildProductTitleSnapshot(product, productMap)
5122
+ product_title: _this13.buildProductTitleSnapshot(product, productMap)
5547
5123
  });
5548
5124
  })
5549
5125
  });
@@ -5551,27 +5127,27 @@ var Server = /*#__PURE__*/function () {
5551
5127
  }, {
5552
5128
  key: "buildProductTitleSnapshot",
5553
5129
  value: function buildProductTitleSnapshot(product, productMap) {
5554
- var _product$product_id4,
5130
+ var _product$product_id2,
5555
5131
  _product$product,
5556
5132
  _fallbackProduct$prod,
5557
- _this16 = this;
5558
- var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
5133
+ _this14 = this;
5134
+ var productId = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : product.id;
5559
5135
  var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
5560
5136
  var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
5561
5137
  var fallbackTitle = (fallbackProduct === null || fallbackProduct === void 0 ? void 0 : fallbackProduct.product_title) || (fallbackProduct === null || fallbackProduct === void 0 ? void 0 : fallbackProduct.title) || (fallbackProduct === null || fallbackProduct === void 0 ? void 0 : fallbackProduct.name) || (fallbackProduct === null || fallbackProduct === void 0 ? void 0 : fallbackProduct.format_title) || (fallbackProduct === null || fallbackProduct === void 0 || (_fallbackProduct$prod = fallbackProduct.product) === null || _fallbackProduct$prod === void 0 ? void 0 : _fallbackProduct$prod.title);
5562
5138
  var currentLocale = this.getProductTitleSnapshotCurrentLocale();
5563
5139
  var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
5564
5140
  return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
5565
- snapshot[key] = _this16.resolveProductTitleValue(ownTitle, key, currentLocale) || _this16.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
5141
+ snapshot[key] = _this14.resolveProductTitleValue(ownTitle, key, currentLocale) || _this14.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
5566
5142
  return snapshot;
5567
5143
  }, {});
5568
5144
  }
5569
5145
  }, {
5570
5146
  key: "getProductTitleSnapshotCurrentLocale",
5571
5147
  value: function getProductTitleSnapshotCurrentLocale() {
5572
- var _this$core$context3, _this$core$context4;
5148
+ var _this$core$context2, _this$core$context3;
5573
5149
  var shopInfo = this.getSmallTicketShopInfo();
5574
- var rawLocale = shopInfo.primary_locale || this.getAppData('locale') || this.getAppData('language') || ((_this$core$context3 = this.core.context) === null || _this$core$context3 === void 0 ? void 0 : _this$core$context3.locale) || ((_this$core$context4 = this.core.context) === null || _this$core$context4 === void 0 ? void 0 : _this$core$context4.language);
5150
+ var rawLocale = shopInfo.primary_locale || this.getAppData('locale') || this.getAppData('language') || ((_this$core$context2 = this.core.context) === null || _this$core$context2 === void 0 ? void 0 : _this$core$context2.locale) || ((_this$core$context3 = this.core.context) === null || _this$core$context3 === void 0 ? void 0 : _this$core$context3.language);
5575
5151
  return this.normalizeProductTitleSnapshotLocale(rawLocale);
5576
5152
  }
5577
5153
  }, {
@@ -5587,7 +5163,7 @@ var Server = /*#__PURE__*/function () {
5587
5163
  }, {
5588
5164
  key: "resolveProductTitleValue",
5589
5165
  value: function resolveProductTitleValue(value, key, currentLocale) {
5590
- var _ref63, _ref64, _value$key;
5166
+ var _ref61, _ref62, _value$key;
5591
5167
  if (value === undefined || value === null || value === '') return null;
5592
5168
  if (_typeof(value) !== 'object') {
5593
5169
  var title = String(value);
@@ -5597,7 +5173,7 @@ var Server = /*#__PURE__*/function () {
5597
5173
  }
5598
5174
  var normalizedKey = key.replace('-', '_');
5599
5175
  var dashedKey = key.replace('_', '-');
5600
- var rawValue = (_ref63 = (_ref64 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref64 !== void 0 ? _ref64 : value[dashedKey]) !== null && _ref63 !== void 0 ? _ref63 : key === 'auto' ? value.default : undefined;
5176
+ var rawValue = (_ref61 = (_ref62 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref62 !== void 0 ? _ref62 : value[dashedKey]) !== null && _ref61 !== void 0 ? _ref61 : key === 'auto' ? value.default : undefined;
5601
5177
  if (rawValue === undefined || rawValue === null || rawValue === '') return null;
5602
5178
  if (_typeof(rawValue) === 'object') return this.resolveFirstProductTitleValue(rawValue);
5603
5179
  return String(rawValue);
@@ -5660,50 +5236,50 @@ var Server = /*#__PURE__*/function () {
5660
5236
  }, {
5661
5237
  key: "enrichPaymentNamesByCode",
5662
5238
  value: function () {
5663
- var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(order) {
5664
- var _this17 = this;
5665
- var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator13, _step13, method, codeKey, name, hasResolvedName, enrichedPayments;
5666
- return _regeneratorRuntime().wrap(function _callee59$(_context59) {
5667
- while (1) switch (_context59.prev = _context59.next) {
5239
+ var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(order) {
5240
+ var _this15 = this;
5241
+ var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
5242
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5243
+ while (1) switch (_context55.prev = _context55.next) {
5668
5244
  case 0:
5669
5245
  payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
5670
5246
  hasMissingName = payments.some(function (payment) {
5671
- return _this17.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this17.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
5247
+ return _this15.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this15.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
5672
5248
  });
5673
5249
  if (hasMissingName) {
5674
- _context59.next = 4;
5250
+ _context55.next = 4;
5675
5251
  break;
5676
5252
  }
5677
- return _context59.abrupt("return", order);
5253
+ return _context55.abrupt("return", order);
5678
5254
  case 4:
5679
- _context59.prev = 4;
5680
- _context59.next = 7;
5255
+ _context55.prev = 4;
5256
+ _context55.next = 7;
5681
5257
  return this.getPaymentRouteModule();
5682
5258
  case 7:
5683
- paymentModule = _context59.sent;
5684
- _context59.next = 10;
5259
+ paymentModule = _context55.sent;
5260
+ _context55.next = 10;
5685
5261
  return paymentModule.getPayMethodListAsync();
5686
5262
  case 10:
5687
- payMethods = _context59.sent;
5263
+ payMethods = _context55.sent;
5688
5264
  nameByCode = new Map();
5689
- _iterator13 = _createForOfIteratorHelper(payMethods || []);
5265
+ _iterator12 = _createForOfIteratorHelper(payMethods || []);
5690
5266
  try {
5691
- for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
5692
- method = _step13.value;
5267
+ for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
5268
+ method = _step12.value;
5693
5269
  codeKey = this.getPaymentCodeKey(method === null || method === void 0 ? void 0 : method.code);
5694
5270
  name = this.resolveFirstProductTitleValue(method === null || method === void 0 ? void 0 : method.name);
5695
5271
  if (codeKey && name) nameByCode.set(codeKey, name);
5696
5272
  }
5697
5273
  } catch (err) {
5698
- _iterator13.e(err);
5274
+ _iterator12.e(err);
5699
5275
  } finally {
5700
- _iterator13.f();
5276
+ _iterator12.f();
5701
5277
  }
5702
5278
  hasResolvedName = false;
5703
5279
  enrichedPayments = payments.map(function (payment) {
5704
- if (!_this17.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
5705
- if (!_this17.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
5706
- var name = nameByCode.get(_this17.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
5280
+ if (!_this15.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
5281
+ if (!_this15.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
5282
+ var name = nameByCode.get(_this15.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
5707
5283
  if (!name) return payment;
5708
5284
  hasResolvedName = true;
5709
5285
  return _objectSpread(_objectSpread({}, payment), {}, {
@@ -5711,28 +5287,28 @@ var Server = /*#__PURE__*/function () {
5711
5287
  });
5712
5288
  });
5713
5289
  if (hasResolvedName) {
5714
- _context59.next = 18;
5290
+ _context55.next = 18;
5715
5291
  break;
5716
5292
  }
5717
- return _context59.abrupt("return", order);
5293
+ return _context55.abrupt("return", order);
5718
5294
  case 18:
5719
- return _context59.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
5295
+ return _context55.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
5720
5296
  payments: enrichedPayments
5721
5297
  }));
5722
5298
  case 21:
5723
- _context59.prev = 21;
5724
- _context59.t0 = _context59["catch"](4);
5299
+ _context55.prev = 21;
5300
+ _context55.t0 = _context55["catch"](4);
5725
5301
  this.logWarning('enrichPaymentNamesByCode: 支付方式名称回填失败', {
5726
- error: _context59.t0 instanceof Error ? _context59.t0.message : String(_context59.t0)
5302
+ error: _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0)
5727
5303
  });
5728
- return _context59.abrupt("return", order);
5304
+ return _context55.abrupt("return", order);
5729
5305
  case 25:
5730
5306
  case "end":
5731
- return _context59.stop();
5307
+ return _context55.stop();
5732
5308
  }
5733
- }, _callee59, this, [[4, 21]]);
5309
+ }, _callee55, this, [[4, 21]]);
5734
5310
  }));
5735
- function enrichPaymentNamesByCode(_x66) {
5311
+ function enrichPaymentNamesByCode(_x61) {
5736
5312
  return _enrichPaymentNamesByCode.apply(this, arguments);
5737
5313
  }
5738
5314
  return enrichPaymentNamesByCode;
@@ -5740,66 +5316,66 @@ var Server = /*#__PURE__*/function () {
5740
5316
  }, {
5741
5317
  key: "withLocalSmallTicketData",
5742
5318
  value: function () {
5743
- var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(order, options) {
5319
+ var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(order, options) {
5744
5320
  var _options$productMap, enrichedOrder, productMap, smallTicketData;
5745
- return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5746
- while (1) switch (_context60.prev = _context60.next) {
5321
+ return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5322
+ while (1) switch (_context56.prev = _context56.next) {
5747
5323
  case 0:
5748
5324
  if (this.shouldBuildSmallTicketData(order)) {
5749
- _context60.next = 2;
5325
+ _context56.next = 2;
5750
5326
  break;
5751
5327
  }
5752
- return _context60.abrupt("return", order);
5328
+ return _context56.abrupt("return", order);
5753
5329
  case 2:
5754
5330
  if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
5755
- _context60.next = 4;
5331
+ _context56.next = 4;
5756
5332
  break;
5757
5333
  }
5758
- return _context60.abrupt("return", order);
5334
+ return _context56.abrupt("return", order);
5759
5335
  case 4:
5760
- _context60.prev = 4;
5761
- _context60.next = 7;
5336
+ _context56.prev = 4;
5337
+ _context56.next = 7;
5762
5338
  return this.enrichPaymentNamesByCode(order);
5763
5339
  case 7:
5764
- enrichedOrder = _context60.sent;
5340
+ enrichedOrder = _context56.sent;
5765
5341
  if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
5766
- _context60.next = 12;
5342
+ _context56.next = 12;
5767
5343
  break;
5768
5344
  }
5769
- _context60.t0 = _options$productMap;
5770
- _context60.next = 15;
5345
+ _context56.t0 = _options$productMap;
5346
+ _context56.next = 15;
5771
5347
  break;
5772
5348
  case 12:
5773
- _context60.next = 14;
5349
+ _context56.next = 14;
5774
5350
  return this.buildSmallTicketProductMap(enrichedOrder);
5775
5351
  case 14:
5776
- _context60.t0 = _context60.sent;
5352
+ _context56.t0 = _context56.sent;
5777
5353
  case 15:
5778
- productMap = _context60.t0;
5354
+ productMap = _context56.t0;
5779
5355
  smallTicketData = buildSmallTicketData({
5780
5356
  order: enrichedOrder,
5781
5357
  shopInfo: this.getSmallTicketShopInfo(),
5782
5358
  productMap: productMap
5783
5359
  });
5784
- return _context60.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
5360
+ return _context56.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
5785
5361
  payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
5786
5362
  small_ticket_data: smallTicketData
5787
5363
  })
5788
5364
  }));
5789
5365
  case 20:
5790
- _context60.prev = 20;
5791
- _context60.t1 = _context60["catch"](4);
5366
+ _context56.prev = 20;
5367
+ _context56.t1 = _context56["catch"](4);
5792
5368
  this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
5793
- error: _context60.t1 instanceof Error ? _context60.t1.message : String(_context60.t1)
5369
+ error: _context56.t1 instanceof Error ? _context56.t1.message : String(_context56.t1)
5794
5370
  });
5795
- return _context60.abrupt("return", order);
5371
+ return _context56.abrupt("return", order);
5796
5372
  case 24:
5797
5373
  case "end":
5798
- return _context60.stop();
5374
+ return _context56.stop();
5799
5375
  }
5800
- }, _callee60, this, [[4, 20]]);
5376
+ }, _callee56, this, [[4, 20]]);
5801
5377
  }));
5802
- function withLocalSmallTicketData(_x67, _x68) {
5378
+ function withLocalSmallTicketData(_x62, _x63) {
5803
5379
  return _withLocalSmallTicketData.apply(this, arguments);
5804
5380
  }
5805
5381
  return withLocalSmallTicketData;
@@ -5861,22 +5437,22 @@ var Server = /*#__PURE__*/function () {
5861
5437
  }, {
5862
5438
  key: "handleUpdateLocalOrdersBatch",
5863
5439
  value: (function () {
5864
- var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(orderIds) {
5440
+ var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(orderIds) {
5865
5441
  var _this$app17;
5866
- var existedBefore, _iterator14, _step14, id, fetched, message, fetchedMap, _iterator15, _step15, order, oid, freshOrders, succeedIds, failed, _iterator16, _step16, _id, fresh, _message2, overwritten, inserted;
5867
- return _regeneratorRuntime().wrap(function _callee61$(_context61) {
5868
- while (1) switch (_context61.prev = _context61.next) {
5442
+ var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message2, overwritten, inserted;
5443
+ return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5444
+ while (1) switch (_context57.prev = _context57.next) {
5869
5445
  case 0:
5870
5446
  this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
5871
5447
  count: orderIds.length,
5872
5448
  orderIds: orderIds
5873
5449
  });
5874
5450
  if (this.order) {
5875
- _context61.next = 4;
5451
+ _context57.next = 4;
5876
5452
  break;
5877
5453
  }
5878
5454
  this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
5879
- return _context61.abrupt("return", {
5455
+ return _context57.abrupt("return", {
5880
5456
  code: 500,
5881
5457
  status: false,
5882
5458
  message: 'Order 模块未注册',
@@ -5884,11 +5460,11 @@ var Server = /*#__PURE__*/function () {
5884
5460
  });
5885
5461
  case 4:
5886
5462
  if ((_this$app17 = this.app) !== null && _this$app17 !== void 0 && _this$app17.request) {
5887
- _context61.next = 7;
5463
+ _context57.next = 7;
5888
5464
  break;
5889
5465
  }
5890
5466
  this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
5891
- return _context61.abrupt("return", {
5467
+ return _context57.abrupt("return", {
5892
5468
  code: 500,
5893
5469
  status: false,
5894
5470
  message: 'app.request 不可用',
@@ -5897,35 +5473,35 @@ var Server = /*#__PURE__*/function () {
5897
5473
  case 7:
5898
5474
  // 拉取前先记录"本地是否已存在",用于区分 overwritten / inserted
5899
5475
  existedBefore = new Map();
5900
- _iterator14 = _createForOfIteratorHelper(orderIds);
5476
+ _iterator13 = _createForOfIteratorHelper(orderIds);
5901
5477
  try {
5902
- for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
5903
- id = _step14.value;
5478
+ for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
5479
+ id = _step13.value;
5904
5480
  existedBefore.set(id, !!this.order.getOrderByOrderId(id));
5905
5481
  }
5906
5482
 
5907
5483
  // 走 orderDataSource 的批量 HTTP 通道,一次请求拉回多笔详情
5908
5484
  } catch (err) {
5909
- _iterator14.e(err);
5485
+ _iterator13.e(err);
5910
5486
  } finally {
5911
- _iterator14.f();
5487
+ _iterator13.f();
5912
5488
  }
5913
5489
  fetched = [];
5914
- _context61.prev = 11;
5915
- _context61.next = 14;
5490
+ _context57.prev = 11;
5491
+ _context57.next = 14;
5916
5492
  return this.order.fetchOrdersByHttp(orderIds);
5917
5493
  case 14:
5918
- fetched = _context61.sent;
5919
- _context61.next = 22;
5494
+ fetched = _context57.sent;
5495
+ _context57.next = 22;
5920
5496
  break;
5921
5497
  case 17:
5922
- _context61.prev = 17;
5923
- _context61.t0 = _context61["catch"](11);
5924
- message = _context61.t0 instanceof Error ? _context61.t0.message : String(_context61.t0);
5498
+ _context57.prev = 17;
5499
+ _context57.t0 = _context57["catch"](11);
5500
+ message = _context57.t0 instanceof Error ? _context57.t0.message : String(_context57.t0);
5925
5501
  this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
5926
5502
  message: message
5927
5503
  });
5928
- return _context61.abrupt("return", {
5504
+ return _context57.abrupt("return", {
5929
5505
  code: 500,
5930
5506
  status: false,
5931
5507
  message: message,
@@ -5934,45 +5510,45 @@ var Server = /*#__PURE__*/function () {
5934
5510
  case 22:
5935
5511
  // 按返回结果中的 order_id 建索引,未命中即视为单笔失败
5936
5512
  fetchedMap = new Map();
5937
- _iterator15 = _createForOfIteratorHelper(fetched);
5938
- _context61.prev = 24;
5939
- _iterator15.s();
5513
+ _iterator14 = _createForOfIteratorHelper(fetched);
5514
+ _context57.prev = 24;
5515
+ _iterator14.s();
5940
5516
  case 26:
5941
- if ((_step15 = _iterator15.n()).done) {
5942
- _context61.next = 34;
5517
+ if ((_step14 = _iterator14.n()).done) {
5518
+ _context57.next = 34;
5943
5519
  break;
5944
5520
  }
5945
- order = _step15.value;
5521
+ order = _step14.value;
5946
5522
  oid = order === null || order === void 0 ? void 0 : order.order_id;
5947
5523
  if (!(oid === undefined || oid === null)) {
5948
- _context61.next = 31;
5524
+ _context57.next = 31;
5949
5525
  break;
5950
5526
  }
5951
- return _context61.abrupt("continue", 32);
5527
+ return _context57.abrupt("continue", 32);
5952
5528
  case 31:
5953
5529
  fetchedMap.set(String(oid), order);
5954
5530
  case 32:
5955
- _context61.next = 26;
5531
+ _context57.next = 26;
5956
5532
  break;
5957
5533
  case 34:
5958
- _context61.next = 39;
5534
+ _context57.next = 39;
5959
5535
  break;
5960
5536
  case 36:
5961
- _context61.prev = 36;
5962
- _context61.t1 = _context61["catch"](24);
5963
- _iterator15.e(_context61.t1);
5537
+ _context57.prev = 36;
5538
+ _context57.t1 = _context57["catch"](24);
5539
+ _iterator14.e(_context57.t1);
5964
5540
  case 39:
5965
- _context61.prev = 39;
5966
- _iterator15.f();
5967
- return _context61.finish(39);
5541
+ _context57.prev = 39;
5542
+ _iterator14.f();
5543
+ return _context57.finish(39);
5968
5544
  case 42:
5969
5545
  freshOrders = [];
5970
5546
  succeedIds = [];
5971
5547
  failed = [];
5972
- _iterator16 = _createForOfIteratorHelper(orderIds);
5548
+ _iterator15 = _createForOfIteratorHelper(orderIds);
5973
5549
  try {
5974
- for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
5975
- _id = _step16.value;
5550
+ for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
5551
+ _id = _step15.value;
5976
5552
  fresh = fetchedMap.get(_id);
5977
5553
  if (fresh) {
5978
5554
  freshOrders.push(fresh);
@@ -5985,28 +5561,28 @@ var Server = /*#__PURE__*/function () {
5985
5561
  }
5986
5562
  }
5987
5563
  } catch (err) {
5988
- _iterator16.e(err);
5564
+ _iterator15.e(err);
5989
5565
  } finally {
5990
- _iterator16.f();
5566
+ _iterator15.f();
5991
5567
  }
5992
5568
  if (!(freshOrders.length > 0)) {
5993
- _context61.next = 58;
5569
+ _context57.next = 58;
5994
5570
  break;
5995
5571
  }
5996
- _context61.prev = 48;
5997
- _context61.next = 51;
5572
+ _context57.prev = 48;
5573
+ _context57.next = 51;
5998
5574
  return this.order.upsertOrdersFromRemote(freshOrders);
5999
5575
  case 51:
6000
- _context61.next = 58;
5576
+ _context57.next = 58;
6001
5577
  break;
6002
5578
  case 53:
6003
- _context61.prev = 53;
6004
- _context61.t2 = _context61["catch"](48);
6005
- _message2 = _context61.t2 instanceof Error ? _context61.t2.message : String(_context61.t2);
5579
+ _context57.prev = 53;
5580
+ _context57.t2 = _context57["catch"](48);
5581
+ _message2 = _context57.t2 instanceof Error ? _context57.t2.message : String(_context57.t2);
6006
5582
  this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
6007
5583
  message: _message2
6008
5584
  });
6009
- return _context61.abrupt("return", {
5585
+ return _context57.abrupt("return", {
6010
5586
  code: 500,
6011
5587
  status: false,
6012
5588
  message: _message2,
@@ -6025,7 +5601,7 @@ var Server = /*#__PURE__*/function () {
6025
5601
  insertedCount: inserted.length,
6026
5602
  failedCount: failed.length
6027
5603
  });
6028
- return _context61.abrupt("return", {
5604
+ return _context57.abrupt("return", {
6029
5605
  code: 200,
6030
5606
  status: true,
6031
5607
  message: '',
@@ -6037,11 +5613,11 @@ var Server = /*#__PURE__*/function () {
6037
5613
  });
6038
5614
  case 62:
6039
5615
  case "end":
6040
- return _context61.stop();
5616
+ return _context57.stop();
6041
5617
  }
6042
- }, _callee61, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
5618
+ }, _callee57, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
6043
5619
  }));
6044
- function handleUpdateLocalOrdersBatch(_x69) {
5620
+ function handleUpdateLocalOrdersBatch(_x64) {
6045
5621
  return _handleUpdateLocalOrdersBatch.apply(this, arguments);
6046
5622
  }
6047
5623
  return handleUpdateLocalOrdersBatch;
@@ -6062,11 +5638,11 @@ var Server = /*#__PURE__*/function () {
6062
5638
  var queryIndex = url.indexOf('?');
6063
5639
  if (queryIndex < 0) return null;
6064
5640
  var query = url.slice(queryIndex + 1);
6065
- var _iterator17 = _createForOfIteratorHelper(query.split('&')),
6066
- _step17;
5641
+ var _iterator16 = _createForOfIteratorHelper(query.split('&')),
5642
+ _step16;
6067
5643
  try {
6068
- for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
6069
- var pair = _step17.value;
5644
+ for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
5645
+ var pair = _step16.value;
6070
5646
  if (!pair) continue;
6071
5647
  var _pair$split = pair.split('='),
6072
5648
  _pair$split2 = _slicedToArray(_pair$split, 2),
@@ -6082,9 +5658,9 @@ var Server = /*#__PURE__*/function () {
6082
5658
  }
6083
5659
  }
6084
5660
  } catch (err) {
6085
- _iterator17.e(err);
5661
+ _iterator16.e(err);
6086
5662
  } finally {
6087
- _iterator17.f();
5663
+ _iterator16.f();
6088
5664
  }
6089
5665
  return null;
6090
5666
  }
@@ -6283,10 +5859,10 @@ var Server = /*#__PURE__*/function () {
6283
5859
  value: function extractBackendErrorResponse(error) {
6284
5860
  var _error$response3,
6285
5861
  _error$response4,
6286
- _this18 = this;
5862
+ _this16 = this;
6287
5863
  var candidates = [error === null || error === void 0 || (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response4 = error.response) === null || _error$response4 === void 0 ? void 0 : _error$response4.body, error === null || error === void 0 ? void 0 : error.body];
6288
5864
  return candidates.find(function (candidate) {
6289
- return _this18.isExplicitBackendErrorResponse(candidate);
5865
+ return _this16.isExplicitBackendErrorResponse(candidate);
6290
5866
  }) || null;
6291
5867
  }
6292
5868
  }, {
@@ -6405,24 +5981,24 @@ var Server = /*#__PURE__*/function () {
6405
5981
  }, {
6406
5982
  key: "recomputeAndNotifyFloorPlanQuery",
6407
5983
  value: (function () {
6408
- var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62() {
6409
- var _iterator18, _step18, _step18$value, subscriberId, sub, result, errorMessage;
6410
- return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6411
- while (1) switch (_context62.prev = _context62.next) {
5984
+ var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58() {
5985
+ var _iterator17, _step17, _step17$value, subscriberId, sub, result, errorMessage;
5986
+ return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5987
+ while (1) switch (_context58.prev = _context58.next) {
6412
5988
  case 0:
6413
5989
  if (!(this.floorPlanQuerySubscribers.size === 0)) {
6414
- _context62.next = 2;
5990
+ _context58.next = 2;
6415
5991
  break;
6416
5992
  }
6417
- return _context62.abrupt("return");
5993
+ return _context58.abrupt("return");
6418
5994
  case 2:
6419
5995
  this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
6420
5996
  subscriberCount: this.floorPlanQuerySubscribers.size
6421
5997
  });
6422
- _iterator18 = _createForOfIteratorHelper(this.floorPlanQuerySubscribers.entries());
5998
+ _iterator17 = _createForOfIteratorHelper(this.floorPlanQuerySubscribers.entries());
6423
5999
  try {
6424
- for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
6425
- _step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], sub = _step18$value[1];
6000
+ for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
6001
+ _step17$value = _slicedToArray(_step17.value, 2), subscriberId = _step17$value[0], sub = _step17$value[1];
6426
6002
  try {
6427
6003
  result = this.computeFloorPlanQueryResult(sub.context);
6428
6004
  sub.callback(result);
@@ -6438,15 +6014,15 @@ var Server = /*#__PURE__*/function () {
6438
6014
  }
6439
6015
  }
6440
6016
  } catch (err) {
6441
- _iterator18.e(err);
6017
+ _iterator17.e(err);
6442
6018
  } finally {
6443
- _iterator18.f();
6019
+ _iterator17.f();
6444
6020
  }
6445
6021
  case 5:
6446
6022
  case "end":
6447
- return _context62.stop();
6023
+ return _context58.stop();
6448
6024
  }
6449
- }, _callee62, this);
6025
+ }, _callee58, this);
6450
6026
  }));
6451
6027
  function recomputeAndNotifyFloorPlanQuery() {
6452
6028
  return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
@@ -6476,21 +6052,21 @@ var Server = /*#__PURE__*/function () {
6476
6052
  * filter 逻辑暂为 mock,仅记录参数
6477
6053
  */
6478
6054
  function () {
6479
- var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(data) {
6055
+ var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(data) {
6480
6056
  var rawList, result;
6481
- return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6482
- while (1) switch (_context63.prev = _context63.next) {
6057
+ return _regeneratorRuntime().wrap(function _callee59$(_context59) {
6058
+ while (1) switch (_context59.prev = _context59.next) {
6483
6059
  case 0:
6484
6060
  this.logInfo('computeOrderQueryResult: 开始过滤', {
6485
6061
  data: data
6486
6062
  });
6487
6063
  console.log('[Server] computeOrderQueryResult', data);
6488
6064
  if (this.order) {
6489
- _context63.next = 5;
6065
+ _context59.next = 5;
6490
6066
  break;
6491
6067
  }
6492
6068
  this.logError('computeOrderQueryResult: Order 模块未注册');
6493
- return _context63.abrupt("return", {
6069
+ return _context59.abrupt("return", {
6494
6070
  code: 500,
6495
6071
  message: 'Order 模块未注册',
6496
6072
  data: {
@@ -6514,7 +6090,7 @@ var Server = /*#__PURE__*/function () {
6514
6090
  skip: result.skip,
6515
6091
  rejected: result.rejected
6516
6092
  });
6517
- return _context63.abrupt("return", {
6093
+ return _context59.abrupt("return", {
6518
6094
  code: 200,
6519
6095
  data: result,
6520
6096
  message: '',
@@ -6522,11 +6098,11 @@ var Server = /*#__PURE__*/function () {
6522
6098
  });
6523
6099
  case 10:
6524
6100
  case "end":
6525
- return _context63.stop();
6101
+ return _context59.stop();
6526
6102
  }
6527
- }, _callee63, this);
6103
+ }, _callee59, this);
6528
6104
  }));
6529
- function computeOrderQueryResult(_x70) {
6105
+ function computeOrderQueryResult(_x65) {
6530
6106
  return _computeOrderQueryResult.apply(this, arguments);
6531
6107
  }
6532
6108
  return computeOrderQueryResult;
@@ -6539,17 +6115,17 @@ var Server = /*#__PURE__*/function () {
6539
6115
  }, {
6540
6116
  key: "computeBookingQueryResult",
6541
6117
  value: (function () {
6542
- var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(data) {
6118
+ var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(data) {
6543
6119
  var rawOrders, result;
6544
- return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6545
- while (1) switch (_context64.prev = _context64.next) {
6120
+ return _regeneratorRuntime().wrap(function _callee60$(_context60) {
6121
+ while (1) switch (_context60.prev = _context60.next) {
6546
6122
  case 0:
6547
6123
  if (this.order) {
6548
- _context64.next = 3;
6124
+ _context60.next = 3;
6549
6125
  break;
6550
6126
  }
6551
6127
  this.logError('computeBookingQueryResult: Order 模块未注册');
6552
- return _context64.abrupt("return", {
6128
+ return _context60.abrupt("return", {
6553
6129
  code: 500,
6554
6130
  message: 'Order 模块未注册',
6555
6131
  data: {
@@ -6568,7 +6144,7 @@ var Server = /*#__PURE__*/function () {
6568
6144
  size: result.size,
6569
6145
  skip: result.skip
6570
6146
  });
6571
- return _context64.abrupt("return", {
6147
+ return _context60.abrupt("return", {
6572
6148
  code: 200,
6573
6149
  data: result,
6574
6150
  message: '',
@@ -6576,11 +6152,11 @@ var Server = /*#__PURE__*/function () {
6576
6152
  });
6577
6153
  case 8:
6578
6154
  case "end":
6579
- return _context64.stop();
6155
+ return _context60.stop();
6580
6156
  }
6581
- }, _callee64, this);
6157
+ }, _callee60, this);
6582
6158
  }));
6583
- function computeBookingQueryResult(_x71) {
6159
+ function computeBookingQueryResult(_x66) {
6584
6160
  return _computeBookingQueryResult.apply(this, arguments);
6585
6161
  }
6586
6162
  return computeBookingQueryResult;
@@ -6639,26 +6215,20 @@ var Server = /*#__PURE__*/function () {
6639
6215
  }, {
6640
6216
  key: "computeProductQueryResult",
6641
6217
  value: (function () {
6642
- var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(context, options) {
6218
+ var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(context, options) {
6643
6219
  var _menu_list_ids$length3,
6644
- _this19 = this;
6645
- var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, strategy_context, queryIds, formatterContext, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu, menuList, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
6646
- return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6647
- while (1) switch (_context65.prev = _context65.next) {
6220
+ _this17 = this;
6221
+ var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, queryIds, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu, menuList, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
6222
+ return _regeneratorRuntime().wrap(function _callee61$(_context61) {
6223
+ while (1) switch (_context61.prev = _context61.next) {
6648
6224
  case 0:
6649
6225
  tTotal = performance.now();
6650
- menu_list_ids = context.menu_list_ids, ids = context.ids, schedule_date = context.schedule_date, schedule_datetime = context.schedule_datetime, customer_id = context.customer_id, extension_type = context.extension_type, product_id = context.product_id, strategy_context = context.strategy_context;
6226
+ menu_list_ids = context.menu_list_ids, ids = context.ids, schedule_date = context.schedule_date, schedule_datetime = context.schedule_datetime, customer_id = context.customer_id, extension_type = context.extension_type, product_id = context.product_id;
6651
6227
  queryIds = Array.isArray(ids) ? ids.map(function (id) {
6652
6228
  return Number(id);
6653
6229
  }).filter(function (id) {
6654
6230
  return Number.isFinite(id);
6655
6231
  }) : [];
6656
- formatterContext = this.buildProductFormatterContext({
6657
- schedule_date: schedule_date,
6658
- schedule_datetime: schedule_datetime,
6659
- customer_id: customer_id,
6660
- strategy_context: strategy_context
6661
- });
6662
6232
  this.logInfo('computeProductQueryResult 开始', {
6663
6233
  menuListIdsCount: (_menu_list_ids$length3 = menu_list_ids === null || menu_list_ids === void 0 ? void 0 : menu_list_ids.length) !== null && _menu_list_ids$length3 !== void 0 ? _menu_list_ids$length3 : 0,
6664
6234
  ids: queryIds,
@@ -6667,32 +6237,38 @@ var Server = /*#__PURE__*/function () {
6667
6237
  customer_id: customer_id,
6668
6238
  extension_type: extension_type,
6669
6239
  product_id: product_id,
6670
- strategyContextKeys: strategy_context ? Object.keys(strategy_context) : [],
6671
6240
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
6672
6241
  });
6673
6242
  if (this.products) {
6674
- _context65.next = 8;
6243
+ _context61.next = 7;
6675
6244
  break;
6676
6245
  }
6677
6246
  this.logError('computeProductQueryResult: Products 模块未注册');
6678
- return _context65.abrupt("return", {
6247
+ return _context61.abrupt("return", {
6679
6248
  message: 'Products 模块未注册',
6680
- data: this.buildProductQueryResultPayload([], 0)
6249
+ data: {
6250
+ list: [],
6251
+ count: 0
6252
+ }
6681
6253
  });
6682
- case 8:
6254
+ case 7:
6683
6255
  if (!(queryIds.length > 0)) {
6684
- _context65.next = 20;
6256
+ _context61.next = 19;
6685
6257
  break;
6686
6258
  }
6687
6259
  uniqueIds = Array.from(new Set(queryIds));
6688
6260
  _tPrice = performance.now();
6689
- _context65.next = 13;
6690
- return this.products.getProductsWithPrice(schedule_date, formatterContext, {
6261
+ _context61.next = 12;
6262
+ return this.products.getProductsWithPrice(schedule_date, {
6263
+ scheduleModule: this.getSchedule(),
6264
+ schedule_datetime: schedule_datetime,
6265
+ customer_id: customer_id
6266
+ }, {
6691
6267
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
6692
6268
  productIds: uniqueIds
6693
6269
  });
6694
- case 13:
6695
- productsWithPrice = _context65.sent;
6270
+ case 12:
6271
+ productsWithPrice = _context61.sent;
6696
6272
  perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
6697
6273
  count: productsWithPrice.length,
6698
6274
  ids: uniqueIds
@@ -6712,25 +6288,30 @@ var Server = /*#__PURE__*/function () {
6712
6288
  ids: uniqueIds,
6713
6289
  count: extensionFilteredProducts.length
6714
6290
  });
6715
- return _context65.abrupt("return", {
6291
+ return _context61.abrupt("return", {
6716
6292
  code: 200,
6717
- data: this.buildProductQueryResultPayload(extensionFilteredProducts),
6293
+ data: {
6294
+ list: extensionFilteredProducts,
6295
+ count: extensionFilteredProducts.length
6296
+ },
6718
6297
  message: '',
6719
6298
  status: true
6720
6299
  });
6721
- case 20:
6300
+ case 19:
6722
6301
  if (!(product_id != null && Number.isFinite(Number(product_id)))) {
6723
- _context65.next = 32;
6302
+ _context61.next = 31;
6724
6303
  break;
6725
6304
  }
6726
6305
  pid = Number(product_id);
6727
6306
  _tPrice2 = performance.now();
6728
- _context65.next = 25;
6729
- return this.products.getProductsWithPrice(schedule_date, formatterContext, {
6307
+ _context61.next = 24;
6308
+ return this.products.getProductsWithPrice(schedule_date, {
6309
+ scheduleModule: this.getSchedule()
6310
+ }, {
6730
6311
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
6731
6312
  });
6732
- case 25:
6733
- allProductsWithPrice = _context65.sent;
6313
+ case 24:
6314
+ allProductsWithPrice = _context61.sent;
6734
6315
  perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
6735
6316
  count: allProductsWithPrice.length,
6736
6317
  productId: pid
@@ -6750,24 +6331,28 @@ var Server = /*#__PURE__*/function () {
6750
6331
  productId: pid,
6751
6332
  found: !!item
6752
6333
  });
6753
- return _context65.abrupt("return", {
6334
+ return _context61.abrupt("return", {
6754
6335
  code: 200,
6755
6336
  data: item,
6756
6337
  message: item ? '' : '商品不存在或未发布',
6757
6338
  status: true
6758
6339
  });
6759
- case 32:
6340
+ case 31:
6760
6341
  if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
6761
- _context65.next = 52;
6342
+ _context61.next = 51;
6762
6343
  break;
6763
6344
  }
6764
6345
  _tPrice3 = performance.now();
6765
- _context65.next = 36;
6766
- return this.products.getProductsWithPrice(schedule_date, formatterContext, {
6346
+ _context61.next = 35;
6347
+ return this.products.getProductsWithPrice(schedule_date, {
6348
+ scheduleModule: this.getSchedule(),
6349
+ schedule_datetime: schedule_datetime,
6350
+ customer_id: customer_id
6351
+ }, {
6767
6352
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
6768
6353
  });
6769
- case 36:
6770
- _filteredProducts2 = _context65.sent;
6354
+ case 35:
6355
+ _filteredProducts2 = _context61.sent;
6771
6356
  perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
6772
6357
  count: _filteredProducts2.length,
6773
6358
  extension_type: extension_type
@@ -6806,40 +6391,49 @@ var Server = /*#__PURE__*/function () {
6806
6391
  filteredCount: _filteredProducts2.length,
6807
6392
  extension_type: extension_type
6808
6393
  });
6809
- return _context65.abrupt("return", {
6394
+ return _context61.abrupt("return", {
6810
6395
  code: 200,
6811
- data: this.buildProductQueryResultPayload(_filteredProducts2),
6396
+ data: {
6397
+ list: _filteredProducts2,
6398
+ count: _filteredProducts2.length
6399
+ },
6812
6400
  message: '',
6813
6401
  status: true
6814
6402
  });
6815
- case 52:
6403
+ case 51:
6816
6404
  if (this.menu) {
6817
- _context65.next = 55;
6405
+ _context61.next = 54;
6818
6406
  break;
6819
6407
  }
6820
6408
  this.logError('computeProductQueryResult: Menu 模块未注册');
6821
- return _context65.abrupt("return", {
6409
+ return _context61.abrupt("return", {
6822
6410
  message: 'Menu 模块未注册',
6823
- data: this.buildProductQueryResultPayload([], 0)
6411
+ data: {
6412
+ list: [],
6413
+ count: 0
6414
+ }
6824
6415
  });
6825
- case 55:
6416
+ case 54:
6826
6417
  if (this.schedule) {
6827
- _context65.next = 58;
6418
+ _context61.next = 57;
6828
6419
  break;
6829
6420
  }
6830
6421
  this.logError('computeProductQueryResult: Schedule 模块未注册');
6831
- return _context65.abrupt("return", {
6422
+ return _context61.abrupt("return", {
6832
6423
  message: 'Schedule 模块未注册',
6833
- data: this.buildProductQueryResultPayload([], 0)
6424
+ data: {
6425
+ list: [],
6426
+ count: 0
6427
+ }
6834
6428
  });
6835
- case 58:
6429
+ case 57:
6836
6430
  activeMenuList = [];
6837
6431
  if (menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0) {
6838
6432
  tMenu = performance.now();
6839
6433
  menuList = this.menu.getMenuByIds(menu_list_ids);
6840
6434
  activeMenuList = menuList.filter(function (menu) {
6841
- var _this19$schedule;
6842
- return ((_this19$schedule = _this19.schedule) === null || _this19$schedule === void 0 ? void 0 : _this19$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
6435
+ var _this17$schedule;
6436
+ return ((_this17$schedule = _this17.schedule) === null || _this17$schedule === void 0 ? void 0 : _this17$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
6843
6437
  });
6844
6438
  perfMark('computeQuery.filterActiveMenu', performance.now() - tMenu, {
6845
6439
  totalMenu: menuList.length,
@@ -6856,22 +6450,26 @@ var Server = /*#__PURE__*/function () {
6856
6450
  });
6857
6451
  tPrice = performance.now();
6858
6452
  if (!(scopedProductIds.length > 0)) {
6859
- _context65.next = 71;
6453
+ _context61.next = 70;
6860
6454
  break;
6861
6455
  }
6862
- _context65.next = 68;
6863
- return this.products.getProductsWithPrice(schedule_date, formatterContext, {
6456
+ _context61.next = 67;
6457
+ return this.products.getProductsWithPrice(schedule_date, {
6458
+ scheduleModule: this.getSchedule(),
6459
+ schedule_datetime: schedule_datetime,
6460
+ customer_id: customer_id
6461
+ }, {
6864
6462
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
6865
6463
  productIds: productScope.isAllProducts ? undefined : scopedProductIds
6866
6464
  });
6867
- case 68:
6868
- _context65.t0 = _context65.sent;
6869
- _context65.next = 72;
6465
+ case 67:
6466
+ _context61.t0 = _context61.sent;
6467
+ _context61.next = 71;
6870
6468
  break;
6469
+ case 70:
6470
+ _context61.t0 = [];
6871
6471
  case 71:
6872
- _context65.t0 = [];
6873
- case 72:
6874
- filteredProducts = _context65.t0;
6472
+ filteredProducts = _context61.t0;
6875
6473
  perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
6876
6474
  count: filteredProducts.length,
6877
6475
  scopedProductCount: scopedProductIds.length
@@ -6912,120 +6510,102 @@ var Server = /*#__PURE__*/function () {
6912
6510
  filteredCount: filteredProducts.length,
6913
6511
  activeMenuCount: activeMenuList.length
6914
6512
  });
6915
- return _context65.abrupt("return", {
6513
+ return _context61.abrupt("return", {
6916
6514
  code: 200,
6917
- data: this.buildProductQueryResultPayload(filteredProducts),
6515
+ data: {
6516
+ list: filteredProducts,
6517
+ count: filteredProducts.length
6518
+ },
6918
6519
  message: '',
6919
6520
  status: true
6920
6521
  });
6921
- case 88:
6522
+ case 87:
6922
6523
  case "end":
6923
- return _context65.stop();
6524
+ return _context61.stop();
6924
6525
  }
6925
- }, _callee65, this);
6526
+ }, _callee61, this);
6926
6527
  }));
6927
- function computeProductQueryResult(_x72, _x73) {
6528
+ function computeProductQueryResult(_x67, _x68) {
6928
6529
  return _computeProductQueryResult.apply(this, arguments);
6929
6530
  }
6930
6531
  return computeProductQueryResult;
6931
6532
  }()
6932
- /**
6933
- * 构建商品格式化上下文。
6934
- *
6935
- * 智能定价条件使用全量 menuList/scheduleList;Product Query 顶层参数只保留筛选商品集合所需字段。
6936
- */
6937
- )
6938
- }, {
6939
- key: "buildProductFormatterContext",
6940
- value: function buildProductFormatterContext(context) {
6941
- var _this$menu, _this$menu$getMenuLis, _scheduleModule$getSc, _this$core$context5;
6942
- var scheduleModule = this.getSchedule();
6943
- return {
6944
- scheduleModule: scheduleModule,
6945
- schedule_datetime: context.schedule_datetime,
6946
- customer_id: context.customer_id,
6947
- strategy_context: context.strategy_context,
6948
- menuList: ((_this$menu = this.menu) === null || _this$menu === void 0 || (_this$menu$getMenuLis = _this$menu.getMenuList) === null || _this$menu$getMenuLis === void 0 ? void 0 : _this$menu$getMenuLis.call(_this$menu)) || [],
6949
- scheduleList: (scheduleModule === null || scheduleModule === void 0 || (_scheduleModule$getSc = scheduleModule.getScheduleList) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule)) || [],
6950
- dataVariantEvaluator: (_this$core$context5 = this.core.context) === null || _this$core$context5 === void 0 ? void 0 : _this$core$context5.dataVariantEvaluator
6951
- };
6952
- }
6953
-
6954
6533
  /**
6955
6534
  * 数据变更后,遍历所有订阅者重新计算查询结果并通过 callback 推送
6956
6535
  * 由 ProductsModule 的 onProductsSyncCompleted 事件触发
6957
6536
  * @param options 可选参数
6958
6537
  * @param options.changedIds 变更的商品 IDs,用于增量更新价格缓存
6959
6538
  */
6539
+ )
6960
6540
  }, {
6961
6541
  key: "recomputeAndNotifyProductQuery",
6962
6542
  value: (function () {
6963
- var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(options) {
6964
- var _iterator19, _step19, _step19$value, subscriberId, subscriber, result, errorMessage;
6965
- return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6966
- while (1) switch (_context66.prev = _context66.next) {
6543
+ var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(options) {
6544
+ var _iterator18, _step18, _step18$value, subscriberId, subscriber, result, errorMessage;
6545
+ return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6546
+ while (1) switch (_context62.prev = _context62.next) {
6967
6547
  case 0:
6968
6548
  if (!(this.productQuerySubscribers.size === 0)) {
6969
- _context66.next = 2;
6549
+ _context62.next = 2;
6970
6550
  break;
6971
6551
  }
6972
- return _context66.abrupt("return");
6552
+ return _context62.abrupt("return");
6973
6553
  case 2:
6974
6554
  this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
6975
6555
  subscriberCount: this.productQuerySubscribers.size,
6976
6556
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
6977
6557
  });
6978
- _iterator19 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
6979
- _context66.prev = 4;
6980
- _iterator19.s();
6558
+ _iterator18 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
6559
+ _context62.prev = 4;
6560
+ _iterator18.s();
6981
6561
  case 6:
6982
- if ((_step19 = _iterator19.n()).done) {
6983
- _context66.next = 22;
6562
+ if ((_step18 = _iterator18.n()).done) {
6563
+ _context62.next = 22;
6984
6564
  break;
6985
6565
  }
6986
- _step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
6987
- _context66.prev = 8;
6988
- _context66.next = 11;
6566
+ _step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
6567
+ _context62.prev = 8;
6568
+ _context62.next = 11;
6989
6569
  return this.computeProductQueryResult(subscriber.context, {
6990
6570
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
6991
6571
  });
6992
6572
  case 11:
6993
- result = _context66.sent;
6573
+ result = _context62.sent;
6994
6574
  subscriber.callback(result);
6995
6575
  this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
6996
6576
  subscriberId: subscriberId
6997
6577
  });
6998
- _context66.next = 20;
6578
+ _context62.next = 20;
6999
6579
  break;
7000
6580
  case 16:
7001
- _context66.prev = 16;
7002
- _context66.t0 = _context66["catch"](8);
7003
- errorMessage = _context66.t0 instanceof Error ? _context66.t0.message : String(_context66.t0);
6581
+ _context62.prev = 16;
6582
+ _context62.t0 = _context62["catch"](8);
6583
+ errorMessage = _context62.t0 instanceof Error ? _context62.t0.message : String(_context62.t0);
7004
6584
  this.logError('recomputeAndNotifyProductQuery: 推送失败', {
7005
6585
  subscriberId: subscriberId,
7006
6586
  error: errorMessage
7007
6587
  });
7008
6588
  case 20:
7009
- _context66.next = 6;
6589
+ _context62.next = 6;
7010
6590
  break;
7011
6591
  case 22:
7012
- _context66.next = 27;
6592
+ _context62.next = 27;
7013
6593
  break;
7014
6594
  case 24:
7015
- _context66.prev = 24;
7016
- _context66.t1 = _context66["catch"](4);
7017
- _iterator19.e(_context66.t1);
6595
+ _context62.prev = 24;
6596
+ _context62.t1 = _context62["catch"](4);
6597
+ _iterator18.e(_context62.t1);
7018
6598
  case 27:
7019
- _context66.prev = 27;
7020
- _iterator19.f();
7021
- return _context66.finish(27);
6599
+ _context62.prev = 27;
6600
+ _iterator18.f();
6601
+ return _context62.finish(27);
7022
6602
  case 30:
7023
6603
  case "end":
7024
- return _context66.stop();
6604
+ return _context62.stop();
7025
6605
  }
7026
- }, _callee66, this, [[4, 24, 27, 30], [8, 16]]);
6606
+ }, _callee62, this, [[4, 24, 27, 30], [8, 16]]);
7027
6607
  }));
7028
- function recomputeAndNotifyProductQuery(_x74) {
6608
+ function recomputeAndNotifyProductQuery(_x69) {
7029
6609
  return _recomputeAndNotifyProductQuery.apply(this, arguments);
7030
6610
  }
7031
6611
  return recomputeAndNotifyProductQuery;
@@ -7037,37 +6617,37 @@ var Server = /*#__PURE__*/function () {
7037
6617
  }, {
7038
6618
  key: "recomputeAndNotifyOrderQuery",
7039
6619
  value: (function () {
7040
- var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67() {
7041
- var notifyStartAt, _iterator20, _step20, _step20$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
7042
- return _regeneratorRuntime().wrap(function _callee67$(_context67) {
7043
- while (1) switch (_context67.prev = _context67.next) {
6620
+ var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63() {
6621
+ var notifyStartAt, _iterator19, _step19, _step19$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
6622
+ return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6623
+ while (1) switch (_context63.prev = _context63.next) {
7044
6624
  case 0:
7045
6625
  if (!(this.orderQuerySubscribers.size === 0)) {
7046
- _context67.next = 2;
6626
+ _context63.next = 2;
7047
6627
  break;
7048
6628
  }
7049
- return _context67.abrupt("return");
6629
+ return _context63.abrupt("return");
7050
6630
  case 2:
7051
6631
  notifyStartAt = Date.now();
7052
6632
  this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
7053
6633
  subscriberCount: this.orderQuerySubscribers.size,
7054
6634
  notifyStartAt: new Date(notifyStartAt).toISOString()
7055
6635
  });
7056
- _iterator20 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
7057
- _context67.prev = 5;
7058
- _iterator20.s();
6636
+ _iterator19 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
6637
+ _context63.prev = 5;
6638
+ _iterator19.s();
7059
6639
  case 7:
7060
- if ((_step20 = _iterator20.n()).done) {
7061
- _context67.next = 27;
6640
+ if ((_step19 = _iterator19.n()).done) {
6641
+ _context63.next = 27;
7062
6642
  break;
7063
6643
  }
7064
- _step20$value = _slicedToArray(_step20.value, 2), subscriberId = _step20$value[0], subscriber = _step20$value[1];
7065
- _context67.prev = 9;
6644
+ _step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
6645
+ _context63.prev = 9;
7066
6646
  computeStartAt = Date.now();
7067
- _context67.next = 13;
6647
+ _context63.next = 13;
7068
6648
  return this.computeOrderQueryResult(subscriber.context);
7069
6649
  case 13:
7070
- result = _context67.sent;
6650
+ result = _context63.sent;
7071
6651
  computeEndAt = Date.now();
7072
6652
  callbackStartAt = Date.now();
7073
6653
  subscriber.callback(result);
@@ -7078,30 +6658,30 @@ var Server = /*#__PURE__*/function () {
7078
6658
  callbackDurationMs: callbackEndAt - callbackStartAt,
7079
6659
  totalDurationMs: callbackEndAt - computeStartAt
7080
6660
  });
7081
- _context67.next = 25;
6661
+ _context63.next = 25;
7082
6662
  break;
7083
6663
  case 21:
7084
- _context67.prev = 21;
7085
- _context67.t0 = _context67["catch"](9);
7086
- errorMessage = _context67.t0 instanceof Error ? _context67.t0.message : String(_context67.t0);
6664
+ _context63.prev = 21;
6665
+ _context63.t0 = _context63["catch"](9);
6666
+ errorMessage = _context63.t0 instanceof Error ? _context63.t0.message : String(_context63.t0);
7087
6667
  this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
7088
6668
  subscriberId: subscriberId,
7089
6669
  error: errorMessage
7090
6670
  });
7091
6671
  case 25:
7092
- _context67.next = 7;
6672
+ _context63.next = 7;
7093
6673
  break;
7094
6674
  case 27:
7095
- _context67.next = 32;
6675
+ _context63.next = 32;
7096
6676
  break;
7097
6677
  case 29:
7098
- _context67.prev = 29;
7099
- _context67.t1 = _context67["catch"](5);
7100
- _iterator20.e(_context67.t1);
6678
+ _context63.prev = 29;
6679
+ _context63.t1 = _context63["catch"](5);
6680
+ _iterator19.e(_context63.t1);
7101
6681
  case 32:
7102
- _context67.prev = 32;
7103
- _iterator20.f();
7104
- return _context67.finish(32);
6682
+ _context63.prev = 32;
6683
+ _iterator19.f();
6684
+ return _context63.finish(32);
7105
6685
  case 35:
7106
6686
  notifyEndAt = Date.now();
7107
6687
  this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
@@ -7110,9 +6690,9 @@ var Server = /*#__PURE__*/function () {
7110
6690
  });
7111
6691
  case 37:
7112
6692
  case "end":
7113
- return _context67.stop();
6693
+ return _context63.stop();
7114
6694
  }
7115
- }, _callee67, this, [[5, 29, 32, 35], [9, 21]]);
6695
+ }, _callee63, this, [[5, 29, 32, 35], [9, 21]]);
7116
6696
  }));
7117
6697
  function recomputeAndNotifyOrderQuery() {
7118
6698
  return _recomputeAndNotifyOrderQuery.apply(this, arguments);
@@ -7130,7 +6710,7 @@ var Server = /*#__PURE__*/function () {
7130
6710
  }, {
7131
6711
  key: "notifySalesSearchSubscribers",
7132
6712
  value: function notifySalesSearchSubscribers(payload) {
7133
- var _this20 = this;
6713
+ var _this18 = this;
7134
6714
  if (this.salesSearchSubscribers.size === 0) return;
7135
6715
  var changedOrders = this.extractChangedOrdersFromPayload(payload);
7136
6716
  if (changedOrders.length === 0) {
@@ -7139,42 +6719,42 @@ var Server = /*#__PURE__*/function () {
7139
6719
  // 如果当前开启了 checkout 弹窗,先不进行刷新,下面的代码会导致在全局搜索页调用 bookingTicket.destroy()
7140
6720
  // 导致模块被销毁 ,checkout 弹窗永远无法关闭
7141
6721
  if (window.isPaymentModalPluginOpen) return;
7142
- var _iterator21 = _createForOfIteratorHelper(this.salesSearchSubscribers.entries()),
7143
- _step21;
6722
+ var _iterator20 = _createForOfIteratorHelper(this.salesSearchSubscribers.entries()),
6723
+ _step20;
7144
6724
  try {
7145
- var _loop2 = function _loop2() {
7146
- var _step21$value = _slicedToArray(_step21.value, 2),
7147
- subscriberId = _step21$value[0],
7148
- subscriber = _step21$value[1];
6725
+ var _loop = function _loop() {
6726
+ var _step20$value = _slicedToArray(_step20.value, 2),
6727
+ subscriberId = _step20$value[0],
6728
+ subscriber = _step20$value[1];
7149
6729
  try {
7150
6730
  var changedVisibleOrders = changedOrders.filter(function (order) {
7151
- var orderId = _this20.getSalesSearchOrderId(order);
6731
+ var orderId = _this18.getSalesSearchOrderId(order);
7152
6732
  return !!orderId && subscriber.visibleOrderIds.has(orderId);
7153
6733
  });
7154
6734
  if (changedVisibleOrders.length === 0) {
7155
6735
  return 1; // continue
7156
6736
  }
7157
- subscriber.callback(_this20.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
7158
- _this20.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
6737
+ subscriber.callback(_this18.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
6738
+ _this18.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
7159
6739
  subscriberId: subscriberId,
7160
6740
  kind: subscriber.kind,
7161
6741
  count: changedVisibleOrders.length
7162
6742
  });
7163
6743
  } catch (error) {
7164
6744
  var errorMessage = error instanceof Error ? error.message : String(error);
7165
- _this20.logError('notifySalesSearchSubscribers: 推送失败', {
6745
+ _this18.logError('notifySalesSearchSubscribers: 推送失败', {
7166
6746
  subscriberId: subscriberId,
7167
6747
  error: errorMessage
7168
6748
  });
7169
6749
  }
7170
6750
  };
7171
- for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
7172
- if (_loop2()) continue;
6751
+ for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {
6752
+ if (_loop()) continue;
7173
6753
  }
7174
6754
  } catch (err) {
7175
- _iterator21.e(err);
6755
+ _iterator20.e(err);
7176
6756
  } finally {
7177
- _iterator21.f();
6757
+ _iterator20.f();
7178
6758
  }
7179
6759
  }
7180
6760
 
@@ -7253,67 +6833,67 @@ var Server = /*#__PURE__*/function () {
7253
6833
  }, {
7254
6834
  key: "recomputeAndNotifyBookingQuery",
7255
6835
  value: (function () {
7256
- var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68() {
7257
- var _iterator22, _step22, _step22$value, subscriberId, subscriber, result, errorMessage;
7258
- return _regeneratorRuntime().wrap(function _callee68$(_context68) {
7259
- while (1) switch (_context68.prev = _context68.next) {
6836
+ var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64() {
6837
+ var _iterator21, _step21, _step21$value, subscriberId, subscriber, result, errorMessage;
6838
+ return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6839
+ while (1) switch (_context64.prev = _context64.next) {
7260
6840
  case 0:
7261
6841
  if (!(this.bookingQuerySubscribers.size === 0)) {
7262
- _context68.next = 2;
6842
+ _context64.next = 2;
7263
6843
  break;
7264
6844
  }
7265
- return _context68.abrupt("return");
6845
+ return _context64.abrupt("return");
7266
6846
  case 2:
7267
6847
  this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
7268
6848
  subscriberCount: this.bookingQuerySubscribers.size
7269
6849
  });
7270
- _iterator22 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
7271
- _context68.prev = 4;
7272
- _iterator22.s();
6850
+ _iterator21 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
6851
+ _context64.prev = 4;
6852
+ _iterator21.s();
7273
6853
  case 6:
7274
- if ((_step22 = _iterator22.n()).done) {
7275
- _context68.next = 22;
6854
+ if ((_step21 = _iterator21.n()).done) {
6855
+ _context64.next = 22;
7276
6856
  break;
7277
6857
  }
7278
- _step22$value = _slicedToArray(_step22.value, 2), subscriberId = _step22$value[0], subscriber = _step22$value[1];
7279
- _context68.prev = 8;
7280
- _context68.next = 11;
6858
+ _step21$value = _slicedToArray(_step21.value, 2), subscriberId = _step21$value[0], subscriber = _step21$value[1];
6859
+ _context64.prev = 8;
6860
+ _context64.next = 11;
7281
6861
  return this.computeBookingQueryResult(subscriber.context);
7282
6862
  case 11:
7283
- result = _context68.sent;
6863
+ result = _context64.sent;
7284
6864
  subscriber.callback(result);
7285
6865
  this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
7286
6866
  subscriberId: subscriberId
7287
6867
  });
7288
- _context68.next = 20;
6868
+ _context64.next = 20;
7289
6869
  break;
7290
6870
  case 16:
7291
- _context68.prev = 16;
7292
- _context68.t0 = _context68["catch"](8);
7293
- errorMessage = _context68.t0 instanceof Error ? _context68.t0.message : String(_context68.t0);
6871
+ _context64.prev = 16;
6872
+ _context64.t0 = _context64["catch"](8);
6873
+ errorMessage = _context64.t0 instanceof Error ? _context64.t0.message : String(_context64.t0);
7294
6874
  this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
7295
6875
  subscriberId: subscriberId,
7296
6876
  error: errorMessage
7297
6877
  });
7298
6878
  case 20:
7299
- _context68.next = 6;
6879
+ _context64.next = 6;
7300
6880
  break;
7301
6881
  case 22:
7302
- _context68.next = 27;
6882
+ _context64.next = 27;
7303
6883
  break;
7304
6884
  case 24:
7305
- _context68.prev = 24;
7306
- _context68.t1 = _context68["catch"](4);
7307
- _iterator22.e(_context68.t1);
6885
+ _context64.prev = 24;
6886
+ _context64.t1 = _context64["catch"](4);
6887
+ _iterator21.e(_context64.t1);
7308
6888
  case 27:
7309
- _context68.prev = 27;
7310
- _iterator22.f();
7311
- return _context68.finish(27);
6889
+ _context64.prev = 27;
6890
+ _iterator21.f();
6891
+ return _context64.finish(27);
7312
6892
  case 30:
7313
6893
  case "end":
7314
- return _context68.stop();
6894
+ return _context64.stop();
7315
6895
  }
7316
- }, _callee68, this, [[4, 24, 27, 30], [8, 16]]);
6896
+ }, _callee64, this, [[4, 24, 27, 30], [8, 16]]);
7317
6897
  }));
7318
6898
  function recomputeAndNotifyBookingQuery() {
7319
6899
  return _recomputeAndNotifyBookingQuery.apply(this, arguments);
@@ -7343,11 +6923,11 @@ var Server = /*#__PURE__*/function () {
7343
6923
  var allowedProductIds = new Set();
7344
6924
  var allowedCollectionIds = new Set();
7345
6925
  var hasProductAll = false;
7346
- var _iterator23 = _createForOfIteratorHelper(activeMenuList),
7347
- _step23;
6926
+ var _iterator22 = _createForOfIteratorHelper(activeMenuList),
6927
+ _step22;
7348
6928
  try {
7349
- for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
7350
- var menu = _step23.value;
6929
+ for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
6930
+ var menu = _step22.value;
7351
6931
  var config = menu.partyroom_package;
7352
6932
  if (!config) {
7353
6933
  console.warn('[Server] 餐牌缺少 partyroom_package 配置:', menu);
@@ -7407,9 +6987,9 @@ var Server = /*#__PURE__*/function () {
7407
6987
 
7408
6988
  // 如果有餐牌允许所有商品,返回所有商品
7409
6989
  } catch (err) {
7410
- _iterator23.e(err);
6990
+ _iterator22.e(err);
7411
6991
  } finally {
7412
- _iterator23.f();
6992
+ _iterator22.f();
7413
6993
  }
7414
6994
  if (hasProductAll) {
7415
6995
  this.logInfo('getProductScopeByMenuConfig: 返回所有商品 scope(product_all)');