@pisell/pisellos 2.3.114 → 2.3.116

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.
@@ -346,6 +346,7 @@ function areBaseSalesNotesEquivalent(currentValue, loadedValue, options) {
346
346
  return currentNotes !== null && loadedNotes !== null && (0, _lodashEs.isEqual)(currentNotes, loadedNotes);
347
347
  }
348
348
  function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, strategy) {
349
+ const loadedHasOrderMetaList = Object.prototype.hasOwnProperty.call(loadedRecord || {}, 'order_meta_list');
349
350
  const loadedHasSalesNotes = Object.prototype.hasOwnProperty.call(loadedRecord || {}, 'notes');
350
351
  const hasDirtyLocalSalesNotes = currentTempOrder?._extend?.salesNotesState?.dirty === true;
351
352
  const incomingSalesNotesMatchLocal = loadedHasSalesNotes && areBaseSalesNotesEquivalent(currentTempOrder?.notes, loadedRecord.notes, {
@@ -364,6 +365,12 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
364
365
  });
365
366
  const uidRemaps = [];
366
367
  const mergedRecord = (0, _lodashEs.mergeWith)(normalizedCurrentTempOrder, normalizedLoadedRecord, (currentValue, loadedValue, key) => {
368
+ // order_meta_list 是服务端/本地订单携带的完整业务快照。若 incoming
369
+ // 明确提供它,必须整体替换;若省略,则保留当前值,避免 snapshot
370
+ // 数组递归拼接后出现同 ID 的旧数据。
371
+ if (key === 'order_meta_list') {
372
+ return (0, _lodashEs.cloneDeep)(loadedHasOrderMetaList ? loadedValue : currentValue);
373
+ }
367
374
  if (key === 'notes') {
368
375
  if (preserveDirtyLocalSalesNotes && Array.isArray(currentValue)) {
369
376
  return (0, _lodashEs.cloneDeep)(currentValue);
@@ -1342,9 +1349,22 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
1342
1349
  }
1343
1350
  syncAppDataToTempOrder(tempOrder) {
1344
1351
  const isPriceIncludeTax = this.getAppData('is_price_include_tax');
1345
- const taxCountryCode = this.getAppData('tax_country_code');
1346
- const currencyCode = this.getAppData('shop_currency_code');
1347
- const currencySymbol = this.getAppData('shop_symbol');
1352
+ const rawTaxCountryCode = this.getAppData('tax_country_code');
1353
+ const rawCurrencyCode = this.getAppData('shop_currency_code');
1354
+ const rawCurrencySymbol = this.getAppData('shop_symbol');
1355
+ const normalizeNonBlankValue = value => {
1356
+ if (value === undefined || value === null) return undefined;
1357
+ const normalizedValue = String(value).trim();
1358
+ return normalizedValue || undefined;
1359
+ };
1360
+ const taxCountryCode = normalizeNonBlankValue(rawTaxCountryCode);
1361
+ const currencyCode = normalizeNonBlankValue(rawCurrencyCode);
1362
+ const currencySymbol = normalizeNonBlankValue(rawCurrencySymbol);
1363
+ const before = {
1364
+ tax_country_code: tempOrder.tax_country_code,
1365
+ currency_code: tempOrder.currency_code,
1366
+ currency_symbol: tempOrder.currency_symbol
1367
+ };
1348
1368
  // 历史虚拟币订单不依赖交易开关;普通 POS 不从商品行残留快照推断订单币种。
1349
1369
  const isHistoricalVirtualSettlement = this.isHistoricalVirtualSettlementOrder(tempOrder);
1350
1370
  const isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder) || isHistoricalVirtualSettlement;
@@ -1358,9 +1378,8 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
1358
1378
  }
1359
1379
  }
1360
1380
  if (taxCountryCode !== undefined) {
1361
- const nextTaxCountryCode = String(taxCountryCode || '');
1362
- if (tempOrder.tax_country_code !== nextTaxCountryCode) {
1363
- tempOrder.tax_country_code = nextTaxCountryCode;
1381
+ if (tempOrder.tax_country_code !== taxCountryCode) {
1382
+ tempOrder.tax_country_code = taxCountryCode;
1364
1383
  isChanged = true;
1365
1384
  }
1366
1385
  }
@@ -1377,19 +1396,45 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
1377
1396
  }
1378
1397
  }
1379
1398
  if (!isVirtualSettlement && currencyCode !== undefined) {
1380
- const nextCurrencyCode = String(currencyCode || '');
1381
- if (tempOrder.currency_code !== nextCurrencyCode) {
1382
- tempOrder.currency_code = nextCurrencyCode;
1399
+ if (tempOrder.currency_code !== currencyCode) {
1400
+ tempOrder.currency_code = currencyCode;
1383
1401
  isChanged = true;
1384
1402
  }
1385
1403
  }
1386
1404
  if (!isVirtualSettlement && currencySymbol !== undefined) {
1387
- const nextCurrencySymbol = String(currencySymbol || '');
1388
- if (tempOrder.currency_symbol !== nextCurrencySymbol) {
1389
- tempOrder.currency_symbol = nextCurrencySymbol;
1405
+ if (tempOrder.currency_symbol !== currencySymbol) {
1406
+ tempOrder.currency_symbol = currencySymbol;
1390
1407
  isChanged = true;
1391
1408
  }
1392
1409
  }
1410
+ try {
1411
+ const orderIdentity = this.store.order?.getOrderIdentity?.();
1412
+ this.logger?.addLog?.({
1413
+ type: 'info',
1414
+ title: 'syncAppDataToTempOrder',
1415
+ metadata: {
1416
+ moduleName: this.name,
1417
+ cacheId: this.cacheId,
1418
+ orderId: orderIdentity?.orderId ?? tempOrder.order_id,
1419
+ externalSaleNumber: orderIdentity?.externalSaleNumber ?? tempOrder.external_sale_number,
1420
+ shopOrderNumber: orderIdentity?.shopOrderNumber ?? tempOrder.shop_order_number,
1421
+ readValues: {
1422
+ tax_country_code: rawTaxCountryCode,
1423
+ shop_currency_code: rawCurrencyCode,
1424
+ shop_symbol: rawCurrencySymbol
1425
+ },
1426
+ before,
1427
+ after: {
1428
+ tax_country_code: tempOrder.tax_country_code,
1429
+ currency_code: tempOrder.currency_code,
1430
+ currency_symbol: tempOrder.currency_symbol
1431
+ },
1432
+ isChanged
1433
+ }
1434
+ });
1435
+ } catch {
1436
+ // 诊断日志不能影响订单字段同步。
1437
+ }
1393
1438
  return isChanged;
1394
1439
  }
1395
1440
  async initialize(core, options = {}) {
@@ -1896,19 +1941,46 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
1896
1941
  return discount;
1897
1942
  });
1898
1943
  }
1944
+ resolveDiscountConfigCustomerId(tempOrder) {
1945
+ return Number(tempOrder?.customer_id || tempOrder?.customer?.id || tempOrder?._extend?.customerSnapshot?.id || tempOrder?._extend?.customerSnapshot?.customer_id || 0);
1946
+ }
1947
+
1948
+ /**
1949
+ * Stable across notifyTempOrderChanged's immutable object replacement, while
1950
+ * still distinguishing two local orders for the same customer.
1951
+ */
1952
+ getDiscountConfigOrderIdentityKey(tempOrder) {
1953
+ const identity = this.store.order?.getOrderIdentity?.();
1954
+ return JSON.stringify([identity?.orderId ?? tempOrder?.order_id ?? '', tempOrder?.request_unique_idempotency_token ?? '', identity?.externalSaleNumber ?? tempOrder?.external_sale_number ?? '', identity?.localId ?? tempOrder?._extend?.localId ?? this.cacheId ?? '']);
1955
+ }
1899
1956
  async loadDiscountConfig(params) {
1900
1957
  if (!this.store.order) throw new Error('order 模块未初始化');
1901
1958
  const tempOrder = this.store.order.ensureTempOrder();
1902
1959
  const orderStore = this.store.order.store || {};
1903
1960
  const discountModule = orderStore.discount;
1904
1961
  const rulesModule = orderStore.rules;
1905
- const orderId = tempOrder.order_id || this.getOrderIdentity?.()?.orderId;
1962
+ const orderId = tempOrder.order_id || this.store.order.getOrderIdentity?.()?.orderId;
1906
1963
  const customerId = Number(params?.customerId || tempOrder.customer_id || tempOrder.customer?.id || tempOrder._extend?.customerSnapshot?.id || tempOrder._extend?.customerSnapshot?.customer_id || 0);
1907
1964
  const currentDiscountList = discountModule?.getDiscountList?.() || [];
1908
1965
  const originalDiscountList = discountModule?.getOriginalDiscountList?.() || [];
1909
1966
  const hasManualDiscountSelection = this.hasManualDiscountSelection || currentDiscountList.some(discount => discount.isManualSelect);
1910
1967
  const discountAction = params?.action || (orderId ? 'edit' : 'create');
1911
- const discountConfigCacheKey = [customerId, discountAction, Number(orderId) || 0].join(':');
1968
+ const requestOrderIdentityKey = this.getDiscountConfigOrderIdentityKey(tempOrder);
1969
+ const discountConfigCacheKey = JSON.stringify([customerId, discountAction, Number(orderId) || 0, requestOrderIdentityKey]);
1970
+ let requestEpoch = this.store.order.getCustomerWalletPrepareConfigEpoch?.();
1971
+ const isCurrentRequest = () => {
1972
+ const currentTempOrder = this.store.order?.getTempOrder?.();
1973
+ return Boolean(currentTempOrder && (requestEpoch === undefined || this.store.order?.getCustomerWalletPrepareConfigEpoch?.() === requestEpoch) && this.resolveDiscountConfigCustomerId(currentTempOrder) === customerId && this.getDiscountConfigOrderIdentityKey(currentTempOrder) === requestOrderIdentityKey);
1974
+ };
1975
+ const getCurrentResult = () => {
1976
+ const currentTempOrder = this.store.order?.getTempOrder?.();
1977
+ return {
1978
+ productList: currentTempOrder?.products || [],
1979
+ discountList: discountModule?.getDiscountList?.() || [],
1980
+ availableWalletIds: this.getAvailableWalletIds(),
1981
+ virtualCurrencyList: this.getVirtualCurrencyList()
1982
+ };
1983
+ };
1912
1984
 
1913
1985
  // Walk-In 不请求 prepare config;当前搜索/扫码券必须继续参与本次重算。
1914
1986
  // current 优先于 original,保留搜索后的最新选择与可用状态。
@@ -1919,26 +1991,34 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
1919
1991
  if (!params?.force && this.discountConfigCacheKey === discountConfigCacheKey) {
1920
1992
  preparedDiscountList = originalDiscountList;
1921
1993
  } else {
1922
- preparedDiscountList = await this.store.order.loadDiscountConfig({
1994
+ const prepareConfigPromise = this.store.order.loadDiscountConfig({
1923
1995
  customerId,
1924
1996
  action: discountAction,
1925
1997
  orderId: Number(orderId) || undefined,
1926
1998
  apply: false
1927
1999
  });
1928
- this.discountConfigCacheKey = discountConfigCacheKey;
2000
+ // OrderModule increments this epoch synchronously before its first await.
2001
+ requestEpoch = this.store.order.getCustomerWalletPrepareConfigEpoch?.();
2002
+ preparedDiscountList = await prepareConfigPromise;
2003
+ if (!isCurrentRequest()) return getCurrentResult();
1929
2004
  await discountModule?.setOriginalDiscountList?.(preparedDiscountList);
2005
+ if (!isCurrentRequest()) return getCurrentResult();
2006
+ this.discountConfigCacheKey = discountConfigCacheKey;
1930
2007
  }
1931
2008
  }
1932
2009
  if (this.isActiveVirtualSettlementOrder(tempOrder)) {
2010
+ if (!isCurrentRequest()) return getCurrentResult();
1933
2011
  await discountModule?.setOriginalDiscountList?.([]);
2012
+ if (!isCurrentRequest()) return getCurrentResult();
1934
2013
  await discountModule?.setDiscountList?.([]);
2014
+ if (!isCurrentRequest()) return getCurrentResult();
1935
2015
  tempOrder.discount_list = [];
1936
2016
  tempOrder.shop_discount = '0.00';
1937
2017
  return {
1938
2018
  productList: tempOrder.products || [],
1939
2019
  discountList: [],
1940
2020
  availableWalletIds: this.getAvailableWalletIds(),
1941
- virtualCurrencyList: this.store.order.getVirtualCurrencyList()
2021
+ virtualCurrencyList: this.getVirtualCurrencyList()
1942
2022
  };
1943
2023
  }
1944
2024
  if (hasManualDiscountSelection && currentDiscountList.length) {
@@ -1946,12 +2026,14 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
1946
2026
  productList: tempOrder.products || [],
1947
2027
  discountList: currentDiscountList,
1948
2028
  availableWalletIds: this.getAvailableWalletIds(),
1949
- virtualCurrencyList: this.store.order.getVirtualCurrencyList()
2029
+ virtualCurrencyList: this.getVirtualCurrencyList()
1950
2030
  };
1951
2031
  }
1952
2032
  let nextDiscountList = this.mergeHistoricalDiscountList(preparedDiscountList || discountModule?.getDiscountList?.() || [], tempOrder.products || []);
1953
2033
  nextDiscountList = this.mergeCurrentDiscountSelectionState(nextDiscountList, currentDiscountList);
2034
+ if (!isCurrentRequest()) return getCurrentResult();
1954
2035
  await discountModule?.setDiscountList(nextDiscountList);
2036
+ if (!isCurrentRequest()) return getCurrentResult();
1955
2037
  const shouldSkipAutoApplyFetchedDiscounts = this.shouldSkipAutoApplyFetchedDiscountsInEditMode({
1956
2038
  discountAction,
1957
2039
  products: tempOrder.products || [],
@@ -1959,24 +2041,28 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
1959
2041
  nextDiscountList
1960
2042
  });
1961
2043
  if (shouldSkipAutoApplyFetchedDiscounts) {
1962
- const summary = await this.store.order.recalculateSummary({
2044
+ await this.store.order.recalculateSummary({
1963
2045
  createIfMissing: true
1964
2046
  });
2047
+ if (!isCurrentRequest()) return getCurrentResult();
1965
2048
  this.store.order.persistTempOrder();
2049
+ if (!isCurrentRequest()) return getCurrentResult();
1966
2050
  await this.effectsEmit('onDiscountApplied', {
1967
2051
  productList: tempOrder.products || [],
1968
2052
  discountList: nextDiscountList,
1969
2053
  selectedDiscountList: tempOrder.discount_list || [],
1970
2054
  tempOrder
1971
2055
  });
2056
+ if (!isCurrentRequest()) return getCurrentResult();
1972
2057
  return {
1973
2058
  productList: tempOrder.products || [],
1974
2059
  discountList: nextDiscountList,
1975
2060
  availableWalletIds: this.getAvailableWalletIds(),
1976
- virtualCurrencyList: this.store.order.getVirtualCurrencyList()
2061
+ virtualCurrencyList: this.getVirtualCurrencyList()
1977
2062
  };
1978
2063
  }
1979
2064
  if (rulesModule) {
2065
+ if (!isCurrentRequest()) return getCurrentResult();
1980
2066
  const orderTotalAmount = Number(orderStore.summary?.total_amount || 0);
1981
2067
  const result = rulesModule.calcDiscount({
1982
2068
  productList: tempOrder.products,
@@ -2012,25 +2098,31 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2012
2098
  if (result.discountList) {
2013
2099
  nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
2014
2100
  _Order.OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
2101
+ if (!isCurrentRequest()) return getCurrentResult();
2015
2102
  await discountModule?.setDiscountList(nextDiscountList);
2103
+ if (!isCurrentRequest()) return getCurrentResult();
2016
2104
  tempOrder.discount_list = nextDiscountList.filter(discount => discount.isSelected);
2017
2105
  }
2018
2106
  }
2019
- const summary = await this.store.order.recalculateSummary({
2107
+ if (!isCurrentRequest()) return getCurrentResult();
2108
+ await this.store.order.recalculateSummary({
2020
2109
  createIfMissing: true
2021
2110
  });
2111
+ if (!isCurrentRequest()) return getCurrentResult();
2022
2112
  this.store.order.persistTempOrder();
2113
+ if (!isCurrentRequest()) return getCurrentResult();
2023
2114
  await this.effectsEmit('onDiscountApplied', {
2024
2115
  productList: tempOrder.products || [],
2025
2116
  discountList: nextDiscountList,
2026
2117
  selectedDiscountList: tempOrder.discount_list || [],
2027
2118
  tempOrder
2028
2119
  });
2120
+ if (!isCurrentRequest()) return getCurrentResult();
2029
2121
  return {
2030
2122
  productList: tempOrder.products || [],
2031
2123
  discountList: nextDiscountList,
2032
2124
  availableWalletIds: this.getAvailableWalletIds(),
2033
- virtualCurrencyList: this.store.order.getVirtualCurrencyList()
2125
+ virtualCurrencyList: this.getVirtualCurrencyList()
2034
2126
  };
2035
2127
  }
2036
2128
  getAvailableWalletIds() {
@@ -3211,7 +3303,13 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
3211
3303
  */
3212
3304
  updateOrderCustomer(customer) {
3213
3305
  if (!this.store.order) throw new Error('order 模块未初始化');
3306
+ const previousCustomerId = this.resolveDiscountConfigCustomerId(this.store.order.getTempOrder?.());
3214
3307
  const result = this.store.order.updateTempOrderCustomer(customer);
3308
+ const nextCustomerId = this.resolveDiscountConfigCustomerId(this.store.order.getTempOrder?.());
3309
+ if (String(previousCustomerId) !== String(nextCustomerId)) {
3310
+ this.discountConfigCacheKey = null;
3311
+ this.hasManualDiscountSelection = false;
3312
+ }
3215
3313
  this.store.order.recalculateSummary({
3216
3314
  createIfMissing: true
3217
3315
  });
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 2 | 3 | 1 | 5 | 6 | 4;
329
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -8,6 +8,7 @@ import { BaseSalesImpl } from '../BaseSales';
8
8
  import type { BaseSalesScanCodeResult } from '../BaseSales/types';
9
9
  import type { ISalesDetail } from '../BaseSales/utils/parseSalesResponse';
10
10
  import type { LoadSalesDetailParams } from '../../modules/Order/types';
11
+ import type { GlobalScanSearchType } from './utils/scan/formatGlobalScan';
11
12
  import type { AddAddTimeProductToBookingInput, AddAddTimeProductsToBookingInput, GlobalScanHandleResult, GlobalScanHostBridge } from './types';
12
13
  import { AddProductDecideContext, AddProductRequiresDetailPayload } from './utils/addProductDecision';
13
14
  import { type BuildCacheItemFromOrderLineInput } from '../../modules/BookingContext/utils/buildCacheItemFromOrderLine';
@@ -29,6 +30,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
29
30
  private addTimeProductsCatalog;
30
31
  private orderCustomerDiscountRefreshInFlight;
31
32
  private orderCustomerDiscountRefreshCustomerId;
33
+ private orderCustomerDiscountRefreshTarget;
32
34
  private orderCustomerPromotionRefreshInFlight;
33
35
  protected loadOpenDataInFlight: Promise<OpenDataConfig> | null;
34
36
  protected loadOpenDataInFlightTarget: string | null;
@@ -537,6 +539,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
537
539
  * ```
538
540
  */
539
541
  handleGlobalScanCode(code: string, bridge?: GlobalScanHostBridge): Promise<GlobalScanHandleResult>;
542
+ /** 查询码类型;复用原有识别和缓存,不写订单、不打开选择 UI。 */
543
+ getGlobalScanCodeType(code: string): Promise<GlobalScanSearchType | null>;
540
544
  resolveBestAddTimePlan(addTimeProducts: any[], targetMinutes: number): any;
541
545
  /**
542
546
  * 构造一条绑定到已有 booking 的加时商品行。
@@ -160,6 +160,7 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
160
160
  addTimeProductsCatalog = [];
161
161
  orderCustomerDiscountRefreshInFlight = null;
162
162
  orderCustomerDiscountRefreshCustomerId = null;
163
+ orderCustomerDiscountRefreshTarget = null;
163
164
  orderCustomerPromotionRefreshInFlight = null;
164
165
  loadOpenDataInFlight = null;
165
166
  loadOpenDataInFlightTarget = null;
@@ -1121,7 +1122,13 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
1121
1122
  }
1122
1123
  refreshDiscountConfigAfterOrderCustomerChange(customerId) {
1123
1124
  if (!customerId || customerId === 1) return Promise.resolve();
1124
- if (this.orderCustomerDiscountRefreshInFlight && this.orderCustomerDiscountRefreshCustomerId === customerId) {
1125
+ const tempOrder = this.store.order.getTempOrder?.();
1126
+ const orderIdentity = this.getOrderIdentity?.();
1127
+ const orderId = tempOrder?.order_id || orderIdentity?.orderId;
1128
+ const action = !orderId || String(orderId).startsWith('local_order') ? 'create' : 'edit';
1129
+ const orderTarget = orderId ? `order:${String(orderId)}` : `external:${String(tempOrder?.external_sale_number || orderIdentity?.externalSaleNumber || orderIdentity?.localId || 'new')}`;
1130
+ const refreshTarget = `${customerId}:${action}:${orderTarget}`;
1131
+ if (this.orderCustomerDiscountRefreshInFlight && this.orderCustomerDiscountRefreshTarget === refreshTarget) {
1125
1132
  return this.orderCustomerDiscountRefreshInFlight;
1126
1133
  }
1127
1134
  const previousRefresh = this.orderCustomerDiscountRefreshInFlight;
@@ -1133,22 +1140,33 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
1133
1140
  if (!currentCustomer || Number(currentCustomer.customer_id) !== customerId) {
1134
1141
  return;
1135
1142
  }
1136
- const tempOrder = this.store.order.getTempOrder?.();
1137
- const orderId = tempOrder?.order_id || this.getOrderIdentity?.()?.orderId;
1138
- const action = !orderId || String(orderId).startsWith('local_order') ? 'create' : 'edit';
1143
+ const currentTempOrder = this.store.order.getTempOrder?.();
1144
+ const currentOrderIdentity = this.getOrderIdentity?.();
1145
+ const currentOrderId = currentTempOrder?.order_id || currentOrderIdentity?.orderId;
1146
+ const currentAction = !currentOrderId || String(currentOrderId).startsWith('local_order') ? 'create' : 'edit';
1147
+ const currentOrderTarget = currentOrderId ? `order:${String(currentOrderId)}` : `external:${String(currentTempOrder?.external_sale_number || currentOrderIdentity?.externalSaleNumber || currentOrderIdentity?.localId || 'new')}`;
1148
+ if (`${customerId}:${currentAction}:${currentOrderTarget}` !== refreshTarget) {
1149
+ return;
1150
+ }
1151
+
1152
+ // 上一个订单的迟到请求可能在客户切换后重新写入 BaseSales cache key;
1153
+ // 客户变更触发的目标订单刷新必须绕过该缓存。
1139
1154
  await this.loadDiscountConfig({
1140
1155
  customerId,
1141
- action
1156
+ action,
1157
+ force: true
1142
1158
  });
1143
1159
  })();
1144
1160
  this.orderCustomerDiscountRefreshInFlight = refreshTask;
1145
1161
  this.orderCustomerDiscountRefreshCustomerId = customerId;
1162
+ this.orderCustomerDiscountRefreshTarget = refreshTarget;
1146
1163
  refreshTask.catch(error => {
1147
1164
  console.error('Failed to load discount config after customer change:', error);
1148
1165
  }).finally(() => {
1149
1166
  if (this.orderCustomerDiscountRefreshInFlight !== refreshTask) return;
1150
1167
  this.orderCustomerDiscountRefreshInFlight = null;
1151
1168
  this.orderCustomerDiscountRefreshCustomerId = null;
1169
+ this.orderCustomerDiscountRefreshTarget = null;
1152
1170
  });
1153
1171
  return refreshTask;
1154
1172
  }
@@ -1689,6 +1707,18 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
1689
1707
  };
1690
1708
  }
1691
1709
  }
1710
+
1711
+ /** 查询码类型;复用原有识别和缓存,不写订单、不打开选择 UI。 */
1712
+ async getGlobalScanCodeType(code) {
1713
+ const trimmed = typeof code === 'string' ? code.trim() : '';
1714
+ if (!trimmed) return null;
1715
+ const scan = (0, _handleScan.handleGlobalScan)(this.request, value => this.store.products.findProductsByCodeOrBarcode(value), this.getSubmitOrderSalesChannel());
1716
+ const raw = await scan({
1717
+ type: 'nativeScanner',
1718
+ value: trimmed
1719
+ });
1720
+ return (0, _formatGlobalScan.formatGlobalScanResult)(raw, trimmed)?.searchType ?? null;
1721
+ }
1692
1722
  resolveBestAddTimePlan(addTimeProducts, targetMinutes) {
1693
1723
  return (0, _resolveBestAddTimePlan.resolveBestAddTimePlan)(addTimeProducts, targetMinutes);
1694
1724
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.114",
4
+ "version": "2.3.116",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",