@pisell/pisellos 2.3.211 → 2.3.213

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.
@@ -640,7 +640,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
640
640
  generateIdempotencyToken(): string;
641
641
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
642
642
  createOrder(params: CommitOrderParams['query']): {
643
- type: "virtual" | "appointment_booking";
643
+ type: "appointment_booking" | "virtual";
644
644
  platform: string;
645
645
  sales_channel: string;
646
646
  order_sales_channel: string;
@@ -43,6 +43,7 @@ import dayjs from 'dayjs';
43
43
  import { getDiscountLifecycleReason } from "../Discount/availability";
44
44
  import { allowsProductVoucher, productVoucherGroupKey, validateProductVoucherGroups, voucherGroupError } from "./utils/productVoucherGroups";
45
45
  import { stripOsPrivatePayloadFields } from "../../utils/os-private-payload";
46
+ import { buildResourceIdentifierBuzzer } from "../../utils/resource-identifier-buzzer";
46
47
  import { buildSalesNoteText, decodeSalesNotesSnapshot, getSalesNotePolicy } from "./salesNotes";
47
48
  import { ensureOrderPaymentNumber, mergeOrderPaymentRecord, resolveOrderPaymentIdentity } from "./payment-utils";
48
49
  import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
@@ -8750,18 +8751,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
8750
8751
  key: "submitSalesOrder",
8751
8752
  value: function () {
8752
8753
  var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
8753
- var url, query, fetchUrl, requestQuery;
8754
+ var url, query, fetchUrl, handledByOsServer, requestQuery;
8754
8755
  return _regeneratorRuntime().wrap(function _callee58$(_context62) {
8755
8756
  while (1) switch (_context62.prev = _context62.next) {
8756
8757
  case 0:
8757
8758
  url = params.url, query = params.query;
8758
8759
  fetchUrl = url || '/order/sales/checkout';
8759
- requestQuery = this.isSalesCheckoutHandledByOsServer(fetchUrl) ? query : stripLocalEftposState(stripOsPrivatePayloadFields(query));
8760
+ handledByOsServer = this.isSalesCheckoutHandledByOsServer(fetchUrl);
8761
+ requestQuery = handledByOsServer ? query : stripLocalEftposState(stripOsPrivatePayloadFields(query));
8762
+ if (!handledByOsServer && String((query === null || query === void 0 ? void 0 : query._os_fulfillment_ref_mode) || '').trim() === 'resource_identifier') {
8763
+ requestQuery.buzzer = buildResourceIdentifierBuzzer(requestQuery.bookings);
8764
+ }
8760
8765
  return _context62.abrupt("return", this.request.post(fetchUrl, requestQuery, {
8761
8766
  osServer: true,
8762
8767
  customToast: function customToast() {}
8763
8768
  }));
8764
- case 4:
8769
+ case 6:
8765
8770
  case "end":
8766
8771
  return _context62.stop();
8767
8772
  }
@@ -657,6 +657,9 @@ export interface SubmitSalesOrderParams {
657
657
  note: string;
658
658
  delivery_type?: string;
659
659
  table_number?: Record<string, any>;
660
+ buzzer?: string;
661
+ /** Runtime-only fulfillment mode, removed before a cloud checkout. */
662
+ _os_fulfillment_ref_mode?: string;
660
663
  schedule_date: string;
661
664
  created_at?: string | undefined;
662
665
  products: OrderSubmitProduct[];
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "session" | "duration";
52
+ getProductType(): "normal" | "duration" | "session";
53
53
  }
@@ -524,9 +524,6 @@ declare class Server {
524
524
  private normalizePrintInvoiceTemplateSettings;
525
525
  private extractInvoiceTemplateSettings;
526
526
  private applyCheckoutFulfillmentBuzzer;
527
- private buildCheckoutResourceIdentifierBuzzer;
528
- private getCheckoutResourceIdentifier;
529
- private stringifyCheckoutResourceIdentifier;
530
527
  private normalizeCheckoutSubmitData;
531
528
  private ensureCheckoutOrderNumbers;
532
529
  /**
@@ -25,6 +25,7 @@ import dayjs from 'dayjs';
25
25
  import Decimal from 'decimal.js';
26
26
  import { isLocalFinalizedPayment, PAYMENT_REFRESH_MESSAGE, requiresLocalPaymentRefresh, stripLocalEftposState } from "../modules/Order/localEftposState";
27
27
  import { cloneDeep } from 'lodash-es';
28
+ import { buildResourceIdentifierBuzzer } from "../utils/resource-identifier-buzzer";
28
29
  import { ProductsModule } from "./modules/products";
29
30
  import { MenuModule } from "./modules/menu";
30
31
  import { QuotationModule } from "./modules/quotation";
@@ -5894,7 +5895,7 @@ var Server = /*#__PURE__*/function () {
5894
5895
  return next;
5895
5896
  }
5896
5897
  if (refMode === 'resource_identifier') {
5897
- next.buzzer = this.buildCheckoutResourceIdentifierBuzzer(next.bookings);
5898
+ next.buzzer = buildResourceIdentifierBuzzer(next.bookings);
5898
5899
  } else if (refMode === 'sale_number') {
5899
5900
  next.buzzer = this.isBlankCheckoutValue(next.shop_order_number) ? '' : String(next.shop_order_number);
5900
5901
  } else if (refMode === 'short_number') {
@@ -5911,63 +5912,6 @@ var Server = /*#__PURE__*/function () {
5911
5912
  });
5912
5913
  return next;
5913
5914
  }
5914
- }, {
5915
- key: "buildCheckoutResourceIdentifierBuzzer",
5916
- value: function buildCheckoutResourceIdentifierBuzzer(bookings) {
5917
- var _this17 = this;
5918
- if (!Array.isArray(bookings)) return '';
5919
- var values = [];
5920
- var seen = new Set();
5921
- var visitResource = function visitResource(resource, fallbackName) {
5922
- var identifier = _this17.getCheckoutResourceIdentifier(resource, fallbackName);
5923
- if (identifier && !seen.has(identifier)) {
5924
- seen.add(identifier);
5925
- values.push(identifier);
5926
- }
5927
- if (Array.isArray(resource === null || resource === void 0 ? void 0 : resource.children)) {
5928
- resource.children.forEach(function (child) {
5929
- return visitResource(child);
5930
- });
5931
- }
5932
- };
5933
- bookings.forEach(function (booking) {
5934
- if (Array.isArray(booking === null || booking === void 0 ? void 0 : booking.resources)) {
5935
- booking.resources.forEach(function (resource, index) {
5936
- visitResource(resource, index === 0 ? booking === null || booking === void 0 ? void 0 : booking.relation_form_name : undefined);
5937
- });
5938
- }
5939
- });
5940
- return values.join(',');
5941
- }
5942
- }, {
5943
- key: "getCheckoutResourceIdentifier",
5944
- value: function getCheckoutResourceIdentifier(resource, fallbackName) {
5945
- var _resource$metadata, _resource$metadata2;
5946
- if (!resource || _typeof(resource) !== 'object') return '';
5947
- var candidates = [resource.main_field, resource.name, resource.title, (_resource$metadata = resource.metadata) === null || _resource$metadata === void 0 ? void 0 : _resource$metadata.resource_name, (_resource$metadata2 = resource.metadata) === null || _resource$metadata2 === void 0 ? void 0 : _resource$metadata2.name, fallbackName, resource.relation_id, resource.id];
5948
- for (var _i2 = 0, _candidates = candidates; _i2 < _candidates.length; _i2++) {
5949
- var candidate = _candidates[_i2];
5950
- var value = this.stringifyCheckoutResourceIdentifier(candidate);
5951
- if (value) return value;
5952
- }
5953
- return '';
5954
- }
5955
- }, {
5956
- key: "stringifyCheckoutResourceIdentifier",
5957
- value: function stringifyCheckoutResourceIdentifier(value) {
5958
- if (value === undefined || value === null) return '';
5959
- if (typeof value === 'string' || typeof value === 'number') {
5960
- return String(value).trim();
5961
- }
5962
- if (_typeof(value) !== 'object' || Array.isArray(value)) return '';
5963
- var localeCandidates = [value.original, value.auto, value.en, value['zh-CN'], value.zh_CN, value['zh-HK'], value.zh_HK];
5964
- for (var _i3 = 0, _localeCandidates = localeCandidates; _i3 < _localeCandidates.length; _i3++) {
5965
- var candidate = _localeCandidates[_i3];
5966
- var normalized = this.stringifyCheckoutResourceIdentifier(candidate);
5967
- if (normalized) return normalized;
5968
- }
5969
- return '';
5970
- }
5971
5915
  }, {
5972
5916
  key: "normalizeCheckoutSubmitData",
5973
5917
  value: function () {
@@ -6968,7 +6912,7 @@ var Server = /*#__PURE__*/function () {
6968
6912
  key: "handlePendingSyncCheckoutOrder",
6969
6913
  value: function () {
6970
6914
  var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(params) {
6971
- var _this18 = this;
6915
+ var _this17 = this;
6972
6916
  var backendPath, data, title, reason, invoiceTemplateSettings, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
6973
6917
  return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6974
6918
  while (1) switch (_context69.prev = _context69.next) {
@@ -7021,7 +6965,7 @@ var Server = /*#__PURE__*/function () {
7021
6965
  });
7022
6966
  changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
7023
6967
  var _payment$metadata;
7024
- 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);
6968
+ return sum + _this17.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
7025
6969
  }, 0);
7026
6970
  return _context69.abrupt("return", {
7027
6971
  code: 200,
@@ -7141,11 +7085,11 @@ var Server = /*#__PURE__*/function () {
7141
7085
  }, {
7142
7086
  key: "shouldAutoPrintReceiptForPaymentStatus",
7143
7087
  value: function shouldAutoPrintReceiptForPaymentStatus(order, statuses) {
7144
- var _this19 = this;
7088
+ var _this18 = this;
7145
7089
  if (statuses === undefined) return this.isSalesOrderFullyPaid(order);
7146
7090
  var paymentStatus = String((order === null || order === void 0 ? void 0 : order.payment_status) || '').toLowerCase();
7147
7091
  return statuses.some(function (status) {
7148
- return status === 'paid' ? _this19.isSalesOrderFullyPaid(order) : paymentStatus === status;
7092
+ return status === 'paid' ? _this18.isSalesOrderFullyPaid(order) : paymentStatus === status;
7149
7093
  });
7150
7094
  }
7151
7095
  }, {
@@ -7193,13 +7137,13 @@ var Server = /*#__PURE__*/function () {
7193
7137
  }, {
7194
7138
  key: "sumPaidOrderPayments",
7195
7139
  value: function sumPaidOrderPayments(payments) {
7196
- var _this20 = this;
7140
+ var _this19 = this;
7197
7141
  if (!Array.isArray(payments)) return 0;
7198
7142
  return payments.reduce(function (sum, payment) {
7199
7143
  var _payment$amount;
7200
7144
  var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
7201
7145
  if (status !== 'paid') return sum;
7202
- 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);
7146
+ return sum + _this19.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);
7203
7147
  }, 0);
7204
7148
  }
7205
7149
  }, {
@@ -7215,7 +7159,7 @@ var Server = /*#__PURE__*/function () {
7215
7159
  value: function () {
7216
7160
  var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(order) {
7217
7161
  var _this$products3,
7218
- _this21 = this;
7162
+ _this20 = this;
7219
7163
  var products, productIdSet, productIds, entries;
7220
7164
  return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7221
7165
  while (1) switch (_context72.prev = _context72.next) {
@@ -7248,20 +7192,20 @@ var Server = /*#__PURE__*/function () {
7248
7192
  _context72.next = 8;
7249
7193
  return Promise.all(productIds.map( /*#__PURE__*/function () {
7250
7194
  var _ref77 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(id) {
7251
- var _this21$products, _this21$products$getP, product;
7195
+ var _this20$products, _this20$products$getP, product;
7252
7196
  return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7253
7197
  while (1) switch (_context71.prev = _context71.next) {
7254
7198
  case 0:
7255
7199
  _context71.prev = 0;
7256
7200
  _context71.next = 3;
7257
- 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));
7201
+ return (_this20$products = _this20.products) === null || _this20$products === void 0 || (_this20$products$getP = _this20$products.getProductById) === null || _this20$products$getP === void 0 ? void 0 : _this20$products$getP.call(_this20$products, Number(id));
7258
7202
  case 3:
7259
7203
  product = _context71.sent;
7260
7204
  return _context71.abrupt("return", product ? [String(id), product] : null);
7261
7205
  case 7:
7262
7206
  _context71.prev = 7;
7263
7207
  _context71.t0 = _context71["catch"](0);
7264
- _this21.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
7208
+ _this20.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
7265
7209
  product_id: id,
7266
7210
  error: _context71.t0 instanceof Error ? _context71.t0.message : String(_context71.t0)
7267
7211
  });
@@ -7412,7 +7356,7 @@ var Server = /*#__PURE__*/function () {
7412
7356
  key: "withSalesDetailProductSnapshots",
7413
7357
  value: function () {
7414
7358
  var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(order) {
7415
- var _this22 = this;
7359
+ var _this21 = this;
7416
7360
  var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
7417
7361
  return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7418
7362
  while (1) switch (_context74.prev = _context74.next) {
@@ -7436,8 +7380,8 @@ var Server = /*#__PURE__*/function () {
7436
7380
  case 8:
7437
7381
  hasChanged = false;
7438
7382
  enrichedProducts = products.map(function (product) {
7439
- var productWithBundleSnapshots = _this22.withBundleCatalogSnapshots(product, snapshotMap);
7440
- var nextProduct = _this22.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
7383
+ var productWithBundleSnapshots = _this21.withBundleCatalogSnapshots(product, snapshotMap);
7384
+ var nextProduct = _this21.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
7441
7385
  if (nextProduct !== product) hasChanged = true;
7442
7386
  return nextProduct;
7443
7387
  });
@@ -7465,13 +7409,13 @@ var Server = /*#__PURE__*/function () {
7465
7409
  }, {
7466
7410
  key: "withPendingSyncProductTitles",
7467
7411
  value: function withPendingSyncProductTitles(order, productMap) {
7468
- var _this23 = this;
7412
+ var _this22 = this;
7469
7413
  var products = Array.isArray(order.products) ? order.products : null;
7470
7414
  if (!(products !== null && products !== void 0 && products.length)) return order;
7471
7415
  return _objectSpread(_objectSpread({}, order), {}, {
7472
7416
  products: products.map(function (product) {
7473
7417
  return _objectSpread(_objectSpread({}, product), {}, {
7474
- product_title: _this23.buildProductTitleSnapshot(product, productMap)
7418
+ product_title: _this22.buildProductTitleSnapshot(product, productMap)
7475
7419
  });
7476
7420
  })
7477
7421
  });
@@ -7482,7 +7426,7 @@ var Server = /*#__PURE__*/function () {
7482
7426
  var _product$product_id4,
7483
7427
  _product$product,
7484
7428
  _fallbackProduct$prod,
7485
- _this24 = this;
7429
+ _this23 = this;
7486
7430
  var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
7487
7431
  var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
7488
7432
  var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
@@ -7490,7 +7434,7 @@ var Server = /*#__PURE__*/function () {
7490
7434
  var currentLocale = this.getProductTitleSnapshotCurrentLocale();
7491
7435
  var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
7492
7436
  return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
7493
- snapshot[key] = _this24.resolveProductTitleValue(ownTitle, key, currentLocale) || _this24.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
7437
+ snapshot[key] = _this23.resolveProductTitleValue(ownTitle, key, currentLocale) || _this23.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
7494
7438
  return snapshot;
7495
7439
  }, {});
7496
7440
  }
@@ -7552,8 +7496,8 @@ var Server = /*#__PURE__*/function () {
7552
7496
  if (value === undefined || value === null || value === '') return null;
7553
7497
  if (_typeof(value) !== 'object') return String(value);
7554
7498
  var preferredKeys = ['auto', 'en', 'original', 'zh-CN', 'zh_CN', 'zh-HK', 'zh_HK', 'kitchen', 'ja', 'pt', 'default'];
7555
- for (var _i4 = 0, _preferredKeys = preferredKeys; _i4 < _preferredKeys.length; _i4++) {
7556
- var _key6 = _preferredKeys[_i4];
7499
+ for (var _i2 = 0, _preferredKeys = preferredKeys; _i2 < _preferredKeys.length; _i2++) {
7500
+ var _key6 = _preferredKeys[_i2];
7557
7501
  var rawValue = value[_key6];
7558
7502
  if (rawValue !== undefined && rawValue !== null && rawValue !== '') return String(rawValue);
7559
7503
  }
@@ -7589,14 +7533,14 @@ var Server = /*#__PURE__*/function () {
7589
7533
  key: "enrichPaymentNamesByCode",
7590
7534
  value: function () {
7591
7535
  var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(order) {
7592
- var _this25 = this;
7536
+ var _this24 = this;
7593
7537
  var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
7594
7538
  return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7595
7539
  while (1) switch (_context75.prev = _context75.next) {
7596
7540
  case 0:
7597
7541
  payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
7598
7542
  hasMissingName = payments.some(function (payment) {
7599
- return _this25.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this25.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
7543
+ return _this24.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this24.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
7600
7544
  });
7601
7545
  if (hasMissingName) {
7602
7546
  _context75.next = 4;
@@ -7629,9 +7573,9 @@ var Server = /*#__PURE__*/function () {
7629
7573
  }
7630
7574
  hasResolvedName = false;
7631
7575
  enrichedPayments = payments.map(function (payment) {
7632
- if (!_this25.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
7633
- if (!_this25.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
7634
- var name = nameByCode.get(_this25.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
7576
+ if (!_this24.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
7577
+ if (!_this24.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
7578
+ var name = nameByCode.get(_this24.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
7635
7579
  if (!name) return payment;
7636
7580
  hasResolvedName = true;
7637
7581
  return _objectSpread(_objectSpread({}, payment), {}, {
@@ -8050,8 +7994,8 @@ var Server = /*#__PURE__*/function () {
8050
7994
  pushRaw(this.extractQueryParam(url, 'order_ids'));
8051
7995
  var seen = new Set();
8052
7996
  var result = [];
8053
- for (var _i5 = 0, _collected = collected; _i5 < _collected.length; _i5++) {
8054
- var id = _collected[_i5];
7997
+ for (var _i3 = 0, _collected = collected; _i3 < _collected.length; _i3++) {
7998
+ var id = _collected[_i3];
8055
7999
  if (seen.has(id)) continue;
8056
8000
  seen.add(id);
8057
8001
  result.push(id);
@@ -8329,8 +8273,8 @@ var Server = /*#__PURE__*/function () {
8329
8273
  value: function extractOrderDataFromCheckoutResponse(response) {
8330
8274
  var _response$data5, _response$data6;
8331
8275
  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];
8332
- for (var _i6 = 0, _candidates2 = candidates; _i6 < _candidates2.length; _i6++) {
8333
- var candidate = _candidates2[_i6];
8276
+ for (var _i4 = 0, _candidates = candidates; _i4 < _candidates.length; _i4++) {
8277
+ var candidate = _candidates[_i4];
8334
8278
  if (!candidate || _typeof(candidate) !== 'object') continue;
8335
8279
  if (candidate.order_id !== undefined && candidate.order_id !== null) {
8336
8280
  return candidate;
@@ -8497,10 +8441,10 @@ var Server = /*#__PURE__*/function () {
8497
8441
  value: function extractBackendErrorResponse(error) {
8498
8442
  var _error$response3,
8499
8443
  _error$response4,
8500
- _this26 = this;
8444
+ _this25 = this;
8501
8445
  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];
8502
8446
  return candidates.find(function (candidate) {
8503
- return _this26.isExplicitBackendErrorResponse(candidate);
8447
+ return _this25.isExplicitBackendErrorResponse(candidate);
8504
8448
  }) || null;
8505
8449
  }
8506
8450
  }, {
@@ -8862,7 +8806,7 @@ var Server = /*#__PURE__*/function () {
8862
8806
  value: (function () {
8863
8807
  var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee82(context, options) {
8864
8808
  var _menu_list_ids$length3,
8865
- _this27 = this;
8809
+ _this26 = this;
8866
8810
  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;
8867
8811
  return _regeneratorRuntime().wrap(function _callee82$(_context82) {
8868
8812
  while (1) switch (_context82.prev = _context82.next) {
@@ -9072,9 +9016,9 @@ var Server = /*#__PURE__*/function () {
9072
9016
  }
9073
9017
  tMenu = performance.now();
9074
9018
  getActiveMenus = function getActiveMenus() {
9075
- return _this27.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
9076
- var _this27$schedule;
9077
- return ((_this27$schedule = _this27.schedule) === null || _this27$schedule === void 0 ? void 0 : _this27$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
9019
+ return _this26.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
9020
+ var _this26$schedule;
9021
+ return ((_this26$schedule = _this26.schedule) === null || _this26$schedule === void 0 ? void 0 : _this26$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
9078
9022
  });
9079
9023
  };
9080
9024
  activeMenuList = getActiveMenus();
@@ -9385,7 +9329,7 @@ var Server = /*#__PURE__*/function () {
9385
9329
  }, {
9386
9330
  key: "notifySalesSearchSubscribers",
9387
9331
  value: function notifySalesSearchSubscribers(payload) {
9388
- var _this28 = this;
9332
+ var _this27 = this;
9389
9333
  if (this.salesSearchSubscribers.size === 0) return;
9390
9334
  var changedOrders = this.extractChangedOrdersFromPayload(payload);
9391
9335
  if (changedOrders.length === 0) {
@@ -9403,21 +9347,21 @@ var Server = /*#__PURE__*/function () {
9403
9347
  subscriber = _step20$value[1];
9404
9348
  try {
9405
9349
  var changedVisibleOrders = changedOrders.filter(function (order) {
9406
- var orderId = _this28.getSalesSearchOrderId(order);
9350
+ var orderId = _this27.getSalesSearchOrderId(order);
9407
9351
  return !!orderId && subscriber.visibleOrderIds.has(orderId);
9408
9352
  });
9409
9353
  if (changedVisibleOrders.length === 0) {
9410
9354
  return 1; // continue
9411
9355
  }
9412
- subscriber.callback(_this28.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
9413
- _this28.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
9356
+ subscriber.callback(_this27.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
9357
+ _this27.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
9414
9358
  subscriberId: subscriberId,
9415
9359
  kind: subscriber.kind,
9416
9360
  count: changedVisibleOrders.length
9417
9361
  });
9418
9362
  } catch (error) {
9419
9363
  var errorMessage = error instanceof Error ? error.message : String(error);
9420
- _this28.logError('notifySalesSearchSubscribers: 推送失败', {
9364
+ _this27.logError('notifySalesSearchSubscribers: 推送失败', {
9421
9365
  subscriberId: subscriberId,
9422
9366
  error: errorMessage
9423
9367
  });
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
342
342
  date: string;
343
343
  status: string;
344
344
  week: string;
345
- weekNum: 0 | 2 | 1 | 3 | 5 | 4 | 6;
345
+ weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
346
346
  }[]>;
347
347
  submitTimeSlot(timeSlots: TimeSliceItem): void;
348
348
  private getScheduleDataByIds;
@@ -389,7 +389,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
389
389
  };
390
390
  setOtherData(key: string, value: any): void;
391
391
  getOtherData(key: string): any;
392
- getProductTypeById(id: number): Promise<"normal" | "session" | "duration">;
392
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
393
393
  /**
394
394
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
395
395
  *
@@ -1358,7 +1358,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1358
1358
  return 1;
1359
1359
  };
1360
1360
  return function (payload, _ref3) {
1361
- var _resourceState$relati, _tempOrder$metadata, _ref4, _pickOriginal, _resourceState$table_2, _resourceState$relati2, _pickFirstCustomCapac;
1361
+ var _resourceState$relati, _tempOrder$metadata, _resourceState$table_2, _this5$core, _this5$core$getPlugin, _this5$core$getPlugin2, _coreState$core, _ref4, _ref5, _ref6, _ref7, _pickFromCandidates, _resourceState$table_3, _resourceState$relati2, _pickFirstCustomCapac;
1362
1362
  var bookingUuid = _ref3.bookingUuid,
1363
1363
  tempOrder = _ref3.tempOrder,
1364
1364
  now = _ref3.now;
@@ -1373,14 +1373,46 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1373
1373
  var rawCollectPax = (_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.collect_pax;
1374
1374
  var hasExplicitCollectPax = rawCollectPax !== null && rawCollectPax !== undefined && rawCollectPax !== '';
1375
1375
  var bookingCapacityValue = resolveBookingCapacityValue();
1376
- var pickOriginal = function pickOriginal(value) {
1377
- if (value && _typeof(value) === 'object' && !Array.isArray(value)) {
1378
- var original = value.original;
1379
- return typeof original === 'string' && original.length > 0 ? original : undefined;
1376
+ var resourceNameCandidates = [tempOrder.table_number, resourceState === null || resourceState === void 0 || (_resourceState$table_2 = resourceState.table_form_record) === null || _resourceState$table_2 === void 0 ? void 0 : _resourceState$table_2.name];
1377
+ var toNonEmptyString = function toNonEmptyString(value) {
1378
+ return typeof value === 'string' && value.trim().length > 0 ? value : undefined;
1379
+ };
1380
+ var toNameMap = function toNameMap(value) {
1381
+ return value && _typeof(value) === 'object' && !Array.isArray(value) ? value : undefined;
1382
+ };
1383
+ var pickFromCandidates = function pickFromCandidates(picker) {
1384
+ for (var _i3 = 0, _resourceNameCandidat = resourceNameCandidates; _i3 < _resourceNameCandidat.length; _i3++) {
1385
+ var candidate = _resourceNameCandidat[_i3];
1386
+ var resolved = picker(candidate);
1387
+ if (resolved !== undefined) return resolved;
1388
+ }
1389
+ return undefined;
1390
+ };
1391
+ var pickDirectOrOriginal = function pickDirectOrOriginal(value) {
1392
+ var _toNonEmptyString, _toNameMap;
1393
+ return (_toNonEmptyString = toNonEmptyString(value)) !== null && _toNonEmptyString !== void 0 ? _toNonEmptyString : toNonEmptyString((_toNameMap = toNameMap(value)) === null || _toNameMap === void 0 ? void 0 : _toNameMap.original);
1394
+ };
1395
+ var pickLocalized = function pickLocalized(value, locale) {
1396
+ var _toNameMap2;
1397
+ return toNonEmptyString((_toNameMap2 = toNameMap(value)) === null || _toNameMap2 === void 0 ? void 0 : _toNameMap2[locale]);
1398
+ };
1399
+ var pickFirstNonEmpty = function pickFirstNonEmpty(value) {
1400
+ var nameMap = toNameMap(value);
1401
+ if (!nameMap) return undefined;
1402
+ for (var _i4 = 0, _Object$values = Object.values(nameMap); _i4 < _Object$values.length; _i4++) {
1403
+ var candidate = _Object$values[_i4];
1404
+ var resolved = toNonEmptyString(candidate);
1405
+ if (resolved !== undefined) return resolved;
1380
1406
  }
1381
1407
  return undefined;
1382
1408
  };
1383
- var mainField = (_ref4 = (_pickOriginal = pickOriginal(tempOrder.table_number)) !== null && _pickOriginal !== void 0 ? _pickOriginal : pickOriginal(resourceState === null || resourceState === void 0 || (_resourceState$table_2 = resourceState.table_form_record) === null || _resourceState$table_2 === void 0 ? void 0 : _resourceState$table_2.name)) !== null && _ref4 !== void 0 ? _ref4 : '';
1409
+ var coreState = (_this5$core = _this5.core) === null || _this5$core === void 0 || (_this5$core$getPlugin = _this5$core.getPlugin) === null || _this5$core$getPlugin === void 0 || (_this5$core$getPlugin = _this5$core$getPlugin.call(_this5$core, 'shopStore')) === null || _this5$core$getPlugin === void 0 || (_this5$core$getPlugin2 = _this5$core$getPlugin.get) === null || _this5$core$getPlugin2 === void 0 ? void 0 : _this5$core$getPlugin2.call(_this5$core$getPlugin, 'core');
1410
+ var activeLocale = String((coreState === null || coreState === void 0 ? void 0 : coreState.translateLocale) || (coreState === null || coreState === void 0 || (_coreState$core = coreState.core) === null || _coreState$core === void 0 || (_coreState$core = _coreState$core.shop) === null || _coreState$core === void 0 ? void 0 : _coreState$core.primary_locale) || 'en');
1411
+ var mainField = (_ref4 = (_ref5 = (_ref6 = (_ref7 = (_pickFromCandidates = pickFromCandidates(pickDirectOrOriginal)) !== null && _pickFromCandidates !== void 0 ? _pickFromCandidates : toNonEmptyString(resourceState === null || resourceState === void 0 || (_resourceState$table_3 = resourceState.table_form_record) === null || _resourceState$table_3 === void 0 ? void 0 : _resourceState$table_3.main_field)) !== null && _ref7 !== void 0 ? _ref7 : pickFromCandidates(function (value) {
1412
+ return pickLocalized(value, activeLocale);
1413
+ })) !== null && _ref6 !== void 0 ? _ref6 : pickFromCandidates(function (value) {
1414
+ return pickLocalized(value, 'en');
1415
+ })) !== null && _ref5 !== void 0 ? _ref5 : pickFromCandidates(pickFirstNonEmpty)) !== null && _ref4 !== void 0 ? _ref4 : '';
1384
1416
  var resourceEntry = resourceState && resourceId ? {
1385
1417
  relation_type: 'form',
1386
1418
  like_status: 'common',
@@ -1448,9 +1480,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1448
1480
  var nextProducts = _toConsumableArray(payload.products || []);
1449
1481
  // 加餐(已有 order_id)走 scanOrderMore,原单已含 booking 规则行,勿再追加虚拟规则商品
1450
1482
  if (ruleProduct && ruleProductUid && !tempOrder.order_id) {
1451
- var _ruleProduct$price, _ref5, _ruleProduct$original, _ruleProduct$is_gst;
1483
+ var _ruleProduct$price, _ref8, _ruleProduct$original, _ruleProduct$is_gst;
1452
1484
  var sellingPrice = String((_ruleProduct$price = ruleProduct.price) !== null && _ruleProduct$price !== void 0 ? _ruleProduct$price : '0.00');
1453
- var originalPrice = String((_ref5 = (_ruleProduct$original = ruleProduct.original_price) !== null && _ruleProduct$original !== void 0 ? _ruleProduct$original : ruleProduct.price) !== null && _ref5 !== void 0 ? _ref5 : '0.00');
1485
+ var originalPrice = String((_ref8 = (_ruleProduct$original = ruleProduct.original_price) !== null && _ruleProduct$original !== void 0 ? _ruleProduct$original : ruleProduct.price) !== null && _ref8 !== void 0 ? _ref8 : '0.00');
1454
1486
  nextProducts.push({
1455
1487
  product_id: ruleProduct.id,
1456
1488
  product_variant_id: 0,
@@ -1570,8 +1602,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1570
1602
  var product = _step5.value;
1571
1603
  var uid = (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.unique_identification_number;
1572
1604
  var origins = [product._origin, (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.origin, uid ? (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend.productsByUid) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend[String(uid)]) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.origin : undefined];
1573
- for (var _i3 = 0, _origins = origins; _i3 < _origins.length; _i3++) {
1574
- var origin = _origins[_i3];
1605
+ for (var _i5 = 0, _origins = origins; _i5 < _origins.length; _i5++) {
1606
+ var origin = _origins[_i5];
1575
1607
  if (origin && _typeof(origin) === 'object' && !Array.isArray(origin)) {
1576
1608
  sources.push(_objectSpread(_objectSpread({}, origin), {}, {
1577
1609
  product_id: product.product_id
@@ -2105,16 +2137,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2105
2137
  var rawProductId = (_node$product_id = node.product_id) !== null && _node$product_id !== void 0 ? _node$product_id : node.id;
2106
2138
  var productId = Number(rawProductId);
2107
2139
  if (Number.isFinite(productId) && productId > 0) {
2108
- var _ref6, _node$product_variant;
2109
- var productVariantId = Number((_ref6 = (_node$product_variant = node.product_variant_id) !== null && _node$product_variant !== void 0 ? _node$product_variant : node.variant_id) !== null && _ref6 !== void 0 ? _ref6 : 0);
2140
+ var _ref9, _node$product_variant;
2141
+ var productVariantId = Number((_ref9 = (_node$product_variant = node.product_variant_id) !== null && _node$product_variant !== void 0 ? _node$product_variant : node.variant_id) !== null && _ref9 !== void 0 ? _ref9 : 0);
2110
2142
  var normalizedVariantId = Number.isNaN(productVariantId) ? 0 : productVariantId;
2111
2143
  var key = buildProductKey(productId, normalizedVariantId);
2112
2144
  if (!sourceMap.has(key)) {
2113
2145
  sourceMap.set(key, node);
2114
2146
  }
2115
2147
  }
2116
- for (var _i4 = 0, _Object$values = Object.values(node); _i4 < _Object$values.length; _i4++) {
2117
- var childValue = _Object$values[_i4];
2148
+ for (var _i6 = 0, _Object$values2 = Object.values(node); _i6 < _Object$values2.length; _i6++) {
2149
+ var childValue = _Object$values2[_i6];
2118
2150
  if (childValue && _typeof(childValue) === 'object') {
2119
2151
  collectFromValue(childValue);
2120
2152
  }
@@ -2143,10 +2175,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2143
2175
  }, {
2144
2176
  key: "getItemRuleRuntimeConfig",
2145
2177
  value: function getItemRuleRuntimeConfig() {
2146
- var _ref7, _runtimeConfig$channe, _runtimeConfig$custom, _this$otherParams14;
2178
+ var _ref10, _runtimeConfig$channe, _runtimeConfig$custom, _this$otherParams14;
2147
2179
  var runtimeConfig = this.itemRuleRuntimeConfig || {};
2148
2180
  return _objectSpread(_objectSpread({}, runtimeConfig), {}, {
2149
- channel: (_ref7 = (_runtimeConfig$channe = runtimeConfig.channel) !== null && _runtimeConfig$channe !== void 0 ? _runtimeConfig$channe : (_runtimeConfig$custom = runtimeConfig.custom) === null || _runtimeConfig$custom === void 0 ? void 0 : _runtimeConfig$custom.channel) !== null && _ref7 !== void 0 ? _ref7 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.channel
2181
+ channel: (_ref10 = (_runtimeConfig$channe = runtimeConfig.channel) !== null && _runtimeConfig$channe !== void 0 ? _runtimeConfig$channe : (_runtimeConfig$custom = runtimeConfig.custom) === null || _runtimeConfig$custom === void 0 ? void 0 : _runtimeConfig$custom.channel) !== null && _ref10 !== void 0 ? _ref10 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.channel
2150
2182
  });
2151
2183
  }
2152
2184
  }, {
@@ -3367,14 +3399,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3367
3399
  key: "setOtherParams",
3368
3400
  value: function () {
3369
3401
  var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
3370
- var _ref9,
3371
- _ref9$cover,
3402
+ var _ref12,
3403
+ _ref12$cover,
3372
3404
  cover,
3373
3405
  _args41 = arguments;
3374
3406
  return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3375
3407
  while (1) switch (_context41.prev = _context41.next) {
3376
3408
  case 0:
3377
- _ref9 = _args41.length > 1 && _args41[1] !== undefined ? _args41[1] : {}, _ref9$cover = _ref9.cover, cover = _ref9$cover === void 0 ? false : _ref9$cover;
3409
+ _ref12 = _args41.length > 1 && _args41[1] !== undefined ? _args41[1] : {}, _ref12$cover = _ref12.cover, cover = _ref12$cover === void 0 ? false : _ref12$cover;
3378
3410
  if (cover) {
3379
3411
  this.otherParams = params;
3380
3412
  } else {
@@ -3525,7 +3557,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3525
3557
  key: "syncAdditionalOrderFromResource",
3526
3558
  value: function () {
3527
3559
  var _syncAdditionalOrderFromResource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(resourceId) {
3528
- var _ref10, _ref11, _ref12, _this$store$resource5, _this$store$resource6, _occupyDetails$2, _this$store$resource7, _this$otherParams22, _this$store$resource8, _this$store$order8;
3560
+ var _ref13, _ref14, _ref15, _this$store$resource5, _this$store$resource6, _occupyDetails$2, _this$store$resource7, _this$otherParams22, _this$store$resource8, _this$store$order8;
3529
3561
  var tempOrder, normalizedResourceId, _result, occupyDetails, occupyDetail, resourceSelectType, allowAddItems, result, resourceState;
3530
3562
  return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3531
3563
  while (1) switch (_context43.prev = _context43.next) {
@@ -3537,7 +3569,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3537
3569
  throw new Error('order 模块未初始化');
3538
3570
  case 2:
3539
3571
  tempOrder = this.store.order.ensureTempOrder();
3540
- normalizedResourceId = String((_ref10 = (_ref11 = (_ref12 = resourceId !== null && resourceId !== void 0 ? resourceId : tempOrder.resource_id) !== null && _ref12 !== void 0 ? _ref12 : (_this$store$resource5 = this.store.resource) === null || _this$store$resource5 === void 0 ? void 0 : _this$store$resource5.relationId) !== null && _ref11 !== void 0 ? _ref11 : (_this$store$resource6 = this.store.resource) === null || _this$store$resource6 === void 0 ? void 0 : _this$store$resource6.relation_id) !== null && _ref10 !== void 0 ? _ref10 : '').trim();
3572
+ normalizedResourceId = String((_ref13 = (_ref14 = (_ref15 = resourceId !== null && resourceId !== void 0 ? resourceId : tempOrder.resource_id) !== null && _ref15 !== void 0 ? _ref15 : (_this$store$resource5 = this.store.resource) === null || _this$store$resource5 === void 0 ? void 0 : _this$store$resource5.relationId) !== null && _ref14 !== void 0 ? _ref14 : (_this$store$resource6 = this.store.resource) === null || _this$store$resource6 === void 0 ? void 0 : _this$store$resource6.relation_id) !== null && _ref13 !== void 0 ? _ref13 : '').trim();
3541
3573
  this.logMethodStart('syncAdditionalOrderFromResource', {
3542
3574
  resourceId: normalizedResourceId
3543
3575
  });
@@ -0,0 +1 @@
1
+ export declare function buildResourceIdentifierBuzzer(bookings: any): string;
@@ -0,0 +1,51 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ export function buildResourceIdentifierBuzzer(bookings) {
3
+ if (!Array.isArray(bookings)) return '';
4
+ var values = [];
5
+ var seen = new Set();
6
+ var visitResource = function visitResource(resource, fallbackName) {
7
+ var identifier = getResourceIdentifier(resource, fallbackName);
8
+ if (identifier && !seen.has(identifier)) {
9
+ seen.add(identifier);
10
+ values.push(identifier);
11
+ }
12
+ if (Array.isArray(resource === null || resource === void 0 ? void 0 : resource.children)) {
13
+ resource.children.forEach(function (child) {
14
+ return visitResource(child);
15
+ });
16
+ }
17
+ };
18
+ bookings.forEach(function (booking) {
19
+ if (Array.isArray(booking === null || booking === void 0 ? void 0 : booking.resources)) {
20
+ booking.resources.forEach(function (resource, index) {
21
+ visitResource(resource, index === 0 ? booking === null || booking === void 0 ? void 0 : booking.relation_form_name : undefined);
22
+ });
23
+ }
24
+ });
25
+ return values.join(',');
26
+ }
27
+ function getResourceIdentifier(resource, fallbackName) {
28
+ var _resource$metadata, _resource$metadata2;
29
+ if (!resource || _typeof(resource) !== 'object') return '';
30
+ var candidates = [resource.main_field, resource.name, resource.title, (_resource$metadata = resource.metadata) === null || _resource$metadata === void 0 ? void 0 : _resource$metadata.resource_name, (_resource$metadata2 = resource.metadata) === null || _resource$metadata2 === void 0 ? void 0 : _resource$metadata2.name, fallbackName, resource.relation_id, resource.id];
31
+ for (var _i = 0, _candidates = candidates; _i < _candidates.length; _i++) {
32
+ var candidate = _candidates[_i];
33
+ var value = stringifyResourceIdentifier(candidate);
34
+ if (value) return value;
35
+ }
36
+ return '';
37
+ }
38
+ function stringifyResourceIdentifier(value) {
39
+ if (value === undefined || value === null) return '';
40
+ if (typeof value === 'string' || typeof value === 'number') {
41
+ return String(value).trim();
42
+ }
43
+ if (_typeof(value) !== 'object' || Array.isArray(value)) return '';
44
+ var localeCandidates = [value.original, value.auto, value.en, value['zh-CN'], value.zh_CN, value['zh-HK'], value.zh_HK];
45
+ for (var _i2 = 0, _localeCandidates = localeCandidates; _i2 < _localeCandidates.length; _i2++) {
46
+ var candidate = _localeCandidates[_i2];
47
+ var normalized = stringifyResourceIdentifier(candidate);
48
+ if (normalized) return normalized;
49
+ }
50
+ return '';
51
+ }
@@ -1,46 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
7
- enumerable: true,
8
- get: function () {
9
- return _examples.BUY_X_GET_Y_FREE_STRATEGY;
10
- }
11
- });
12
- Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
13
- enumerable: true,
14
- get: function () {
15
- return _examples.ITEM_REWARD_STRATEGY;
16
- }
17
- });
18
- Object.defineProperty(exports, "PromotionAdapter", {
19
- enumerable: true,
20
- get: function () {
21
- return _adapter.PromotionAdapter;
22
- }
23
- });
24
- Object.defineProperty(exports, "PromotionEvaluator", {
25
- enumerable: true,
26
- get: function () {
27
- return _evaluator.PromotionEvaluator;
28
- }
29
- });
30
- Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
31
- enumerable: true,
32
- get: function () {
33
- return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
34
- }
35
- });
36
- Object.defineProperty(exports, "default", {
37
- enumerable: true,
38
- get: function () {
39
- return _adapter.default;
40
- }
41
- });
42
- var _evaluator = require("./evaluator");
43
- var _adapter = _interopRequireWildcard(require("./adapter"));
44
- var _examples = require("./examples");
45
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
46
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
1
+ "use strict";
@@ -640,7 +640,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
640
640
  generateIdempotencyToken(): string;
641
641
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
642
642
  createOrder(params: CommitOrderParams['query']): {
643
- type: "virtual" | "appointment_booking";
643
+ type: "appointment_booking" | "virtual";
644
644
  platform: string;
645
645
  sales_channel: string;
646
646
  order_sales_channel: string;
@@ -23,6 +23,7 @@ var _dayjs = _interopRequireDefault(require("dayjs"));
23
23
  var _availability = require("../Discount/availability");
24
24
  var _productVoucherGroups = require("./utils/productVoucherGroups");
25
25
  var _osPrivatePayload = require("../../utils/os-private-payload");
26
+ var _resourceIdentifierBuzzer = require("../../utils/resource-identifier-buzzer");
26
27
  var _salesNotes = require("./salesNotes");
27
28
  var _paymentUtils = require("./payment-utils");
28
29
  var _paymentNumber = require("../../utils/payment-number");
@@ -5781,7 +5782,11 @@ class OrderModule extends _BaseModule.BaseModule {
5781
5782
  query
5782
5783
  } = params;
5783
5784
  const fetchUrl = url || '/order/sales/checkout';
5784
- const requestQuery = this.isSalesCheckoutHandledByOsServer(fetchUrl) ? query : (0, _localEftposState.stripLocalEftposState)((0, _osPrivatePayload.stripOsPrivatePayloadFields)(query));
5785
+ const handledByOsServer = this.isSalesCheckoutHandledByOsServer(fetchUrl);
5786
+ const requestQuery = handledByOsServer ? query : (0, _localEftposState.stripLocalEftposState)((0, _osPrivatePayload.stripOsPrivatePayloadFields)(query));
5787
+ if (!handledByOsServer && String(query?._os_fulfillment_ref_mode || '').trim() === 'resource_identifier') {
5788
+ requestQuery.buzzer = (0, _resourceIdentifierBuzzer.buildResourceIdentifierBuzzer)(requestQuery.bookings);
5789
+ }
5785
5790
  return this.request.post(fetchUrl, requestQuery, {
5786
5791
  osServer: true,
5787
5792
  customToast: () => {}
@@ -657,6 +657,9 @@ export interface SubmitSalesOrderParams {
657
657
  note: string;
658
658
  delivery_type?: string;
659
659
  table_number?: Record<string, any>;
660
+ buzzer?: string;
661
+ /** Runtime-only fulfillment mode, removed before a cloud checkout. */
662
+ _os_fulfillment_ref_mode?: string;
660
663
  schedule_date: string;
661
664
  created_at?: string | undefined;
662
665
  products: OrderSubmitProduct[];
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "session" | "duration";
52
+ getProductType(): "normal" | "duration" | "session";
53
53
  }
@@ -524,9 +524,6 @@ declare class Server {
524
524
  private normalizePrintInvoiceTemplateSettings;
525
525
  private extractInvoiceTemplateSettings;
526
526
  private applyCheckoutFulfillmentBuzzer;
527
- private buildCheckoutResourceIdentifierBuzzer;
528
- private getCheckoutResourceIdentifier;
529
- private stringifyCheckoutResourceIdentifier;
530
527
  private normalizeCheckoutSubmitData;
531
528
  private ensureCheckoutOrderNumbers;
532
529
  /**
@@ -9,6 +9,7 @@ var _dayjs = _interopRequireDefault(require("dayjs"));
9
9
  var _decimal = _interopRequireDefault(require("decimal.js"));
10
10
  var _localEftposState = require("../modules/Order/localEftposState");
11
11
  var _lodashEs = require("lodash-es");
12
+ var _resourceIdentifierBuzzer = require("../utils/resource-identifier-buzzer");
12
13
  var _products = require("./modules/products");
13
14
  var _menu = require("./modules/menu");
14
15
  var _quotation = require("./modules/quotation");
@@ -3671,7 +3672,7 @@ class Server {
3671
3672
  return next;
3672
3673
  }
3673
3674
  if (refMode === 'resource_identifier') {
3674
- next.buzzer = this.buildCheckoutResourceIdentifierBuzzer(next.bookings);
3675
+ next.buzzer = (0, _resourceIdentifierBuzzer.buildResourceIdentifierBuzzer)(next.bookings);
3675
3676
  } else if (refMode === 'sale_number') {
3676
3677
  next.buzzer = this.isBlankCheckoutValue(next.shop_order_number) ? '' : String(next.shop_order_number);
3677
3678
  } else if (refMode === 'short_number') {
@@ -3688,51 +3689,6 @@ class Server {
3688
3689
  });
3689
3690
  return next;
3690
3691
  }
3691
- buildCheckoutResourceIdentifierBuzzer(bookings) {
3692
- if (!Array.isArray(bookings)) return '';
3693
- const values = [];
3694
- const seen = new Set();
3695
- const visitResource = (resource, fallbackName) => {
3696
- const identifier = this.getCheckoutResourceIdentifier(resource, fallbackName);
3697
- if (identifier && !seen.has(identifier)) {
3698
- seen.add(identifier);
3699
- values.push(identifier);
3700
- }
3701
- if (Array.isArray(resource?.children)) {
3702
- resource.children.forEach(child => visitResource(child));
3703
- }
3704
- };
3705
- bookings.forEach(booking => {
3706
- if (Array.isArray(booking?.resources)) {
3707
- booking.resources.forEach((resource, index) => {
3708
- visitResource(resource, index === 0 ? booking?.relation_form_name : undefined);
3709
- });
3710
- }
3711
- });
3712
- return values.join(',');
3713
- }
3714
- getCheckoutResourceIdentifier(resource, fallbackName) {
3715
- if (!resource || typeof resource !== 'object') return '';
3716
- const candidates = [resource.main_field, resource.name, resource.title, resource.metadata?.resource_name, resource.metadata?.name, fallbackName, resource.relation_id, resource.id];
3717
- for (const candidate of candidates) {
3718
- const value = this.stringifyCheckoutResourceIdentifier(candidate);
3719
- if (value) return value;
3720
- }
3721
- return '';
3722
- }
3723
- stringifyCheckoutResourceIdentifier(value) {
3724
- if (value === undefined || value === null) return '';
3725
- if (typeof value === 'string' || typeof value === 'number') {
3726
- return String(value).trim();
3727
- }
3728
- if (typeof value !== 'object' || Array.isArray(value)) return '';
3729
- const localeCandidates = [value.original, value.auto, value.en, value['zh-CN'], value.zh_CN, value['zh-HK'], value.zh_HK];
3730
- for (const candidate of localeCandidates) {
3731
- const normalized = this.stringifyCheckoutResourceIdentifier(candidate);
3732
- if (normalized) return normalized;
3733
- }
3734
- return '';
3735
- }
3736
3692
  async normalizeCheckoutSubmitData(data, title) {
3737
3693
  if (!data || typeof data !== 'object') return data;
3738
3694
  const next = {
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
342
342
  date: string;
343
343
  status: string;
344
344
  week: string;
345
- weekNum: 0 | 2 | 1 | 3 | 5 | 4 | 6;
345
+ weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
346
346
  }[]>;
347
347
  submitTimeSlot(timeSlots: TimeSliceItem): void;
348
348
  private getScheduleDataByIds;
@@ -389,7 +389,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
389
389
  };
390
390
  setOtherData(key: string, value: any): void;
391
391
  getOtherData(key: string): any;
392
- getProductTypeById(id: number): Promise<"normal" | "session" | "duration">;
392
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
393
393
  /**
394
394
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
395
395
  *
@@ -835,14 +835,30 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
835
835
  const rawCollectPax = tempOrder.metadata?.collect_pax;
836
836
  const hasExplicitCollectPax = rawCollectPax !== null && rawCollectPax !== undefined && rawCollectPax !== '';
837
837
  const bookingCapacityValue = resolveBookingCapacityValue();
838
- const pickOriginal = value => {
839
- if (value && typeof value === 'object' && !Array.isArray(value)) {
840
- const original = value.original;
841
- return typeof original === 'string' && original.length > 0 ? original : undefined;
838
+ const resourceNameCandidates = [tempOrder.table_number, resourceState?.table_form_record?.name];
839
+ const toNonEmptyString = value => typeof value === 'string' && value.trim().length > 0 ? value : undefined;
840
+ const toNameMap = value => value && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
841
+ const pickFromCandidates = picker => {
842
+ for (const candidate of resourceNameCandidates) {
843
+ const resolved = picker(candidate);
844
+ if (resolved !== undefined) return resolved;
842
845
  }
843
846
  return undefined;
844
847
  };
845
- const mainField = pickOriginal(tempOrder.table_number) ?? pickOriginal(resourceState?.table_form_record?.name) ?? '';
848
+ const pickDirectOrOriginal = value => toNonEmptyString(value) ?? toNonEmptyString(toNameMap(value)?.original);
849
+ const pickLocalized = (value, locale) => toNonEmptyString(toNameMap(value)?.[locale]);
850
+ const pickFirstNonEmpty = value => {
851
+ const nameMap = toNameMap(value);
852
+ if (!nameMap) return undefined;
853
+ for (const candidate of Object.values(nameMap)) {
854
+ const resolved = toNonEmptyString(candidate);
855
+ if (resolved !== undefined) return resolved;
856
+ }
857
+ return undefined;
858
+ };
859
+ const coreState = this.core?.getPlugin?.('shopStore')?.get?.('core');
860
+ const activeLocale = String(coreState?.translateLocale || coreState?.core?.shop?.primary_locale || 'en');
861
+ const mainField = pickFromCandidates(pickDirectOrOriginal) ?? toNonEmptyString(resourceState?.table_form_record?.main_field) ?? pickFromCandidates(value => pickLocalized(value, activeLocale)) ?? pickFromCandidates(value => pickLocalized(value, 'en')) ?? pickFromCandidates(pickFirstNonEmpty) ?? '';
846
862
  const resourceEntry = resourceState && resourceId ? {
847
863
  relation_type: 'form',
848
864
  like_status: 'common',
@@ -0,0 +1 @@
1
+ export declare function buildResourceIdentifierBuzzer(bookings: any): string;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.buildResourceIdentifierBuzzer = buildResourceIdentifierBuzzer;
7
+ function buildResourceIdentifierBuzzer(bookings) {
8
+ if (!Array.isArray(bookings)) return '';
9
+ const values = [];
10
+ const seen = new Set();
11
+ const visitResource = (resource, fallbackName) => {
12
+ const identifier = getResourceIdentifier(resource, fallbackName);
13
+ if (identifier && !seen.has(identifier)) {
14
+ seen.add(identifier);
15
+ values.push(identifier);
16
+ }
17
+ if (Array.isArray(resource?.children)) {
18
+ resource.children.forEach(child => visitResource(child));
19
+ }
20
+ };
21
+ bookings.forEach(booking => {
22
+ if (Array.isArray(booking?.resources)) {
23
+ booking.resources.forEach((resource, index) => {
24
+ visitResource(resource, index === 0 ? booking?.relation_form_name : undefined);
25
+ });
26
+ }
27
+ });
28
+ return values.join(',');
29
+ }
30
+ function getResourceIdentifier(resource, fallbackName) {
31
+ if (!resource || typeof resource !== 'object') return '';
32
+ const candidates = [resource.main_field, resource.name, resource.title, resource.metadata?.resource_name, resource.metadata?.name, fallbackName, resource.relation_id, resource.id];
33
+ for (const candidate of candidates) {
34
+ const value = stringifyResourceIdentifier(candidate);
35
+ if (value) return value;
36
+ }
37
+ return '';
38
+ }
39
+ function stringifyResourceIdentifier(value) {
40
+ if (value === undefined || value === null) return '';
41
+ if (typeof value === 'string' || typeof value === 'number') {
42
+ return String(value).trim();
43
+ }
44
+ if (typeof value !== 'object' || Array.isArray(value)) return '';
45
+ const localeCandidates = [value.original, value.auto, value.en, value['zh-CN'], value.zh_CN, value['zh-HK'], value.zh_HK];
46
+ for (const candidate of localeCandidates) {
47
+ const normalized = stringifyResourceIdentifier(candidate);
48
+ if (normalized) return normalized;
49
+ }
50
+ return '';
51
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.211",
4
+ "version": "2.3.213",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",