@pisell/pisellos 2.3.86 → 2.3.87

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.
@@ -40,6 +40,8 @@ Object.keys(_modules).forEach(function (key) {
40
40
  });
41
41
  });
42
42
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
43
+ const OS_FULFILLMENT_REF_MODE_FIELD = '_os_fulfillment_ref_mode';
44
+
43
45
  // 重新导出类型供外部使用
44
46
 
45
47
  /** 商品查询订阅者 */
@@ -624,7 +626,8 @@ class Server {
624
626
  title
625
627
  } = params;
626
628
  const normalizedData = await this.normalizeCheckoutSubmitData(params.data, title);
627
- const checkoutData = await this.ensureCheckoutOrderNumbers(normalizedData, title);
629
+ const numberedData = await this.ensureCheckoutOrderNumbers(normalizedData, title);
630
+ const checkoutData = this.applyCheckoutFulfillmentBuzzer(numberedData, title);
628
631
  const remoteCheckoutData = this.buildRemoteCheckoutData(checkoutData, title);
629
632
  if (!this.app?.request?.post) {
630
633
  throw new Error('app.request 不可用');
@@ -693,6 +696,7 @@ class Server {
693
696
  const next = (0, _lodashEs.cloneDeep)(this.omitCheckoutSyncMode(data));
694
697
  if (!next || typeof next !== 'object') return next;
695
698
  const record = next;
699
+ delete record[OS_FULFILLMENT_REF_MODE_FIELD];
696
700
  if (!Array.isArray(record.payments)) return next;
697
701
  const originalPayments = record.payments;
698
702
  const filteredPayments = originalPayments.filter(payment => !(0, _paymentUtils.isPendingOrderPayment)(payment));
@@ -3379,6 +3383,82 @@ class Server {
3379
3383
  isLocalCheckoutOrderId(orderId) {
3380
3384
  return typeof orderId === 'string' && orderId.startsWith('LOCAL_');
3381
3385
  }
3386
+ applyCheckoutFulfillmentBuzzer(data, title) {
3387
+ if (!data || typeof data !== 'object') return data;
3388
+ const next = {
3389
+ ...data
3390
+ };
3391
+ const refMode = String(next[OS_FULFILLMENT_REF_MODE_FIELD] || '').trim();
3392
+ delete next[OS_FULFILLMENT_REF_MODE_FIELD];
3393
+ if (!refMode) return next;
3394
+ if (refMode === 'manual_input') {
3395
+ this.logInfo(`${title}: fulfillment ref mode 保留手动 buzzer`, {
3396
+ fulfillment_ref_mode: refMode,
3397
+ has_buzzer: !this.isBlankCheckoutValue(next.buzzer)
3398
+ });
3399
+ return next;
3400
+ }
3401
+ if (refMode === 'resource_identifier') {
3402
+ next.buzzer = this.buildCheckoutResourceIdentifierBuzzer(next.bookings);
3403
+ } else if (refMode === 'sale_number') {
3404
+ next.buzzer = this.isBlankCheckoutValue(next.shop_order_number) ? '' : String(next.shop_order_number);
3405
+ } else if (refMode === 'short_number') {
3406
+ next.buzzer = this.isBlankCheckoutValue(next.shop_full_order_number) ? '' : String(next.shop_full_order_number);
3407
+ } else {
3408
+ this.logWarning(`${title}: 未识别的 fulfillment ref mode,跳过 buzzer 自动填充`, {
3409
+ fulfillment_ref_mode: refMode
3410
+ });
3411
+ return next;
3412
+ }
3413
+ this.logInfo(`${title}: fulfillment ref mode 已填充 buzzer`, {
3414
+ fulfillment_ref_mode: refMode,
3415
+ buzzer: next.buzzer
3416
+ });
3417
+ return next;
3418
+ }
3419
+ buildCheckoutResourceIdentifierBuzzer(bookings) {
3420
+ if (!Array.isArray(bookings)) return '';
3421
+ const values = [];
3422
+ const seen = new Set();
3423
+ const visitResource = resource => {
3424
+ const identifier = this.getCheckoutResourceIdentifier(resource);
3425
+ if (identifier && !seen.has(identifier)) {
3426
+ seen.add(identifier);
3427
+ values.push(identifier);
3428
+ }
3429
+ if (Array.isArray(resource?.children)) {
3430
+ resource.children.forEach(visitResource);
3431
+ }
3432
+ };
3433
+ bookings.forEach(booking => {
3434
+ if (Array.isArray(booking?.resources)) {
3435
+ booking.resources.forEach(visitResource);
3436
+ }
3437
+ });
3438
+ return values.join(',');
3439
+ }
3440
+ getCheckoutResourceIdentifier(resource) {
3441
+ if (!resource || typeof resource !== 'object') return '';
3442
+ const candidates = [resource.main_field, resource.name, resource.title, resource.metadata?.resource_name, resource.metadata?.name, resource.relation_id, resource.id];
3443
+ for (const candidate of candidates) {
3444
+ const value = this.stringifyCheckoutResourceIdentifier(candidate);
3445
+ if (value) return value;
3446
+ }
3447
+ return '';
3448
+ }
3449
+ stringifyCheckoutResourceIdentifier(value) {
3450
+ if (value === undefined || value === null) return '';
3451
+ if (typeof value === 'string' || typeof value === 'number') {
3452
+ return String(value).trim();
3453
+ }
3454
+ if (typeof value !== 'object' || Array.isArray(value)) return '';
3455
+ const localeCandidates = [value.original, value.auto, value.en, value['zh-CN'], value.zh_CN, value['zh-HK'], value.zh_HK];
3456
+ for (const candidate of localeCandidates) {
3457
+ const normalized = this.stringifyCheckoutResourceIdentifier(candidate);
3458
+ if (normalized) return normalized;
3459
+ }
3460
+ return '';
3461
+ }
3382
3462
  async normalizeCheckoutSubmitData(data, title) {
3383
3463
  if (!data || typeof data !== 'object') return data;
3384
3464
  const next = {
@@ -3936,7 +4016,8 @@ class Server {
3936
4016
  });
3937
4017
  }
3938
4018
  const normalizedData = await this.normalizeCheckoutSubmitData(data, title);
3939
- const checkoutData = await this.ensureCheckoutOrderNumbers(normalizedData, title);
4019
+ const numberedData = await this.ensureCheckoutOrderNumbers(normalizedData, title);
4020
+ const checkoutData = this.applyCheckoutFulfillmentBuzzer(numberedData, title);
3940
4021
  const pendingResult = await this.handlePendingSyncCheckoutOrder({
3941
4022
  backendPath,
3942
4023
  data: checkoutData,
@@ -151,6 +151,9 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
151
151
  private getAuthoritativeBundleUnitPrice;
152
152
  private mergeProductForPriceQuery;
153
153
  protected getSubmitOrderSalesChannel(): string | undefined;
154
+ private getFulfillmentRefModeConfigs;
155
+ private getFulfillmentRefMode;
156
+ private buildSubmitPayloadEnhancerWithFulfillmentRefMode;
154
157
  /**
155
158
  * 工厂入口:根据子模块名实例化对应模块。
156
159
  * 默认使用 BookingByStep 公共 `createModule`。子类若需引入额外类型(如 customer),
@@ -36,6 +36,7 @@ var _transformBaseProductToOrderProduct = require("./utils/transformBaseProductT
36
36
  var _quotationPrice = require("./utils/quotationPrice");
37
37
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
38
38
  const SERVER_ORDER_CHANGED_EVENT = 'order:onOrdersChanged';
39
+ const OS_FULFILLMENT_REF_MODE_FIELD = '_os_fulfillment_ref_mode';
39
40
  const WALLET_PAYMENT_CODE_BY_TAG = {
40
41
  product_voucher: 'PRODUCTVOUCHER',
41
42
  gift_card: 'GIFTCARD',
@@ -1041,6 +1042,30 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
1041
1042
  getSubmitOrderSalesChannel() {
1042
1043
  return this.otherParams?.channel;
1043
1044
  }
1045
+ getFulfillmentRefModeConfigs() {
1046
+ const candidates = [this.otherParams?.openData, this.otherParams?.dineInConfig, this.store?.openData?.getOpenData?.()];
1047
+ return candidates.filter(candidate => candidate && typeof candidate === 'object' && !Array.isArray(candidate));
1048
+ }
1049
+ getFulfillmentRefMode() {
1050
+ for (const config of this.getFulfillmentRefModeConfigs()) {
1051
+ const mode = config['fulfillment.fulfillment_ref_mode'];
1052
+ if (mode === undefined || mode === null) continue;
1053
+ const normalized = String(mode).trim();
1054
+ if (normalized) return normalized;
1055
+ }
1056
+ return undefined;
1057
+ }
1058
+ buildSubmitPayloadEnhancerWithFulfillmentRefMode(enhancePayload) {
1059
+ const fulfillmentRefMode = this.getFulfillmentRefMode();
1060
+ if (!fulfillmentRefMode) return enhancePayload;
1061
+ return (payload, ctx) => {
1062
+ const enhancedPayload = enhancePayload ? enhancePayload(payload, ctx) : payload;
1063
+ return {
1064
+ ...enhancedPayload,
1065
+ [OS_FULFILLMENT_REF_MODE_FIELD]: fulfillmentRefMode
1066
+ };
1067
+ };
1068
+ }
1044
1069
 
1045
1070
  /**
1046
1071
  * 工厂入口:根据子模块名实例化对应模块。
@@ -2018,6 +2043,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2018
2043
  // this.store.order.persistTempOrder();
2019
2044
  const inferredPaymentStatus = this.getSubmitPaymentStatus(params?.paymentStatus);
2020
2045
  const smallTicketDataFlag = params?.smallTicketDataFlag ?? this.getDefaultCheckoutSmallTicketDataFlag();
2046
+ const enhancePayload = this.buildSubmitPayloadEnhancerWithFulfillmentRefMode(params?.enhancePayload);
2021
2047
  const submitParams = {
2022
2048
  cacheId: this.cacheId,
2023
2049
  platform: this.otherParams?.platform,
@@ -2037,8 +2063,8 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2037
2063
  ...(params?.confirmPendingVoucherPayments !== undefined ? {
2038
2064
  confirmPendingVoucherPayments: params.confirmPendingVoucherPayments
2039
2065
  } : {}),
2040
- ...(params?.enhancePayload !== undefined ? {
2041
- enhancePayload: params.enhancePayload
2066
+ ...(enhancePayload !== undefined ? {
2067
+ enhancePayload
2042
2068
  } : {})
2043
2069
  };
2044
2070
  return this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams);
@@ -2064,6 +2090,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2064
2090
  }
2065
2091
  const inferredPaymentStatus = this.getSubmitPaymentStatus(params?.paymentStatus);
2066
2092
  const smallTicketDataFlag = params?.smallTicketDataFlag ?? this.getDefaultCheckoutSmallTicketDataFlag();
2093
+ const enhancePayload = this.buildSubmitPayloadEnhancerWithFulfillmentRefMode(params?.enhancePayload);
2067
2094
  const submitParams = {
2068
2095
  cacheId: this.cacheId,
2069
2096
  platform: this.otherParams?.platform,
@@ -2083,8 +2110,8 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2083
2110
  ...(params?.confirmPendingVoucherPayments !== undefined ? {
2084
2111
  confirmPendingVoucherPayments: params.confirmPendingVoucherPayments
2085
2112
  } : {}),
2086
- ...(params?.enhancePayload !== undefined ? {
2087
- enhancePayload: params.enhancePayload
2113
+ ...(enhancePayload !== undefined ? {
2114
+ enhancePayload
2088
2115
  } : {})
2089
2116
  };
2090
2117
  return this.store.order.submitTempOrderAsync(submitParams);
@@ -2157,6 +2184,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2157
2184
  if (!this.store.order) throw new Error('order 模块未初始化');
2158
2185
  const businessCode = params.businessCode ?? this.otherParams?.businessCode ?? this.otherParams?.business_code;
2159
2186
  const channel = params.channel ?? this.getSubmitOrderSalesChannel();
2187
+ const enhancePayload = this.buildSubmitPayloadEnhancerWithFulfillmentRefMode(params.enhancePayload);
2160
2188
  const syncParams = {
2161
2189
  ...params,
2162
2190
  checkoutSyncTaskEnabled: this.shouldUseCheckoutSyncTask(),
@@ -2165,6 +2193,9 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2165
2193
  } : {}),
2166
2194
  ...(channel !== undefined ? {
2167
2195
  channel
2196
+ } : {}),
2197
+ ...(enhancePayload !== undefined ? {
2198
+ enhancePayload
2168
2199
  } : {})
2169
2200
  };
2170
2201
  const syncState = this.store.order.getOrderSyncState();
@@ -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 | 1 | 5 | 2 | 3 | 4 | 6;
329
+ weekNum: 0 | 1 | 2 | 5 | 3 | 4 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -275,7 +275,10 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
275
275
  const prefix = this.normalizeIdPrefix(openDataConfig?.['sale.short_number_prefix'], '');
276
276
  const shopOrderPrefix = this.normalizeIdPrefix(openDataConfig?.['sale.sale_number_prefix'], '');
277
277
  const resetReceiptSequenceDaily = typeof openDataConfig?.['sale.short_number_daily_reset'] === 'boolean' ? openDataConfig?.['sale.short_number_daily_reset'] : false;
278
- const operatingDayBoundary = this.getAppData('operating_day_boundary');
278
+ const operatingDayBoundary = this.getAppData('operating_day_boundary') || {
279
+ "type": "start_time",
280
+ "time": "00:00"
281
+ };
279
282
  const deviceId = await this.getShortNumberOrDeviceId();
280
283
  this.setPaymentNumberDevicePrefix(deviceId);
281
284
  const businessCode = this.getBookingTicketBusinessCode();
@@ -293,7 +296,7 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
293
296
  padReceiptSequence: false,
294
297
  receiptSequenceLength,
295
298
  resetReceiptSequenceDaily,
296
- receiptSequenceResetTime: operatingDayBoundary.time,
299
+ receiptSequenceResetTime: operatingDayBoundary?.time,
297
300
  receiptSequenceStart,
298
301
  shopOrderPrefix
299
302
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.86",
4
+ "version": "2.3.87",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",