@pisell/pisellos 2.2.215 → 2.2.217

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.
@@ -334,7 +334,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
334
334
  private logSubmitBackendRejected;
335
335
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
336
336
  createOrder(params: CommitOrderParams['query']): {
337
- type: "appointment_booking" | "virtual";
337
+ type: "virtual" | "appointment_booking";
338
338
  platform: string;
339
339
  sales_channel: string;
340
340
  order_sales_channel: string;
@@ -2653,6 +2653,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2653
2653
  var hasSyncedOrderPayment = function hasSyncedOrderPayment(payment) {
2654
2654
  return payment.order_payment_id !== undefined && payment.order_payment_id !== null;
2655
2655
  };
2656
+ // const normalizeVoucherPaymentStatus = (payment: OrderPaymentSource): OrderPaymentSource => {
2657
+ // const paymentRecord = payment as Record<string, any>;
2658
+ // // if (paymentRecord.status !== 'active') return payment;
2659
+ // // return {
2660
+ // // ...paymentRecord,
2661
+ // // status: 'paid',
2662
+ // // };
2663
+ // if (paymentRecord.status === 'active') {
2664
+ // paymentRecord.status = 'paid'
2665
+ // }
2666
+ // return paymentRecord
2667
+ // };
2656
2668
  var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
2657
2669
  return _this15.normalizePaymentSource(payment, {
2658
2670
  defaultPaid: true
@@ -4185,7 +4197,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4185
4197
  }
4186
4198
  throw new Error('加载销售详情需要 lookup');
4187
4199
  case 3:
4188
- _context35.next = 5;
4200
+ // 如果 lookup 是external_sale_number,则forceRemote强制为 false
4201
+ if (lookup.startsWith('LOCAL_')) {
4202
+ params.forceRemote = false;
4203
+ }
4204
+ _context35.next = 6;
4189
4205
  return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
4190
4206
  with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
4191
4207
  }, params.forceRemote ? {
@@ -4193,13 +4209,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4193
4209
  } : {}), {
4194
4210
  osServer: true
4195
4211
  });
4196
- case 5:
4212
+ case 6:
4197
4213
  res = _context35.sent;
4198
4214
  if (res.code === 200) {
4199
4215
  this.store.lastOrderInfo = res.data;
4200
4216
  }
4201
4217
  return _context35.abrupt("return", res);
4202
- case 8:
4218
+ case 9:
4203
4219
  case "end":
4204
4220
  return _context35.stop();
4205
4221
  }
@@ -719,19 +719,28 @@ var Server = /*#__PURE__*/function () {
719
719
  */
720
720
  _defineProperty(this, "handleUpdateLocalOrder", /*#__PURE__*/function () {
721
721
  var _ref32 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(_ref31) {
722
- var _ref33, _this$app;
722
+ var _data$order_id, _ref33, _this$app;
723
723
  var url, data, batchIds, rawOrderId, orderId, backendPath, _response$data, response, fresh, exists, _yield$_this$order$ov, overwritten, errorMessage;
724
724
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
725
725
  while (1) switch (_context13.prev = _context13.next) {
726
726
  case 0:
727
727
  url = _ref31.url, data = _ref31.data;
728
+ if (!(typeof (data === null || data === void 0 ? void 0 : data.order_id) === 'string' && data !== null && data !== void 0 && (_data$order_id = data.order_id) !== null && _data$order_id !== void 0 && _data$order_id.startsWith('LOCAL_'))) {
729
+ _context13.next = 3;
730
+ break;
731
+ }
732
+ return _context13.abrupt("return", {
733
+ code: 200,
734
+ status: true
735
+ });
736
+ case 3:
728
737
  batchIds = _this.parseOrderIdsParam(url, data);
729
738
  if (!(batchIds.length > 0)) {
730
- _context13.next = 4;
739
+ _context13.next = 6;
731
740
  break;
732
741
  }
733
742
  return _context13.abrupt("return", _this.handleUpdateLocalOrdersBatch(batchIds));
734
- case 4:
743
+ case 6:
735
744
  rawOrderId = (_ref33 = data && _typeof(data) === 'object' ? data.order_id : undefined) !== null && _ref33 !== void 0 ? _ref33 : _this.extractQueryParam(url, 'order_id');
736
745
  orderId = rawOrderId === undefined || rawOrderId === null || rawOrderId === '' ? null : String(rawOrderId).trim();
737
746
  _this.logInfo('handleUpdateLocalOrder: 开始处理', {
@@ -739,7 +748,7 @@ var Server = /*#__PURE__*/function () {
739
748
  orderId: orderId
740
749
  });
741
750
  if (orderId) {
742
- _context13.next = 10;
751
+ _context13.next = 12;
743
752
  break;
744
753
  }
745
754
  _this.logWarning('handleUpdateLocalOrder: order_id 缺失', {
@@ -752,9 +761,9 @@ var Server = /*#__PURE__*/function () {
752
761
  message: 'order_id 缺失',
753
762
  data: null
754
763
  });
755
- case 10:
764
+ case 12:
756
765
  if (_this.order) {
757
- _context13.next = 13;
766
+ _context13.next = 15;
758
767
  break;
759
768
  }
760
769
  _this.logError('handleUpdateLocalOrder: Order 模块未注册');
@@ -764,9 +773,9 @@ var Server = /*#__PURE__*/function () {
764
773
  message: 'Order 模块未注册',
765
774
  data: null
766
775
  });
767
- case 13:
776
+ case 15:
768
777
  if ((_this$app = _this.app) !== null && _this$app !== void 0 && _this$app.request) {
769
- _context13.next = 16;
778
+ _context13.next = 18;
770
779
  break;
771
780
  }
772
781
  _this.logError('handleUpdateLocalOrder: app.request 不可用');
@@ -776,18 +785,18 @@ var Server = /*#__PURE__*/function () {
776
785
  message: 'app.request 不可用',
777
786
  data: null
778
787
  });
779
- case 16:
788
+ case 18:
780
789
  backendPath = "/shop/order/sales/".concat(encodeURIComponent(orderId), "?with%5B%5D=all");
781
- _context13.prev = 17;
782
- _context13.next = 20;
790
+ _context13.prev = 19;
791
+ _context13.next = 22;
783
792
  return _this.app.request.get(backendPath, undefined, {
784
793
  isShopApi: true
785
794
  });
786
- case 20:
795
+ case 22:
787
796
  response = _context13.sent;
788
797
  fresh = (_response$data = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data !== void 0 ? _response$data : response;
789
798
  if (!(!fresh || _typeof(fresh) !== 'object' || fresh.order_id == null)) {
790
- _context13.next = 25;
799
+ _context13.next = 27;
791
800
  break;
792
801
  }
793
802
  _this.logError('handleUpdateLocalOrder: 后端返回订单为空', {
@@ -800,15 +809,15 @@ var Server = /*#__PURE__*/function () {
800
809
  message: '后端返回订单为空',
801
810
  data: null
802
811
  });
803
- case 25:
812
+ case 27:
804
813
  exists = !!_this.order.getOrderByOrderId(orderId);
805
814
  if (!exists) {
806
- _context13.next = 33;
815
+ _context13.next = 35;
807
816
  break;
808
817
  }
809
- _context13.next = 29;
818
+ _context13.next = 31;
810
819
  return _this.order.overwriteExistingOrder(fresh);
811
- case 29:
820
+ case 31:
812
821
  _yield$_this$order$ov = _context13.sent;
813
822
  overwritten = _yield$_this$order$ov.overwritten;
814
823
  _this.logInfo('handleUpdateLocalOrder: 覆盖完成', {
@@ -825,10 +834,10 @@ var Server = /*#__PURE__*/function () {
825
834
  order_id: orderId
826
835
  }
827
836
  });
828
- case 33:
829
- _context13.next = 35;
830
- return _this.order.upsertOrdersFromRemote([fresh]);
831
837
  case 35:
838
+ _context13.next = 37;
839
+ return _this.order.upsertOrdersFromRemote([fresh]);
840
+ case 37:
832
841
  _this.logInfo('handleUpdateLocalOrder: 本地合并新订单完成', {
833
842
  orderId: orderId
834
843
  });
@@ -842,9 +851,9 @@ var Server = /*#__PURE__*/function () {
842
851
  order_id: orderId
843
852
  }
844
853
  });
845
- case 39:
846
- _context13.prev = 39;
847
- _context13.t0 = _context13["catch"](17);
854
+ case 41:
855
+ _context13.prev = 41;
856
+ _context13.t0 = _context13["catch"](19);
848
857
  errorMessage = _context13.t0 instanceof Error ? _context13.t0.message : String(_context13.t0);
849
858
  _this.logError('handleUpdateLocalOrder: 请求失败', {
850
859
  orderId: orderId,
@@ -857,11 +866,11 @@ var Server = /*#__PURE__*/function () {
857
866
  message: errorMessage,
858
867
  data: null
859
868
  });
860
- case 44:
869
+ case 46:
861
870
  case "end":
862
871
  return _context13.stop();
863
872
  }
864
- }, _callee13, null, [[17, 39]]);
873
+ }, _callee13, null, [[19, 41]]);
865
874
  }));
866
875
  return function (_x13) {
867
876
  return _ref32.apply(this, arguments);
@@ -4133,7 +4142,8 @@ var Server = /*#__PURE__*/function () {
4133
4142
  key: "handlePendingSyncCheckoutOrder",
4134
4143
  value: function () {
4135
4144
  var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
4136
- var backendPath, data, title, reason, pendingOrder, errorMessage;
4145
+ var _this10 = this;
4146
+ var backendPath, data, title, reason, pendingOrder, _pendingOrder$payment, _pendingOrder$order_i, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
4137
4147
  return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4138
4148
  while (1) switch (_context45.prev = _context45.next) {
4139
4149
  case 0:
@@ -4176,21 +4186,34 @@ var Server = /*#__PURE__*/function () {
4176
4186
  _context45.next = 13;
4177
4187
  return this.order.upsertPendingSyncOrders([pendingOrder]);
4178
4188
  case 13:
4179
- this.logWarning("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
4189
+ this.logInfo("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
4180
4190
  backendPath: backendPath,
4181
4191
  reason: reason,
4182
4192
  order_id: pendingOrder.order_id,
4183
4193
  external_sale_number: pendingOrder.external_sale_number,
4184
4194
  order_number: pendingOrder.order_number
4185
4195
  });
4196
+ changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
4197
+ var _payment$metadata;
4198
+ 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);
4199
+ }, 0);
4186
4200
  return _context45.abrupt("return", {
4187
4201
  code: 200,
4188
4202
  status: true,
4189
4203
  message: '',
4190
- data: pendingOrder
4204
+ data: {
4205
+ order_id: (_pendingOrder$order_i = pendingOrder === null || pendingOrder === void 0 ? void 0 : pendingOrder.order_id) !== null && _pendingOrder$order_i !== void 0 ? _pendingOrder$order_i : pendingOrder === null || pendingOrder === void 0 ? void 0 : pendingOrder.external_sale_number,
4206
+ amount_gap: pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$summary = pendingOrder.summary) === null || _pendingOrder$summary === void 0 ? void 0 : _pendingOrder$summary.amount_gap,
4207
+ expect_amount: pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$summary2 = pendingOrder.summary) === null || _pendingOrder$summary2 === void 0 ? void 0 : _pendingOrder$summary2.expect_amount,
4208
+ total_amount: pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$summary3 = pendingOrder.summary) === null || _pendingOrder$summary3 === void 0 ? void 0 : _pendingOrder$summary3.total_amount,
4209
+ payment_status: pendingOrder === null || pendingOrder === void 0 ? void 0 : pendingOrder.payment_status,
4210
+ payment_info: {
4211
+ current_change_given_amount: changeGivenAmount
4212
+ }
4213
+ }
4191
4214
  });
4192
- case 17:
4193
- _context45.prev = 17;
4215
+ case 18:
4216
+ _context45.prev = 18;
4194
4217
  _context45.t0 = _context45["catch"](10);
4195
4218
  errorMessage = _context45.t0 instanceof Error ? _context45.t0.message : String(_context45.t0);
4196
4219
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u5F85\u540C\u6B65\u8BA2\u5355\u5931\u8D25"), {
@@ -4204,11 +4227,11 @@ var Server = /*#__PURE__*/function () {
4204
4227
  message: errorMessage,
4205
4228
  data: null
4206
4229
  });
4207
- case 22:
4230
+ case 23:
4208
4231
  case "end":
4209
4232
  return _context45.stop();
4210
4233
  }
4211
- }, _callee45, this, [[10, 17]]);
4234
+ }, _callee45, this, [[10, 18]]);
4212
4235
  }));
4213
4236
  function handlePendingSyncCheckoutOrder(_x48) {
4214
4237
  return _handlePendingSyncCheckoutOrder.apply(this, arguments);
@@ -4302,13 +4325,13 @@ var Server = /*#__PURE__*/function () {
4302
4325
  }, {
4303
4326
  key: "sumPaidOrderPayments",
4304
4327
  value: function sumPaidOrderPayments(payments) {
4305
- var _this10 = this;
4328
+ var _this11 = this;
4306
4329
  if (!Array.isArray(payments)) return 0;
4307
4330
  return payments.reduce(function (sum, payment) {
4308
4331
  var _payment$amount;
4309
4332
  var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
4310
4333
  if (status === 'voided' || status === 'failed' || status === 'cancelled') return sum;
4311
- return sum + _this10.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);
4334
+ 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);
4312
4335
  }, 0);
4313
4336
  }
4314
4337
  }, {
@@ -4324,7 +4347,7 @@ var Server = /*#__PURE__*/function () {
4324
4347
  value: function () {
4325
4348
  var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(order) {
4326
4349
  var _this$products,
4327
- _this11 = this;
4350
+ _this12 = this;
4328
4351
  var products, productIds, entries;
4329
4352
  return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4330
4353
  while (1) switch (_context48.prev = _context48.next) {
@@ -4345,20 +4368,20 @@ var Server = /*#__PURE__*/function () {
4345
4368
  _context48.next = 6;
4346
4369
  return Promise.all(productIds.map( /*#__PURE__*/function () {
4347
4370
  var _ref57 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(id) {
4348
- var _this11$products, _this11$products$getP, product;
4371
+ var _this12$products, _this12$products$getP, product;
4349
4372
  return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4350
4373
  while (1) switch (_context47.prev = _context47.next) {
4351
4374
  case 0:
4352
4375
  _context47.prev = 0;
4353
4376
  _context47.next = 3;
4354
- return (_this11$products = _this11.products) === null || _this11$products === void 0 || (_this11$products$getP = _this11$products.getProductById) === null || _this11$products$getP === void 0 ? void 0 : _this11$products$getP.call(_this11$products, Number(id));
4377
+ 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));
4355
4378
  case 3:
4356
4379
  product = _context47.sent;
4357
4380
  return _context47.abrupt("return", product ? [String(id), product] : null);
4358
4381
  case 7:
4359
4382
  _context47.prev = 7;
4360
4383
  _context47.t0 = _context47["catch"](0);
4361
- _this11.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
4384
+ _this12.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
4362
4385
  product_id: id,
4363
4386
  error: _context47.t0 instanceof Error ? _context47.t0.message : String(_context47.t0)
4364
4387
  });
@@ -4397,13 +4420,13 @@ var Server = /*#__PURE__*/function () {
4397
4420
  }, {
4398
4421
  key: "withPendingSyncProductTitles",
4399
4422
  value: function withPendingSyncProductTitles(order, productMap) {
4400
- var _this12 = this;
4423
+ var _this13 = this;
4401
4424
  var products = Array.isArray(order.products) ? order.products : null;
4402
4425
  if (!(products !== null && products !== void 0 && products.length)) return order;
4403
4426
  return _objectSpread(_objectSpread({}, order), {}, {
4404
4427
  products: products.map(function (product) {
4405
4428
  return _objectSpread(_objectSpread({}, product), {}, {
4406
- product_title: _this12.buildProductTitleSnapshot(product, productMap)
4429
+ product_title: _this13.buildProductTitleSnapshot(product, productMap)
4407
4430
  });
4408
4431
  })
4409
4432
  });
@@ -4414,7 +4437,7 @@ var Server = /*#__PURE__*/function () {
4414
4437
  var _product$product_id2,
4415
4438
  _product$product,
4416
4439
  _fallbackProduct$prod,
4417
- _this13 = this;
4440
+ _this14 = this;
4418
4441
  var productId = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : product.id;
4419
4442
  var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
4420
4443
  var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
@@ -4422,7 +4445,7 @@ var Server = /*#__PURE__*/function () {
4422
4445
  var currentLocale = this.getProductTitleSnapshotCurrentLocale();
4423
4446
  var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
4424
4447
  return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
4425
- snapshot[key] = _this13.resolveProductTitleValue(ownTitle, key, currentLocale) || _this13.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
4448
+ snapshot[key] = _this14.resolveProductTitleValue(ownTitle, key, currentLocale) || _this14.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
4426
4449
  return snapshot;
4427
4450
  }, {});
4428
4451
  }
@@ -4950,10 +4973,10 @@ var Server = /*#__PURE__*/function () {
4950
4973
  value: function extractBackendErrorResponse(error) {
4951
4974
  var _error$response,
4952
4975
  _error$response2,
4953
- _this14 = this;
4976
+ _this15 = this;
4954
4977
  var candidates = [error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.body, error === null || error === void 0 ? void 0 : error.body];
4955
4978
  return candidates.find(function (candidate) {
4956
- return _this14.isExplicitBackendErrorResponse(candidate);
4979
+ return _this15.isExplicitBackendErrorResponse(candidate);
4957
4980
  }) || null;
4958
4981
  }
4959
4982
  }, {
@@ -5265,7 +5288,7 @@ var Server = /*#__PURE__*/function () {
5265
5288
  value: (function () {
5266
5289
  var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(context, options) {
5267
5290
  var _menu_list_ids$length3,
5268
- _this15 = this;
5291
+ _this16 = this;
5269
5292
  var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, product_id, queryIds, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, activeMenuList, tMenu, menuList, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tSort;
5270
5293
  return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5271
5294
  while (1) switch (_context54.prev = _context54.next) {
@@ -5415,8 +5438,8 @@ var Server = /*#__PURE__*/function () {
5415
5438
  tMenu = performance.now();
5416
5439
  menuList = this.menu.getMenuByIds(menu_list_ids);
5417
5440
  activeMenuList = menuList.filter(function (menu) {
5418
- var _this15$schedule;
5419
- return ((_this15$schedule = _this15.schedule) === null || _this15$schedule === void 0 ? void 0 : _this15$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
5441
+ var _this16$schedule;
5442
+ return ((_this16$schedule = _this16.schedule) === null || _this16$schedule === void 0 ? void 0 : _this16$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
5420
5443
  });
5421
5444
  perfMark('computeQuery.filterActiveMenu', performance.now() - tMenu, {
5422
5445
  totalMenu: menuList.length,
@@ -5685,7 +5708,7 @@ var Server = /*#__PURE__*/function () {
5685
5708
  }, {
5686
5709
  key: "notifySalesSearchSubscribers",
5687
5710
  value: function notifySalesSearchSubscribers(payload) {
5688
- var _this16 = this;
5711
+ var _this17 = this;
5689
5712
  if (this.salesSearchSubscribers.size === 0) return;
5690
5713
  var changedOrders = this.extractChangedOrdersFromPayload(payload);
5691
5714
  if (changedOrders.length === 0) {
@@ -5700,21 +5723,21 @@ var Server = /*#__PURE__*/function () {
5700
5723
  subscriber = _step19$value[1];
5701
5724
  try {
5702
5725
  var changedVisibleOrders = changedOrders.filter(function (order) {
5703
- var orderId = _this16.getSalesSearchOrderId(order);
5726
+ var orderId = _this17.getSalesSearchOrderId(order);
5704
5727
  return !!orderId && subscriber.visibleOrderIds.has(orderId);
5705
5728
  });
5706
5729
  if (changedVisibleOrders.length === 0) {
5707
5730
  return 1; // continue
5708
5731
  }
5709
- subscriber.callback(_this16.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
5710
- _this16.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
5732
+ subscriber.callback(_this17.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
5733
+ _this17.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
5711
5734
  subscriberId: subscriberId,
5712
5735
  kind: subscriber.kind,
5713
5736
  count: changedVisibleOrders.length
5714
5737
  });
5715
5738
  } catch (error) {
5716
5739
  var errorMessage = error instanceof Error ? error.message : String(error);
5717
- _this16.logError('notifySalesSearchSubscribers: 推送失败', {
5740
+ _this17.logError('notifySalesSearchSubscribers: 推送失败', {
5718
5741
  subscriberId: subscriberId,
5719
5742
  error: errorMessage
5720
5743
  });
@@ -43,6 +43,7 @@ export declare class OrderModule extends BaseModule implements Module {
43
43
  * @param metadata 日志元数据
44
44
  */
45
45
  private logError;
46
+ private logWarning;
46
47
  /**
47
48
  * 记录订单最近一次 SQLite 写入,供 pubsub 回声去重使用。
48
49
  *
@@ -119,6 +120,9 @@ export declare class OrderModule extends BaseModule implements Module {
119
120
  getRoutes(): RouteDefinition[];
120
121
  destroy(): void;
121
122
  private syncOrdersMap;
123
+ private getOrderMapKey;
124
+ private isBlankIdentityValue;
125
+ private getOrderIdentityEntries;
122
126
  private getOrderIdentityKeys;
123
127
  private extractResourceIds;
124
128
  private getOrderDateKey;
@@ -182,6 +186,15 @@ export declare class OrderModule extends BaseModule implements Module {
182
186
  * // => 'S-1001'
183
187
  */
184
188
  private getOrderStorageKey;
189
+ private getOrderIdentityMatchKeys;
190
+ private doOrdersShareIdentity;
191
+ private findOrderIndexByIdentity;
192
+ private getOrderCompletenessScore;
193
+ private pickPreferredOrder;
194
+ private mergeOrderRecords;
195
+ private summarizeDuplicateOrders;
196
+ private logDuplicateOrders;
197
+ private compactOrderListByIdentity;
185
198
  /**
186
199
  * 当前订单拉取窗口:
187
200
  * - 优先使用 createdAtQuery.sales_time_between(已按营业日边界初始化)