@pisell/pisellos 2.3.162 → 2.3.163

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.
@@ -1,9 +0,0 @@
1
- // 导出评估器
2
- export { PromotionEvaluator } from "./evaluator";
3
-
4
- // 导出适配器
5
- export { PromotionAdapter } from "./adapter";
6
- export { default } from "./adapter";
7
-
8
- // 导出策略配置示例常量
9
- export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
@@ -595,7 +595,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
595
595
  generateIdempotencyToken(): string;
596
596
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
597
597
  createOrder(params: CommitOrderParams['query']): {
598
- type: "appointment_booking" | "virtual";
598
+ type: "virtual" | "appointment_booking";
599
599
  platform: string;
600
600
  sales_channel: string;
601
601
  order_sales_channel: string;
@@ -213,6 +213,7 @@ export declare function normalizeBookingSubType(booking: Record<string, any>): s
213
213
  export declare function normalizeSubmitBooking<T extends {
214
214
  metadata?: Record<string, any>;
215
215
  }>(booking: T): T;
216
+ export declare function resolveTableOccupancyDuration(tempOrder: OrderTempOrder): number;
216
217
  /** 提交用人数:有限且为正则向下取整,否则为 1 */
217
218
  export declare function normalizeSubmitCollectPaxValue(value: unknown): number;
218
219
  /** 从临时订单 metadata 解析合成 booking 的 collect_pax */
@@ -1344,7 +1344,7 @@ export function normalizeSubmitBooking(booking) {
1344
1344
  });
1345
1345
  }
1346
1346
  var DEFAULT_TABLE_OCCUPANCY_DURATION = 20;
1347
- function resolveTableOccupancyDuration(tempOrder) {
1347
+ export function resolveTableOccupancyDuration(tempOrder) {
1348
1348
  var _metadata$table_confi, _metadata$tableConfig, _metadata$resource_co, _metadata$resourceCon;
1349
1349
  var metadata = tempOrder.metadata || {};
1350
1350
  var candidates = [metadata.table_occupancy_duration, metadata.booking_duration, metadata.table_duration, metadata.duration, (_metadata$table_confi = metadata.table_config) === null || _metadata$table_confi === void 0 ? void 0 : _metadata$table_confi.occupancy_duration, (_metadata$tableConfig = metadata.tableConfig) === null || _metadata$tableConfig === void 0 ? void 0 : _metadata$tableConfig.occupancy_duration, (_metadata$resource_co = metadata.resource_config) === null || _metadata$resource_co === void 0 ? void 0 : _metadata$resource_co.occupancy_duration, (_metadata$resourceCon = metadata.resourceConfig) === null || _metadata$resourceCon === void 0 ? void 0 : _metadata$resourceCon.occupancy_duration];
@@ -328,7 +328,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
328
328
  date: string;
329
329
  status: string;
330
330
  week: string;
331
- weekNum: 0 | 5 | 3 | 1 | 2 | 4 | 6;
331
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
332
332
  }[]>;
333
333
  submitTimeSlot(timeSlots: TimeSliceItem): void;
334
334
  private getScheduleDataByIds;
@@ -347,7 +347,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
347
347
  count: number;
348
348
  left: number;
349
349
  summaryCount: number;
350
- status: "sold_out" | "lots_of_space" | "filling_up_fast";
350
+ status: "lots_of_space" | "filling_up_fast" | "sold_out";
351
351
  }[];
352
352
  /**
353
353
  * 找到多个资源的公共可用时间段
@@ -36,7 +36,7 @@ import { attachItemRuleLimitsToTopLevelProducts, buildProductKey, buildItemRuleB
36
36
  import { createModule } from "../BookingByStep/types";
37
37
  import { ProductList } from "../../modules/ProductList";
38
38
  import { getDateIsInSchedule } from "../../modules/Schedule/getDateIsInSchedule";
39
- import { composeLinePrice, buildSubmitPayload, createUuidV4, getProductSkuOptions, normalizeSubmitCollectPaxValue, sumOptionUnitPrice } from "../../modules/Order/utils";
39
+ import { composeLinePrice, buildSubmitPayload, createUuidV4, getProductSkuOptions, normalizeSubmitBooking, normalizeSubmitCollectPaxValue, resolveTableOccupancyDuration, sumOptionUnitPrice } from "../../modules/Order/utils";
40
40
  import dayjs from 'dayjs';
41
41
  import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
42
42
  export * from "./types";
@@ -1332,6 +1332,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1332
1332
  }
1333
1333
  return prepareRetailAvailability;
1334
1334
  }() // ScanOrder 提交 payload enhancer:
1335
+ // - 新单有桌台上下文但无 booking 时,补建基础预约(通用 Order 已不再自动生成)
1335
1336
  // - 给所有 booking 注入 appointment_status: 'started'(扫码点餐语义)
1336
1337
  // - 给所有 booking 的 metadata 注入 resource_select_type(来自预约规则商品的 resource.type)
1337
1338
  // - 给第一条 booking 补 resources 与 product_uid(仅当存在 resource / rule product)
@@ -1358,7 +1359,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1358
1359
  return function (payload, _ref3) {
1359
1360
  var _resourceState$relati, _tempOrder$metadata, _ref4, _pickOriginal, _resourceState$table_2, _resourceState$relati2, _pickFirstCustomCapac;
1360
1361
  var bookingUuid = _ref3.bookingUuid,
1361
- tempOrder = _ref3.tempOrder;
1362
+ tempOrder = _ref3.tempOrder,
1363
+ now = _ref3.now;
1362
1364
  var resourceId = String((_resourceState$relati = resourceState === null || resourceState === void 0 ? void 0 : resourceState.relationId) !== null && _resourceState$relati !== void 0 ? _resourceState$relati : '').trim();
1363
1365
  var hasReservationBookingContext = Boolean(ruleProduct && resourceState && resourceId && resourceState.relationId && resourceState.tableFormId);
1364
1366
  if (!hasReservationBookingContext) {
@@ -1393,7 +1395,31 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1393
1395
  } : undefined;
1394
1396
  var ruleProductUid = ruleProduct ? createUuidV4() : undefined;
1395
1397
  var bookingCapacityDimensionId = (_pickFirstCustomCapac = pickFirstCustomCapacityDimensionId(_this5.enabledReservationRuleProducts)) !== null && _pickFirstCustomCapac !== void 0 ? _pickFirstCustomCapac : 0;
1396
- var nextBookings = (payload.bookings || []).map(function (booking, idx) {
1398
+ var bookings = payload.bookings || [];
1399
+ if (!tempOrder.order_id && bookings.length === 0) {
1400
+ var bookingStart = dayjs(now);
1401
+ var bookingDuration = resolveTableOccupancyDuration(tempOrder);
1402
+ var bookingEnd = bookingStart.add(bookingDuration, 'minute');
1403
+ bookings = [normalizeSubmitBooking({
1404
+ relation_id: 0,
1405
+ form_id: 0,
1406
+ start_time: bookingStart.format('HH:mm'),
1407
+ start_date: bookingStart.format('YYYY-MM-DD'),
1408
+ end_time: bookingEnd.format('HH:mm'),
1409
+ end_date: bookingEnd.format('YYYY-MM-DD'),
1410
+ duration: bookingDuration,
1411
+ metadata: {
1412
+ unique_identification_number: bookingUuid
1413
+ },
1414
+ select_date: bookingStart.format('YYYY-MM-DD'),
1415
+ is_all: false,
1416
+ like_status: 'common',
1417
+ schedule_id: 0,
1418
+ relation_type: '',
1419
+ number: 1
1420
+ })];
1421
+ }
1422
+ var nextBookings = bookings.map(function (booking, idx) {
1397
1423
  var metadata = _objectSpread({}, booking.metadata || {});
1398
1424
  if (hasExplicitCollectPax) {
1399
1425
  metadata.collect_pax = normalizeSubmitCollectPaxValue(rawCollectPax);
@@ -595,7 +595,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
595
595
  generateIdempotencyToken(): string;
596
596
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
597
597
  createOrder(params: CommitOrderParams['query']): {
598
- type: "appointment_booking" | "virtual";
598
+ type: "virtual" | "appointment_booking";
599
599
  platform: string;
600
600
  sales_channel: string;
601
601
  order_sales_channel: string;
@@ -213,6 +213,7 @@ export declare function normalizeBookingSubType(booking: Record<string, any>): s
213
213
  export declare function normalizeSubmitBooking<T extends {
214
214
  metadata?: Record<string, any>;
215
215
  }>(booking: T): T;
216
+ export declare function resolveTableOccupancyDuration(tempOrder: OrderTempOrder): number;
216
217
  /** 提交用人数:有限且为正则向下取整,否则为 1 */
217
218
  export declare function normalizeSubmitCollectPaxValue(value: unknown): number;
218
219
  /** 从临时订单 metadata 解析合成 booking 的 collect_pax */
@@ -109,6 +109,7 @@ Object.defineProperty(exports, "resolveSafeProductNum", {
109
109
  });
110
110
  exports.resolveSubmitCollectPax = resolveSubmitCollectPax;
111
111
  exports.resolveSubmitOrderType = resolveSubmitOrderType;
112
+ exports.resolveTableOccupancyDuration = resolveTableOccupancyDuration;
112
113
  Object.defineProperty(exports, "shouldBuildManualProductDiscount", {
113
114
  enumerable: true,
114
115
  get: function () {
@@ -328,7 +328,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
328
328
  date: string;
329
329
  status: string;
330
330
  week: string;
331
- weekNum: 0 | 5 | 3 | 1 | 2 | 4 | 6;
331
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
332
332
  }[]>;
333
333
  submitTimeSlot(timeSlots: TimeSliceItem): void;
334
334
  private getScheduleDataByIds;
@@ -347,7 +347,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
347
347
  count: number;
348
348
  left: number;
349
349
  summaryCount: number;
350
- status: "sold_out" | "lots_of_space" | "filling_up_fast";
350
+ status: "lots_of_space" | "filling_up_fast" | "sold_out";
351
351
  }[];
352
352
  /**
353
353
  * 找到多个资源的公共可用时间段
@@ -797,6 +797,7 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
797
797
  }
798
798
 
799
799
  // ScanOrder 提交 payload enhancer:
800
+ // - 新单有桌台上下文但无 booking 时,补建基础预约(通用 Order 已不再自动生成)
800
801
  // - 给所有 booking 注入 appointment_status: 'started'(扫码点餐语义)
801
802
  // - 给所有 booking 的 metadata 注入 resource_select_type(来自预约规则商品的 resource.type)
802
803
  // - 给第一条 booking 补 resources 与 product_uid(仅当存在 resource / rule product)
@@ -818,7 +819,8 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
818
819
  };
819
820
  return (payload, {
820
821
  bookingUuid,
821
- tempOrder
822
+ tempOrder,
823
+ now
822
824
  }) => {
823
825
  const resourceId = String(resourceState?.relationId ?? '').trim();
824
826
  const hasReservationBookingContext = Boolean(ruleProduct && resourceState && resourceId && resourceState.relationId && resourceState.tableFormId);
@@ -855,7 +857,31 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
855
857
  } : undefined;
856
858
  const ruleProductUid = ruleProduct ? (0, _utils2.createUuidV4)() : undefined;
857
859
  const bookingCapacityDimensionId = (0, _utils.pickFirstCustomCapacityDimensionId)(this.enabledReservationRuleProducts) ?? 0;
858
- const nextBookings = (payload.bookings || []).map((booking, idx) => {
860
+ let bookings = payload.bookings || [];
861
+ if (!tempOrder.order_id && bookings.length === 0) {
862
+ const bookingStart = (0, _dayjs.default)(now);
863
+ const bookingDuration = (0, _utils2.resolveTableOccupancyDuration)(tempOrder);
864
+ const bookingEnd = bookingStart.add(bookingDuration, 'minute');
865
+ bookings = [(0, _utils2.normalizeSubmitBooking)({
866
+ relation_id: 0,
867
+ form_id: 0,
868
+ start_time: bookingStart.format('HH:mm'),
869
+ start_date: bookingStart.format('YYYY-MM-DD'),
870
+ end_time: bookingEnd.format('HH:mm'),
871
+ end_date: bookingEnd.format('YYYY-MM-DD'),
872
+ duration: bookingDuration,
873
+ metadata: {
874
+ unique_identification_number: bookingUuid
875
+ },
876
+ select_date: bookingStart.format('YYYY-MM-DD'),
877
+ is_all: false,
878
+ like_status: 'common',
879
+ schedule_id: 0,
880
+ relation_type: '',
881
+ number: 1
882
+ })];
883
+ }
884
+ const nextBookings = bookings.map((booking, idx) => {
859
885
  const metadata = {
860
886
  ...(booking.metadata || {})
861
887
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.162",
4
+ "version": "2.3.163",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",