@pisell/pisellos 0.0.555 → 0.0.557

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.
@@ -84,7 +84,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
84
84
  enhancePayload?: SubmitPayloadEnhancer;
85
85
  }): Promise<T>;
86
86
  createOrder(params: CommitOrderParams['query']): {
87
- type: "virtual" | "appointment_booking";
87
+ type: "appointment_booking" | "virtual";
88
88
  platform: string;
89
89
  sales_channel: string;
90
90
  order_sales_channel: string;
@@ -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 | 3 | 2 | 4 | 6;
329
+ weekNum: 0 | 2 | 1 | 3 | 5 | 4 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -131,7 +131,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
131
131
  * 获取当前的客户搜索条件
132
132
  * @returns 当前搜索条件
133
133
  */
134
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
134
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
135
135
  /**
136
136
  * 获取客户列表状态(包含滚动加载相关状态)
137
137
  * @returns 客户状态
@@ -121,6 +121,7 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
121
121
  private fetchResourceOccupyDetailsByResourceId;
122
122
  private resolveAdditionalOrderFromOccupyDetail;
123
123
  checkResourceAvailable(resourceId?: string | null, hasOrderId?: boolean): Promise<ScanOrderAvailabilityInfo>;
124
+ restorePreviousOrderData(): Promise<void>;
124
125
  getAdditionalOrderInfo(): Promise<{
125
126
  orderId: string;
126
127
  orderStatus: 'pending' | 'processing' | 'completed' | 'cancelled';
@@ -32,7 +32,7 @@ import { OrderModule } from "../../modules/Order";
32
32
  import { AccountHooks } from "../../modules/Account/types";
33
33
  import { RegisterAndLoginHooks } from "../RegisterAndLogin/types";
34
34
  import Decimal from 'decimal.js';
35
- import { attachItemRuleLimitsToTopLevelProducts, buildProductKey, buildItemRuleBusinessData, collectLinkProductIdsFromReservationRules, computeResourceIsFull, createEmptySummary, getProductIdentityIndex, getSafeProductNum, hasCustomCapacityProduct, pickFirstCustomCapacityDimensionId, pickFirstCustomCapacityPaxBounds, normalizeEnabledItemRuleIds, normalizeOrderProduct, normalizeItemRuleStrategies, pickFirstDurationMinutesFromProducts, toNonNegativeInt, toPriceString, toBoolean, toPositiveString } from "./utils";
35
+ import { attachItemRuleLimitsToTopLevelProducts, buildProductKey, buildItemRuleBusinessData, collectLinkProductIdsFromReservationRules, computeResourceIsFull, createEmptySummary, findReservationRuleProductByResourceId, getProductIdentityIndex, getSafeProductNum, hasCustomCapacityProduct, pickFirstCustomCapacityDimensionId, pickFirstCustomCapacityPaxBounds, normalizeEnabledItemRuleIds, normalizeOrderProduct, normalizeItemRuleStrategies, pickFirstDurationMinutesFromProducts, toNonNegativeInt, toPriceString, toBoolean, toPositiveString } from "./utils";
36
36
  import { createModule } from "../BookingByStep/types";
37
37
  import { ProductList } from "../../modules/ProductList";
38
38
  import { ScheduleModule } from "../../modules/Schedule";
@@ -1411,13 +1411,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1411
1411
  var resourceState = this.store.resource;
1412
1412
  var resourceSelectType = resourceState === null || resourceState === void 0 ? void 0 : resourceState.resourceSelectType;
1413
1413
 
1414
- // collect_pax 时的资源占用兜底:single 独占整张桌台,其余模式占 1 个容量位。
1415
- var resolveResourceCapacity = function resolveResourceCapacity() {
1414
+ // ScanOrder booking 容量只由预约规则决定:single 占用整张桌台,multiple 占用 1 个容量位。
1415
+ var resolveBookingCapacityValue = function resolveBookingCapacityValue() {
1416
1416
  if (resourceSelectType === 'single') {
1417
1417
  var _resourceState$table_;
1418
1418
  var raw = resourceState === null || resourceState === void 0 || (_resourceState$table_ = resourceState.table_form_record) === null || _resourceState$table_ === void 0 ? void 0 : _resourceState$table_.capacity;
1419
1419
  var num = Number(raw);
1420
- if (Number.isFinite(num) && num > 0) return num;
1420
+ if (Number.isFinite(num) && num > 0) return Math.max(1, Math.floor(num));
1421
1421
  return 1;
1422
1422
  }
1423
1423
  return 1;
@@ -1435,8 +1435,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1435
1435
  });
1436
1436
  }
1437
1437
  var rawCollectPax = (_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.collect_pax;
1438
- var hasCollectPaxForCapacity = rawCollectPax !== null && rawCollectPax !== undefined && rawCollectPax !== '';
1439
- var resourceCapacityValue = hasCollectPaxForCapacity ? normalizeSubmitCollectPaxValue(rawCollectPax) : resolveResourceCapacity();
1438
+ var hasExplicitCollectPax = rawCollectPax !== null && rawCollectPax !== undefined && rawCollectPax !== '';
1439
+ var bookingCapacityValue = resolveBookingCapacityValue();
1440
1440
  var pickOriginal = function pickOriginal(value) {
1441
1441
  if (value && _typeof(value) === 'object' && !Array.isArray(value)) {
1442
1442
  var original = value.original;
@@ -1452,21 +1452,25 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1452
1452
  main_field: mainField,
1453
1453
  form_id: resourceState.tableFormId,
1454
1454
  relation_id: (_resourceState$relati = resourceState.relationId) !== null && _resourceState$relati !== void 0 ? _resourceState$relati : resourceId,
1455
- capacity: resourceCapacityValue,
1455
+ capacity: bookingCapacityValue,
1456
1456
  metadata: _this5.buildScanOrderResourceMetadata({
1457
1457
  resourceState: resourceState,
1458
1458
  resourceName: mainField
1459
1459
  })
1460
1460
  } : undefined;
1461
1461
  var ruleProductUid = ruleProduct ? createUuidV4() : undefined;
1462
- // 有 collect_pax 时 booking/resource capacity 与 number 都代表本次 pax;否则使用资源占用兜底值。
1463
- var bookingCapacityValue = resourceCapacityValue;
1464
1462
  var bookingCapacityDimensionId = (_pickFirstCustomCapac = pickFirstCustomCapacityDimensionId(_this5.enabledReservationRuleProducts)) !== null && _pickFirstCustomCapac !== void 0 ? _pickFirstCustomCapac : 0;
1465
1463
  var nextBookings = (payload.bookings || []).map(function (booking, idx) {
1464
+ var metadata = _objectSpread({}, booking.metadata || {});
1465
+ if (hasExplicitCollectPax) {
1466
+ metadata.collect_pax = normalizeSubmitCollectPaxValue(rawCollectPax);
1467
+ } else {
1468
+ delete metadata.collect_pax;
1469
+ }
1466
1470
  return _objectSpread(_objectSpread(_objectSpread({}, booking), {}, {
1467
1471
  number: bookingCapacityValue,
1468
1472
  appointment_status: 'started',
1469
- metadata: _objectSpread(_objectSpread(_objectSpread({}, booking.metadata || {}), resourceSelectType ? {
1473
+ metadata: _objectSpread(_objectSpread(_objectSpread({}, metadata), resourceSelectType ? {
1470
1474
  resource_select_type: resourceSelectType
1471
1475
  } : {}), resourceSelectType ? {
1472
1476
  capacity: [{
@@ -1516,7 +1520,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1516
1520
  key: "submitScanOrder",
1517
1521
  value: function () {
1518
1522
  var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1519
- var _this$store$resource, _this$otherParams5, _this$otherParams6, _this$otherParams7, _this$otherParams8, _tempOrder$products, pax, tempOrderForSubmit, resourceTableName, enhancePayload, result, tempOrder;
1523
+ var _this$store$resource, _this$otherParams5, _this$otherParams6, _this$otherParams7, _this$otherParams8, _tempOrder$products, tempOrderForSubmit, resourceTableName, enhancePayload, result, tempOrder;
1520
1524
  return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1521
1525
  while (1) switch (_context18.prev = _context18.next) {
1522
1526
  case 0:
@@ -1531,12 +1535,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1531
1535
  }
1532
1536
  throw new Error('scanOrder解决方案需要 order 模块支持');
1533
1537
  case 6:
1534
- pax = normalizeSubmitCollectPaxValue(this.store.entryPaxNumber);
1535
- this.store.entryPaxNumber = pax;
1536
1538
  tempOrderForSubmit = this.store.order.ensureTempOrder();
1537
- tempOrderForSubmit.metadata = _objectSpread(_objectSpread({}, tempOrderForSubmit.metadata), {}, {
1538
- collect_pax: pax
1539
- });
1540
1539
  tempOrderForSubmit.delivery_type = 'shop_service';
1541
1540
  resourceTableName = (_this$store$resource = this.store.resource) === null || _this$store$resource === void 0 || (_this$store$resource = _this$store$resource.table_form_record) === null || _this$store$resource === void 0 ? void 0 : _this$store$resource.name;
1542
1541
  if (resourceTableName && _typeof(resourceTableName) === 'object') {
@@ -1546,7 +1545,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1546
1545
  }
1547
1546
  this.store.order.persistTempOrder();
1548
1547
  enhancePayload = this.buildSubmitPayloadEnhancer();
1549
- _context18.next = 17;
1548
+ _context18.next = 14;
1550
1549
  return this.store.order.submitTempOrder({
1551
1550
  cacheId: this.cacheId,
1552
1551
  platform: (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform,
@@ -1555,23 +1554,23 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1555
1554
  type: (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.type,
1556
1555
  enhancePayload: enhancePayload
1557
1556
  });
1558
- case 17:
1557
+ case 14:
1559
1558
  result = _context18.sent;
1560
1559
  tempOrder = this.store.order.getTempOrder();
1561
1560
  this.logMethodSuccess('submitScanOrder', {
1562
1561
  productCount: (tempOrder === null || tempOrder === void 0 || (_tempOrder$products = tempOrder.products) === null || _tempOrder$products === void 0 ? void 0 : _tempOrder$products.length) || 0
1563
1562
  });
1564
1563
  return _context18.abrupt("return", result);
1565
- case 23:
1566
- _context18.prev = 23;
1564
+ case 20:
1565
+ _context18.prev = 20;
1567
1566
  _context18.t0 = _context18["catch"](1);
1568
1567
  this.logMethodError('submitScanOrder', _context18.t0);
1569
1568
  throw _context18.t0;
1570
- case 27:
1569
+ case 24:
1571
1570
  case "end":
1572
1571
  return _context18.stop();
1573
1572
  }
1574
- }, _callee18, this, [[1, 23]]);
1573
+ }, _callee18, this, [[1, 20]]);
1575
1574
  }));
1576
1575
  function submitScanOrder() {
1577
1576
  return _submitScanOrder.apply(this, arguments);
@@ -2688,8 +2687,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2688
2687
  _occupyDetail$form_re2,
2689
2688
  _this$otherParams14,
2690
2689
  _this$store$order6,
2691
- _this$store$order8,
2692
- _this$store$order8$ge,
2690
+ _this$store$order7,
2691
+ _this$store$order7$ge,
2693
2692
  _this$otherParams15,
2694
2693
  businessCode,
2695
2694
  channel,
@@ -2714,6 +2713,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2714
2713
  scheduleDate,
2715
2714
  scheduleDatetime,
2716
2715
  loaded,
2716
+ matchedRuleProduct,
2717
+ ruleProductsForResource,
2717
2718
  occupancyMinutes,
2718
2719
  paxBounds,
2719
2720
  error,
@@ -2729,10 +2730,6 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2729
2730
  additionalOrderId,
2730
2731
  availabilityInfo,
2731
2732
  isAdditionalOrderMode,
2732
- _this$store$order7,
2733
- _res$data,
2734
- res,
2735
- entryPaxNumber,
2736
2733
  lastOrderInfo,
2737
2734
  historicalItems,
2738
2735
  _args37 = arguments;
@@ -2864,14 +2861,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2864
2861
  case 46:
2865
2862
  loaded = _context37.sent;
2866
2863
  if (Array.isArray(loaded)) {
2867
- this.enabledReservationRuleProducts = loaded;
2868
- occupancyMinutes = pickFirstDurationMinutesFromProducts(loaded);
2864
+ matchedRuleProduct = findReservationRuleProductByResourceId(loaded, normalizedResourceId);
2865
+ ruleProductsForResource = matchedRuleProduct ? [matchedRuleProduct] : [];
2866
+ this.enabledReservationRuleProducts = ruleProductsForResource;
2867
+ occupancyMinutes = pickFirstDurationMinutesFromProducts(ruleProductsForResource);
2869
2868
  if (occupancyMinutes !== undefined) {
2870
2869
  tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
2871
2870
  }
2872
- if (hasCustomCapacityProduct(loaded)) {
2871
+ if (hasCustomCapacityProduct(ruleProductsForResource)) {
2873
2872
  pendingRequestEntryPax = 1;
2874
- paxBounds = pickFirstCustomCapacityPaxBounds(loaded);
2873
+ paxBounds = pickFirstCustomCapacityPaxBounds(ruleProductsForResource);
2875
2874
  if ((paxBounds === null || paxBounds === void 0 ? void 0 : paxBounds.min) !== undefined) pendingRequestPaxMin = paxBounds.min;
2876
2875
  if ((paxBounds === null || paxBounds === void 0 ? void 0 : paxBounds.max) !== undefined) pendingRequestPaxMax = paxBounds.max;
2877
2876
  }
@@ -2978,27 +2977,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2978
2977
  if (isAdditionalOrderMode) {
2979
2978
  tempOrder.order_id = additionalOrderId;
2980
2979
  }
2981
- if (!tempOrder.order_id) {
2982
- _context37.next = 86;
2983
- break;
2984
- }
2985
- _context37.next = 81;
2986
- return (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getOrderInfoByRemote(tempOrder.order_id);
2987
- case 81:
2988
- res = _context37.sent;
2989
- // 找到下单的时候输入的 entryPaxNumber
2990
- entryPaxNumber = res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 || (_res$data = _res$data.bookings) === null || _res$data === void 0 || (_res$data = _res$data.find(function (p) {
2991
- var _p$metadata;
2992
- return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
2993
- })) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
2994
- if (!entryPaxNumber) {
2995
- _context37.next = 86;
2996
- break;
2997
- }
2998
- _context37.next = 86;
2999
- return this.setEntryPaxNumber(entryPaxNumber);
3000
- case 86:
3001
- lastOrderInfo = (_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 || (_this$store$order8$ge = _this$store$order8.getLastOrderInfo) === null || _this$store$order8$ge === void 0 ? void 0 : _this$store$order8$ge.call(_this$store$order8);
2980
+ lastOrderInfo = (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 || (_this$store$order7$ge = _this$store$order7.getLastOrderInfo) === null || _this$store$order7$ge === void 0 ? void 0 : _this$store$order7$ge.call(_this$store$order7);
3002
2981
  historicalItems = isAdditionalOrderMode && Array.isArray(lastOrderInfo === null || lastOrderInfo === void 0 ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce(function (acc, p) {
3003
2982
  if (typeof (p === null || p === void 0 ? void 0 : p.product_id) !== 'number') return acc;
3004
2983
  acc.push(_objectSpread({
@@ -3009,13 +2988,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3009
2988
  } : {}));
3010
2989
  return acc;
3011
2990
  }, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
3012
- _context37.next = 90;
2991
+ _context37.next = 82;
3013
2992
  return this.setItemRuleRuntimeConfig({
3014
2993
  serviceType: (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.businessCode,
3015
2994
  submissionIndex: isAdditionalOrderMode ? 1 : 0,
3016
2995
  historicalItems: historicalItems
3017
2996
  });
3018
- case 90:
2997
+ case 82:
3019
2998
  // operating_hours 超出营业时段 + closed_behavior=show_menu_disabled:
3020
2999
  // 允许浏览商品但 UI 层需拦截“下一步”,这里覆盖最终 mode 并回传错误提示
3021
3000
  if (outsideOperatingHours && closedBehaviorValue === 'show_menu_disabled') {
@@ -3037,31 +3016,70 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3037
3016
  isFull: resourceState.isFull
3038
3017
  });
3039
3018
  return _context37.abrupt("return", availabilityInfo);
3040
- case 95:
3041
- _context37.prev = 95;
3019
+ case 87:
3020
+ _context37.prev = 87;
3042
3021
  _context37.t0 = _context37["catch"](3);
3043
3022
  this.logMethodError('checkResourceAvailable', _context37.t0.message, {
3044
3023
  resourceId: normalizedResourceId
3045
3024
  });
3046
3025
  throw _context37.t0;
3047
- case 99:
3026
+ case 91:
3048
3027
  case "end":
3049
3028
  return _context37.stop();
3050
3029
  }
3051
- }, _callee37, this, [[3, 95]]);
3030
+ }, _callee37, this, [[3, 87]]);
3052
3031
  }));
3053
3032
  function checkResourceAvailable(_x19) {
3054
3033
  return _checkResourceAvailable.apply(this, arguments);
3055
3034
  }
3056
3035
  return checkResourceAvailable;
3036
+ }() // 恢复之前订单的数据,读取 entrypax
3037
+ }, {
3038
+ key: "restorePreviousOrderData",
3039
+ value: function () {
3040
+ var _restorePreviousOrderData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
3041
+ var tempOrder, _this$store$order8, _res$data, res, entryPaxNumber;
3042
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3043
+ while (1) switch (_context38.prev = _context38.next) {
3044
+ case 0:
3045
+ tempOrder = this.ensureTempOrder();
3046
+ if (!tempOrder.order_id) {
3047
+ _context38.next = 9;
3048
+ break;
3049
+ }
3050
+ _context38.next = 4;
3051
+ return (_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getOrderInfoByRemote(tempOrder.order_id);
3052
+ case 4:
3053
+ res = _context38.sent;
3054
+ // 找到下单的时候输入的 entryPaxNumber
3055
+ entryPaxNumber = res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 || (_res$data = _res$data.bookings) === null || _res$data === void 0 || (_res$data = _res$data.find(function (p) {
3056
+ var _p$metadata;
3057
+ return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
3058
+ })) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
3059
+ if (!entryPaxNumber) {
3060
+ _context38.next = 9;
3061
+ break;
3062
+ }
3063
+ _context38.next = 9;
3064
+ return this.setEntryPaxNumber(entryPaxNumber);
3065
+ case 9:
3066
+ case "end":
3067
+ return _context38.stop();
3068
+ }
3069
+ }, _callee38, this);
3070
+ }));
3071
+ function restorePreviousOrderData() {
3072
+ return _restorePreviousOrderData.apply(this, arguments);
3073
+ }
3074
+ return restorePreviousOrderData;
3057
3075
  }() // 如果是加单的情况,提供返回当前订单相关信息的能力
3058
3076
  }, {
3059
3077
  key: "getAdditionalOrderInfo",
3060
3078
  value: function () {
3061
- var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
3079
+ var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
3062
3080
  var result;
3063
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3064
- while (1) switch (_context38.prev = _context38.next) {
3081
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3082
+ while (1) switch (_context39.prev = _context39.next) {
3065
3083
  case 0:
3066
3084
  this.logMethodStart('getAdditionalOrderInfo');
3067
3085
  result = {
@@ -3075,12 +3093,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3075
3093
  orderId: result.orderId,
3076
3094
  orderStatus: result.orderStatus
3077
3095
  });
3078
- return _context38.abrupt("return", result);
3096
+ return _context39.abrupt("return", result);
3079
3097
  case 4:
3080
3098
  case "end":
3081
- return _context38.stop();
3099
+ return _context39.stop();
3082
3100
  }
3083
- }, _callee38, this);
3101
+ }, _callee39, this);
3084
3102
  }));
3085
3103
  function getAdditionalOrderInfo() {
3086
3104
  return _getAdditionalOrderInfo.apply(this, arguments);
@@ -3090,25 +3108,25 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3090
3108
  }, {
3091
3109
  key: "getProductList",
3092
3110
  value: function () {
3093
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
3111
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
3094
3112
  var _this$otherParams16;
3095
3113
  var menu_list_ids, res, productList, formattedRes;
3096
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3097
- while (1) switch (_context39.prev = _context39.next) {
3114
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3115
+ while (1) switch (_context40.prev = _context40.next) {
3098
3116
  case 0:
3099
3117
  this.logMethodStart('getProductList');
3100
3118
  // 可以直接通过配置里的 menu 读取
3101
3119
  menu_list_ids = ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 || (_this$otherParams16 = _this$otherParams16.dineInConfig) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16['menu.associated_menus'].map(function (n) {
3102
3120
  return Number(n.value);
3103
3121
  })) || [];
3104
- _context39.prev = 2;
3122
+ _context40.prev = 2;
3105
3123
  if (this.store.products) {
3106
- _context39.next = 5;
3124
+ _context40.next = 5;
3107
3125
  break;
3108
3126
  }
3109
3127
  throw new Error('products 模块未初始化');
3110
3128
  case 5:
3111
- _context39.next = 7;
3129
+ _context40.next = 7;
3112
3130
  return this.store.products.loadProducts({
3113
3131
  menu_list_ids: menu_list_ids,
3114
3132
  cacheId: this.cacheId,
@@ -3116,7 +3134,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3116
3134
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
3117
3135
  });
3118
3136
  case 7:
3119
- res = _context39.sent;
3137
+ res = _context40.sent;
3120
3138
  productList = this.assertProductListLoaded('getProductList', res, {
3121
3139
  menu_list_ids: menu_list_ids,
3122
3140
  cacheId: this.cacheId
@@ -3125,22 +3143,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3125
3143
  this.logMethodSuccess('getProductList', {
3126
3144
  menuCount: menu_list_ids.length
3127
3145
  });
3128
- return _context39.abrupt("return", formattedRes);
3146
+ return _context40.abrupt("return", formattedRes);
3129
3147
  case 14:
3130
- _context39.prev = 14;
3131
- _context39.t0 = _context39["catch"](2);
3132
- if (!(_context39.t0 !== null && _context39.t0 !== void 0 && _context39.t0.__scanOrderLogged)) {
3133
- this.logMethodError('getProductList', _context39.t0, {
3148
+ _context40.prev = 14;
3149
+ _context40.t0 = _context40["catch"](2);
3150
+ if (!(_context40.t0 !== null && _context40.t0 !== void 0 && _context40.t0.__scanOrderLogged)) {
3151
+ this.logMethodError('getProductList', _context40.t0, {
3134
3152
  menu_list_ids: menu_list_ids,
3135
3153
  cacheId: this.cacheId
3136
3154
  });
3137
3155
  }
3138
- throw _context39.t0;
3156
+ throw _context40.t0;
3139
3157
  case 18:
3140
3158
  case "end":
3141
- return _context39.stop();
3159
+ return _context40.stop();
3142
3160
  }
3143
- }, _callee39, this, [[2, 14]]);
3161
+ }, _callee40, this, [[2, 14]]);
3144
3162
  }));
3145
3163
  function getProductList() {
3146
3164
  return _getProductList.apply(this, arguments);
@@ -3155,15 +3173,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3155
3173
  }, {
3156
3174
  key: "setOtherParams",
3157
3175
  value: function () {
3158
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
3176
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
3159
3177
  var _ref9,
3160
3178
  _ref9$cover,
3161
3179
  cover,
3162
- _args40 = arguments;
3163
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3164
- while (1) switch (_context40.prev = _context40.next) {
3180
+ _args41 = arguments;
3181
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3182
+ while (1) switch (_context41.prev = _context41.next) {
3165
3183
  case 0:
3166
- _ref9 = _args40.length > 1 && _args40[1] !== undefined ? _args40[1] : {}, _ref9$cover = _ref9.cover, cover = _ref9$cover === void 0 ? false : _ref9$cover;
3184
+ _ref9 = _args41.length > 1 && _args41[1] !== undefined ? _args41[1] : {}, _ref9$cover = _ref9.cover, cover = _ref9$cover === void 0 ? false : _ref9$cover;
3167
3185
  if (cover) {
3168
3186
  this.otherParams = params;
3169
3187
  } else {
@@ -3171,9 +3189,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3171
3189
  }
3172
3190
  case 2:
3173
3191
  case "end":
3174
- return _context40.stop();
3192
+ return _context41.stop();
3175
3193
  }
3176
- }, _callee40, this);
3194
+ }, _callee41, this);
3177
3195
  }));
3178
3196
  function setOtherParams(_x20) {
3179
3197
  return _setOtherParams.apply(this, arguments);
@@ -3265,10 +3283,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3265
3283
  }, {
3266
3284
  key: "setEntryPaxNumber",
3267
3285
  value: function () {
3268
- var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(number) {
3286
+ var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(number) {
3269
3287
  var pax, t;
3270
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3271
- while (1) switch (_context41.prev = _context41.next) {
3288
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3289
+ while (1) switch (_context42.prev = _context42.next) {
3272
3290
  case 0:
3273
3291
  pax = normalizeSubmitCollectPaxValue(number);
3274
3292
  this.store.entryPaxNumber = pax;
@@ -3289,16 +3307,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3289
3307
  }
3290
3308
  });
3291
3309
  this.itemRulePrefillApplied = false;
3292
- _context41.next = 7;
3310
+ _context42.next = 7;
3293
3311
  return this.refreshItemRuleQuantityLimits();
3294
3312
  case 7:
3295
- _context41.next = 9;
3313
+ _context42.next = 9;
3296
3314
  return this.refreshCartValidationPassed();
3297
3315
  case 9:
3298
3316
  case "end":
3299
- return _context41.stop();
3317
+ return _context42.stop();
3300
3318
  }
3301
- }, _callee41, this);
3319
+ }, _callee42, this);
3302
3320
  }));
3303
3321
  function setEntryPaxNumber(_x21) {
3304
3322
  return _setEntryPaxNumber.apply(this, arguments);
@@ -3313,11 +3331,11 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3313
3331
  }, {
3314
3332
  key: "syncAdditionalOrderFromResource",
3315
3333
  value: function () {
3316
- var _syncAdditionalOrderFromResource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(resourceId) {
3334
+ var _syncAdditionalOrderFromResource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(resourceId) {
3317
3335
  var _ref10, _ref11, _ref12, _this$store$resource2, _this$store$resource3, _occupyDetails$2, _this$store$resource4, _this$otherParams17, _this$store$order9;
3318
3336
  var tempOrder, normalizedResourceId, _result, occupyDetails, occupyDetail, resourceSelectType, allowAddItems, result;
3319
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3320
- while (1) switch (_context42.prev = _context42.next) {
3337
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3338
+ while (1) switch (_context43.prev = _context43.next) {
3321
3339
  case 0:
3322
3340
  tempOrder = this.ensureTempOrder();
3323
3341
  normalizedResourceId = String((_ref10 = (_ref11 = (_ref12 = resourceId !== null && resourceId !== void 0 ? resourceId : tempOrder.resource_id) !== null && _ref12 !== void 0 ? _ref12 : (_this$store$resource2 = this.store.resource) === null || _this$store$resource2 === void 0 ? void 0 : _this$store$resource2.relationId) !== null && _ref11 !== void 0 ? _ref11 : (_this$store$resource3 = this.store.resource) === null || _this$store$resource3 === void 0 ? void 0 : _this$store$resource3.relation_id) !== null && _ref10 !== void 0 ? _ref10 : '').trim();
@@ -3325,7 +3343,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3325
3343
  resourceId: normalizedResourceId
3326
3344
  });
3327
3345
  if (normalizedResourceId) {
3328
- _context42.next = 7;
3346
+ _context43.next = 7;
3329
3347
  break;
3330
3348
  }
3331
3349
  _result = {
@@ -3333,18 +3351,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3333
3351
  reason: 'missing_resource_id'
3334
3352
  };
3335
3353
  this.logMethodSuccess('syncAdditionalOrderFromResource', _result);
3336
- return _context42.abrupt("return", _result);
3354
+ return _context43.abrupt("return", _result);
3337
3355
  case 7:
3338
- _context42.next = 9;
3356
+ _context43.next = 9;
3339
3357
  return this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
3340
3358
  case 9:
3341
- occupyDetails = _context42.sent;
3359
+ occupyDetails = _context43.sent;
3342
3360
  occupyDetail = (_occupyDetails$2 = occupyDetails[0]) !== null && _occupyDetails$2 !== void 0 ? _occupyDetails$2 : null;
3343
3361
  resourceSelectType = ((_this$store$resource4 = this.store.resource) === null || _this$store$resource4 === void 0 ? void 0 : _this$store$resource4.resourceSelectType) || this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id));
3344
3362
  allowAddItems = toBoolean((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 || (_this$otherParams17 = _this$otherParams17.dineInConfig) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17['sale.allow_add_items']);
3345
3363
  result = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
3346
3364
  if (!(!result.matched || !result.order_id)) {
3347
- _context42.next = 17;
3365
+ _context43.next = 17;
3348
3366
  break;
3349
3367
  }
3350
3368
  this.logMethodSuccess('syncAdditionalOrderFromResource', _objectSpread(_objectSpread({}, result), {}, {
@@ -3352,7 +3370,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3352
3370
  resourceSelectType: resourceSelectType,
3353
3371
  allowAddItems: allowAddItems
3354
3372
  }));
3355
- return _context42.abrupt("return", result);
3373
+ return _context43.abrupt("return", result);
3356
3374
  case 17:
3357
3375
  tempOrder.order_id = result.order_id;
3358
3376
  tempOrder.resource_id = normalizedResourceId;
@@ -3364,12 +3382,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3364
3382
  resourceSelectType: resourceSelectType,
3365
3383
  allowAddItems: allowAddItems
3366
3384
  }));
3367
- return _context42.abrupt("return", result);
3385
+ return _context43.abrupt("return", result);
3368
3386
  case 24:
3369
3387
  case "end":
3370
- return _context42.stop();
3388
+ return _context43.stop();
3371
3389
  }
3372
- }, _callee42, this);
3390
+ }, _callee43, this);
3373
3391
  }));
3374
3392
  function syncAdditionalOrderFromResource(_x22) {
3375
3393
  return _syncAdditionalOrderFromResource.apply(this, arguments);
@@ -134,6 +134,11 @@ export declare function normalizeOrderProduct(product: Partial<ScanOrderOrderPro
134
134
  * 从 reservation.enabled_reservation_rules 中收集 type=link 的商品 id。
135
135
  */
136
136
  export declare function collectLinkProductIdsFromReservationRules(rules: unknown): number[];
137
+ /**
138
+ * 找到第一个归属指定桌台的预约规则商品。
139
+ * 归属判断基于商品资源中的 default_resource / optional_resource。
140
+ */
141
+ export declare function findReservationRuleProductByResourceId(products: ProductData[], resourceId: string | number | null | undefined): ProductData | undefined;
137
142
  /**
138
143
  * 返回列表中第一个带有效 duration.value(分钟)的商品时长。
139
144
  */
@@ -629,23 +629,55 @@ export function collectLinkProductIdsFromReservationRules(rules) {
629
629
  }
630
630
 
631
631
  /**
632
- * 返回列表中第一个带有效 duration.value(分钟)的商品时长。
632
+ * 找到第一个归属指定桌台的预约规则商品。
633
+ * 归属判断基于商品资源中的 default_resource / optional_resource。
633
634
  */
634
- export function pickFirstDurationMinutesFromProducts(products) {
635
+ export function findReservationRuleProductByResourceId(products, resourceId) {
636
+ var numericResourceId = Number(resourceId);
637
+ if (!Number.isFinite(numericResourceId) || numericResourceId <= 0) return undefined;
635
638
  var _iterator7 = _createForOfIteratorHelper(products),
636
639
  _step7;
637
640
  try {
638
641
  for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
639
- var _product$duration;
642
+ var _product$product_reso;
640
643
  var product = _step7.value;
644
+ var resources = product === null || product === void 0 || (_product$product_reso = product.product_resource) === null || _product$product_reso === void 0 ? void 0 : _product$product_reso.resources;
645
+ if (!Array.isArray(resources)) continue;
646
+ var hasMatchedResource = resources.some(function (resource) {
647
+ var defaultResources = Array.isArray(resource === null || resource === void 0 ? void 0 : resource.default_resource) ? resource.default_resource : [];
648
+ var optionalResources = Array.isArray(resource === null || resource === void 0 ? void 0 : resource.optional_resource) ? resource.optional_resource : [];
649
+ return [].concat(_toConsumableArray(defaultResources), _toConsumableArray(optionalResources)).some(function (id) {
650
+ return Number(id) === numericResourceId;
651
+ });
652
+ });
653
+ if (hasMatchedResource) return product;
654
+ }
655
+ } catch (err) {
656
+ _iterator7.e(err);
657
+ } finally {
658
+ _iterator7.f();
659
+ }
660
+ return undefined;
661
+ }
662
+
663
+ /**
664
+ * 返回列表中第一个带有效 duration.value(分钟)的商品时长。
665
+ */
666
+ export function pickFirstDurationMinutesFromProducts(products) {
667
+ var _iterator8 = _createForOfIteratorHelper(products),
668
+ _step8;
669
+ try {
670
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
671
+ var _product$duration;
672
+ var product = _step8.value;
641
673
  var value = product === null || product === void 0 || (_product$duration = product.duration) === null || _product$duration === void 0 ? void 0 : _product$duration.value;
642
674
  var n = Number(value);
643
675
  if (Number.isFinite(n) && n > 0) return Math.floor(n);
644
676
  }
645
677
  } catch (err) {
646
- _iterator7.e(err);
678
+ _iterator8.e(err);
647
679
  } finally {
648
- _iterator7.f();
680
+ _iterator8.f();
649
681
  }
650
682
  return undefined;
651
683
  }
@@ -675,11 +707,11 @@ export function computeResourceIsFull(params) {
675
707
  if (!Number.isFinite(totalCapacity) || totalCapacity <= 0) return false;
676
708
  var now = dayjs();
677
709
  var occupied = 0;
678
- var _iterator8 = _createForOfIteratorHelper(capacityList || []),
679
- _step8;
710
+ var _iterator9 = _createForOfIteratorHelper(capacityList || []),
711
+ _step9;
680
712
  try {
681
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
682
- var slot = _step8.value;
713
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
714
+ var slot = _step9.value;
683
715
  var start = dayjs(slot === null || slot === void 0 ? void 0 : slot.start_at);
684
716
  var end = dayjs(slot === null || slot === void 0 ? void 0 : slot.end_at);
685
717
  if (!start.isValid() || !end.isValid()) continue;
@@ -689,9 +721,9 @@ export function computeResourceIsFull(params) {
689
721
  }
690
722
  }
691
723
  } catch (err) {
692
- _iterator8.e(err);
724
+ _iterator9.e(err);
693
725
  } finally {
694
- _iterator8.f();
726
+ _iterator9.f();
695
727
  }
696
728
  return occupied >= totalCapacity;
697
729
  }
@@ -701,11 +733,11 @@ export function computeResourceIsFull(params) {
701
733
  * 仅返回有限数字字段;若均无法解析则返回 `undefined`。
702
734
  */
703
735
  export function pickFirstCustomCapacityPaxBounds(products) {
704
- var _iterator9 = _createForOfIteratorHelper(products),
705
- _step9;
736
+ var _iterator10 = _createForOfIteratorHelper(products),
737
+ _step10;
706
738
  try {
707
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
708
- var p = _step9.value;
739
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
740
+ var p = _step10.value;
709
741
  var cap = p === null || p === void 0 ? void 0 : p.capacity;
710
742
  if (!cap || cap.type !== 'custom') continue;
711
743
  if (!Array.isArray(cap.custom) || cap.custom.length === 0) continue;
@@ -724,9 +756,9 @@ export function pickFirstCustomCapacityPaxBounds(products) {
724
756
  if (out.min !== undefined || out.max !== undefined) return out;
725
757
  }
726
758
  } catch (err) {
727
- _iterator9.e(err);
759
+ _iterator10.e(err);
728
760
  } finally {
729
- _iterator9.f();
761
+ _iterator10.f();
730
762
  }
731
763
  return undefined;
732
764
  }
@@ -736,11 +768,11 @@ export function pickFirstCustomCapacityPaxBounds(products) {
736
768
  * 无匹配时返回 `undefined`,调用方应回退为 `0`。
737
769
  */
738
770
  export function pickFirstCustomCapacityDimensionId(products) {
739
- var _iterator10 = _createForOfIteratorHelper(products),
740
- _step10;
771
+ var _iterator11 = _createForOfIteratorHelper(products),
772
+ _step11;
741
773
  try {
742
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
743
- var p = _step10.value;
774
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
775
+ var p = _step11.value;
744
776
  var cap = p === null || p === void 0 ? void 0 : p.capacity;
745
777
  if (!cap || cap.type !== 'custom') continue;
746
778
  if (!Array.isArray(cap.custom) || cap.custom.length === 0) continue;
@@ -756,9 +788,9 @@ export function pickFirstCustomCapacityDimensionId(products) {
756
788
  }
757
789
  }
758
790
  } catch (err) {
759
- _iterator10.e(err);
791
+ _iterator11.e(err);
760
792
  } finally {
761
- _iterator10.f();
793
+ _iterator11.f();
762
794
  }
763
795
  return undefined;
764
796
  }
@@ -1,49 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/model/strategy/adapter/promotion/index.ts
30
- var promotion_exports = {};
31
- __export(promotion_exports, {
32
- BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
33
- PromotionAdapter: () => import_adapter.PromotionAdapter,
34
- PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
35
- X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
36
- default: () => import_adapter2.default
37
- });
38
- module.exports = __toCommonJS(promotion_exports);
39
- var import_evaluator = require("./evaluator");
40
- var import_adapter = require("./adapter");
41
- var import_adapter2 = __toESM(require("./adapter"));
42
- var import_examples = require("./examples");
43
- // Annotate the CommonJS export names for ESM import in node:
44
- 0 && (module.exports = {
45
- BUY_X_GET_Y_FREE_STRATEGY,
46
- PromotionAdapter,
47
- PromotionEvaluator,
48
- X_ITEMS_FOR_Y_PRICE_STRATEGY
49
- });
@@ -84,7 +84,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
84
84
  enhancePayload?: SubmitPayloadEnhancer;
85
85
  }): Promise<T>;
86
86
  createOrder(params: CommitOrderParams['query']): {
87
- type: "virtual" | "appointment_booking";
87
+ type: "appointment_booking" | "virtual";
88
88
  platform: string;
89
89
  sales_channel: string;
90
90
  order_sales_channel: string;
@@ -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 | 3 | 2 | 4 | 6;
329
+ weekNum: 0 | 2 | 1 | 3 | 5 | 4 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -131,7 +131,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
131
131
  * 获取当前的客户搜索条件
132
132
  * @returns 当前搜索条件
133
133
  */
134
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
134
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
135
135
  /**
136
136
  * 获取客户列表状态(包含滚动加载相关状态)
137
137
  * @returns 客户状态
@@ -121,6 +121,7 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
121
121
  private fetchResourceOccupyDetailsByResourceId;
122
122
  private resolveAdditionalOrderFromOccupyDetail;
123
123
  checkResourceAvailable(resourceId?: string | null, hasOrderId?: boolean): Promise<ScanOrderAvailabilityInfo>;
124
+ restorePreviousOrderData(): Promise<void>;
124
125
  getAdditionalOrderInfo(): Promise<{
125
126
  orderId: string;
126
127
  orderStatus: 'pending' | 'processing' | 'completed' | 'cancelled';
@@ -867,13 +867,13 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
867
867
  const ruleProduct = this.enabledReservationRuleProducts[0];
868
868
  const resourceState = this.store.resource;
869
869
  const resourceSelectType = resourceState == null ? void 0 : resourceState.resourceSelectType;
870
- const resolveResourceCapacity = () => {
870
+ const resolveBookingCapacityValue = () => {
871
871
  var _a;
872
872
  if (resourceSelectType === "single") {
873
873
  const raw = (_a = resourceState == null ? void 0 : resourceState.table_form_record) == null ? void 0 : _a.capacity;
874
874
  const num = Number(raw);
875
875
  if (Number.isFinite(num) && num > 0)
876
- return num;
876
+ return Math.max(1, Math.floor(num));
877
877
  return 1;
878
878
  }
879
879
  return 1;
@@ -892,8 +892,8 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
892
892
  };
893
893
  }
894
894
  const rawCollectPax = (_a = tempOrder.metadata) == null ? void 0 : _a.collect_pax;
895
- const hasCollectPaxForCapacity = rawCollectPax !== null && rawCollectPax !== void 0 && rawCollectPax !== "";
896
- const resourceCapacityValue = hasCollectPaxForCapacity ? (0, import_utils2.normalizeSubmitCollectPaxValue)(rawCollectPax) : resolveResourceCapacity();
895
+ const hasExplicitCollectPax = rawCollectPax !== null && rawCollectPax !== void 0 && rawCollectPax !== "";
896
+ const bookingCapacityValue = resolveBookingCapacityValue();
897
897
  const pickOriginal = (value) => {
898
898
  if (value && typeof value === "object" && !Array.isArray(value)) {
899
899
  const original = value.original;
@@ -909,35 +909,42 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
909
909
  main_field: mainField,
910
910
  form_id: resourceState.tableFormId,
911
911
  relation_id: resourceState.relationId ?? resourceId,
912
- capacity: resourceCapacityValue,
912
+ capacity: bookingCapacityValue,
913
913
  metadata: this.buildScanOrderResourceMetadata({
914
914
  resourceState,
915
915
  resourceName: mainField
916
916
  })
917
917
  } : void 0;
918
918
  const ruleProductUid = ruleProduct ? (0, import_utils2.createUuidV4)() : void 0;
919
- const bookingCapacityValue = resourceCapacityValue;
920
919
  const bookingCapacityDimensionId = (0, import_utils.pickFirstCustomCapacityDimensionId)(this.enabledReservationRuleProducts) ?? 0;
921
- const nextBookings = (payload.bookings || []).map((booking, idx) => ({
922
- ...booking,
923
- number: bookingCapacityValue,
924
- appointment_status: "started",
925
- metadata: {
926
- ...booking.metadata || {},
927
- ...resourceSelectType ? { resource_select_type: resourceSelectType } : {},
928
- ...resourceSelectType ? {
929
- capacity: [
930
- {
931
- id: bookingCapacityDimensionId,
932
- value: bookingCapacityValue,
933
- name: ""
934
- }
935
- ]
936
- } : {}
937
- },
938
- ...idx === 0 && resourceEntry ? { resources: [resourceEntry] } : {},
939
- ...idx === 0 && ruleProductUid ? { product_uid: ruleProductUid } : {}
940
- }));
920
+ const nextBookings = (payload.bookings || []).map((booking, idx) => {
921
+ const metadata = { ...booking.metadata || {} };
922
+ if (hasExplicitCollectPax) {
923
+ metadata.collect_pax = (0, import_utils2.normalizeSubmitCollectPaxValue)(rawCollectPax);
924
+ } else {
925
+ delete metadata.collect_pax;
926
+ }
927
+ return {
928
+ ...booking,
929
+ number: bookingCapacityValue,
930
+ appointment_status: "started",
931
+ metadata: {
932
+ ...metadata,
933
+ ...resourceSelectType ? { resource_select_type: resourceSelectType } : {},
934
+ ...resourceSelectType ? {
935
+ capacity: [
936
+ {
937
+ id: bookingCapacityDimensionId,
938
+ value: bookingCapacityValue,
939
+ name: ""
940
+ }
941
+ ]
942
+ } : {}
943
+ },
944
+ ...idx === 0 && resourceEntry ? { resources: [resourceEntry] } : {},
945
+ ...idx === 0 && ruleProductUid ? { product_uid: ruleProductUid } : {}
946
+ };
947
+ });
941
948
  const nextProducts = [...payload.products || []];
942
949
  if (ruleProduct && ruleProductUid && !tempOrder.order_id) {
943
950
  const sellingPrice = String(ruleProduct.price ?? "0.00");
@@ -974,10 +981,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
974
981
  if (!this.store.order) {
975
982
  throw new Error("scanOrder解决方案需要 order 模块支持");
976
983
  }
977
- const pax = (0, import_utils2.normalizeSubmitCollectPaxValue)(this.store.entryPaxNumber);
978
- this.store.entryPaxNumber = pax;
979
984
  const tempOrderForSubmit = this.store.order.ensureTempOrder();
980
- tempOrderForSubmit.metadata = { ...tempOrderForSubmit.metadata, collect_pax: pax };
981
985
  tempOrderForSubmit.delivery_type = "shop_service";
982
986
  const resourceTableName = (_b = (_a = this.store.resource) == null ? void 0 : _a.table_form_record) == null ? void 0 : _b.name;
983
987
  if (resourceTableName && typeof resourceTableName === "object") {
@@ -1597,7 +1601,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1597
1601
  // 通过 resource_id + 店铺配置
1598
1602
  // hasOrderId 表示 url 上是否有 orderid,如果是的话,后续的流程会走加单
1599
1603
  async checkResourceAvailable(resourceId, hasOrderId = false) {
1600
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
1604
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
1601
1605
  const normalizedResourceId = String(resourceId ?? "").trim();
1602
1606
  this.logMethodStart("checkResourceAvailable", {
1603
1607
  resourceId: normalizedResourceId
@@ -1689,14 +1693,19 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1689
1693
  cacheId: this.cacheId
1690
1694
  });
1691
1695
  if (Array.isArray(loaded)) {
1692
- this.enabledReservationRuleProducts = loaded;
1693
- const occupancyMinutes = (0, import_utils.pickFirstDurationMinutesFromProducts)(loaded);
1696
+ const matchedRuleProduct = (0, import_utils.findReservationRuleProductByResourceId)(
1697
+ loaded,
1698
+ normalizedResourceId
1699
+ );
1700
+ const ruleProductsForResource = matchedRuleProduct ? [matchedRuleProduct] : [];
1701
+ this.enabledReservationRuleProducts = ruleProductsForResource;
1702
+ const occupancyMinutes = (0, import_utils.pickFirstDurationMinutesFromProducts)(ruleProductsForResource);
1694
1703
  if (occupancyMinutes !== void 0) {
1695
1704
  tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
1696
1705
  }
1697
- if ((0, import_utils.hasCustomCapacityProduct)(loaded)) {
1706
+ if ((0, import_utils.hasCustomCapacityProduct)(ruleProductsForResource)) {
1698
1707
  pendingRequestEntryPax = 1;
1699
- const paxBounds = (0, import_utils.pickFirstCustomCapacityPaxBounds)(loaded);
1708
+ const paxBounds = (0, import_utils.pickFirstCustomCapacityPaxBounds)(ruleProductsForResource);
1700
1709
  if ((paxBounds == null ? void 0 : paxBounds.min) !== void 0)
1701
1710
  pendingRequestPaxMin = paxBounds.min;
1702
1711
  if ((paxBounds == null ? void 0 : paxBounds.max) !== void 0)
@@ -1795,17 +1804,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1795
1804
  if (isAdditionalOrderMode) {
1796
1805
  tempOrder.order_id = additionalOrderId;
1797
1806
  }
1798
- if (tempOrder.order_id) {
1799
- const res = await ((_j = this.store.order) == null ? void 0 : _j.getOrderInfoByRemote(tempOrder.order_id));
1800
- const entryPaxNumber = (_n = (_m = (_l = (_k = res == null ? void 0 : res.data) == null ? void 0 : _k.bookings) == null ? void 0 : _l.find((p) => {
1801
- var _a2;
1802
- return (_a2 = p.metadata) == null ? void 0 : _a2.collect_pax;
1803
- })) == null ? void 0 : _m.metadata) == null ? void 0 : _n.collect_pax;
1804
- if (entryPaxNumber) {
1805
- await this.setEntryPaxNumber(entryPaxNumber);
1806
- }
1807
- }
1808
- const lastOrderInfo = (_p = (_o = this.store.order) == null ? void 0 : _o.getLastOrderInfo) == null ? void 0 : _p.call(_o);
1807
+ const lastOrderInfo = (_k = (_j = this.store.order) == null ? void 0 : _j.getLastOrderInfo) == null ? void 0 : _k.call(_j);
1809
1808
  const historicalItems = isAdditionalOrderMode && Array.isArray(lastOrderInfo == null ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce((acc, p) => {
1810
1809
  if (typeof (p == null ? void 0 : p.product_id) !== "number")
1811
1810
  return acc;
@@ -1817,7 +1816,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1817
1816
  return acc;
1818
1817
  }, []) : [];
1819
1818
  await this.setItemRuleRuntimeConfig({
1820
- serviceType: (_q = this.otherParams) == null ? void 0 : _q.businessCode,
1819
+ serviceType: (_l = this.otherParams) == null ? void 0 : _l.businessCode,
1821
1820
  submissionIndex: isAdditionalOrderMode ? 1 : 0,
1822
1821
  historicalItems
1823
1822
  });
@@ -1847,6 +1846,21 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1847
1846
  throw error;
1848
1847
  }
1849
1848
  }
1849
+ // 恢复之前订单的数据,读取 entrypax
1850
+ async restorePreviousOrderData() {
1851
+ var _a, _b, _c, _d, _e;
1852
+ const tempOrder = this.ensureTempOrder();
1853
+ if (tempOrder.order_id) {
1854
+ const res = await ((_a = this.store.order) == null ? void 0 : _a.getOrderInfoByRemote(tempOrder.order_id));
1855
+ const entryPaxNumber = (_e = (_d = (_c = (_b = res == null ? void 0 : res.data) == null ? void 0 : _b.bookings) == null ? void 0 : _c.find((p) => {
1856
+ var _a2;
1857
+ return (_a2 = p.metadata) == null ? void 0 : _a2.collect_pax;
1858
+ })) == null ? void 0 : _d.metadata) == null ? void 0 : _e.collect_pax;
1859
+ if (entryPaxNumber) {
1860
+ await this.setEntryPaxNumber(entryPaxNumber);
1861
+ }
1862
+ }
1863
+ }
1850
1864
  // 如果是加单的情况,提供返回当前订单相关信息的能力
1851
1865
  async getAdditionalOrderInfo() {
1852
1866
  this.logMethodStart("getAdditionalOrderInfo");
@@ -134,6 +134,11 @@ export declare function normalizeOrderProduct(product: Partial<ScanOrderOrderPro
134
134
  * 从 reservation.enabled_reservation_rules 中收集 type=link 的商品 id。
135
135
  */
136
136
  export declare function collectLinkProductIdsFromReservationRules(rules: unknown): number[];
137
+ /**
138
+ * 找到第一个归属指定桌台的预约规则商品。
139
+ * 归属判断基于商品资源中的 default_resource / optional_resource。
140
+ */
141
+ export declare function findReservationRuleProductByResourceId(products: ProductData[], resourceId: string | number | null | undefined): ProductData | undefined;
137
142
  /**
138
143
  * 返回列表中第一个带有效 duration.value(分钟)的商品时长。
139
144
  */
@@ -39,6 +39,7 @@ __export(utils_exports, {
39
39
  computeResourceIsFull: () => computeResourceIsFull,
40
40
  createEmptySummary: () => createEmptySummary,
41
41
  extractStrategyModelIdsFromTableConfig: () => extractStrategyModelIdsFromTableConfig,
42
+ findReservationRuleProductByResourceId: () => findReservationRuleProductByResourceId,
42
43
  getProductIdentityIndex: () => getProductIdentityIndex,
43
44
  getSafeProductNum: () => getSafeProductNum,
44
45
  getTopLevelProductId: () => getTopLevelProductId,
@@ -510,6 +511,27 @@ function collectLinkProductIdsFromReservationRules(rules) {
510
511
  }
511
512
  return [...new Set(ids)];
512
513
  }
514
+ function findReservationRuleProductByResourceId(products, resourceId) {
515
+ var _a;
516
+ const numericResourceId = Number(resourceId);
517
+ if (!Number.isFinite(numericResourceId) || numericResourceId <= 0)
518
+ return void 0;
519
+ for (const product of products) {
520
+ const resources = (_a = product == null ? void 0 : product.product_resource) == null ? void 0 : _a.resources;
521
+ if (!Array.isArray(resources))
522
+ continue;
523
+ const hasMatchedResource = resources.some((resource) => {
524
+ const defaultResources = Array.isArray(resource == null ? void 0 : resource.default_resource) ? resource.default_resource : [];
525
+ const optionalResources = Array.isArray(resource == null ? void 0 : resource.optional_resource) ? resource.optional_resource : [];
526
+ return [...defaultResources, ...optionalResources].some(
527
+ (id) => Number(id) === numericResourceId
528
+ );
529
+ });
530
+ if (hasMatchedResource)
531
+ return product;
532
+ }
533
+ return void 0;
534
+ }
513
535
  function pickFirstDurationMinutesFromProducts(products) {
514
536
  var _a;
515
537
  for (const product of products) {
@@ -613,6 +635,7 @@ function pickFirstCustomCapacityDimensionId(products) {
613
635
  computeResourceIsFull,
614
636
  createEmptySummary,
615
637
  extractStrategyModelIdsFromTableConfig,
638
+ findReservationRuleProductByResourceId,
616
639
  getProductIdentityIndex,
617
640
  getSafeProductNum,
618
641
  getTopLevelProductId,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.555",
4
+ "version": "0.0.557",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",