@pisell/pisellos 2.2.324 → 2.2.325

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.
@@ -129,6 +129,7 @@ var Server = /*#__PURE__*/function () {
129
129
  _defineProperty(this, "deviceTaskActionsRegistered", false);
130
130
  _defineProperty(this, "localPaymentUpdateQueues", new Map());
131
131
  _defineProperty(this, "paymentIdentityRefreshes", new Map());
132
+ _defineProperty(this, "receiptFulfillmentConfigInFlight", new Map());
132
133
  _defineProperty(this, "floorPlanQuerySubscribers", new Map());
133
134
  // 模块注册表 - 定义所有可用的模块配置
134
135
  _defineProperty(this, "moduleRegistry", {
@@ -1477,7 +1478,8 @@ var Server = /*#__PURE__*/function () {
1477
1478
  locales: _this.normalizeRequestedReceiptLocales(input.locales),
1478
1479
  invoiceTemplateSettings: input.template_settings === undefined ? undefined : _this.normalizePrintInvoiceTemplateSettings(input.template_settings),
1479
1480
  applyTemplateVisibility: true,
1480
- includeReceiptKeys: input.template_settings !== undefined
1481
+ includeReceiptKeys: input.template_settings !== undefined,
1482
+ refreshResourceReference: true
1481
1483
  });
1482
1484
  case 22:
1483
1485
  rebuiltOrder = _context22.sent;
@@ -5939,6 +5941,123 @@ var Server = /*#__PURE__*/function () {
5939
5941
  });
5940
5942
  return values.join(',');
5941
5943
  }
5944
+
5945
+ /** Refresh derived references on receipt copies; manual references and stored orders stay intact. */
5946
+ }, {
5947
+ key: "withCurrentReceiptResourceReference",
5948
+ value: (function () {
5949
+ var _withCurrentReceiptResourceReference = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(order) {
5950
+ var _order$buzzer,
5951
+ _this$app17,
5952
+ _this18 = this;
5953
+ var resourceReference, businessCode, channel, shopId, tenantId, key, inFlight, _this$getAppData, mode;
5954
+ return _regeneratorRuntime().wrap(function _callee61$(_context61) {
5955
+ while (1) switch (_context61.prev = _context61.next) {
5956
+ case 0:
5957
+ resourceReference = this.buildCheckoutResourceIdentifierBuzzer(order.bookings);
5958
+ if (!(!resourceReference || resourceReference === String((_order$buzzer = order.buzzer) !== null && _order$buzzer !== void 0 ? _order$buzzer : ''))) {
5959
+ _context61.next = 3;
5960
+ break;
5961
+ }
5962
+ return _context61.abrupt("return", order);
5963
+ case 3:
5964
+ businessCode = String(order.business_code || '').trim();
5965
+ channel = String(order.order_sales_channel || '').trim();
5966
+ shopId = this.getAppData('shop_id');
5967
+ tenantId = this.getAppData('tenant_id');
5968
+ if (!(!businessCode || !channel || !shopId || !((_this$app17 = this.app) !== null && _this$app17 !== void 0 && (_this$app17 = _this$app17.request) !== null && _this$app17 !== void 0 && _this$app17.post))) {
5969
+ _context61.next = 9;
5970
+ break;
5971
+ }
5972
+ return _context61.abrupt("return", order);
5973
+ case 9:
5974
+ // A receipt can be printed outside a Sales instance. Read the order's own
5975
+ // business/channel settings rather than borrowing the currently open page.
5976
+ key = JSON.stringify([String(shopId), String(tenantId !== null && tenantId !== void 0 ? tenantId : ''), businessCode, channel]);
5977
+ inFlight = this.receiptFulfillmentConfigInFlight.get(key);
5978
+ if (!inFlight) {
5979
+ inFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60() {
5980
+ var _response$data5;
5981
+ var response;
5982
+ return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5983
+ while (1) switch (_context60.prev = _context60.next) {
5984
+ case 0:
5985
+ _context60.next = 2;
5986
+ return _this18.app.request.post("/open/my-pisell/".concat(shopId, "/setting"), {
5987
+ scope: 'board',
5988
+ target: "".concat(businessCode, "+").concat(channel),
5989
+ section_code: ['fulfillment']
5990
+ }, _objectSpread({
5991
+ pisell2: true,
5992
+ isPisell2: true,
5993
+ prefix: false,
5994
+ customToast: function customToast() {}
5995
+ }, tenantId ? {
5996
+ headers: {
5997
+ 'Tenant-Id': String(tenantId)
5998
+ }
5999
+ } : {}));
6000
+ case 2:
6001
+ response = _context60.sent;
6002
+ if (!((response === null || response === void 0 ? void 0 : response.status) === false || (response === null || response === void 0 ? void 0 : response.code) != null && Number(response.code) !== 200)) {
6003
+ _context60.next = 5;
6004
+ break;
6005
+ }
6006
+ throw new Error('Receipt fulfillment settings are unavailable');
6007
+ case 5:
6008
+ return _context60.abrupt("return", response === null || response === void 0 || (_response$data5 = response.data) === null || _response$data5 === void 0 ? void 0 : _response$data5['fulfillment.fulfillment_ref_mode']);
6009
+ case 6:
6010
+ case "end":
6011
+ return _context60.stop();
6012
+ }
6013
+ }, _callee60);
6014
+ }))();
6015
+ this.receiptFulfillmentConfigInFlight.set(key, inFlight);
6016
+ }
6017
+ _context61.prev = 12;
6018
+ _context61.next = 15;
6019
+ return inFlight;
6020
+ case 15:
6021
+ mode = _context61.sent;
6022
+ if (!(mode !== 'resource_identifier' || String(this.getAppData('shop_id')) !== String(shopId) || String((_this$getAppData = this.getAppData('tenant_id')) !== null && _this$getAppData !== void 0 ? _this$getAppData : '') !== String(tenantId !== null && tenantId !== void 0 ? tenantId : ''))) {
6023
+ _context61.next = 18;
6024
+ break;
6025
+ }
6026
+ return _context61.abrupt("return", order);
6027
+ case 18:
6028
+ return _context61.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
6029
+ buzzer: resourceReference
6030
+ }));
6031
+ case 21:
6032
+ _context61.prev = 21;
6033
+ _context61.t0 = _context61["catch"](12);
6034
+ // Offline/manual printing still works. Without a confirmed policy, do not
6035
+ // mistake a manually entered pickup reference for an obsolete table name.
6036
+ this.logWarning('withCurrentReceiptResourceReference: 配置不可用,保留原取单号', {
6037
+ order_id: order.order_id,
6038
+ target: "".concat(businessCode, "+").concat(channel),
6039
+ error: _context61.t0 instanceof Error ? _context61.t0.message : String(_context61.t0)
6040
+ });
6041
+ return _context61.abrupt("return", order);
6042
+ case 25:
6043
+ _context61.prev = 25;
6044
+ // Only coalesce concurrent outputs; settings changes and failures must be
6045
+ // re-read on the next receipt instead of becoming a permanent cache.
6046
+ if (this.receiptFulfillmentConfigInFlight.get(key) === inFlight) {
6047
+ this.receiptFulfillmentConfigInFlight.delete(key);
6048
+ }
6049
+ return _context61.finish(25);
6050
+ case 28:
6051
+ case "end":
6052
+ return _context61.stop();
6053
+ }
6054
+ }, _callee61, this, [[12, 21, 25, 28]]);
6055
+ }));
6056
+ function withCurrentReceiptResourceReference(_x63) {
6057
+ return _withCurrentReceiptResourceReference.apply(this, arguments);
6058
+ }
6059
+ return withCurrentReceiptResourceReference;
6060
+ }())
5942
6061
  }, {
5943
6062
  key: "getCheckoutResourceIdentifier",
5944
6063
  value: function getCheckoutResourceIdentifier(resource, fallbackName) {
@@ -5971,16 +6090,16 @@ var Server = /*#__PURE__*/function () {
5971
6090
  }, {
5972
6091
  key: "normalizeCheckoutSubmitData",
5973
6092
  value: function () {
5974
- var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(data, title) {
6093
+ var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(data, title) {
5975
6094
  var next, externalSaleNumber, shouldClearLocalOrderId, hasCheckoutOrderNumbers, localOrder;
5976
- return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5977
- while (1) switch (_context60.prev = _context60.next) {
6095
+ return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6096
+ while (1) switch (_context62.prev = _context62.next) {
5978
6097
  case 0:
5979
6098
  if (!(!data || _typeof(data) !== 'object')) {
5980
- _context60.next = 2;
6099
+ _context62.next = 2;
5981
6100
  break;
5982
6101
  }
5983
- return _context60.abrupt("return", data);
6102
+ return _context62.abrupt("return", data);
5984
6103
  case 2:
5985
6104
  next = _objectSpread({}, data);
5986
6105
  externalSaleNumber = next.external_sale_number;
@@ -5990,7 +6109,7 @@ var Server = /*#__PURE__*/function () {
5990
6109
  delete next.vouchers;
5991
6110
  hasCheckoutOrderNumbers = !this.isBlankCheckoutValue(next.shop_order_number) && !this.isBlankCheckoutValue(next.shop_full_order_number);
5992
6111
  if (!hasCheckoutOrderNumbers) {
5993
- _context60.next = 11;
6112
+ _context62.next = 11;
5994
6113
  break;
5995
6114
  }
5996
6115
  this.logInfo("".concat(title, ": checkout \u5DF2\u643A\u5E26\u8BA2\u5355\u53F7\uFF0C\u8DF3\u8FC7\u67E5\u91CD"), {
@@ -6000,10 +6119,10 @@ var Server = /*#__PURE__*/function () {
6000
6119
  shop_order_number: next.shop_order_number,
6001
6120
  shop_full_order_number: next.shop_full_order_number
6002
6121
  });
6003
- return _context60.abrupt("return", next);
6122
+ return _context62.abrupt("return", next);
6004
6123
  case 11:
6005
6124
  if (!this.isBlankCheckoutValue(externalSaleNumber)) {
6006
- _context60.next = 14;
6125
+ _context62.next = 14;
6007
6126
  break;
6008
6127
  }
6009
6128
  if (shouldClearLocalOrderId) {
@@ -6012,10 +6131,10 @@ var Server = /*#__PURE__*/function () {
6012
6131
  order_id: next.order_id
6013
6132
  });
6014
6133
  }
6015
- return _context60.abrupt("return", next);
6134
+ return _context62.abrupt("return", next);
6016
6135
  case 14:
6017
6136
  if (!(!this.order || typeof this.order.getLocalOrderFromMemoryByLookup !== 'function')) {
6018
- _context60.next = 17;
6137
+ _context62.next = 17;
6019
6138
  break;
6020
6139
  }
6021
6140
  if (shouldClearLocalOrderId) {
@@ -6024,12 +6143,12 @@ var Server = /*#__PURE__*/function () {
6024
6143
  external_sale_number: externalSaleNumber
6025
6144
  });
6026
6145
  }
6027
- return _context60.abrupt("return", next);
6146
+ return _context62.abrupt("return", next);
6028
6147
  case 17:
6029
- _context60.prev = 17;
6148
+ _context62.prev = 17;
6030
6149
  localOrder = this.order.getLocalOrderFromMemoryByLookup(externalSaleNumber);
6031
6150
  if (localOrder) {
6032
- _context60.next = 22;
6151
+ _context62.next = 22;
6033
6152
  break;
6034
6153
  }
6035
6154
  if (shouldClearLocalOrderId) {
@@ -6039,7 +6158,7 @@ var Server = /*#__PURE__*/function () {
6039
6158
  localOrderFound: false
6040
6159
  });
6041
6160
  }
6042
- return _context60.abrupt("return", next);
6161
+ return _context62.abrupt("return", next);
6043
6162
  case 22:
6044
6163
  if (this.isBlankCheckoutValue(next.shop_order_number)) {
6045
6164
  next.shop_order_number = localOrder.shop_order_number;
@@ -6056,23 +6175,23 @@ var Server = /*#__PURE__*/function () {
6056
6175
  shop_full_order_number: next.shop_full_order_number
6057
6176
  });
6058
6177
  // 删除 数据体中的 vouchers,对小票和后端来说他们不需要,这个字段只是单向同步给前端用的,而且目前对订单来说还没什么用
6059
- return _context60.abrupt("return", next);
6178
+ return _context62.abrupt("return", next);
6060
6179
  case 28:
6061
- _context60.prev = 28;
6062
- _context60.t0 = _context60["catch"](17);
6180
+ _context62.prev = 28;
6181
+ _context62.t0 = _context62["catch"](17);
6063
6182
  this.logWarning("".concat(title, ": checkout \u67E5\u627E\u672C\u5730\u8BA2\u5355\u5931\u8D25"), {
6064
6183
  external_sale_number: externalSaleNumber,
6065
- error: this.getUnknownErrorMessage(_context60.t0),
6066
- error_detail: this.normalizeUnknownError(_context60.t0)
6184
+ error: this.getUnknownErrorMessage(_context62.t0),
6185
+ error_detail: this.normalizeUnknownError(_context62.t0)
6067
6186
  });
6068
- return _context60.abrupt("return", next);
6187
+ return _context62.abrupt("return", next);
6069
6188
  case 32:
6070
6189
  case "end":
6071
- return _context60.stop();
6190
+ return _context62.stop();
6072
6191
  }
6073
- }, _callee60, this, [[17, 28]]);
6192
+ }, _callee62, this, [[17, 28]]);
6074
6193
  }));
6075
- function normalizeCheckoutSubmitData(_x63, _x64) {
6194
+ function normalizeCheckoutSubmitData(_x64, _x65) {
6076
6195
  return _normalizeCheckoutSubmitData.apply(this, arguments);
6077
6196
  }
6078
6197
  return normalizeCheckoutSubmitData;
@@ -6080,81 +6199,81 @@ var Server = /*#__PURE__*/function () {
6080
6199
  }, {
6081
6200
  key: "ensureCheckoutOrderNumbers",
6082
6201
  value: function () {
6083
- var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(data, title) {
6202
+ var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(data, title) {
6084
6203
  var next, needsShopOrderNumber, needsShopFullOrderNumber, idGenerator;
6085
- return _regeneratorRuntime().wrap(function _callee61$(_context61) {
6086
- while (1) switch (_context61.prev = _context61.next) {
6204
+ return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6205
+ while (1) switch (_context63.prev = _context63.next) {
6087
6206
  case 0:
6088
6207
  if (!(!data || _typeof(data) !== 'object')) {
6089
- _context61.next = 2;
6208
+ _context63.next = 2;
6090
6209
  break;
6091
6210
  }
6092
- return _context61.abrupt("return", data);
6211
+ return _context63.abrupt("return", data);
6093
6212
  case 2:
6094
6213
  next = _objectSpread({}, data);
6095
6214
  needsShopOrderNumber = next.shop_order_number === undefined || next.shop_order_number === null || next.shop_order_number === '';
6096
6215
  needsShopFullOrderNumber = next.shop_full_order_number === undefined || next.shop_full_order_number === null || next.shop_full_order_number === '';
6097
6216
  if (!(!needsShopOrderNumber && !needsShopFullOrderNumber)) {
6098
- _context61.next = 7;
6217
+ _context63.next = 7;
6099
6218
  break;
6100
6219
  }
6101
- return _context61.abrupt("return", this.finalizeCheckoutSalesNotes(next, title));
6220
+ return _context63.abrupt("return", this.finalizeCheckoutSalesNotes(next, title));
6102
6221
  case 7:
6103
6222
  idGenerator = this.getIdGeneratorPlugin();
6104
6223
  if (idGenerator) {
6105
- _context61.next = 11;
6224
+ _context63.next = 11;
6106
6225
  break;
6107
6226
  }
6108
6227
  this.logWarning("".concat(title, ": idGenerator \u63D2\u4EF6\u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u751F\u6210\u8BA2\u5355\u53F7"), {
6109
6228
  needsShopOrderNumber: needsShopOrderNumber,
6110
6229
  needsShopFullOrderNumber: needsShopFullOrderNumber
6111
6230
  });
6112
- return _context61.abrupt("return", this.finalizeCheckoutSalesNotes(next, title));
6231
+ return _context63.abrupt("return", this.finalizeCheckoutSalesNotes(next, title));
6113
6232
  case 11:
6114
- _context61.prev = 11;
6233
+ _context63.prev = 11;
6115
6234
  if (!(needsShopOrderNumber && idGenerator.generateShopOrderNumber)) {
6116
- _context61.next = 16;
6235
+ _context63.next = 16;
6117
6236
  break;
6118
6237
  }
6119
- _context61.next = 15;
6238
+ _context63.next = 15;
6120
6239
  return idGenerator.generateShopOrderNumber({
6121
6240
  biz: next.business_code || 'ticket'
6122
6241
  });
6123
6242
  case 15:
6124
- next.shop_order_number = _context61.sent;
6243
+ next.shop_order_number = _context63.sent;
6125
6244
  case 16:
6126
6245
  if (!(needsShopFullOrderNumber && idGenerator.generateReceiptId)) {
6127
- _context61.next = 20;
6246
+ _context63.next = 20;
6128
6247
  break;
6129
6248
  }
6130
- _context61.next = 19;
6249
+ _context63.next = 19;
6131
6250
  return idGenerator.generateReceiptId({
6132
6251
  biz: next.business_code || 'ticket'
6133
6252
  });
6134
6253
  case 19:
6135
- next.shop_full_order_number = _context61.sent;
6254
+ next.shop_full_order_number = _context63.sent;
6136
6255
  case 20:
6137
6256
  this.logInfo("".concat(title, ": checkout \u8BA2\u5355\u53F7\u5DF2\u51C6\u5907"), {
6138
6257
  shop_order_number: next.shop_order_number,
6139
6258
  shop_full_order_number: next.shop_full_order_number
6140
6259
  });
6141
- _context61.next = 26;
6260
+ _context63.next = 26;
6142
6261
  break;
6143
6262
  case 23:
6144
- _context61.prev = 23;
6145
- _context61.t0 = _context61["catch"](11);
6263
+ _context63.prev = 23;
6264
+ _context63.t0 = _context63["catch"](11);
6146
6265
  this.logError("".concat(title, ": \u751F\u6210 checkout \u8BA2\u5355\u53F7\u5931\u8D25"), {
6147
- error: _context61.t0 instanceof Error ? _context61.t0.message : String(_context61.t0)
6266
+ error: _context63.t0 instanceof Error ? _context63.t0.message : String(_context63.t0)
6148
6267
  });
6149
6268
  case 26:
6150
- return _context61.abrupt("return", this.finalizeCheckoutSalesNotes(next, title));
6269
+ return _context63.abrupt("return", this.finalizeCheckoutSalesNotes(next, title));
6151
6270
  case 27:
6152
6271
  case "end":
6153
- return _context61.stop();
6272
+ return _context63.stop();
6154
6273
  }
6155
- }, _callee61, this, [[11, 23]]);
6274
+ }, _callee63, this, [[11, 23]]);
6156
6275
  }));
6157
- function ensureCheckoutOrderNumbers(_x65, _x66) {
6276
+ function ensureCheckoutOrderNumbers(_x66, _x67) {
6158
6277
  return _ensureCheckoutOrderNumbers.apply(this, arguments);
6159
6278
  }
6160
6279
  return ensureCheckoutOrderNumbers;
@@ -6201,27 +6320,27 @@ var Server = /*#__PURE__*/function () {
6201
6320
  }, {
6202
6321
  key: "dispatchCheckoutSyncTask",
6203
6322
  value: function () {
6204
- var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
6323
+ var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(params) {
6205
6324
  var deviceTask, debugDeviceId, debugIdempotencyKey, _params$data, _params$data2, _params$data3, _params$data4, result;
6206
- return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6207
- while (1) switch (_context62.prev = _context62.next) {
6325
+ return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6326
+ while (1) switch (_context64.prev = _context64.next) {
6208
6327
  case 0:
6209
6328
  this.registerDeviceTaskActions();
6210
6329
  deviceTask = this.getDeviceTaskPlugin();
6211
- _context62.next = 4;
6330
+ _context64.next = 4;
6212
6331
  return this.getShortNumberOrDeviceId();
6213
6332
  case 4:
6214
- debugDeviceId = _context62.sent;
6333
+ debugDeviceId = _context64.sent;
6215
6334
  debugIdempotencyKey = this.buildCheckoutTaskIdempotencyKey(params.data);
6216
6335
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
6217
- _context62.next = 9;
6336
+ _context64.next = 9;
6218
6337
  break;
6219
6338
  }
6220
6339
  this.logError("".concat(params.title, ": deviceTask.dispatch \u4E0D\u53EF\u7528"));
6221
- return _context62.abrupt("return");
6340
+ return _context64.abrupt("return");
6222
6341
  case 9:
6223
- _context62.prev = 9;
6224
- _context62.next = 12;
6342
+ _context64.prev = 9;
6343
+ _context64.next = 12;
6225
6344
  return deviceTask.dispatch({
6226
6345
  action: 'sync_sales',
6227
6346
  device_id: debugDeviceId,
@@ -6241,27 +6360,27 @@ var Server = /*#__PURE__*/function () {
6241
6360
  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)
6242
6361
  });
6243
6362
  case 12:
6244
- result = _context62.sent;
6363
+ result = _context64.sent;
6245
6364
  this.logInfo("".concat(params.title, ": sync_sales \u4EFB\u52A1\u5DF2\u6D3E\u53D1"), {
6246
6365
  uuid: result === null || result === void 0 ? void 0 : result.uuid,
6247
6366
  status: result === null || result === void 0 ? void 0 : result.status,
6248
6367
  reused: result === null || result === void 0 ? void 0 : result.reused
6249
6368
  });
6250
- _context62.next = 19;
6369
+ _context64.next = 19;
6251
6370
  break;
6252
6371
  case 16:
6253
- _context62.prev = 16;
6254
- _context62.t0 = _context62["catch"](9);
6372
+ _context64.prev = 16;
6373
+ _context64.t0 = _context64["catch"](9);
6255
6374
  this.logError("".concat(params.title, ": \u6D3E\u53D1 sync_sales \u4EFB\u52A1\u5931\u8D25"), {
6256
- error: _context62.t0 instanceof Error ? _context62.t0.message : String(_context62.t0)
6375
+ error: _context64.t0 instanceof Error ? _context64.t0.message : String(_context64.t0)
6257
6376
  });
6258
6377
  case 19:
6259
6378
  case "end":
6260
- return _context62.stop();
6379
+ return _context64.stop();
6261
6380
  }
6262
- }, _callee62, this, [[9, 16]]);
6381
+ }, _callee64, this, [[9, 16]]);
6263
6382
  }));
6264
- function dispatchCheckoutSyncTask(_x67) {
6383
+ function dispatchCheckoutSyncTask(_x68) {
6265
6384
  return _dispatchCheckoutSyncTask.apply(this, arguments);
6266
6385
  }
6267
6386
  return dispatchCheckoutSyncTask;
@@ -6269,26 +6388,26 @@ var Server = /*#__PURE__*/function () {
6269
6388
  }, {
6270
6389
  key: "dispatchPrintOtherReceiptTask",
6271
6390
  value: function () {
6272
- var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
6391
+ var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(params) {
6273
6392
  var deviceTask, _params$deviceId, _params$syncedOrder, _params$syncedOrder2, _params$syncedOrder3, printIdentity, deviceId;
6274
- return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6275
- while (1) switch (_context63.prev = _context63.next) {
6393
+ return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6394
+ while (1) switch (_context65.prev = _context65.next) {
6276
6395
  case 0:
6277
6396
  deviceTask = this.getDeviceTaskPlugin();
6278
6397
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
6279
- _context63.next = 4;
6398
+ _context65.next = 4;
6280
6399
  break;
6281
6400
  }
6282
6401
  this.logWarning('dispatchPrintOtherReceiptTask: deviceTask.dispatch 不可用');
6283
- return _context63.abrupt("return");
6402
+ return _context65.abrupt("return");
6284
6403
  case 4:
6285
- _context63.prev = 4;
6404
+ _context65.prev = 4;
6286
6405
  printIdentity = this.getPrintOrderIdentity(params.syncedOrder);
6287
- _context63.next = 8;
6406
+ _context65.next = 8;
6288
6407
  return this.getShortNumberOrDeviceId();
6289
6408
  case 8:
6290
- deviceId = _context63.sent;
6291
- _context63.next = 11;
6409
+ deviceId = _context65.sent;
6410
+ _context65.next = 11;
6292
6411
  return deviceTask.dispatch({
6293
6412
  action: 'print_all',
6294
6413
  device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : deviceId,
@@ -6317,21 +6436,21 @@ var Server = /*#__PURE__*/function () {
6317
6436
  source_id: printIdentity
6318
6437
  });
6319
6438
  case 11:
6320
- _context63.next = 16;
6439
+ _context65.next = 16;
6321
6440
  break;
6322
6441
  case 13:
6323
- _context63.prev = 13;
6324
- _context63.t0 = _context63["catch"](4);
6442
+ _context65.prev = 13;
6443
+ _context65.t0 = _context65["catch"](4);
6325
6444
  this.logError('dispatchPrintOtherReceiptTask: 派发失败', {
6326
- error: _context63.t0 instanceof Error ? _context63.t0.message : String(_context63.t0)
6445
+ error: _context65.t0 instanceof Error ? _context65.t0.message : String(_context65.t0)
6327
6446
  });
6328
6447
  case 16:
6329
6448
  case "end":
6330
- return _context63.stop();
6449
+ return _context65.stop();
6331
6450
  }
6332
- }, _callee63, this, [[4, 13]]);
6451
+ }, _callee65, this, [[4, 13]]);
6333
6452
  }));
6334
- function dispatchPrintOtherReceiptTask(_x68) {
6453
+ function dispatchPrintOtherReceiptTask(_x69) {
6335
6454
  return _dispatchPrintOtherReceiptTask.apply(this, arguments);
6336
6455
  }
6337
6456
  return dispatchPrintOtherReceiptTask;
@@ -6351,34 +6470,35 @@ var Server = /*#__PURE__*/function () {
6351
6470
  }, {
6352
6471
  key: "dispatchLocalReceiptPrint",
6353
6472
  value: function () {
6354
- var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(params) {
6473
+ var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(params) {
6355
6474
  var _payment_info2;
6356
6475
  var printableOrder;
6357
- return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6358
- while (1) switch (_context64.prev = _context64.next) {
6476
+ return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6477
+ while (1) switch (_context66.prev = _context66.next) {
6359
6478
  case 0:
6360
6479
  if (!(params.requireFullyPaid && !this.isSalesOrderFullyPaid(params.order))) {
6361
- _context64.next = 2;
6480
+ _context66.next = 2;
6362
6481
  break;
6363
6482
  }
6364
- return _context64.abrupt("return", {
6483
+ return _context66.abrupt("return", {
6365
6484
  printed: false,
6366
6485
  order: params.order
6367
6486
  });
6368
6487
  case 2:
6369
- _context64.next = 4;
6488
+ _context66.next = 4;
6370
6489
  return this.withLocalSmallTicketData(params.order, {
6371
6490
  requireFullyPaid: params.requireFullyPaid,
6372
6491
  invoiceTemplateSettings: params.invoiceTemplateSettings,
6373
- applyTemplateVisibility: true
6492
+ applyTemplateVisibility: true,
6493
+ refreshResourceReference: true
6374
6494
  });
6375
6495
  case 4:
6376
- printableOrder = _context64.sent;
6496
+ printableOrder = _context66.sent;
6377
6497
  if (hasSmallTicketData((_payment_info2 = printableOrder.payment_info) === null || _payment_info2 === void 0 ? void 0 : _payment_info2.small_ticket_data)) {
6378
- _context64.next = 7;
6498
+ _context66.next = 7;
6379
6499
  break;
6380
6500
  }
6381
- return _context64.abrupt("return", {
6501
+ return _context66.abrupt("return", {
6382
6502
  printed: false,
6383
6503
  order: printableOrder
6384
6504
  });
@@ -6388,7 +6508,7 @@ var Server = /*#__PURE__*/function () {
6388
6508
  printableOrder: printableOrder,
6389
6509
  response: params.response
6390
6510
  });
6391
- _context64.next = 10;
6511
+ _context66.next = 10;
6392
6512
  return this.dispatchPrintOtherReceiptTask({
6393
6513
  checkoutData: params.checkoutData,
6394
6514
  syncedOrder: printableOrder,
@@ -6399,17 +6519,17 @@ var Server = /*#__PURE__*/function () {
6399
6519
  invoiceTemplateSettings: params.invoiceTemplateSettings
6400
6520
  });
6401
6521
  case 10:
6402
- return _context64.abrupt("return", {
6522
+ return _context66.abrupt("return", {
6403
6523
  printed: true,
6404
6524
  order: requiresInvoiceDataFiltering(params.invoiceTemplateSettings) ? params.order : printableOrder
6405
6525
  });
6406
6526
  case 11:
6407
6527
  case "end":
6408
- return _context64.stop();
6528
+ return _context66.stop();
6409
6529
  }
6410
- }, _callee64, this);
6530
+ }, _callee66, this);
6411
6531
  }));
6412
- function dispatchLocalReceiptPrint(_x69) {
6532
+ function dispatchLocalReceiptPrint(_x70) {
6413
6533
  return _dispatchLocalReceiptPrint.apply(this, arguments);
6414
6534
  }
6415
6535
  return dispatchLocalReceiptPrint;
@@ -6436,15 +6556,15 @@ var Server = /*#__PURE__*/function () {
6436
6556
  }, {
6437
6557
  key: "mergeLocalPrintOrderInput",
6438
6558
  value: function mergeLocalPrintOrderInput(localOrder, inputOrder) {
6439
- var _ref72, _localOrder$order_id, _ref73, _external_sale_number4;
6440
- var definedInput = Object.fromEntries(Object.entries(inputOrder || {}).filter(function (_ref70) {
6441
- var _ref71 = _slicedToArray(_ref70, 2),
6442
- value = _ref71[1];
6559
+ var _ref73, _localOrder$order_id, _ref74, _external_sale_number4;
6560
+ var definedInput = Object.fromEntries(Object.entries(inputOrder || {}).filter(function (_ref71) {
6561
+ var _ref72 = _slicedToArray(_ref71, 2),
6562
+ value = _ref72[1];
6443
6563
  return value !== undefined;
6444
6564
  }));
6445
6565
  return _objectSpread(_objectSpread(_objectSpread({}, localOrder), definedInput), {}, {
6446
- order_id: (_ref72 = (_localOrder$order_id = localOrder.order_id) !== null && _localOrder$order_id !== void 0 ? _localOrder$order_id : definedInput.order_id) !== null && _ref72 !== void 0 ? _ref72 : definedInput.orderId,
6447
- external_sale_number: (_ref73 = (_external_sale_number4 = localOrder.external_sale_number) !== null && _external_sale_number4 !== void 0 ? _external_sale_number4 : definedInput.external_sale_number) !== null && _ref73 !== void 0 ? _ref73 : definedInput.externalSaleNumber
6566
+ order_id: (_ref73 = (_localOrder$order_id = localOrder.order_id) !== null && _localOrder$order_id !== void 0 ? _localOrder$order_id : definedInput.order_id) !== null && _ref73 !== void 0 ? _ref73 : definedInput.orderId,
6567
+ external_sale_number: (_ref74 = (_external_sale_number4 = localOrder.external_sale_number) !== null && _external_sale_number4 !== void 0 ? _external_sale_number4 : definedInput.external_sale_number) !== null && _ref74 !== void 0 ? _ref74 : definedInput.externalSaleNumber
6448
6568
  });
6449
6569
  }
6450
6570
  }, {
@@ -6468,57 +6588,57 @@ var Server = /*#__PURE__*/function () {
6468
6588
  }, {
6469
6589
  key: "syncMachinecodeRedeemStatusToLocalOrder",
6470
6590
  value: function () {
6471
- var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(data, ids, status) {
6591
+ var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(data, ids, status) {
6472
6592
  var _this$order5, _data$order_id2;
6473
6593
  var title, lookup, localOrder, orderId, voucherIdSet, vouchers, hasUpdatedVoucher, nextVouchers;
6474
- return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6475
- while (1) switch (_context65.prev = _context65.next) {
6594
+ return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6595
+ while (1) switch (_context67.prev = _context67.next) {
6476
6596
  case 0:
6477
6597
  title = 'handleMachinecodeBatchMetadata';
6478
6598
  lookup = this.resolveMachinecodeBatchMetadataLookup(data);
6479
6599
  if (!(lookup === undefined)) {
6480
- _context65.next = 5;
6600
+ _context67.next = 5;
6481
6601
  break;
6482
6602
  }
6483
6603
  this.logWarning("".concat(title, ": order lookup \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
6484
6604
  batchSize: ids.length,
6485
6605
  status: status
6486
6606
  });
6487
- return _context65.abrupt("return");
6607
+ return _context67.abrupt("return");
6488
6608
  case 5:
6489
6609
  if ((_this$order5 = this.order) !== null && _this$order5 !== void 0 && _this$order5.getLocalOrderByLookup) {
6490
- _context65.next = 8;
6610
+ _context67.next = 8;
6491
6611
  break;
6492
6612
  }
6493
6613
  this.logWarning("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
6494
6614
  lookup: lookup,
6495
6615
  status: status
6496
6616
  });
6497
- return _context65.abrupt("return");
6617
+ return _context67.abrupt("return");
6498
6618
  case 8:
6499
- _context65.next = 10;
6619
+ _context67.next = 10;
6500
6620
  return this.order.getLocalOrderByLookup(lookup);
6501
6621
  case 10:
6502
- localOrder = _context65.sent;
6622
+ localOrder = _context67.sent;
6503
6623
  orderId = (_data$order_id2 = data === null || data === void 0 ? void 0 : data.order_id) !== null && _data$order_id2 !== void 0 ? _data$order_id2 : data === null || data === void 0 ? void 0 : data.orderId;
6504
6624
  if (!(!localOrder && orderId !== undefined && orderId !== null && orderId !== '' && String(orderId) !== String(lookup))) {
6505
- _context65.next = 16;
6625
+ _context67.next = 16;
6506
6626
  break;
6507
6627
  }
6508
- _context65.next = 15;
6628
+ _context67.next = 15;
6509
6629
  return this.order.getLocalOrderByLookup(orderId);
6510
6630
  case 15:
6511
- localOrder = _context65.sent;
6631
+ localOrder = _context67.sent;
6512
6632
  case 16:
6513
6633
  if (localOrder) {
6514
- _context65.next = 19;
6634
+ _context67.next = 19;
6515
6635
  break;
6516
6636
  }
6517
6637
  this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
6518
6638
  lookup: lookup,
6519
6639
  status: status
6520
6640
  });
6521
- return _context65.abrupt("return");
6641
+ return _context67.abrupt("return");
6522
6642
  case 19:
6523
6643
  voucherIdSet = new Set(ids.filter(function (id) {
6524
6644
  return id !== undefined && id !== null && id !== '';
@@ -6526,14 +6646,14 @@ var Server = /*#__PURE__*/function () {
6526
6646
  return String(id);
6527
6647
  }));
6528
6648
  if (!(voucherIdSet.size === 0)) {
6529
- _context65.next = 23;
6649
+ _context67.next = 23;
6530
6650
  break;
6531
6651
  }
6532
6652
  this.logWarning("".concat(title, ": voucher ids \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
6533
6653
  lookup: lookup,
6534
6654
  status: status
6535
6655
  });
6536
- return _context65.abrupt("return");
6656
+ return _context67.abrupt("return");
6537
6657
  case 23:
6538
6658
  vouchers = Array.isArray(localOrder.vouchers) ? localOrder.vouchers : [];
6539
6659
  hasUpdatedVoucher = false;
@@ -6547,7 +6667,7 @@ var Server = /*#__PURE__*/function () {
6547
6667
  });
6548
6668
  });
6549
6669
  if (hasUpdatedVoucher) {
6550
- _context65.next = 29;
6670
+ _context67.next = 29;
6551
6671
  break;
6552
6672
  }
6553
6673
  this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u672A\u547D\u4E2D\u4EFB\u4F55 voucher\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
@@ -6555,13 +6675,13 @@ var Server = /*#__PURE__*/function () {
6555
6675
  voucher_ids: Array.from(voucherIdSet),
6556
6676
  status: status
6557
6677
  });
6558
- return _context65.abrupt("return");
6678
+ return _context67.abrupt("return");
6559
6679
  case 29:
6560
6680
  if (!(typeof this.order.overwriteExistingOrder === 'function')) {
6561
- _context65.next = 34;
6681
+ _context67.next = 34;
6562
6682
  break;
6563
6683
  }
6564
- _context65.next = 32;
6684
+ _context67.next = 32;
6565
6685
  return this.order.overwriteExistingOrder(_objectSpread(_objectSpread({}, localOrder), {}, {
6566
6686
  vouchers: nextVouchers
6567
6687
  }));
@@ -6571,13 +6691,13 @@ var Server = /*#__PURE__*/function () {
6571
6691
  updatedCount: voucherIdSet.size,
6572
6692
  status: status
6573
6693
  });
6574
- return _context65.abrupt("return");
6694
+ return _context67.abrupt("return");
6575
6695
  case 34:
6576
6696
  if (!(data !== null && data !== void 0 && data.external_sale_number && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
6577
- _context65.next = 39;
6697
+ _context67.next = 39;
6578
6698
  break;
6579
6699
  }
6580
- _context65.next = 37;
6700
+ _context67.next = 37;
6581
6701
  return this.order.markOrderSyncedByExternalSaleNumber({
6582
6702
  externalSaleNumber: data.external_sale_number,
6583
6703
  patch: {
@@ -6590,7 +6710,7 @@ var Server = /*#__PURE__*/function () {
6590
6710
  updatedCount: voucherIdSet.size,
6591
6711
  status: status
6592
6712
  });
6593
- return _context65.abrupt("return");
6713
+ return _context67.abrupt("return");
6594
6714
  case 39:
6595
6715
  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"), {
6596
6716
  lookup: lookup,
@@ -6598,11 +6718,11 @@ var Server = /*#__PURE__*/function () {
6598
6718
  });
6599
6719
  case 40:
6600
6720
  case "end":
6601
- return _context65.stop();
6721
+ return _context67.stop();
6602
6722
  }
6603
- }, _callee65, this);
6723
+ }, _callee67, this);
6604
6724
  }));
6605
- function syncMachinecodeRedeemStatusToLocalOrder(_x70, _x71, _x72) {
6725
+ function syncMachinecodeRedeemStatusToLocalOrder(_x71, _x72, _x73) {
6606
6726
  return _syncMachinecodeRedeemStatusToLocalOrder.apply(this, arguments);
6607
6727
  }
6608
6728
  return syncMachinecodeRedeemStatusToLocalOrder;
@@ -6610,30 +6730,30 @@ var Server = /*#__PURE__*/function () {
6610
6730
  }, {
6611
6731
  key: "handleOrderCheckoutSubmit",
6612
6732
  value: function () {
6613
- var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(params) {
6733
+ var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(params) {
6614
6734
  var _params$data5, _params$data6, _this$order6, _this$order6$getLocal;
6615
6735
  var backendPath, title, lookup, localOrder, extractedInvoice, extractedTemplateSettings, data, invoiceLayoutConfig, invoiceTemplateSettings, receiptAutoPrintPaymentStatuses, normalizedData, numberedData, checkoutData, pendingResult, pendingOrder;
6616
- return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6617
- while (1) switch (_context66.prev = _context66.next) {
6736
+ return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6737
+ while (1) switch (_context68.prev = _context68.next) {
6618
6738
  case 0:
6619
6739
  backendPath = params.backendPath, title = params.title;
6620
6740
  lookup = ((_params$data5 = params.data) === null || _params$data5 === void 0 ? void 0 : _params$data5.order_id) || ((_params$data6 = params.data) === null || _params$data6 === void 0 ? void 0 : _params$data6.external_sale_number);
6621
- _context66.t0 = lookup;
6622
- if (!_context66.t0) {
6623
- _context66.next = 7;
6741
+ _context68.t0 = lookup;
6742
+ if (!_context68.t0) {
6743
+ _context68.next = 7;
6624
6744
  break;
6625
6745
  }
6626
- _context66.next = 6;
6746
+ _context68.next = 6;
6627
6747
  return (_this$order6 = this.order) === null || _this$order6 === void 0 || (_this$order6$getLocal = _this$order6.getLocalOrderByLookup) === null || _this$order6$getLocal === void 0 ? void 0 : _this$order6$getLocal.call(_this$order6, lookup);
6628
6748
  case 6:
6629
- _context66.t0 = _context66.sent;
6749
+ _context68.t0 = _context68.sent;
6630
6750
  case 7:
6631
- localOrder = _context66.t0;
6751
+ localOrder = _context68.t0;
6632
6752
  if (!(requiresLocalPaymentRefresh(params.data) || requiresLocalPaymentRefresh(localOrder))) {
6633
- _context66.next = 10;
6753
+ _context68.next = 10;
6634
6754
  break;
6635
6755
  }
6636
- return _context66.abrupt("return", {
6756
+ return _context68.abrupt("return", {
6637
6757
  code: 409,
6638
6758
  status: false,
6639
6759
  message: PAYMENT_REFRESH_MESSAGE,
@@ -6657,10 +6777,10 @@ var Server = /*#__PURE__*/function () {
6657
6777
  order_number: data === null || data === void 0 ? void 0 : data.order_number
6658
6778
  });
6659
6779
  if (!(data !== null && data !== void 0 && data.sync_mode || data !== null && data !== void 0 && data.syncMode)) {
6660
- _context66.next = 19;
6780
+ _context68.next = 19;
6661
6781
  break;
6662
6782
  }
6663
- return _context66.abrupt("return", this.handleSyncCheckoutSubmit({
6783
+ return _context68.abrupt("return", this.handleSyncCheckoutSubmit({
6664
6784
  backendPath: backendPath,
6665
6785
  data: data,
6666
6786
  title: title,
@@ -6669,16 +6789,16 @@ var Server = /*#__PURE__*/function () {
6669
6789
  receiptAutoPrintPaymentStatuses: receiptAutoPrintPaymentStatuses
6670
6790
  }));
6671
6791
  case 19:
6672
- _context66.next = 21;
6792
+ _context68.next = 21;
6673
6793
  return this.normalizeCheckoutSubmitData(data, title);
6674
6794
  case 21:
6675
- normalizedData = _context66.sent;
6676
- _context66.next = 24;
6795
+ normalizedData = _context68.sent;
6796
+ _context68.next = 24;
6677
6797
  return this.ensureCheckoutOrderNumbers(normalizedData, title);
6678
6798
  case 24:
6679
- numberedData = _context66.sent;
6799
+ numberedData = _context68.sent;
6680
6800
  checkoutData = this.normalizeCheckoutCollections(stripOsPrivatePayloadFields(this.applyCheckoutFulfillmentBuzzer(numberedData, title)));
6681
- _context66.next = 28;
6801
+ _context68.next = 28;
6682
6802
  return this.handlePendingSyncCheckoutOrder({
6683
6803
  backendPath: backendPath,
6684
6804
  data: checkoutData,
@@ -6687,18 +6807,18 @@ var Server = /*#__PURE__*/function () {
6687
6807
  invoiceTemplateSettings: invoiceTemplateSettings
6688
6808
  });
6689
6809
  case 28:
6690
- pendingResult = _context66.sent;
6810
+ pendingResult = _context68.sent;
6691
6811
  if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
6692
- _context66.next = 43;
6812
+ _context68.next = 43;
6693
6813
  break;
6694
6814
  }
6695
6815
  pendingOrder = pendingResult.data;
6696
6816
  if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData, invoiceTemplateSettings) && this.shouldAutoPrintReceiptForPaymentStatus(pendingOrder, receiptAutoPrintPaymentStatuses) && this.shouldAutoPrintCheckoutReceipt())) {
6697
- _context66.next = 41;
6817
+ _context68.next = 41;
6698
6818
  break;
6699
6819
  }
6700
- _context66.prev = 32;
6701
- _context66.next = 35;
6820
+ _context68.prev = 32;
6821
+ _context68.next = 35;
6702
6822
  return this.dispatchLocalReceiptPrint({
6703
6823
  checkoutData: checkoutData,
6704
6824
  order: pendingOrder,
@@ -6708,19 +6828,19 @@ var Server = /*#__PURE__*/function () {
6708
6828
  invoiceTemplateSettings: invoiceTemplateSettings
6709
6829
  });
6710
6830
  case 35:
6711
- _context66.next = 41;
6831
+ _context68.next = 41;
6712
6832
  break;
6713
6833
  case 37:
6714
- _context66.prev = 37;
6715
- _context66.t1 = _context66["catch"](32);
6834
+ _context68.prev = 37;
6835
+ _context68.t1 = _context68["catch"](32);
6716
6836
  // The sale is already persisted. A failed receipt must not cancel its
6717
6837
  // sync task or send an unfiltered fallback to the printer.
6718
- pendingResult.receipt_print_error = this.getUnknownErrorMessage(_context66.t1);
6838
+ pendingResult.receipt_print_error = this.getUnknownErrorMessage(_context68.t1);
6719
6839
  this.logError("".concat(title, ": \u5C0F\u7968\u751F\u6210\u5931\u8D25\uFF0C\u8BA2\u5355\u4ECD\u7EE7\u7EED\u540C\u6B65"), {
6720
6840
  error: pendingResult.receipt_print_error
6721
6841
  });
6722
6842
  case 41:
6723
- _context66.next = 43;
6843
+ _context68.next = 43;
6724
6844
  return this.dispatchCheckoutSyncTask({
6725
6845
  backendPath: backendPath,
6726
6846
  data: checkoutData,
@@ -6730,23 +6850,23 @@ var Server = /*#__PURE__*/function () {
6730
6850
  });
6731
6851
  case 43:
6732
6852
  if (pendingResult.data.order_id) {
6733
- _context66.next = 45;
6853
+ _context68.next = 45;
6734
6854
  break;
6735
6855
  }
6736
- return _context66.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
6856
+ return _context68.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
6737
6857
  data: _objectSpread(_objectSpread({}, pendingResult.data), {}, {
6738
6858
  order_id: pendingResult.data.external_sale_number
6739
6859
  })
6740
6860
  }));
6741
6861
  case 45:
6742
- return _context66.abrupt("return", pendingResult);
6862
+ return _context68.abrupt("return", pendingResult);
6743
6863
  case 46:
6744
6864
  case "end":
6745
- return _context66.stop();
6865
+ return _context68.stop();
6746
6866
  }
6747
- }, _callee66, this, [[32, 37]]);
6867
+ }, _callee68, this, [[32, 37]]);
6748
6868
  }));
6749
- function handleOrderCheckoutSubmit(_x73) {
6869
+ function handleOrderCheckoutSubmit(_x74) {
6750
6870
  return _handleOrderCheckoutSubmit.apply(this, arguments);
6751
6871
  }
6752
6872
  return handleOrderCheckoutSubmit;
@@ -6754,27 +6874,27 @@ var Server = /*#__PURE__*/function () {
6754
6874
  }, {
6755
6875
  key: "handleSyncCheckoutSubmit",
6756
6876
  value: function () {
6757
- var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(params) {
6758
- var _this$app17;
6877
+ var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(params) {
6878
+ var _this$app18;
6759
6879
  var backendPath, data, title, invoiceLayoutConfig, invoiceTemplateSettings, receiptAutoPrintPaymentStatuses, syncResult, _normalized$data, normalized, response, syncedOrder, backendError, _normalized$data2, _normalized, message;
6760
- return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6761
- while (1) switch (_context67.prev = _context67.next) {
6880
+ return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6881
+ while (1) switch (_context69.prev = _context69.next) {
6762
6882
  case 0:
6763
6883
  backendPath = params.backendPath, data = params.data, title = params.title, invoiceLayoutConfig = params.invoiceLayoutConfig, invoiceTemplateSettings = params.invoiceTemplateSettings, receiptAutoPrintPaymentStatuses = params.receiptAutoPrintPaymentStatuses;
6764
- if ((_this$app17 = this.app) !== null && _this$app17 !== void 0 && (_this$app17 = _this$app17.request) !== null && _this$app17 !== void 0 && _this$app17.post) {
6765
- _context67.next = 4;
6884
+ if ((_this$app18 = this.app) !== null && _this$app18 !== void 0 && (_this$app18 = _this$app18.request) !== null && _this$app18 !== void 0 && _this$app18.post) {
6885
+ _context69.next = 4;
6766
6886
  break;
6767
6887
  }
6768
6888
  this.logError("".concat(title, ": sync checkout app.request \u4E0D\u53EF\u7528"));
6769
- return _context67.abrupt("return", {
6889
+ return _context69.abrupt("return", {
6770
6890
  code: 500,
6771
6891
  status: false,
6772
6892
  message: 'app.request 不可用',
6773
6893
  data: null
6774
6894
  });
6775
6895
  case 4:
6776
- _context67.prev = 4;
6777
- _context67.next = 7;
6896
+ _context69.prev = 4;
6897
+ _context69.next = 7;
6778
6898
  return this.runCheckoutSync({
6779
6899
  backendPath: backendPath,
6780
6900
  data: data,
@@ -6784,13 +6904,13 @@ var Server = /*#__PURE__*/function () {
6784
6904
  invoiceTemplateSettings: invoiceTemplateSettings
6785
6905
  });
6786
6906
  case 7:
6787
- syncResult = _context67.sent;
6907
+ syncResult = _context69.sent;
6788
6908
  if (!syncResult.rejected) {
6789
- _context67.next = 11;
6909
+ _context69.next = 11;
6790
6910
  break;
6791
6911
  }
6792
6912
  normalized = this.normalizeCheckoutResponse(syncResult.errorResponse);
6793
- return _context67.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
6913
+ return _context69.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
6794
6914
  status: false,
6795
6915
  message: syncResult.message || (normalized === null || normalized === void 0 ? void 0 : normalized.message) || '后端明确拒绝 checkout',
6796
6916
  data: (_normalized$data = normalized === null || normalized === void 0 ? void 0 : normalized.data) !== null && _normalized$data !== void 0 ? _normalized$data : null
@@ -6799,11 +6919,11 @@ var Server = /*#__PURE__*/function () {
6799
6919
  response = this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder);
6800
6920
  syncedOrder = syncResult.syncedOrder;
6801
6921
  if (!(syncedOrder && this.shouldBuildSmallTicketData(syncResult.checkoutData, invoiceTemplateSettings) && this.shouldAutoPrintReceiptForPaymentStatus(syncedOrder, receiptAutoPrintPaymentStatuses) && (receiptAutoPrintPaymentStatuses === undefined || this.shouldAutoPrintCheckoutReceipt()))) {
6802
- _context67.next = 23;
6922
+ _context69.next = 23;
6803
6923
  break;
6804
6924
  }
6805
- _context67.prev = 14;
6806
- _context67.next = 17;
6925
+ _context69.prev = 14;
6926
+ _context69.next = 17;
6807
6927
  return this.dispatchLocalReceiptPrint({
6808
6928
  checkoutData: syncResult.checkoutData,
6809
6929
  order: syncedOrder,
@@ -6813,41 +6933,41 @@ var Server = /*#__PURE__*/function () {
6813
6933
  invoiceTemplateSettings: invoiceTemplateSettings
6814
6934
  });
6815
6935
  case 17:
6816
- _context67.next = 23;
6936
+ _context69.next = 23;
6817
6937
  break;
6818
6938
  case 19:
6819
- _context67.prev = 19;
6820
- _context67.t0 = _context67["catch"](14);
6939
+ _context69.prev = 19;
6940
+ _context69.t0 = _context69["catch"](14);
6821
6941
  // Checkout already succeeded remotely; report the receipt failure
6822
6942
  // separately instead of implying that payment/order creation failed.
6823
- response.receipt_print_error = this.getUnknownErrorMessage(_context67.t0);
6943
+ response.receipt_print_error = this.getUnknownErrorMessage(_context69.t0);
6824
6944
  this.logError("".concat(title, ": \u5C0F\u7968\u751F\u6210\u5931\u8D25\uFF0C\u8BA2\u5355\u5DF2\u540C\u6B65"), {
6825
6945
  error: response.receipt_print_error
6826
6946
  });
6827
6947
  case 23:
6828
- return _context67.abrupt("return", response);
6948
+ return _context69.abrupt("return", response);
6829
6949
  case 26:
6830
- _context67.prev = 26;
6831
- _context67.t1 = _context67["catch"](4);
6832
- backendError = this.extractBackendErrorResponse(_context67.t1);
6950
+ _context69.prev = 26;
6951
+ _context69.t1 = _context69["catch"](4);
6952
+ backendError = this.extractBackendErrorResponse(_context69.t1);
6833
6953
  if (!backendError) {
6834
- _context67.next = 32;
6954
+ _context69.next = 32;
6835
6955
  break;
6836
6956
  }
6837
6957
  _normalized = this.normalizeCheckoutResponse(backendError);
6838
- return _context67.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
6958
+ return _context69.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
6839
6959
  status: false,
6840
6960
  message: (backendError === null || backendError === void 0 ? void 0 : backendError.message) || (_normalized === null || _normalized === void 0 ? void 0 : _normalized.message) || '后端明确拒绝 checkout',
6841
6961
  data: (_normalized$data2 = _normalized === null || _normalized === void 0 ? void 0 : _normalized.data) !== null && _normalized$data2 !== void 0 ? _normalized$data2 : null
6842
6962
  }));
6843
6963
  case 32:
6844
- message = this.getUnknownErrorMessage(_context67.t1);
6964
+ message = this.getUnknownErrorMessage(_context69.t1);
6845
6965
  this.logError("".concat(title, ": sync checkout \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
6846
6966
  backendPath: backendPath,
6847
6967
  error: message,
6848
- error_detail: this.normalizeUnknownError(_context67.t1)
6968
+ error_detail: this.normalizeUnknownError(_context69.t1)
6849
6969
  });
6850
- return _context67.abrupt("return", {
6970
+ return _context69.abrupt("return", {
6851
6971
  code: 500,
6852
6972
  status: false,
6853
6973
  message: message,
@@ -6855,11 +6975,11 @@ var Server = /*#__PURE__*/function () {
6855
6975
  });
6856
6976
  case 35:
6857
6977
  case "end":
6858
- return _context67.stop();
6978
+ return _context69.stop();
6859
6979
  }
6860
- }, _callee67, this, [[4, 26], [14, 19]]);
6980
+ }, _callee69, this, [[4, 26], [14, 19]]);
6861
6981
  }));
6862
- function handleSyncCheckoutSubmit(_x74) {
6982
+ function handleSyncCheckoutSubmit(_x75) {
6863
6983
  return _handleSyncCheckoutSubmit.apply(this, arguments);
6864
6984
  }
6865
6985
  return handleSyncCheckoutSubmit;
@@ -6867,10 +6987,10 @@ var Server = /*#__PURE__*/function () {
6867
6987
  }, {
6868
6988
  key: "handleOrderDraftSubmit",
6869
6989
  value: function () {
6870
- var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(params) {
6990
+ var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(params) {
6871
6991
  var title, extractedInvoice, _this$extractInvoiceT, data, normalizedData, createdAt, draftOrder, _draftOrder$summary, _draftOrder$summary2, _draftOrder$summary3, errorMessage;
6872
- return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6873
- while (1) switch (_context68.prev = _context68.next) {
6992
+ return _regeneratorRuntime().wrap(function _callee70$(_context70) {
6993
+ while (1) switch (_context70.prev = _context70.next) {
6874
6994
  case 0:
6875
6995
  title = params.title;
6876
6996
  extractedInvoice = this.extractInvoiceLayoutConfig(params.data, {
@@ -6884,10 +7004,10 @@ var Server = /*#__PURE__*/function () {
6884
7004
  external_sale_number: data === null || data === void 0 ? void 0 : data.external_sale_number,
6885
7005
  order_number: data === null || data === void 0 ? void 0 : data.order_number
6886
7006
  });
6887
- _context68.next = 6;
7007
+ _context70.next = 6;
6888
7008
  return this.normalizeCheckoutSubmitData(data, title);
6889
7009
  case 6:
6890
- normalizedData = _context68.sent;
7010
+ normalizedData = _context70.sent;
6891
7011
  createdAt = normalizedData.created_at || normalizedData.create_date || dayjs().format('YYYY-MM-DD HH:mm:ss');
6892
7012
  draftOrder = _objectSpread(_objectSpread({}, normalizedData), {}, {
6893
7013
  external_sale_number: normalizedData.external_sale_number || "LOCAL_DRAFT_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 10)),
@@ -6897,26 +7017,26 @@ var Server = /*#__PURE__*/function () {
6897
7017
  is_draft_order: 1
6898
7018
  });
6899
7019
  if (!(!this.order || typeof this.order.upsertLocalDraftOrders !== 'function')) {
6900
- _context68.next = 12;
7020
+ _context70.next = 12;
6901
7021
  break;
6902
7022
  }
6903
7023
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8349\u7A3F\u5199\u5165"));
6904
- return _context68.abrupt("return", {
7024
+ return _context70.abrupt("return", {
6905
7025
  code: 500,
6906
7026
  status: false,
6907
7027
  message: 'Order 模块不支持本地草稿写入',
6908
7028
  data: null
6909
7029
  });
6910
7030
  case 12:
6911
- _context68.prev = 12;
6912
- _context68.next = 15;
7031
+ _context70.prev = 12;
7032
+ _context70.next = 15;
6913
7033
  return this.order.upsertLocalDraftOrders([draftOrder]);
6914
7034
  case 15:
6915
7035
  this.logInfo("".concat(title, ": \u8349\u7A3F\u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730"), {
6916
7036
  order_id: draftOrder.order_id,
6917
7037
  external_sale_number: draftOrder.external_sale_number
6918
7038
  });
6919
- return _context68.abrupt("return", {
7039
+ return _context70.abrupt("return", {
6920
7040
  code: 200,
6921
7041
  status: true,
6922
7042
  message: '',
@@ -6928,13 +7048,13 @@ var Server = /*#__PURE__*/function () {
6928
7048
  })
6929
7049
  });
6930
7050
  case 19:
6931
- _context68.prev = 19;
6932
- _context68.t0 = _context68["catch"](12);
6933
- errorMessage = _context68.t0 instanceof Error ? _context68.t0.message : String(_context68.t0);
7051
+ _context70.prev = 19;
7052
+ _context70.t0 = _context70["catch"](12);
7053
+ errorMessage = _context70.t0 instanceof Error ? _context70.t0.message : String(_context70.t0);
6934
7054
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u8349\u7A3F\u8BA2\u5355\u5931\u8D25"), {
6935
7055
  error: errorMessage
6936
7056
  });
6937
- return _context68.abrupt("return", {
7057
+ return _context70.abrupt("return", {
6938
7058
  code: 500,
6939
7059
  status: false,
6940
7060
  message: errorMessage,
@@ -6942,11 +7062,11 @@ var Server = /*#__PURE__*/function () {
6942
7062
  });
6943
7063
  case 24:
6944
7064
  case "end":
6945
- return _context68.stop();
7065
+ return _context70.stop();
6946
7066
  }
6947
- }, _callee68, this, [[12, 19]]);
7067
+ }, _callee70, this, [[12, 19]]);
6948
7068
  }));
6949
- function handleOrderDraftSubmit(_x75) {
7069
+ function handleOrderDraftSubmit(_x76) {
6950
7070
  return _handleOrderDraftSubmit.apply(this, arguments);
6951
7071
  }
6952
7072
  return handleOrderDraftSubmit;
@@ -6954,26 +7074,26 @@ var Server = /*#__PURE__*/function () {
6954
7074
  }, {
6955
7075
  key: "handlePendingSyncCheckoutOrder",
6956
7076
  value: function () {
6957
- var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(params) {
6958
- var _this18 = this;
7077
+ var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(params) {
7078
+ var _this19 = this;
6959
7079
  var backendPath, data, title, reason, invoiceTemplateSettings, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
6960
- return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6961
- while (1) switch (_context69.prev = _context69.next) {
7080
+ return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7081
+ while (1) switch (_context71.prev = _context71.next) {
6962
7082
  case 0:
6963
7083
  backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason, invoiceTemplateSettings = params.invoiceTemplateSettings;
6964
- _context69.next = 3;
7084
+ _context71.next = 3;
6965
7085
  return this.buildPendingSyncCheckoutOrder(data, invoiceTemplateSettings);
6966
7086
  case 3:
6967
- pendingOrder = _context69.sent;
7087
+ pendingOrder = _context71.sent;
6968
7088
  if (pendingOrder) {
6969
- _context69.next = 7;
7089
+ _context71.next = 7;
6970
7090
  break;
6971
7091
  }
6972
7092
  this.logError("".concat(title, ": checkout \u5931\u8D25\u4E14\u8BA2\u5355\u7F3A\u5C11\u672C\u5730\u5B58\u50A8\u6807\u8BC6"), {
6973
7093
  backendPath: backendPath,
6974
7094
  reason: reason
6975
7095
  });
6976
- return _context69.abrupt("return", {
7096
+ return _context71.abrupt("return", {
6977
7097
  code: 500,
6978
7098
  status: false,
6979
7099
  message: '订单缺少本地存储标识,无法写入待同步队列',
@@ -6981,22 +7101,22 @@ var Server = /*#__PURE__*/function () {
6981
7101
  });
6982
7102
  case 7:
6983
7103
  if (!(!this.order || typeof this.order.upsertPendingSyncOrders !== 'function')) {
6984
- _context69.next = 10;
7104
+ _context71.next = 10;
6985
7105
  break;
6986
7106
  }
6987
7107
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u5F85\u540C\u6B65\u5199\u5165"), {
6988
7108
  backendPath: backendPath,
6989
7109
  reason: reason
6990
7110
  });
6991
- return _context69.abrupt("return", {
7111
+ return _context71.abrupt("return", {
6992
7112
  code: 500,
6993
7113
  status: false,
6994
7114
  message: 'Order 模块不支持本地待同步写入',
6995
7115
  data: null
6996
7116
  });
6997
7117
  case 10:
6998
- _context69.prev = 10;
6999
- _context69.next = 13;
7118
+ _context71.prev = 10;
7119
+ _context71.next = 13;
7000
7120
  return this.order.upsertPendingSyncOrders([pendingOrder]);
7001
7121
  case 13:
7002
7122
  this.logInfo("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
@@ -7008,9 +7128,9 @@ var Server = /*#__PURE__*/function () {
7008
7128
  });
7009
7129
  changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
7010
7130
  var _payment$metadata;
7011
- return sum + _this18.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
7131
+ return sum + _this19.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
7012
7132
  }, 0);
7013
- return _context69.abrupt("return", {
7133
+ return _context71.abrupt("return", {
7014
7134
  code: 200,
7015
7135
  status: true,
7016
7136
  message: '',
@@ -7025,15 +7145,15 @@ var Server = /*#__PURE__*/function () {
7025
7145
  })
7026
7146
  });
7027
7147
  case 18:
7028
- _context69.prev = 18;
7029
- _context69.t0 = _context69["catch"](10);
7030
- errorMessage = _context69.t0 instanceof Error ? _context69.t0.message : String(_context69.t0);
7148
+ _context71.prev = 18;
7149
+ _context71.t0 = _context71["catch"](10);
7150
+ errorMessage = _context71.t0 instanceof Error ? _context71.t0.message : String(_context71.t0);
7031
7151
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u5F85\u540C\u6B65\u8BA2\u5355\u5931\u8D25"), {
7032
7152
  backendPath: backendPath,
7033
7153
  reason: reason,
7034
7154
  error: errorMessage
7035
7155
  });
7036
- return _context69.abrupt("return", {
7156
+ return _context71.abrupt("return", {
7037
7157
  code: 500,
7038
7158
  status: false,
7039
7159
  message: errorMessage,
@@ -7041,11 +7161,11 @@ var Server = /*#__PURE__*/function () {
7041
7161
  });
7042
7162
  case 23:
7043
7163
  case "end":
7044
- return _context69.stop();
7164
+ return _context71.stop();
7045
7165
  }
7046
- }, _callee69, this, [[10, 18]]);
7166
+ }, _callee71, this, [[10, 18]]);
7047
7167
  }));
7048
- function handlePendingSyncCheckoutOrder(_x76) {
7168
+ function handlePendingSyncCheckoutOrder(_x77) {
7049
7169
  return _handlePendingSyncCheckoutOrder.apply(this, arguments);
7050
7170
  }
7051
7171
  return handlePendingSyncCheckoutOrder;
@@ -7053,45 +7173,45 @@ var Server = /*#__PURE__*/function () {
7053
7173
  }, {
7054
7174
  key: "buildPendingSyncCheckoutOrder",
7055
7175
  value: function () {
7056
- var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(data, invoiceTemplateSettings) {
7176
+ var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(data, invoiceTemplateSettings) {
7057
7177
  var hasStorageKey, pendingOrder, productMap, orderWithProductTitles;
7058
- return _regeneratorRuntime().wrap(function _callee70$(_context70) {
7059
- while (1) switch (_context70.prev = _context70.next) {
7178
+ return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7179
+ while (1) switch (_context72.prev = _context72.next) {
7060
7180
  case 0:
7061
7181
  if (!(!data || _typeof(data) !== 'object')) {
7062
- _context70.next = 2;
7182
+ _context72.next = 2;
7063
7183
  break;
7064
7184
  }
7065
- return _context70.abrupt("return", null);
7185
+ return _context72.abrupt("return", null);
7066
7186
  case 2:
7067
7187
  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 !== '';
7068
7188
  if (hasStorageKey) {
7069
- _context70.next = 5;
7189
+ _context72.next = 5;
7070
7190
  break;
7071
7191
  }
7072
- return _context70.abrupt("return", null);
7192
+ return _context72.abrupt("return", null);
7073
7193
  case 5:
7074
7194
  pendingOrder = this.normalizeCheckoutCollections(_objectSpread(_objectSpread({}, data), {}, {
7075
7195
  need_sync: 1,
7076
7196
  is_draft_order: 0
7077
7197
  }));
7078
- _context70.next = 8;
7198
+ _context72.next = 8;
7079
7199
  return this.buildSmallTicketProductMap(pendingOrder);
7080
7200
  case 8:
7081
- productMap = _context70.sent;
7201
+ productMap = _context72.sent;
7082
7202
  orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
7083
- return _context70.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
7203
+ return _context72.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
7084
7204
  requireFullyPaid: true,
7085
7205
  productMap: productMap,
7086
7206
  invoiceTemplateSettings: invoiceTemplateSettings
7087
7207
  }));
7088
7208
  case 11:
7089
7209
  case "end":
7090
- return _context70.stop();
7210
+ return _context72.stop();
7091
7211
  }
7092
- }, _callee70, this);
7212
+ }, _callee72, this);
7093
7213
  }));
7094
- function buildPendingSyncCheckoutOrder(_x77, _x78) {
7214
+ function buildPendingSyncCheckoutOrder(_x78, _x79) {
7095
7215
  return _buildPendingSyncCheckoutOrder.apply(this, arguments);
7096
7216
  }
7097
7217
  return buildPendingSyncCheckoutOrder;
@@ -7119,20 +7239,20 @@ var Server = /*#__PURE__*/function () {
7119
7239
  }, {
7120
7240
  key: "shouldAutoPrintCheckoutReceipt",
7121
7241
  value: function shouldAutoPrintCheckoutReceipt() {
7122
- var _this$core$context2, _this$core$context2$g, _this$app18, _this$app18$getStorag;
7242
+ var _this$core$context2, _this$core$context2$g, _this$app19, _this$app19$getStorag;
7123
7243
  if (((_this$core$context2 = this.core.context) === null || _this$core$context2 === void 0 || (_this$core$context2$g = _this$core$context2.getPlatform) === null || _this$core$context2$g === void 0 ? void 0 : _this$core$context2$g.call(_this$core$context2)) !== 'android') return true;
7124
- return ((_this$app18 = this.app) === null || _this$app18 === void 0 || (_this$app18 = _this$app18.storage) === null || _this$app18 === void 0 || (_this$app18$getStorag = _this$app18.getStorage) === null || _this$app18$getStorag === void 0 ? void 0 : _this$app18$getStorag.call(_this$app18, AUTO_PRINT_STORAGE_KEY)) !== 'false';
7244
+ return ((_this$app19 = this.app) === null || _this$app19 === void 0 || (_this$app19 = _this$app19.storage) === null || _this$app19 === void 0 || (_this$app19$getStorag = _this$app19.getStorage) === null || _this$app19$getStorag === void 0 ? void 0 : _this$app19$getStorag.call(_this$app19, AUTO_PRINT_STORAGE_KEY)) !== 'false';
7125
7245
  }
7126
7246
 
7127
7247
  /** Only receipt auto-printing uses this policy; vouchers retain their paid-order gate. */
7128
7248
  }, {
7129
7249
  key: "shouldAutoPrintReceiptForPaymentStatus",
7130
7250
  value: function shouldAutoPrintReceiptForPaymentStatus(order, statuses) {
7131
- var _this19 = this;
7251
+ var _this20 = this;
7132
7252
  if (statuses === undefined) return this.isSalesOrderFullyPaid(order);
7133
7253
  var paymentStatus = String((order === null || order === void 0 ? void 0 : order.payment_status) || '').toLowerCase();
7134
7254
  return statuses.some(function (status) {
7135
- return status === 'paid' ? _this19.isSalesOrderFullyPaid(order) : paymentStatus === status;
7255
+ return status === 'paid' ? _this20.isSalesOrderFullyPaid(order) : paymentStatus === status;
7136
7256
  });
7137
7257
  }
7138
7258
  }, {
@@ -7161,7 +7281,7 @@ var Server = /*#__PURE__*/function () {
7161
7281
  }, {
7162
7282
  key: "isSalesOrderFullyPaid",
7163
7283
  value: function isSalesOrderFullyPaid(order) {
7164
- var _order$summary$amount, _order$summary, _ref74, _ref75, _order$summary$expect, _order$summary2, _order$summary3;
7284
+ var _order$summary$amount, _order$summary, _ref75, _ref76, _order$summary$expect, _order$summary2, _order$summary3;
7165
7285
  if (!order || _typeof(order) !== 'object') return false;
7166
7286
  var paymentStatus = String(order.payment_status || '').toLowerCase();
7167
7287
  if (paymentStatus === 'paid' || paymentStatus === 'finished') return true;
@@ -7173,20 +7293,20 @@ var Server = /*#__PURE__*/function () {
7173
7293
  return this.toAmountNumber(amountGap) <= 0;
7174
7294
  }
7175
7295
  var paidAmount = this.sumPaidOrderPayments(order.payments);
7176
- var targetAmount = this.toAmountNumber((_ref74 = (_ref75 = (_order$summary$expect = (_order$summary2 = order.summary) === null || _order$summary2 === void 0 ? void 0 : _order$summary2.expect_amount) !== null && _order$summary$expect !== void 0 ? _order$summary$expect : (_order$summary3 = order.summary) === null || _order$summary3 === void 0 ? void 0 : _order$summary3.total_amount) !== null && _ref75 !== void 0 ? _ref75 : order.expect_amount) !== null && _ref74 !== void 0 ? _ref74 : order.total_amount);
7296
+ var targetAmount = this.toAmountNumber((_ref75 = (_ref76 = (_order$summary$expect = (_order$summary2 = order.summary) === null || _order$summary2 === void 0 ? void 0 : _order$summary2.expect_amount) !== null && _order$summary$expect !== void 0 ? _order$summary$expect : (_order$summary3 = order.summary) === null || _order$summary3 === void 0 ? void 0 : _order$summary3.total_amount) !== null && _ref76 !== void 0 ? _ref76 : order.expect_amount) !== null && _ref75 !== void 0 ? _ref75 : order.total_amount);
7177
7297
  if (targetAmount <= 0) return paidAmount > 0;
7178
7298
  return paidAmount >= targetAmount;
7179
7299
  }
7180
7300
  }, {
7181
7301
  key: "sumPaidOrderPayments",
7182
7302
  value: function sumPaidOrderPayments(payments) {
7183
- var _this20 = this;
7303
+ var _this21 = this;
7184
7304
  if (!Array.isArray(payments)) return 0;
7185
7305
  return payments.reduce(function (sum, payment) {
7186
7306
  var _payment$amount;
7187
7307
  var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
7188
7308
  if (status !== 'paid') return sum;
7189
- return sum + _this20.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);
7309
+ return sum + _this21.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);
7190
7310
  }, 0);
7191
7311
  }
7192
7312
  }, {
@@ -7200,12 +7320,12 @@ var Server = /*#__PURE__*/function () {
7200
7320
  }, {
7201
7321
  key: "buildSmallTicketProductMap",
7202
7322
  value: function () {
7203
- var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(order) {
7323
+ var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(order) {
7204
7324
  var _this$products3,
7205
- _this21 = this;
7325
+ _this22 = this;
7206
7326
  var products, productIdSet, productIds, entries;
7207
- return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7208
- while (1) switch (_context72.prev = _context72.next) {
7327
+ return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7328
+ while (1) switch (_context74.prev = _context74.next) {
7209
7329
  case 0:
7210
7330
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
7211
7331
  productIdSet = new Set();
@@ -7217,8 +7337,8 @@ var Server = /*#__PURE__*/function () {
7217
7337
  }
7218
7338
  if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
7219
7339
  product.product_bundle.forEach(function (bundle) {
7220
- var _ref76, _bundle$bundle_produc;
7221
- var bundleProductId = (_ref76 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref76 !== void 0 ? _ref76 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
7340
+ var _ref77, _bundle$bundle_produc;
7341
+ var bundleProductId = (_ref77 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref77 !== void 0 ? _ref77 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
7222
7342
  if (bundleProductId !== undefined && bundleProductId !== null && bundleProductId !== '') {
7223
7343
  productIdSet.add(bundleProductId);
7224
7344
  }
@@ -7227,45 +7347,45 @@ var Server = /*#__PURE__*/function () {
7227
7347
  });
7228
7348
  productIds = Array.from(productIdSet);
7229
7349
  if (!(!productIds.length || typeof ((_this$products3 = this.products) === null || _this$products3 === void 0 ? void 0 : _this$products3.getProductById) !== 'function')) {
7230
- _context72.next = 6;
7350
+ _context74.next = 6;
7231
7351
  break;
7232
7352
  }
7233
- return _context72.abrupt("return", {});
7353
+ return _context74.abrupt("return", {});
7234
7354
  case 6:
7235
- _context72.next = 8;
7355
+ _context74.next = 8;
7236
7356
  return Promise.all(productIds.map( /*#__PURE__*/function () {
7237
- var _ref77 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(id) {
7238
- var _this21$products, _this21$products$getP, product;
7239
- return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7240
- while (1) switch (_context71.prev = _context71.next) {
7357
+ var _ref78 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(id) {
7358
+ var _this22$products, _this22$products$getP, product;
7359
+ return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7360
+ while (1) switch (_context73.prev = _context73.next) {
7241
7361
  case 0:
7242
- _context71.prev = 0;
7243
- _context71.next = 3;
7244
- return (_this21$products = _this21.products) === null || _this21$products === void 0 || (_this21$products$getP = _this21$products.getProductById) === null || _this21$products$getP === void 0 ? void 0 : _this21$products$getP.call(_this21$products, Number(id));
7362
+ _context73.prev = 0;
7363
+ _context73.next = 3;
7364
+ return (_this22$products = _this22.products) === null || _this22$products === void 0 || (_this22$products$getP = _this22$products.getProductById) === null || _this22$products$getP === void 0 ? void 0 : _this22$products$getP.call(_this22$products, Number(id));
7245
7365
  case 3:
7246
- product = _context71.sent;
7247
- return _context71.abrupt("return", product ? [String(id), product] : null);
7366
+ product = _context73.sent;
7367
+ return _context73.abrupt("return", product ? [String(id), product] : null);
7248
7368
  case 7:
7249
- _context71.prev = 7;
7250
- _context71.t0 = _context71["catch"](0);
7251
- _this21.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
7369
+ _context73.prev = 7;
7370
+ _context73.t0 = _context73["catch"](0);
7371
+ _this22.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
7252
7372
  product_id: id,
7253
- error: _context71.t0 instanceof Error ? _context71.t0.message : String(_context71.t0)
7373
+ error: _context73.t0 instanceof Error ? _context73.t0.message : String(_context73.t0)
7254
7374
  });
7255
- return _context71.abrupt("return", null);
7375
+ return _context73.abrupt("return", null);
7256
7376
  case 11:
7257
7377
  case "end":
7258
- return _context71.stop();
7378
+ return _context73.stop();
7259
7379
  }
7260
- }, _callee71, null, [[0, 7]]);
7380
+ }, _callee73, null, [[0, 7]]);
7261
7381
  }));
7262
- return function (_x80) {
7263
- return _ref77.apply(this, arguments);
7382
+ return function (_x81) {
7383
+ return _ref78.apply(this, arguments);
7264
7384
  };
7265
7385
  }()));
7266
7386
  case 8:
7267
- entries = _context72.sent;
7268
- return _context72.abrupt("return", entries.reduce(function (map, entry) {
7387
+ entries = _context74.sent;
7388
+ return _context74.abrupt("return", entries.reduce(function (map, entry) {
7269
7389
  if (!entry) return map;
7270
7390
  var _entry = _slicedToArray(entry, 2),
7271
7391
  id = _entry[0],
@@ -7275,11 +7395,11 @@ var Server = /*#__PURE__*/function () {
7275
7395
  }, {}));
7276
7396
  case 10:
7277
7397
  case "end":
7278
- return _context72.stop();
7398
+ return _context74.stop();
7279
7399
  }
7280
- }, _callee72, this);
7400
+ }, _callee74, this);
7281
7401
  }));
7282
- function buildSmallTicketProductMap(_x79) {
7402
+ function buildSmallTicketProductMap(_x80) {
7283
7403
  return _buildSmallTicketProductMap.apply(this, arguments);
7284
7404
  }
7285
7405
  return buildSmallTicketProductMap;
@@ -7299,8 +7419,8 @@ var Server = /*#__PURE__*/function () {
7299
7419
  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);
7300
7420
  if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
7301
7421
  product.product_bundle.forEach(function (bundle) {
7302
- var _ref78, _bundle$bundle_produc2;
7303
- addProductId((_ref78 = (_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 && _ref78 !== void 0 ? _ref78 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
7422
+ var _ref79, _bundle$bundle_produc2;
7423
+ addProductId((_ref79 = (_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 && _ref79 !== void 0 ? _ref79 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
7304
7424
  });
7305
7425
  }
7306
7426
  });
@@ -7309,40 +7429,40 @@ var Server = /*#__PURE__*/function () {
7309
7429
  }, {
7310
7430
  key: "buildSalesDetailProductSnapshotMap",
7311
7431
  value: function () {
7312
- var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(order) {
7432
+ var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(order) {
7313
7433
  var _this$products4;
7314
7434
  var productIds, getSnapshots;
7315
- return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7316
- while (1) switch (_context73.prev = _context73.next) {
7435
+ return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7436
+ while (1) switch (_context75.prev = _context75.next) {
7317
7437
  case 0:
7318
7438
  productIds = this.collectSalesDetailProductIds(order);
7319
7439
  getSnapshots = (_this$products4 = this.products) === null || _this$products4 === void 0 ? void 0 : _this$products4.getProductSnapshotsByIds;
7320
7440
  if (!(!productIds.length || typeof getSnapshots !== 'function')) {
7321
- _context73.next = 4;
7441
+ _context75.next = 4;
7322
7442
  break;
7323
7443
  }
7324
- return _context73.abrupt("return", {});
7444
+ return _context75.abrupt("return", {});
7325
7445
  case 4:
7326
- _context73.prev = 4;
7327
- _context73.next = 7;
7446
+ _context75.prev = 4;
7447
+ _context75.next = 7;
7328
7448
  return getSnapshots.call(this.products, productIds);
7329
7449
  case 7:
7330
- return _context73.abrupt("return", _context73.sent);
7450
+ return _context75.abrupt("return", _context75.sent);
7331
7451
  case 10:
7332
- _context73.prev = 10;
7333
- _context73.t0 = _context73["catch"](4);
7452
+ _context75.prev = 10;
7453
+ _context75.t0 = _context75["catch"](4);
7334
7454
  this.logWarning('buildSalesDetailProductSnapshotMap: 查询本地商品快照失败', {
7335
7455
  product_ids: productIds,
7336
- error: _context73.t0 instanceof Error ? _context73.t0.message : String(_context73.t0)
7456
+ error: _context75.t0 instanceof Error ? _context75.t0.message : String(_context75.t0)
7337
7457
  });
7338
- return _context73.abrupt("return", {});
7458
+ return _context75.abrupt("return", {});
7339
7459
  case 14:
7340
7460
  case "end":
7341
- return _context73.stop();
7461
+ return _context75.stop();
7342
7462
  }
7343
- }, _callee73, this, [[4, 10]]);
7463
+ }, _callee75, this, [[4, 10]]);
7344
7464
  }));
7345
- function buildSalesDetailProductSnapshotMap(_x81) {
7465
+ function buildSalesDetailProductSnapshotMap(_x82) {
7346
7466
  return _buildSalesDetailProductSnapshotMap.apply(this, arguments);
7347
7467
  }
7348
7468
  return buildSalesDetailProductSnapshotMap;
@@ -7376,9 +7496,9 @@ var Server = /*#__PURE__*/function () {
7376
7496
  if (!Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) return product;
7377
7497
  var hasChanged = false;
7378
7498
  var productBundle = product.product_bundle.map(function (bundle) {
7379
- var _ref79, _bundle$bundle_produc3;
7499
+ var _ref80, _bundle$bundle_produc3;
7380
7500
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
7381
- var rawProductId = (_ref79 = (_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 && _ref79 !== void 0 ? _ref79 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
7501
+ var rawProductId = (_ref80 = (_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 && _ref80 !== void 0 ? _ref80 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
7382
7502
  if (rawProductId === undefined || rawProductId === null || rawProductId === '') return bundle;
7383
7503
  var productId = Number(rawProductId);
7384
7504
  if (!Number.isFinite(productId)) return bundle;
@@ -7398,53 +7518,53 @@ var Server = /*#__PURE__*/function () {
7398
7518
  }, {
7399
7519
  key: "withSalesDetailProductSnapshots",
7400
7520
  value: function () {
7401
- var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(order) {
7402
- var _this22 = this;
7521
+ var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(order) {
7522
+ var _this23 = this;
7403
7523
  var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
7404
- return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7405
- while (1) switch (_context74.prev = _context74.next) {
7524
+ return _regeneratorRuntime().wrap(function _callee76$(_context76) {
7525
+ while (1) switch (_context76.prev = _context76.next) {
7406
7526
  case 0:
7407
7527
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : null;
7408
7528
  if (products !== null && products !== void 0 && products.length) {
7409
- _context74.next = 3;
7529
+ _context76.next = 3;
7410
7530
  break;
7411
7531
  }
7412
- return _context74.abrupt("return", order);
7532
+ return _context76.abrupt("return", order);
7413
7533
  case 3:
7414
- _context74.next = 5;
7534
+ _context76.next = 5;
7415
7535
  return this.buildSalesDetailProductSnapshotMap(order);
7416
7536
  case 5:
7417
- snapshotMap = _context74.sent;
7537
+ snapshotMap = _context76.sent;
7418
7538
  if (Object.keys(snapshotMap).length) {
7419
- _context74.next = 8;
7539
+ _context76.next = 8;
7420
7540
  break;
7421
7541
  }
7422
- return _context74.abrupt("return", order);
7542
+ return _context76.abrupt("return", order);
7423
7543
  case 8:
7424
7544
  hasChanged = false;
7425
7545
  enrichedProducts = products.map(function (product) {
7426
- var productWithBundleSnapshots = _this22.withBundleCatalogSnapshots(product, snapshotMap);
7427
- var nextProduct = _this22.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
7546
+ var productWithBundleSnapshots = _this23.withBundleCatalogSnapshots(product, snapshotMap);
7547
+ var nextProduct = _this23.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
7428
7548
  if (nextProduct !== product) hasChanged = true;
7429
7549
  return nextProduct;
7430
7550
  });
7431
7551
  if (hasChanged) {
7432
- _context74.next = 12;
7552
+ _context76.next = 12;
7433
7553
  break;
7434
7554
  }
7435
- return _context74.abrupt("return", order);
7555
+ return _context76.abrupt("return", order);
7436
7556
  case 12:
7437
7557
  enrichedOrder = _objectSpread(_objectSpread({}, order), {}, {
7438
7558
  products: enrichedProducts
7439
7559
  });
7440
- return _context74.abrupt("return", enrichedOrder);
7560
+ return _context76.abrupt("return", enrichedOrder);
7441
7561
  case 14:
7442
7562
  case "end":
7443
- return _context74.stop();
7563
+ return _context76.stop();
7444
7564
  }
7445
- }, _callee74, this);
7565
+ }, _callee76, this);
7446
7566
  }));
7447
- function withSalesDetailProductSnapshots(_x82) {
7567
+ function withSalesDetailProductSnapshots(_x83) {
7448
7568
  return _withSalesDetailProductSnapshots.apply(this, arguments);
7449
7569
  }
7450
7570
  return withSalesDetailProductSnapshots;
@@ -7452,13 +7572,13 @@ var Server = /*#__PURE__*/function () {
7452
7572
  }, {
7453
7573
  key: "withPendingSyncProductTitles",
7454
7574
  value: function withPendingSyncProductTitles(order, productMap) {
7455
- var _this23 = this;
7575
+ var _this24 = this;
7456
7576
  var products = Array.isArray(order.products) ? order.products : null;
7457
7577
  if (!(products !== null && products !== void 0 && products.length)) return order;
7458
7578
  return _objectSpread(_objectSpread({}, order), {}, {
7459
7579
  products: products.map(function (product) {
7460
7580
  return _objectSpread(_objectSpread({}, product), {}, {
7461
- product_title: _this23.buildProductTitleSnapshot(product, productMap)
7581
+ product_title: _this24.buildProductTitleSnapshot(product, productMap)
7462
7582
  });
7463
7583
  })
7464
7584
  });
@@ -7469,7 +7589,7 @@ var Server = /*#__PURE__*/function () {
7469
7589
  var _product$product_id4,
7470
7590
  _product$product,
7471
7591
  _fallbackProduct$prod,
7472
- _this24 = this;
7592
+ _this25 = this;
7473
7593
  var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
7474
7594
  var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
7475
7595
  var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
@@ -7477,7 +7597,7 @@ var Server = /*#__PURE__*/function () {
7477
7597
  var currentLocale = this.getProductTitleSnapshotCurrentLocale();
7478
7598
  var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
7479
7599
  return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
7480
- snapshot[key] = _this24.resolveProductTitleValue(ownTitle, key, currentLocale) || _this24.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
7600
+ snapshot[key] = _this25.resolveProductTitleValue(ownTitle, key, currentLocale) || _this25.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
7481
7601
  return snapshot;
7482
7602
  }, {});
7483
7603
  }
@@ -7502,7 +7622,7 @@ var Server = /*#__PURE__*/function () {
7502
7622
  }, {
7503
7623
  key: "resolveProductTitleValue",
7504
7624
  value: function resolveProductTitleValue(value, key, currentLocale) {
7505
- var _ref80, _ref81, _value$key;
7625
+ var _ref81, _ref82, _value$key;
7506
7626
  if (value === undefined || value === null || value === '') return null;
7507
7627
  if (_typeof(value) !== 'object') {
7508
7628
  var title = String(value);
@@ -7512,7 +7632,7 @@ var Server = /*#__PURE__*/function () {
7512
7632
  }
7513
7633
  var normalizedKey = key.replace('-', '_');
7514
7634
  var dashedKey = key.replace('_', '-');
7515
- var rawValue = (_ref80 = (_ref81 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref81 !== void 0 ? _ref81 : value[dashedKey]) !== null && _ref80 !== void 0 ? _ref80 : key === 'auto' ? value.default : undefined;
7635
+ var rawValue = (_ref81 = (_ref82 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref82 !== void 0 ? _ref82 : value[dashedKey]) !== null && _ref81 !== void 0 ? _ref81 : key === 'auto' ? value.default : undefined;
7516
7636
  if (rawValue === undefined || rawValue === null || rawValue === '') return null;
7517
7637
  if (_typeof(rawValue) === 'object') return this.resolveFirstProductTitleValue(rawValue);
7518
7638
  return String(rawValue);
@@ -7575,31 +7695,31 @@ var Server = /*#__PURE__*/function () {
7575
7695
  }, {
7576
7696
  key: "enrichPaymentNamesByCode",
7577
7697
  value: function () {
7578
- var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(order) {
7579
- var _this25 = this;
7698
+ var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77(order) {
7699
+ var _this26 = this;
7580
7700
  var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
7581
- return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7582
- while (1) switch (_context75.prev = _context75.next) {
7701
+ return _regeneratorRuntime().wrap(function _callee77$(_context77) {
7702
+ while (1) switch (_context77.prev = _context77.next) {
7583
7703
  case 0:
7584
7704
  payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
7585
7705
  hasMissingName = payments.some(function (payment) {
7586
- return _this25.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this25.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
7706
+ return _this26.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this26.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
7587
7707
  });
7588
7708
  if (hasMissingName) {
7589
- _context75.next = 4;
7709
+ _context77.next = 4;
7590
7710
  break;
7591
7711
  }
7592
- return _context75.abrupt("return", order);
7712
+ return _context77.abrupt("return", order);
7593
7713
  case 4:
7594
- _context75.prev = 4;
7595
- _context75.next = 7;
7714
+ _context77.prev = 4;
7715
+ _context77.next = 7;
7596
7716
  return this.getPaymentRouteModule();
7597
7717
  case 7:
7598
- paymentModule = _context75.sent;
7599
- _context75.next = 10;
7718
+ paymentModule = _context77.sent;
7719
+ _context77.next = 10;
7600
7720
  return paymentModule.getPayMethodListAsync();
7601
7721
  case 10:
7602
- payMethods = _context75.sent;
7722
+ payMethods = _context77.sent;
7603
7723
  nameByCode = new Map();
7604
7724
  _iterator12 = _createForOfIteratorHelper(payMethods || []);
7605
7725
  try {
@@ -7616,9 +7736,9 @@ var Server = /*#__PURE__*/function () {
7616
7736
  }
7617
7737
  hasResolvedName = false;
7618
7738
  enrichedPayments = payments.map(function (payment) {
7619
- if (!_this25.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
7620
- if (!_this25.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
7621
- var name = nameByCode.get(_this25.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
7739
+ if (!_this26.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
7740
+ if (!_this26.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
7741
+ var name = nameByCode.get(_this26.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
7622
7742
  if (!name) return payment;
7623
7743
  hasResolvedName = true;
7624
7744
  return _objectSpread(_objectSpread({}, payment), {}, {
@@ -7626,28 +7746,28 @@ var Server = /*#__PURE__*/function () {
7626
7746
  });
7627
7747
  });
7628
7748
  if (hasResolvedName) {
7629
- _context75.next = 18;
7749
+ _context77.next = 18;
7630
7750
  break;
7631
7751
  }
7632
- return _context75.abrupt("return", order);
7752
+ return _context77.abrupt("return", order);
7633
7753
  case 18:
7634
- return _context75.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
7754
+ return _context77.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
7635
7755
  payments: enrichedPayments
7636
7756
  }));
7637
7757
  case 21:
7638
- _context75.prev = 21;
7639
- _context75.t0 = _context75["catch"](4);
7758
+ _context77.prev = 21;
7759
+ _context77.t0 = _context77["catch"](4);
7640
7760
  this.logWarning('enrichPaymentNamesByCode: 支付方式名称回填失败', {
7641
- error: _context75.t0 instanceof Error ? _context75.t0.message : String(_context75.t0)
7761
+ error: _context77.t0 instanceof Error ? _context77.t0.message : String(_context77.t0)
7642
7762
  });
7643
- return _context75.abrupt("return", order);
7763
+ return _context77.abrupt("return", order);
7644
7764
  case 25:
7645
7765
  case "end":
7646
- return _context75.stop();
7766
+ return _context77.stop();
7647
7767
  }
7648
- }, _callee75, this, [[4, 21]]);
7768
+ }, _callee77, this, [[4, 21]]);
7649
7769
  }));
7650
- function enrichPaymentNamesByCode(_x83) {
7770
+ function enrichPaymentNamesByCode(_x84) {
7651
7771
  return _enrichPaymentNamesByCode.apply(this, arguments);
7652
7772
  }
7653
7773
  return enrichPaymentNamesByCode;
@@ -7655,25 +7775,25 @@ var Server = /*#__PURE__*/function () {
7655
7775
  }, {
7656
7776
  key: "withLocalSmallTicketData",
7657
7777
  value: function () {
7658
- var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(order, options) {
7659
- var mustApplyVisibility, _options$productMap, normalizedCollections, normalizedOrder, collapsedDuplicateCounts, _ref82, _ref83, _order_id, enrichedOrder, productMap, smallTicketData;
7660
- return _regeneratorRuntime().wrap(function _callee76$(_context76) {
7661
- while (1) switch (_context76.prev = _context76.next) {
7778
+ var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78(order, options) {
7779
+ var mustApplyVisibility, _options$productMap, normalizedCollections, normalizedOrder, collapsedDuplicateCounts, _ref83, _ref84, _order_id, receiptOrder, enrichedOrder, productMap, smallTicketData;
7780
+ return _regeneratorRuntime().wrap(function _callee78$(_context78) {
7781
+ while (1) switch (_context78.prev = _context78.next) {
7662
7782
  case 0:
7663
7783
  mustApplyVisibility = (options === null || options === void 0 ? void 0 : options.applyTemplateVisibility) === true && requiresInvoiceDataFiltering(options.invoiceTemplateSettings);
7664
7784
  if (!(!this.shouldBuildSmallTicketData(order) && !mustApplyVisibility)) {
7665
- _context76.next = 3;
7785
+ _context78.next = 3;
7666
7786
  break;
7667
7787
  }
7668
- return _context76.abrupt("return", order);
7788
+ return _context78.abrupt("return", order);
7669
7789
  case 3:
7670
7790
  if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
7671
- _context76.next = 5;
7791
+ _context78.next = 5;
7672
7792
  break;
7673
7793
  }
7674
- return _context76.abrupt("return", order);
7794
+ return _context78.abrupt("return", order);
7675
7795
  case 5:
7676
- _context76.prev = 5;
7796
+ _context78.prev = 5;
7677
7797
  normalizedCollections = normalizeOrderCollections(order, {
7678
7798
  ensureUid: false
7679
7799
  });
@@ -7687,28 +7807,42 @@ var Server = /*#__PURE__*/function () {
7687
7807
  return count > 0;
7688
7808
  })) {
7689
7809
  this.logWarning('withLocalSmallTicketData: 折叠重复订单子项', {
7690
- order_identifier: (_ref82 = (_ref83 = (_order_id = normalizedOrder.order_id) !== null && _order_id !== void 0 ? _order_id : normalizedOrder.external_sale_number) !== null && _ref83 !== void 0 ? _ref83 : normalizedOrder.shop_order_number) !== null && _ref82 !== void 0 ? _ref82 : null,
7810
+ order_identifier: (_ref83 = (_ref84 = (_order_id = normalizedOrder.order_id) !== null && _order_id !== void 0 ? _order_id : normalizedOrder.external_sale_number) !== null && _ref84 !== void 0 ? _ref84 : normalizedOrder.shop_order_number) !== null && _ref83 !== void 0 ? _ref83 : null,
7691
7811
  collapsed_duplicate_counts: collapsedDuplicateCounts
7692
7812
  });
7693
7813
  }
7694
- _context76.next = 12;
7695
- return this.enrichPaymentNamesByCode(normalizedOrder);
7696
- case 12:
7697
- enrichedOrder = _context76.sent;
7698
- if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
7699
- _context76.next = 17;
7814
+ if (!(options !== null && options !== void 0 && options.refreshResourceReference)) {
7815
+ _context78.next = 16;
7700
7816
  break;
7701
7817
  }
7702
- _context76.t0 = _options$productMap;
7703
- _context76.next = 20;
7818
+ _context78.next = 13;
7819
+ return this.withCurrentReceiptResourceReference(normalizedOrder);
7820
+ case 13:
7821
+ _context78.t0 = _context78.sent;
7822
+ _context78.next = 17;
7704
7823
  break;
7824
+ case 16:
7825
+ _context78.t0 = normalizedOrder;
7705
7826
  case 17:
7706
- _context76.next = 19;
7707
- return this.buildSmallTicketProductMap(enrichedOrder);
7708
- case 19:
7709
- _context76.t0 = _context76.sent;
7827
+ receiptOrder = _context78.t0;
7828
+ _context78.next = 20;
7829
+ return this.enrichPaymentNamesByCode(receiptOrder);
7710
7830
  case 20:
7711
- productMap = _context76.t0;
7831
+ enrichedOrder = _context78.sent;
7832
+ if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
7833
+ _context78.next = 25;
7834
+ break;
7835
+ }
7836
+ _context78.t1 = _options$productMap;
7837
+ _context78.next = 28;
7838
+ break;
7839
+ case 25:
7840
+ _context78.next = 27;
7841
+ return this.buildSmallTicketProductMap(enrichedOrder);
7842
+ case 27:
7843
+ _context78.t1 = _context78.sent;
7844
+ case 28:
7845
+ productMap = _context78.t1;
7712
7846
  smallTicketData = buildSmallTicketData({
7713
7847
  order: enrichedOrder,
7714
7848
  shopInfo: this.getSmallTicketShopInfo(),
@@ -7717,31 +7851,31 @@ var Server = /*#__PURE__*/function () {
7717
7851
  includeReceiptKeys: options === null || options === void 0 ? void 0 : options.includeReceiptKeys,
7718
7852
  templateSettings: options !== null && options !== void 0 && options.applyTemplateVisibility ? options.invoiceTemplateSettings : undefined
7719
7853
  });
7720
- return _context76.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
7854
+ return _context78.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
7721
7855
  payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
7722
7856
  small_ticket_data: smallTicketData
7723
7857
  })
7724
7858
  }));
7725
- case 25:
7726
- _context76.prev = 25;
7727
- _context76.t1 = _context76["catch"](5);
7859
+ case 33:
7860
+ _context78.prev = 33;
7861
+ _context78.t2 = _context78["catch"](5);
7728
7862
  this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
7729
- error: _context76.t1 instanceof Error ? _context76.t1.message : String(_context76.t1)
7863
+ error: _context78.t2 instanceof Error ? _context78.t2.message : String(_context78.t2)
7730
7864
  });
7731
7865
  if (!mustApplyVisibility) {
7732
- _context76.next = 30;
7866
+ _context78.next = 38;
7733
7867
  break;
7734
7868
  }
7735
- throw _context76.t1;
7736
- case 30:
7737
- return _context76.abrupt("return", order);
7738
- case 31:
7869
+ throw _context78.t2;
7870
+ case 38:
7871
+ return _context78.abrupt("return", order);
7872
+ case 39:
7739
7873
  case "end":
7740
- return _context76.stop();
7874
+ return _context78.stop();
7741
7875
  }
7742
- }, _callee76, this, [[5, 25]]);
7876
+ }, _callee78, this, [[5, 33]]);
7743
7877
  }));
7744
- function withLocalSmallTicketData(_x84, _x85) {
7878
+ function withLocalSmallTicketData(_x85, _x86) {
7745
7879
  return _withLocalSmallTicketData.apply(this, arguments);
7746
7880
  }
7747
7881
  return withLocalSmallTicketData;
@@ -7756,37 +7890,37 @@ var Server = /*#__PURE__*/function () {
7756
7890
  }, {
7757
7891
  key: "fetchAndPersistSalesOrderByLookup",
7758
7892
  value: function () {
7759
- var _fetchAndPersistSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77(lookup, data, title, paymentIdentityOrder) {
7760
- var _this$order7, _this$order8, _this$app19;
7761
- var backendPath, _this$order$getLocalO, _this$order9, response, _response$code3, responseStatusCode, code, message, fresh, localBeforeRefresh, orderToPersist, remotePayments, paidPayments, paymentIdsComplete, savedOrder, _errorRecord$response, backendError, errorRecord, _responseStatusCode, _ref84, _backendError$code2, backendStatusCode, _code, _message2, _message3;
7762
- return _regeneratorRuntime().wrap(function _callee77$(_context77) {
7763
- while (1) switch (_context77.prev = _context77.next) {
7893
+ var _fetchAndPersistSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee79(lookup, data, title, paymentIdentityOrder) {
7894
+ var _this$order7, _this$order8, _this$app20;
7895
+ var backendPath, _this$order$getLocalO, _this$order9, response, _response$code3, responseStatusCode, code, message, fresh, localBeforeRefresh, orderToPersist, remotePayments, paidPayments, paymentIdsComplete, savedOrder, _errorRecord$response, backendError, errorRecord, _responseStatusCode, _ref85, _backendError$code2, backendStatusCode, _code, _message2, _message3;
7896
+ return _regeneratorRuntime().wrap(function _callee79$(_context79) {
7897
+ while (1) switch (_context79.prev = _context79.next) {
7764
7898
  case 0:
7765
7899
  if (!(!((_this$order7 = this.order) !== null && _this$order7 !== void 0 && _this$order7.getLocalOrderByLookup) || !((_this$order8 = this.order) !== null && _this$order8 !== void 0 && _this$order8.upsertOrdersFromRemote))) {
7766
- _context77.next = 3;
7900
+ _context79.next = 3;
7767
7901
  break;
7768
7902
  }
7769
7903
  this.logError("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C"));
7770
- return _context77.abrupt("return", {
7904
+ return _context79.abrupt("return", {
7771
7905
  code: 500,
7772
7906
  message: 'Order 模块未注册',
7773
7907
  order: null
7774
7908
  });
7775
7909
  case 3:
7776
- if ((_this$app19 = this.app) !== null && _this$app19 !== void 0 && (_this$app19 = _this$app19.request) !== null && _this$app19 !== void 0 && _this$app19.get) {
7777
- _context77.next = 6;
7910
+ if ((_this$app20 = this.app) !== null && _this$app20 !== void 0 && (_this$app20 = _this$app20.request) !== null && _this$app20 !== void 0 && _this$app20.get) {
7911
+ _context79.next = 6;
7778
7912
  break;
7779
7913
  }
7780
7914
  this.logError("".concat(title, ": app.request \u4E0D\u53EF\u7528"));
7781
- return _context77.abrupt("return", {
7915
+ return _context79.abrupt("return", {
7782
7916
  code: 500,
7783
7917
  message: 'app.request 不可用',
7784
7918
  order: null
7785
7919
  });
7786
7920
  case 6:
7787
7921
  backendPath = this.buildOrderSalesDetailBackendPath(String(lookup), data);
7788
- _context77.prev = 7;
7789
- _context77.next = 10;
7922
+ _context79.prev = 7;
7923
+ _context79.next = 10;
7790
7924
  return this.app.request.get(backendPath, {
7791
7925
  lookup_mode: 'multi'
7792
7926
  }, {
@@ -7794,9 +7928,9 @@ var Server = /*#__PURE__*/function () {
7794
7928
  customToast: function customToast() {}
7795
7929
  });
7796
7930
  case 10:
7797
- response = _context77.sent;
7931
+ response = _context79.sent;
7798
7932
  if (!this.isCheckoutResponseRejected(response)) {
7799
- _context77.next = 17;
7933
+ _context79.next = 17;
7800
7934
  break;
7801
7935
  }
7802
7936
  responseStatusCode = typeof (response === null || response === void 0 ? void 0 : response.status) === 'number' ? response.status : undefined;
@@ -7808,7 +7942,7 @@ var Server = /*#__PURE__*/function () {
7808
7942
  code: code,
7809
7943
  message: message
7810
7944
  });
7811
- return _context77.abrupt("return", {
7945
+ return _context79.abrupt("return", {
7812
7946
  code: code,
7813
7947
  message: message,
7814
7948
  order: null
@@ -7816,56 +7950,56 @@ var Server = /*#__PURE__*/function () {
7816
7950
  case 17:
7817
7951
  fresh = this.extractOrderDataFromCheckoutResponse(response);
7818
7952
  if (!(!fresh || fresh.order_id === undefined || fresh.order_id === null || String(fresh.order_id).trim() === '')) {
7819
- _context77.next = 21;
7953
+ _context79.next = 21;
7820
7954
  break;
7821
7955
  }
7822
7956
  this.logInfo("".concat(title, ": \u540E\u7AEF\u8FD4\u56DE\u8BA2\u5355\u4E3A\u7A7A"), {
7823
7957
  lookup: lookup,
7824
7958
  backendPath: backendPath
7825
7959
  });
7826
- return _context77.abrupt("return", {
7960
+ return _context79.abrupt("return", {
7827
7961
  code: 500,
7828
7962
  message: '后端返回订单为空',
7829
7963
  order: null
7830
7964
  });
7831
7965
  case 21:
7832
- _context77.t0 = (_this$order$getLocalO = (_this$order9 = this.order).getLocalOrderFromMemoryByLookup) === null || _this$order$getLocalO === void 0 ? void 0 : _this$order$getLocalO.call(_this$order9, lookup);
7833
- if (_context77.t0) {
7834
- _context77.next = 31;
7966
+ _context79.t0 = (_this$order$getLocalO = (_this$order9 = this.order).getLocalOrderFromMemoryByLookup) === null || _this$order$getLocalO === void 0 ? void 0 : _this$order$getLocalO.call(_this$order9, lookup);
7967
+ if (_context79.t0) {
7968
+ _context79.next = 31;
7835
7969
  break;
7836
7970
  }
7837
7971
  if (!this.shouldForceRemoteSalesDetail(data)) {
7838
- _context77.next = 29;
7972
+ _context79.next = 29;
7839
7973
  break;
7840
7974
  }
7841
- _context77.next = 26;
7975
+ _context79.next = 26;
7842
7976
  return this.order.getLocalOrderByLookup(lookup);
7843
7977
  case 26:
7844
- _context77.t1 = _context77.sent;
7845
- _context77.next = 30;
7978
+ _context79.t1 = _context79.sent;
7979
+ _context79.next = 30;
7846
7980
  break;
7847
7981
  case 29:
7848
- _context77.t1 = null;
7982
+ _context79.t1 = null;
7849
7983
  case 30:
7850
- _context77.t0 = _context77.t1;
7984
+ _context79.t0 = _context79.t1;
7851
7985
  case 31:
7852
- localBeforeRefresh = _context77.t0;
7986
+ localBeforeRefresh = _context79.t0;
7853
7987
  orderToPersist = fresh;
7854
7988
  if (!paymentIdentityOrder) {
7855
- _context77.next = 44;
7989
+ _context79.next = 44;
7856
7990
  break;
7857
7991
  }
7858
7992
  if (!(String(fresh.order_id) !== String(paymentIdentityOrder.order_id) || fresh.external_sale_number && paymentIdentityOrder.external_sale_number && fresh.external_sale_number !== paymentIdentityOrder.external_sale_number || !Array.isArray(fresh.payments))) {
7859
- _context77.next = 36;
7993
+ _context79.next = 36;
7860
7994
  break;
7861
7995
  }
7862
7996
  throw new Error('远端订单身份不匹配或缺少付款明细,暂不补齐付款 ID');
7863
7997
  case 36:
7864
7998
  if (!(!localBeforeRefresh || Number(localBeforeRefresh.need_sync || 0) === 1 || Number(localBeforeRefresh.is_draft_order || 0) === 1)) {
7865
- _context77.next = 38;
7999
+ _context79.next = 38;
7866
8000
  break;
7867
8001
  }
7868
- return _context77.abrupt("return", {
8002
+ return _context79.abrupt("return", {
7869
8003
  code: 200,
7870
8004
  message: '',
7871
8005
  order: localBeforeRefresh || paymentIdentityOrder
@@ -7887,7 +8021,7 @@ var Server = /*#__PURE__*/function () {
7887
8021
  return matches.length === 1 && paymentId !== undefined && paymentId !== null && String(paymentId).trim() !== '';
7888
8022
  });
7889
8023
  if (paymentIdsComplete) {
7890
- _context77.next = 43;
8024
+ _context79.next = 43;
7891
8025
  break;
7892
8026
  }
7893
8027
  throw new Error('远端付款 ID 尚未齐全或付款身份匹配不唯一,保留本地付款等待重试');
@@ -7899,46 +8033,46 @@ var Server = /*#__PURE__*/function () {
7899
8033
  });
7900
8034
  case 44:
7901
8035
  if (!requiresLocalPaymentRefresh(localBeforeRefresh)) {
7902
- _context77.next = 51;
8036
+ _context79.next = 51;
7903
8037
  break;
7904
8038
  }
7905
8039
  if (!(String(fresh.order_id) !== String(localBeforeRefresh.order_id))) {
7906
- _context77.next = 47;
8040
+ _context79.next = 47;
7907
8041
  break;
7908
8042
  }
7909
8043
  throw new Error('远端订单身份不匹配,请重新刷新');
7910
8044
  case 47:
7911
- _context77.next = 49;
8045
+ _context79.next = 49;
7912
8046
  return this.order.completeLocalPaymentRefresh(orderToPersist);
7913
8047
  case 49:
7914
- _context77.next = 53;
8048
+ _context79.next = 53;
7915
8049
  break;
7916
8050
  case 51:
7917
- _context77.next = 53;
8051
+ _context79.next = 53;
7918
8052
  return this.order.upsertOrdersFromRemote([orderToPersist]);
7919
8053
  case 53:
7920
- _context77.next = 55;
8054
+ _context79.next = 55;
7921
8055
  return this.order.getLocalOrderByLookup(lookup);
7922
8056
  case 55:
7923
- savedOrder = _context77.sent;
8057
+ savedOrder = _context79.sent;
7924
8058
  if (!(!savedOrder && fresh.order_id !== undefined && fresh.order_id !== null && String(fresh.order_id) !== String(lookup))) {
7925
- _context77.next = 60;
8059
+ _context79.next = 60;
7926
8060
  break;
7927
8061
  }
7928
- _context77.next = 59;
8062
+ _context79.next = 59;
7929
8063
  return this.order.getLocalOrderByLookup(fresh.order_id);
7930
8064
  case 59:
7931
- savedOrder = _context77.sent;
8065
+ savedOrder = _context79.sent;
7932
8066
  case 60:
7933
8067
  if (savedOrder) {
7934
- _context77.next = 63;
8068
+ _context79.next = 63;
7935
8069
  break;
7936
8070
  }
7937
8071
  this.logError("".concat(title, ": \u8BA2\u5355\u5199\u5165\u540E\u56DE\u8BFB\u5931\u8D25"), {
7938
8072
  lookup: lookup,
7939
8073
  remote_order_id: fresh.order_id
7940
8074
  });
7941
- return _context77.abrupt("return", {
8075
+ return _context79.abrupt("return", {
7942
8076
  code: 500,
7943
8077
  message: '订单写入后回读失败',
7944
8078
  order: null
@@ -7948,54 +8082,54 @@ var Server = /*#__PURE__*/function () {
7948
8082
  lookup: lookup,
7949
8083
  remote_order_id: fresh.order_id
7950
8084
  });
7951
- return _context77.abrupt("return", {
8085
+ return _context79.abrupt("return", {
7952
8086
  code: 200,
7953
8087
  message: '',
7954
8088
  order: savedOrder
7955
8089
  });
7956
8090
  case 67:
7957
- _context77.prev = 67;
7958
- _context77.t2 = _context77["catch"](7);
7959
- backendError = this.extractBackendErrorResponse(_context77.t2);
7960
- errorRecord = _context77.t2;
8091
+ _context79.prev = 67;
8092
+ _context79.t2 = _context79["catch"](7);
8093
+ backendError = this.extractBackendErrorResponse(_context79.t2);
8094
+ errorRecord = _context79.t2;
7961
8095
  _responseStatusCode = typeof (errorRecord === null || errorRecord === void 0 || (_errorRecord$response = errorRecord.response) === null || _errorRecord$response === void 0 ? void 0 : _errorRecord$response.status) === 'number' ? errorRecord.response.status : undefined;
7962
8096
  if (!(backendError || _responseStatusCode !== undefined)) {
7963
- _context77.next = 78;
8097
+ _context79.next = 78;
7964
8098
  break;
7965
8099
  }
7966
8100
  backendStatusCode = typeof (backendError === null || backendError === void 0 ? void 0 : backendError.status) === 'number' ? backendError.status : undefined;
7967
- _code = this.normalizeRemoteSalesOrderErrorCode((_ref84 = (_backendError$code2 = backendError === null || backendError === void 0 ? void 0 : backendError.code) !== null && _backendError$code2 !== void 0 ? _backendError$code2 : backendStatusCode) !== null && _ref84 !== void 0 ? _ref84 : _responseStatusCode);
7968
- _message2 = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || this.getUnknownErrorMessage(_context77.t2);
8101
+ _code = this.normalizeRemoteSalesOrderErrorCode((_ref85 = (_backendError$code2 = backendError === null || backendError === void 0 ? void 0 : backendError.code) !== null && _backendError$code2 !== void 0 ? _backendError$code2 : backendStatusCode) !== null && _ref85 !== void 0 ? _ref85 : _responseStatusCode);
8102
+ _message2 = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || this.getUnknownErrorMessage(_context79.t2);
7969
8103
  this.logInfo("".concat(title, ": \u540E\u7AEF\u8BA2\u5355\u67E5\u8BE2\u5931\u8D25"), {
7970
8104
  lookup: lookup,
7971
8105
  backendPath: backendPath,
7972
8106
  code: _code,
7973
8107
  message: _message2
7974
8108
  });
7975
- return _context77.abrupt("return", {
8109
+ return _context79.abrupt("return", {
7976
8110
  code: _code,
7977
8111
  message: _message2,
7978
8112
  order: null
7979
8113
  });
7980
8114
  case 78:
7981
- _message3 = this.getUnknownErrorMessage(_context77.t2);
8115
+ _message3 = this.getUnknownErrorMessage(_context79.t2);
7982
8116
  this.logInfo("".concat(title, ": \u8BF7\u6C42\u5931\u8D25"), {
7983
8117
  lookup: lookup,
7984
8118
  backendPath: backendPath,
7985
8119
  error: _message3
7986
8120
  });
7987
- return _context77.abrupt("return", {
8121
+ return _context79.abrupt("return", {
7988
8122
  code: 500,
7989
8123
  message: _message3,
7990
8124
  order: null
7991
8125
  });
7992
8126
  case 81:
7993
8127
  case "end":
7994
- return _context77.stop();
8128
+ return _context79.stop();
7995
8129
  }
7996
- }, _callee77, this, [[7, 67]]);
8130
+ }, _callee79, this, [[7, 67]]);
7997
8131
  }));
7998
- function fetchAndPersistSalesOrderByLookup(_x86, _x87, _x88, _x89) {
8132
+ function fetchAndPersistSalesOrderByLookup(_x87, _x88, _x89, _x90) {
7999
8133
  return _fetchAndPersistSalesOrderByLookup.apply(this, arguments);
8000
8134
  }
8001
8135
  return fetchAndPersistSalesOrderByLookup;
@@ -8057,34 +8191,34 @@ var Server = /*#__PURE__*/function () {
8057
8191
  }, {
8058
8192
  key: "handleUpdateLocalOrdersBatch",
8059
8193
  value: (function () {
8060
- var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78(orderIds) {
8061
- var _this$app20;
8194
+ var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee80(orderIds) {
8195
+ var _this$app21;
8062
8196
  var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message4, overwritten, inserted;
8063
- return _regeneratorRuntime().wrap(function _callee78$(_context78) {
8064
- while (1) switch (_context78.prev = _context78.next) {
8197
+ return _regeneratorRuntime().wrap(function _callee80$(_context80) {
8198
+ while (1) switch (_context80.prev = _context80.next) {
8065
8199
  case 0:
8066
8200
  this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
8067
8201
  count: orderIds.length,
8068
8202
  orderIds: orderIds
8069
8203
  });
8070
8204
  if (this.order) {
8071
- _context78.next = 4;
8205
+ _context80.next = 4;
8072
8206
  break;
8073
8207
  }
8074
8208
  this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
8075
- return _context78.abrupt("return", {
8209
+ return _context80.abrupt("return", {
8076
8210
  code: 500,
8077
8211
  status: false,
8078
8212
  message: 'Order 模块未注册',
8079
8213
  data: null
8080
8214
  });
8081
8215
  case 4:
8082
- if ((_this$app20 = this.app) !== null && _this$app20 !== void 0 && _this$app20.request) {
8083
- _context78.next = 7;
8216
+ if ((_this$app21 = this.app) !== null && _this$app21 !== void 0 && _this$app21.request) {
8217
+ _context80.next = 7;
8084
8218
  break;
8085
8219
  }
8086
8220
  this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
8087
- return _context78.abrupt("return", {
8221
+ return _context80.abrupt("return", {
8088
8222
  code: 500,
8089
8223
  status: false,
8090
8224
  message: 'app.request 不可用',
@@ -8107,21 +8241,21 @@ var Server = /*#__PURE__*/function () {
8107
8241
  _iterator13.f();
8108
8242
  }
8109
8243
  fetched = [];
8110
- _context78.prev = 11;
8111
- _context78.next = 14;
8244
+ _context80.prev = 11;
8245
+ _context80.next = 14;
8112
8246
  return this.order.fetchOrdersByHttp(orderIds);
8113
8247
  case 14:
8114
- fetched = _context78.sent;
8115
- _context78.next = 22;
8248
+ fetched = _context80.sent;
8249
+ _context80.next = 22;
8116
8250
  break;
8117
8251
  case 17:
8118
- _context78.prev = 17;
8119
- _context78.t0 = _context78["catch"](11);
8120
- message = _context78.t0 instanceof Error ? _context78.t0.message : String(_context78.t0);
8252
+ _context80.prev = 17;
8253
+ _context80.t0 = _context80["catch"](11);
8254
+ message = _context80.t0 instanceof Error ? _context80.t0.message : String(_context80.t0);
8121
8255
  this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
8122
8256
  message: message
8123
8257
  });
8124
- return _context78.abrupt("return", {
8258
+ return _context80.abrupt("return", {
8125
8259
  code: 500,
8126
8260
  status: false,
8127
8261
  message: message,
@@ -8131,36 +8265,36 @@ var Server = /*#__PURE__*/function () {
8131
8265
  // 按返回结果中的 order_id 建索引,未命中即视为单笔失败
8132
8266
  fetchedMap = new Map();
8133
8267
  _iterator14 = _createForOfIteratorHelper(fetched);
8134
- _context78.prev = 24;
8268
+ _context80.prev = 24;
8135
8269
  _iterator14.s();
8136
8270
  case 26:
8137
8271
  if ((_step14 = _iterator14.n()).done) {
8138
- _context78.next = 34;
8272
+ _context80.next = 34;
8139
8273
  break;
8140
8274
  }
8141
8275
  order = _step14.value;
8142
8276
  oid = order === null || order === void 0 ? void 0 : order.order_id;
8143
8277
  if (!(oid === undefined || oid === null)) {
8144
- _context78.next = 31;
8278
+ _context80.next = 31;
8145
8279
  break;
8146
8280
  }
8147
- return _context78.abrupt("continue", 32);
8281
+ return _context80.abrupt("continue", 32);
8148
8282
  case 31:
8149
8283
  fetchedMap.set(String(oid), order);
8150
8284
  case 32:
8151
- _context78.next = 26;
8285
+ _context80.next = 26;
8152
8286
  break;
8153
8287
  case 34:
8154
- _context78.next = 39;
8288
+ _context80.next = 39;
8155
8289
  break;
8156
8290
  case 36:
8157
- _context78.prev = 36;
8158
- _context78.t1 = _context78["catch"](24);
8159
- _iterator14.e(_context78.t1);
8291
+ _context80.prev = 36;
8292
+ _context80.t1 = _context80["catch"](24);
8293
+ _iterator14.e(_context80.t1);
8160
8294
  case 39:
8161
- _context78.prev = 39;
8295
+ _context80.prev = 39;
8162
8296
  _iterator14.f();
8163
- return _context78.finish(39);
8297
+ return _context80.finish(39);
8164
8298
  case 42:
8165
8299
  freshOrders = [];
8166
8300
  succeedIds = [];
@@ -8186,23 +8320,23 @@ var Server = /*#__PURE__*/function () {
8186
8320
  _iterator15.f();
8187
8321
  }
8188
8322
  if (!(freshOrders.length > 0)) {
8189
- _context78.next = 58;
8323
+ _context80.next = 58;
8190
8324
  break;
8191
8325
  }
8192
- _context78.prev = 48;
8193
- _context78.next = 51;
8326
+ _context80.prev = 48;
8327
+ _context80.next = 51;
8194
8328
  return this.order.upsertOrdersFromRemote(freshOrders);
8195
8329
  case 51:
8196
- _context78.next = 58;
8330
+ _context80.next = 58;
8197
8331
  break;
8198
8332
  case 53:
8199
- _context78.prev = 53;
8200
- _context78.t2 = _context78["catch"](48);
8201
- _message4 = _context78.t2 instanceof Error ? _context78.t2.message : String(_context78.t2);
8333
+ _context80.prev = 53;
8334
+ _context80.t2 = _context80["catch"](48);
8335
+ _message4 = _context80.t2 instanceof Error ? _context80.t2.message : String(_context80.t2);
8202
8336
  this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
8203
8337
  message: _message4
8204
8338
  });
8205
- return _context78.abrupt("return", {
8339
+ return _context80.abrupt("return", {
8206
8340
  code: 500,
8207
8341
  status: false,
8208
8342
  message: _message4,
@@ -8221,7 +8355,7 @@ var Server = /*#__PURE__*/function () {
8221
8355
  insertedCount: inserted.length,
8222
8356
  failedCount: failed.length
8223
8357
  });
8224
- return _context78.abrupt("return", {
8358
+ return _context80.abrupt("return", {
8225
8359
  code: 200,
8226
8360
  status: true,
8227
8361
  message: '',
@@ -8233,11 +8367,11 @@ var Server = /*#__PURE__*/function () {
8233
8367
  });
8234
8368
  case 62:
8235
8369
  case "end":
8236
- return _context78.stop();
8370
+ return _context80.stop();
8237
8371
  }
8238
- }, _callee78, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
8372
+ }, _callee80, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
8239
8373
  }));
8240
- function handleUpdateLocalOrdersBatch(_x90) {
8374
+ function handleUpdateLocalOrdersBatch(_x91) {
8241
8375
  return _handleUpdateLocalOrdersBatch.apply(this, arguments);
8242
8376
  }
8243
8377
  return handleUpdateLocalOrdersBatch;
@@ -8314,8 +8448,8 @@ var Server = /*#__PURE__*/function () {
8314
8448
  }, {
8315
8449
  key: "extractOrderDataFromCheckoutResponse",
8316
8450
  value: function extractOrderDataFromCheckoutResponse(response) {
8317
- var _response$data5, _response$data6;
8318
- var candidates = [response === null || response === void 0 || (_response$data5 = response.data) === null || _response$data5 === void 0 ? void 0 : _response$data5.order, response === null || response === void 0 || (_response$data6 = response.data) === null || _response$data6 === void 0 ? void 0 : _response$data6.sales, response === null || response === void 0 ? void 0 : response.data, response === null || response === void 0 ? void 0 : response.order, response === null || response === void 0 ? void 0 : response.sales, response];
8451
+ var _response$data6, _response$data7;
8452
+ var candidates = [response === null || response === void 0 || (_response$data6 = response.data) === null || _response$data6 === void 0 ? void 0 : _response$data6.order, response === null || response === void 0 || (_response$data7 = response.data) === null || _response$data7 === void 0 ? void 0 : _response$data7.sales, response === null || response === void 0 ? void 0 : response.data, response === null || response === void 0 ? void 0 : response.order, response === null || response === void 0 ? void 0 : response.sales, response];
8319
8453
  for (var _i6 = 0, _candidates2 = candidates; _i6 < _candidates2.length; _i6++) {
8320
8454
  var candidate = _candidates2[_i6];
8321
8455
  if (!candidate || _typeof(candidate) !== 'object') continue;
@@ -8484,10 +8618,10 @@ var Server = /*#__PURE__*/function () {
8484
8618
  value: function extractBackendErrorResponse(error) {
8485
8619
  var _error$response3,
8486
8620
  _error$response4,
8487
- _this26 = this;
8621
+ _this27 = this;
8488
8622
  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];
8489
8623
  return candidates.find(function (candidate) {
8490
- return _this26.isExplicitBackendErrorResponse(candidate);
8624
+ return _this27.isExplicitBackendErrorResponse(candidate);
8491
8625
  }) || null;
8492
8626
  }
8493
8627
  }, {
@@ -8606,16 +8740,16 @@ var Server = /*#__PURE__*/function () {
8606
8740
  }, {
8607
8741
  key: "recomputeAndNotifyFloorPlanQuery",
8608
8742
  value: (function () {
8609
- var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee79() {
8743
+ var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee81() {
8610
8744
  var _iterator17, _step17, _step17$value, subscriberId, sub, result, errorMessage;
8611
- return _regeneratorRuntime().wrap(function _callee79$(_context79) {
8612
- while (1) switch (_context79.prev = _context79.next) {
8745
+ return _regeneratorRuntime().wrap(function _callee81$(_context81) {
8746
+ while (1) switch (_context81.prev = _context81.next) {
8613
8747
  case 0:
8614
8748
  if (!(this.floorPlanQuerySubscribers.size === 0)) {
8615
- _context79.next = 2;
8749
+ _context81.next = 2;
8616
8750
  break;
8617
8751
  }
8618
- return _context79.abrupt("return");
8752
+ return _context81.abrupt("return");
8619
8753
  case 2:
8620
8754
  this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
8621
8755
  subscriberCount: this.floorPlanQuerySubscribers.size
@@ -8645,9 +8779,9 @@ var Server = /*#__PURE__*/function () {
8645
8779
  }
8646
8780
  case 5:
8647
8781
  case "end":
8648
- return _context79.stop();
8782
+ return _context81.stop();
8649
8783
  }
8650
- }, _callee79, this);
8784
+ }, _callee81, this);
8651
8785
  }));
8652
8786
  function recomputeAndNotifyFloorPlanQuery() {
8653
8787
  return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
@@ -8677,20 +8811,20 @@ var Server = /*#__PURE__*/function () {
8677
8811
  * filter 逻辑暂为 mock,仅记录参数
8678
8812
  */
8679
8813
  function () {
8680
- var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee80(data) {
8814
+ var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee82(data) {
8681
8815
  var rawList, result;
8682
- return _regeneratorRuntime().wrap(function _callee80$(_context80) {
8683
- while (1) switch (_context80.prev = _context80.next) {
8816
+ return _regeneratorRuntime().wrap(function _callee82$(_context82) {
8817
+ while (1) switch (_context82.prev = _context82.next) {
8684
8818
  case 0:
8685
8819
  this.logInfo('computeOrderQueryResult: 开始过滤', {
8686
8820
  data: data
8687
8821
  });
8688
8822
  if (this.order) {
8689
- _context80.next = 4;
8823
+ _context82.next = 4;
8690
8824
  break;
8691
8825
  }
8692
8826
  this.logError('computeOrderQueryResult: Order 模块未注册');
8693
- return _context80.abrupt("return", {
8827
+ return _context82.abrupt("return", {
8694
8828
  code: 500,
8695
8829
  message: 'Order 模块未注册',
8696
8830
  data: {
@@ -8722,7 +8856,7 @@ var Server = /*#__PURE__*/function () {
8722
8856
  skip: result.skip,
8723
8857
  rejected: result.rejected
8724
8858
  });
8725
- return _context80.abrupt("return", {
8859
+ return _context82.abrupt("return", {
8726
8860
  code: 200,
8727
8861
  data: result,
8728
8862
  message: '',
@@ -8730,11 +8864,11 @@ var Server = /*#__PURE__*/function () {
8730
8864
  });
8731
8865
  case 10:
8732
8866
  case "end":
8733
- return _context80.stop();
8867
+ return _context82.stop();
8734
8868
  }
8735
- }, _callee80, this);
8869
+ }, _callee82, this);
8736
8870
  }));
8737
- function computeOrderQueryResult(_x91) {
8871
+ function computeOrderQueryResult(_x92) {
8738
8872
  return _computeOrderQueryResult.apply(this, arguments);
8739
8873
  }
8740
8874
  return computeOrderQueryResult;
@@ -8747,17 +8881,17 @@ var Server = /*#__PURE__*/function () {
8747
8881
  }, {
8748
8882
  key: "computeBookingQueryResult",
8749
8883
  value: (function () {
8750
- var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee81(data) {
8884
+ var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee83(data) {
8751
8885
  var rawOrders, result;
8752
- return _regeneratorRuntime().wrap(function _callee81$(_context81) {
8753
- while (1) switch (_context81.prev = _context81.next) {
8886
+ return _regeneratorRuntime().wrap(function _callee83$(_context83) {
8887
+ while (1) switch (_context83.prev = _context83.next) {
8754
8888
  case 0:
8755
8889
  if (this.order) {
8756
- _context81.next = 3;
8890
+ _context83.next = 3;
8757
8891
  break;
8758
8892
  }
8759
8893
  this.logError('computeBookingQueryResult: Order 模块未注册');
8760
- return _context81.abrupt("return", {
8894
+ return _context83.abrupt("return", {
8761
8895
  code: 500,
8762
8896
  message: 'Order 模块未注册',
8763
8897
  data: {
@@ -8776,7 +8910,7 @@ var Server = /*#__PURE__*/function () {
8776
8910
  size: result.size,
8777
8911
  skip: result.skip
8778
8912
  });
8779
- return _context81.abrupt("return", {
8913
+ return _context83.abrupt("return", {
8780
8914
  code: 200,
8781
8915
  data: result,
8782
8916
  message: '',
@@ -8784,11 +8918,11 @@ var Server = /*#__PURE__*/function () {
8784
8918
  });
8785
8919
  case 8:
8786
8920
  case "end":
8787
- return _context81.stop();
8921
+ return _context83.stop();
8788
8922
  }
8789
- }, _callee81, this);
8923
+ }, _callee83, this);
8790
8924
  }));
8791
- function computeBookingQueryResult(_x92) {
8925
+ function computeBookingQueryResult(_x93) {
8792
8926
  return _computeBookingQueryResult.apply(this, arguments);
8793
8927
  }
8794
8928
  return computeBookingQueryResult;
@@ -8847,12 +8981,12 @@ var Server = /*#__PURE__*/function () {
8847
8981
  }, {
8848
8982
  key: "computeProductQueryResult",
8849
8983
  value: (function () {
8850
- var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee82(context, options) {
8984
+ var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee84(context, options) {
8851
8985
  var _menu_list_ids$length3,
8852
- _this27 = this;
8986
+ _this28 = this;
8853
8987
  var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, application_code, strategy_context, isVisibleProduct, queryIds, startupPreloadTask, formatterContext, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu, getActiveMenus, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
8854
- return _regeneratorRuntime().wrap(function _callee82$(_context82) {
8855
- while (1) switch (_context82.prev = _context82.next) {
8988
+ return _regeneratorRuntime().wrap(function _callee84$(_context84) {
8989
+ while (1) switch (_context84.prev = _context84.next) {
8856
8990
  case 0:
8857
8991
  tTotal = performance.now();
8858
8992
  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, application_code = context.application_code, strategy_context = context.strategy_context; // 仅 Kiosk 查询额外按商品销售渠道过滤。
@@ -8881,10 +9015,10 @@ var Server = /*#__PURE__*/function () {
8881
9015
  // SQLite/IndexDB,造成 preload 读到空数据并重复请求。正常运行期该字段为 null,不增加等待。
8882
9016
  startupPreloadTask = this.startupModulePreloadInFlight;
8883
9017
  if (!startupPreloadTask) {
8884
- _context82.next = 9;
9018
+ _context84.next = 9;
8885
9019
  break;
8886
9020
  }
8887
- _context82.next = 9;
9021
+ _context84.next = 9;
8888
9022
  return startupPreloadTask;
8889
9023
  case 9:
8890
9024
  // Menu/Schedule preload 会替换 store 中的数组;必须在等待完成后再读取,
@@ -8896,28 +9030,28 @@ var Server = /*#__PURE__*/function () {
8896
9030
  strategy_context: strategy_context
8897
9031
  });
8898
9032
  if (this.products) {
8899
- _context82.next = 13;
9033
+ _context84.next = 13;
8900
9034
  break;
8901
9035
  }
8902
9036
  this.logError('computeProductQueryResult: Products 模块未注册');
8903
- return _context82.abrupt("return", {
9037
+ return _context84.abrupt("return", {
8904
9038
  message: 'Products 模块未注册',
8905
9039
  data: this.buildProductQueryResultPayload([], 0)
8906
9040
  });
8907
9041
  case 13:
8908
9042
  if (!(queryIds.length > 0)) {
8909
- _context82.next = 25;
9043
+ _context84.next = 25;
8910
9044
  break;
8911
9045
  }
8912
9046
  uniqueIds = Array.from(new Set(queryIds));
8913
9047
  _tPrice = performance.now();
8914
- _context82.next = 18;
9048
+ _context84.next = 18;
8915
9049
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
8916
9050
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
8917
9051
  productIds: uniqueIds
8918
9052
  });
8919
9053
  case 18:
8920
- productsWithPrice = _context82.sent;
9054
+ productsWithPrice = _context84.sent;
8921
9055
  perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
8922
9056
  count: productsWithPrice.length,
8923
9057
  ids: uniqueIds
@@ -8935,7 +9069,7 @@ var Server = /*#__PURE__*/function () {
8935
9069
  ids: uniqueIds,
8936
9070
  count: extensionFilteredProducts.length
8937
9071
  });
8938
- return _context82.abrupt("return", {
9072
+ return _context84.abrupt("return", {
8939
9073
  code: 200,
8940
9074
  data: this.buildProductQueryResultPayload(extensionFilteredProducts),
8941
9075
  message: '',
@@ -8943,17 +9077,17 @@ var Server = /*#__PURE__*/function () {
8943
9077
  });
8944
9078
  case 25:
8945
9079
  if (!(product_id != null && Number.isFinite(Number(product_id)))) {
8946
- _context82.next = 37;
9080
+ _context84.next = 37;
8947
9081
  break;
8948
9082
  }
8949
9083
  pid = Number(product_id);
8950
9084
  _tPrice2 = performance.now();
8951
- _context82.next = 30;
9085
+ _context84.next = 30;
8952
9086
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
8953
9087
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
8954
9088
  });
8955
9089
  case 30:
8956
- allProductsWithPrice = _context82.sent;
9090
+ allProductsWithPrice = _context84.sent;
8957
9091
  perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
8958
9092
  count: allProductsWithPrice.length,
8959
9093
  productId: pid
@@ -8971,7 +9105,7 @@ var Server = /*#__PURE__*/function () {
8971
9105
  productId: pid,
8972
9106
  found: !!item
8973
9107
  });
8974
- return _context82.abrupt("return", {
9108
+ return _context84.abrupt("return", {
8975
9109
  code: 200,
8976
9110
  data: item,
8977
9111
  message: item ? '' : '商品不存在或未发布',
@@ -8979,16 +9113,16 @@ var Server = /*#__PURE__*/function () {
8979
9113
  });
8980
9114
  case 37:
8981
9115
  if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
8982
- _context82.next = 57;
9116
+ _context84.next = 57;
8983
9117
  break;
8984
9118
  }
8985
9119
  _tPrice3 = performance.now();
8986
- _context82.next = 41;
9120
+ _context84.next = 41;
8987
9121
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
8988
9122
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
8989
9123
  });
8990
9124
  case 41:
8991
- _filteredProducts2 = _context82.sent;
9125
+ _filteredProducts2 = _context84.sent;
8992
9126
  perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
8993
9127
  count: _filteredProducts2.length,
8994
9128
  extension_type: extension_type
@@ -9025,7 +9159,7 @@ var Server = /*#__PURE__*/function () {
9025
9159
  filteredCount: _filteredProducts2.length,
9026
9160
  extension_type: extension_type
9027
9161
  });
9028
- return _context82.abrupt("return", {
9162
+ return _context84.abrupt("return", {
9029
9163
  code: 200,
9030
9164
  data: this.buildProductQueryResultPayload(_filteredProducts2),
9031
9165
  message: '',
@@ -9033,50 +9167,50 @@ var Server = /*#__PURE__*/function () {
9033
9167
  });
9034
9168
  case 57:
9035
9169
  if (this.menu) {
9036
- _context82.next = 60;
9170
+ _context84.next = 60;
9037
9171
  break;
9038
9172
  }
9039
9173
  this.logError('computeProductQueryResult: Menu 模块未注册');
9040
- return _context82.abrupt("return", {
9174
+ return _context84.abrupt("return", {
9041
9175
  message: 'Menu 模块未注册',
9042
9176
  data: this.buildProductQueryResultPayload([], 0)
9043
9177
  });
9044
9178
  case 60:
9045
9179
  if (this.schedule) {
9046
- _context82.next = 63;
9180
+ _context84.next = 63;
9047
9181
  break;
9048
9182
  }
9049
9183
  this.logError('computeProductQueryResult: Schedule 模块未注册');
9050
- return _context82.abrupt("return", {
9184
+ return _context84.abrupt("return", {
9051
9185
  message: 'Schedule 模块未注册',
9052
9186
  data: this.buildProductQueryResultPayload([], 0)
9053
9187
  });
9054
9188
  case 63:
9055
9189
  activeMenuList = [];
9056
9190
  if (!(menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0)) {
9057
- _context82.next = 76;
9191
+ _context84.next = 76;
9058
9192
  break;
9059
9193
  }
9060
9194
  tMenu = performance.now();
9061
9195
  getActiveMenus = function getActiveMenus() {
9062
- return _this27.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
9063
- var _this27$schedule;
9064
- return ((_this27$schedule = _this27.schedule) === null || _this27$schedule === void 0 ? void 0 : _this27$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
9196
+ return _this28.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
9197
+ var _this28$schedule;
9198
+ return ((_this28$schedule = _this28.schedule) === null || _this28$schedule === void 0 ? void 0 : _this28$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
9065
9199
  });
9066
9200
  };
9067
9201
  activeMenuList = getActiveMenus();
9068
- _context82.t0 = !activeMenuList.length;
9069
- if (!_context82.t0) {
9070
- _context82.next = 73;
9202
+ _context84.t0 = !activeMenuList.length;
9203
+ if (!_context84.t0) {
9204
+ _context84.next = 73;
9071
9205
  break;
9072
9206
  }
9073
- _context82.next = 72;
9207
+ _context84.next = 72;
9074
9208
  return this.refreshMenuScheduleCacheAfterEmptyResult();
9075
9209
  case 72:
9076
- _context82.t0 = _context82.sent;
9210
+ _context84.t0 = _context84.sent;
9077
9211
  case 73:
9078
- if (!_context82.t0) {
9079
- _context82.next = 75;
9212
+ if (!_context84.t0) {
9213
+ _context84.next = 75;
9080
9214
  break;
9081
9215
  }
9082
9216
  activeMenuList = getActiveMenus();
@@ -9096,22 +9230,22 @@ var Server = /*#__PURE__*/function () {
9096
9230
  });
9097
9231
  tPrice = performance.now();
9098
9232
  if (!(scopedProductIds.length > 0)) {
9099
- _context82.next = 87;
9233
+ _context84.next = 87;
9100
9234
  break;
9101
9235
  }
9102
- _context82.next = 84;
9236
+ _context84.next = 84;
9103
9237
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
9104
9238
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
9105
9239
  productIds: productScope.isAllProducts ? undefined : scopedProductIds
9106
9240
  });
9107
9241
  case 84:
9108
- _context82.t1 = _context82.sent;
9109
- _context82.next = 88;
9242
+ _context84.t1 = _context84.sent;
9243
+ _context84.next = 88;
9110
9244
  break;
9111
9245
  case 87:
9112
- _context82.t1 = [];
9246
+ _context84.t1 = [];
9113
9247
  case 88:
9114
- filteredProducts = _context82.t1;
9248
+ filteredProducts = _context84.t1;
9115
9249
  perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
9116
9250
  count: filteredProducts.length,
9117
9251
  scopedProductCount: scopedProductIds.length
@@ -9150,7 +9284,7 @@ var Server = /*#__PURE__*/function () {
9150
9284
  filteredCount: filteredProducts.length,
9151
9285
  activeMenuCount: activeMenuList.length
9152
9286
  });
9153
- return _context82.abrupt("return", {
9287
+ return _context84.abrupt("return", {
9154
9288
  code: 200,
9155
9289
  data: this.buildProductQueryResultPayload(filteredProducts),
9156
9290
  message: '',
@@ -9158,11 +9292,11 @@ var Server = /*#__PURE__*/function () {
9158
9292
  });
9159
9293
  case 104:
9160
9294
  case "end":
9161
- return _context82.stop();
9295
+ return _context84.stop();
9162
9296
  }
9163
- }, _callee82, this);
9297
+ }, _callee84, this);
9164
9298
  }));
9165
- function computeProductQueryResult(_x93, _x94) {
9299
+ function computeProductQueryResult(_x94, _x95) {
9166
9300
  return _computeProductQueryResult.apply(this, arguments);
9167
9301
  }
9168
9302
  return computeProductQueryResult;
@@ -9200,74 +9334,74 @@ var Server = /*#__PURE__*/function () {
9200
9334
  }, {
9201
9335
  key: "recomputeAndNotifyProductQuery",
9202
9336
  value: (function () {
9203
- var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee83(options) {
9337
+ var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee85(options) {
9204
9338
  var _iterator18, _step18, _step18$value, subscriberId, subscriber, result, errorMessage;
9205
- return _regeneratorRuntime().wrap(function _callee83$(_context83) {
9206
- while (1) switch (_context83.prev = _context83.next) {
9339
+ return _regeneratorRuntime().wrap(function _callee85$(_context85) {
9340
+ while (1) switch (_context85.prev = _context85.next) {
9207
9341
  case 0:
9208
9342
  if (!(this.productQuerySubscribers.size === 0)) {
9209
- _context83.next = 2;
9343
+ _context85.next = 2;
9210
9344
  break;
9211
9345
  }
9212
- return _context83.abrupt("return");
9346
+ return _context85.abrupt("return");
9213
9347
  case 2:
9214
9348
  this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
9215
9349
  subscriberCount: this.productQuerySubscribers.size,
9216
9350
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
9217
9351
  });
9218
9352
  _iterator18 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
9219
- _context83.prev = 4;
9353
+ _context85.prev = 4;
9220
9354
  _iterator18.s();
9221
9355
  case 6:
9222
9356
  if ((_step18 = _iterator18.n()).done) {
9223
- _context83.next = 23;
9357
+ _context85.next = 23;
9224
9358
  break;
9225
9359
  }
9226
9360
  _step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
9227
- _context83.prev = 8;
9228
- _context83.next = 11;
9361
+ _context85.prev = 8;
9362
+ _context85.next = 11;
9229
9363
  return this.computeProductQueryResult(subscriber.context, {
9230
9364
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
9231
9365
  });
9232
9366
  case 11:
9233
- result = _context83.sent;
9234
- _context83.next = 14;
9367
+ result = _context85.sent;
9368
+ _context85.next = 14;
9235
9369
  return subscriber.callback(result);
9236
9370
  case 14:
9237
9371
  this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
9238
9372
  subscriberId: subscriberId
9239
9373
  });
9240
- _context83.next = 21;
9374
+ _context85.next = 21;
9241
9375
  break;
9242
9376
  case 17:
9243
- _context83.prev = 17;
9244
- _context83.t0 = _context83["catch"](8);
9245
- errorMessage = _context83.t0 instanceof Error ? _context83.t0.message : String(_context83.t0);
9377
+ _context85.prev = 17;
9378
+ _context85.t0 = _context85["catch"](8);
9379
+ errorMessage = _context85.t0 instanceof Error ? _context85.t0.message : String(_context85.t0);
9246
9380
  this.logError('recomputeAndNotifyProductQuery: 推送失败', {
9247
9381
  subscriberId: subscriberId,
9248
9382
  error: errorMessage
9249
9383
  });
9250
9384
  case 21:
9251
- _context83.next = 6;
9385
+ _context85.next = 6;
9252
9386
  break;
9253
9387
  case 23:
9254
- _context83.next = 28;
9388
+ _context85.next = 28;
9255
9389
  break;
9256
9390
  case 25:
9257
- _context83.prev = 25;
9258
- _context83.t1 = _context83["catch"](4);
9259
- _iterator18.e(_context83.t1);
9391
+ _context85.prev = 25;
9392
+ _context85.t1 = _context85["catch"](4);
9393
+ _iterator18.e(_context85.t1);
9260
9394
  case 28:
9261
- _context83.prev = 28;
9395
+ _context85.prev = 28;
9262
9396
  _iterator18.f();
9263
- return _context83.finish(28);
9397
+ return _context85.finish(28);
9264
9398
  case 31:
9265
9399
  case "end":
9266
- return _context83.stop();
9400
+ return _context85.stop();
9267
9401
  }
9268
- }, _callee83, this, [[4, 25, 28, 31], [8, 17]]);
9402
+ }, _callee85, this, [[4, 25, 28, 31], [8, 17]]);
9269
9403
  }));
9270
- function recomputeAndNotifyProductQuery(_x95) {
9404
+ function recomputeAndNotifyProductQuery(_x96) {
9271
9405
  return _recomputeAndNotifyProductQuery.apply(this, arguments);
9272
9406
  }
9273
9407
  return recomputeAndNotifyProductQuery;
@@ -9279,16 +9413,16 @@ var Server = /*#__PURE__*/function () {
9279
9413
  }, {
9280
9414
  key: "recomputeAndNotifyOrderQuery",
9281
9415
  value: (function () {
9282
- var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee84() {
9416
+ var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee86() {
9283
9417
  var notifyStartAt, _iterator19, _step19, _step19$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
9284
- return _regeneratorRuntime().wrap(function _callee84$(_context84) {
9285
- while (1) switch (_context84.prev = _context84.next) {
9418
+ return _regeneratorRuntime().wrap(function _callee86$(_context86) {
9419
+ while (1) switch (_context86.prev = _context86.next) {
9286
9420
  case 0:
9287
9421
  if (!(this.orderQuerySubscribers.size === 0)) {
9288
- _context84.next = 2;
9422
+ _context86.next = 2;
9289
9423
  break;
9290
9424
  }
9291
- return _context84.abrupt("return");
9425
+ return _context86.abrupt("return");
9292
9426
  case 2:
9293
9427
  notifyStartAt = Date.now();
9294
9428
  this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
@@ -9296,20 +9430,20 @@ var Server = /*#__PURE__*/function () {
9296
9430
  notifyStartAt: new Date(notifyStartAt).toISOString()
9297
9431
  });
9298
9432
  _iterator19 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
9299
- _context84.prev = 5;
9433
+ _context86.prev = 5;
9300
9434
  _iterator19.s();
9301
9435
  case 7:
9302
9436
  if ((_step19 = _iterator19.n()).done) {
9303
- _context84.next = 27;
9437
+ _context86.next = 27;
9304
9438
  break;
9305
9439
  }
9306
9440
  _step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
9307
- _context84.prev = 9;
9441
+ _context86.prev = 9;
9308
9442
  computeStartAt = Date.now();
9309
- _context84.next = 13;
9443
+ _context86.next = 13;
9310
9444
  return this.computeOrderQueryResult(subscriber.context);
9311
9445
  case 13:
9312
- result = _context84.sent;
9446
+ result = _context86.sent;
9313
9447
  computeEndAt = Date.now();
9314
9448
  callbackStartAt = Date.now();
9315
9449
  subscriber.callback(result);
@@ -9320,30 +9454,30 @@ var Server = /*#__PURE__*/function () {
9320
9454
  callbackDurationMs: callbackEndAt - callbackStartAt,
9321
9455
  totalDurationMs: callbackEndAt - computeStartAt
9322
9456
  });
9323
- _context84.next = 25;
9457
+ _context86.next = 25;
9324
9458
  break;
9325
9459
  case 21:
9326
- _context84.prev = 21;
9327
- _context84.t0 = _context84["catch"](9);
9328
- errorMessage = _context84.t0 instanceof Error ? _context84.t0.message : String(_context84.t0);
9460
+ _context86.prev = 21;
9461
+ _context86.t0 = _context86["catch"](9);
9462
+ errorMessage = _context86.t0 instanceof Error ? _context86.t0.message : String(_context86.t0);
9329
9463
  this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
9330
9464
  subscriberId: subscriberId,
9331
9465
  error: errorMessage
9332
9466
  });
9333
9467
  case 25:
9334
- _context84.next = 7;
9468
+ _context86.next = 7;
9335
9469
  break;
9336
9470
  case 27:
9337
- _context84.next = 32;
9471
+ _context86.next = 32;
9338
9472
  break;
9339
9473
  case 29:
9340
- _context84.prev = 29;
9341
- _context84.t1 = _context84["catch"](5);
9342
- _iterator19.e(_context84.t1);
9474
+ _context86.prev = 29;
9475
+ _context86.t1 = _context86["catch"](5);
9476
+ _iterator19.e(_context86.t1);
9343
9477
  case 32:
9344
- _context84.prev = 32;
9478
+ _context86.prev = 32;
9345
9479
  _iterator19.f();
9346
- return _context84.finish(32);
9480
+ return _context86.finish(32);
9347
9481
  case 35:
9348
9482
  notifyEndAt = Date.now();
9349
9483
  this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
@@ -9352,9 +9486,9 @@ var Server = /*#__PURE__*/function () {
9352
9486
  });
9353
9487
  case 37:
9354
9488
  case "end":
9355
- return _context84.stop();
9489
+ return _context86.stop();
9356
9490
  }
9357
- }, _callee84, this, [[5, 29, 32, 35], [9, 21]]);
9491
+ }, _callee86, this, [[5, 29, 32, 35], [9, 21]]);
9358
9492
  }));
9359
9493
  function recomputeAndNotifyOrderQuery() {
9360
9494
  return _recomputeAndNotifyOrderQuery.apply(this, arguments);
@@ -9372,7 +9506,7 @@ var Server = /*#__PURE__*/function () {
9372
9506
  }, {
9373
9507
  key: "notifySalesSearchSubscribers",
9374
9508
  value: function notifySalesSearchSubscribers(payload) {
9375
- var _this28 = this;
9509
+ var _this29 = this;
9376
9510
  if (this.salesSearchSubscribers.size === 0) return;
9377
9511
  var changedOrders = this.extractChangedOrdersFromPayload(payload);
9378
9512
  if (changedOrders.length === 0) {
@@ -9390,21 +9524,21 @@ var Server = /*#__PURE__*/function () {
9390
9524
  subscriber = _step20$value[1];
9391
9525
  try {
9392
9526
  var changedVisibleOrders = changedOrders.filter(function (order) {
9393
- var orderId = _this28.getSalesSearchOrderId(order);
9527
+ var orderId = _this29.getSalesSearchOrderId(order);
9394
9528
  return !!orderId && subscriber.visibleOrderIds.has(orderId);
9395
9529
  });
9396
9530
  if (changedVisibleOrders.length === 0) {
9397
9531
  return 1; // continue
9398
9532
  }
9399
- subscriber.callback(_this28.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
9400
- _this28.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
9533
+ subscriber.callback(_this29.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
9534
+ _this29.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
9401
9535
  subscriberId: subscriberId,
9402
9536
  kind: subscriber.kind,
9403
9537
  count: changedVisibleOrders.length
9404
9538
  });
9405
9539
  } catch (error) {
9406
9540
  var errorMessage = error instanceof Error ? error.message : String(error);
9407
- _this28.logError('notifySalesSearchSubscribers: 推送失败', {
9541
+ _this29.logError('notifySalesSearchSubscribers: 推送失败', {
9408
9542
  subscriberId: subscriberId,
9409
9543
  error: errorMessage
9410
9544
  });
@@ -9495,67 +9629,67 @@ var Server = /*#__PURE__*/function () {
9495
9629
  }, {
9496
9630
  key: "recomputeAndNotifyBookingQuery",
9497
9631
  value: (function () {
9498
- var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee85() {
9632
+ var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee87() {
9499
9633
  var _iterator21, _step21, _step21$value, subscriberId, subscriber, result, errorMessage;
9500
- return _regeneratorRuntime().wrap(function _callee85$(_context85) {
9501
- while (1) switch (_context85.prev = _context85.next) {
9634
+ return _regeneratorRuntime().wrap(function _callee87$(_context87) {
9635
+ while (1) switch (_context87.prev = _context87.next) {
9502
9636
  case 0:
9503
9637
  if (!(this.bookingQuerySubscribers.size === 0)) {
9504
- _context85.next = 2;
9638
+ _context87.next = 2;
9505
9639
  break;
9506
9640
  }
9507
- return _context85.abrupt("return");
9641
+ return _context87.abrupt("return");
9508
9642
  case 2:
9509
9643
  this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
9510
9644
  subscriberCount: this.bookingQuerySubscribers.size
9511
9645
  });
9512
9646
  _iterator21 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
9513
- _context85.prev = 4;
9647
+ _context87.prev = 4;
9514
9648
  _iterator21.s();
9515
9649
  case 6:
9516
9650
  if ((_step21 = _iterator21.n()).done) {
9517
- _context85.next = 22;
9651
+ _context87.next = 22;
9518
9652
  break;
9519
9653
  }
9520
9654
  _step21$value = _slicedToArray(_step21.value, 2), subscriberId = _step21$value[0], subscriber = _step21$value[1];
9521
- _context85.prev = 8;
9522
- _context85.next = 11;
9655
+ _context87.prev = 8;
9656
+ _context87.next = 11;
9523
9657
  return this.computeBookingQueryResult(subscriber.context);
9524
9658
  case 11:
9525
- result = _context85.sent;
9659
+ result = _context87.sent;
9526
9660
  subscriber.callback(result);
9527
9661
  this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
9528
9662
  subscriberId: subscriberId
9529
9663
  });
9530
- _context85.next = 20;
9664
+ _context87.next = 20;
9531
9665
  break;
9532
9666
  case 16:
9533
- _context85.prev = 16;
9534
- _context85.t0 = _context85["catch"](8);
9535
- errorMessage = _context85.t0 instanceof Error ? _context85.t0.message : String(_context85.t0);
9667
+ _context87.prev = 16;
9668
+ _context87.t0 = _context87["catch"](8);
9669
+ errorMessage = _context87.t0 instanceof Error ? _context87.t0.message : String(_context87.t0);
9536
9670
  this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
9537
9671
  subscriberId: subscriberId,
9538
9672
  error: errorMessage
9539
9673
  });
9540
9674
  case 20:
9541
- _context85.next = 6;
9675
+ _context87.next = 6;
9542
9676
  break;
9543
9677
  case 22:
9544
- _context85.next = 27;
9678
+ _context87.next = 27;
9545
9679
  break;
9546
9680
  case 24:
9547
- _context85.prev = 24;
9548
- _context85.t1 = _context85["catch"](4);
9549
- _iterator21.e(_context85.t1);
9681
+ _context87.prev = 24;
9682
+ _context87.t1 = _context87["catch"](4);
9683
+ _iterator21.e(_context87.t1);
9550
9684
  case 27:
9551
- _context85.prev = 27;
9685
+ _context87.prev = 27;
9552
9686
  _iterator21.f();
9553
- return _context85.finish(27);
9687
+ return _context87.finish(27);
9554
9688
  case 30:
9555
9689
  case "end":
9556
- return _context85.stop();
9690
+ return _context87.stop();
9557
9691
  }
9558
- }, _callee85, this, [[4, 24, 27, 30], [8, 16]]);
9692
+ }, _callee87, this, [[4, 24, 27, 30], [8, 16]]);
9559
9693
  }));
9560
9694
  function recomputeAndNotifyBookingQuery() {
9561
9695
  return _recomputeAndNotifyBookingQuery.apply(this, arguments);