@pisell/pisellos 0.0.551 → 0.0.553

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.
Files changed (32) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/Holder/index.d.ts +7 -1
  3. package/dist/modules/Holder/index.js +153 -14
  4. package/dist/modules/Holder/types.d.ts +9 -1
  5. package/dist/modules/Holder/utils.d.ts +7 -3
  6. package/dist/modules/Holder/utils.js +16 -2
  7. package/dist/modules/Order/index.js +5 -1
  8. package/dist/modules/Order/utils.d.ts +2 -1
  9. package/dist/modules/Order/utils.js +21 -17
  10. package/dist/solution/BookingByStep/index.d.ts +8 -2
  11. package/dist/solution/BookingByStep/index.js +251 -212
  12. package/dist/solution/ScanOrder/index.d.ts +1 -1
  13. package/dist/solution/ScanOrder/index.js +72 -29
  14. package/dist/solution/ScanOrder/types.d.ts +6 -1
  15. package/dist/solution/VenueBooking/index.d.ts +5 -2
  16. package/dist/solution/VenueBooking/index.js +684 -656
  17. package/lib/modules/Holder/index.d.ts +7 -1
  18. package/lib/modules/Holder/index.js +75 -3
  19. package/lib/modules/Holder/types.d.ts +9 -1
  20. package/lib/modules/Holder/utils.d.ts +7 -3
  21. package/lib/modules/Holder/utils.js +18 -4
  22. package/lib/modules/Order/index.js +4 -1
  23. package/lib/modules/Order/utils.d.ts +2 -1
  24. package/lib/modules/Order/utils.js +11 -7
  25. package/lib/solution/BookingByStep/index.d.ts +8 -2
  26. package/lib/solution/BookingByStep/index.js +22 -10
  27. package/lib/solution/ScanOrder/index.d.ts +1 -1
  28. package/lib/solution/ScanOrder/index.js +40 -8
  29. package/lib/solution/ScanOrder/types.d.ts +6 -1
  30. package/lib/solution/VenueBooking/index.d.ts +5 -2
  31. package/lib/solution/VenueBooking/index.js +37 -16
  32. package/package.json +1 -1
@@ -118,7 +118,7 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
118
118
  setItemRuleRuntimeConfig(config?: ScanOrderItemRuleRuntimeConfig): Promise<void>;
119
119
  private normalizeResourceState;
120
120
  private resolveResourceSelectType;
121
- private fetchResourceOccupyDetailByResourceId;
121
+ private fetchResourceOccupyDetailsByResourceId;
122
122
  checkResourceAvailable(resourceId?: string | null, hasOrderId?: boolean): Promise<ScanOrderAvailabilityInfo>;
123
123
  getAdditionalOrderInfo(): Promise<{
124
124
  orderId: string;
@@ -2569,9 +2569,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2569
2569
  return matched === null || matched === void 0 ? void 0 : matched.type;
2570
2570
  }
2571
2571
  }, {
2572
- key: "fetchResourceOccupyDetailByResourceId",
2572
+ key: "fetchResourceOccupyDetailsByResourceId",
2573
2573
  value: function () {
2574
- var _fetchResourceOccupyDetailByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(resourceId) {
2574
+ var _fetchResourceOccupyDetailsByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(resourceId) {
2575
2575
  var _this$otherParams10, _this$otherParams10$g, _response$data$occupy, _response$data;
2576
2576
  var formRecordId, shopId, response;
2577
2577
  return _regeneratorRuntime().wrap(function _callee36$(_context36) {
@@ -2607,17 +2607,17 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2607
2607
  }
2608
2608
  throw new Error((response === null || response === void 0 ? void 0 : response.message) || '获取资源占用详情失败');
2609
2609
  case 11:
2610
- return _context36.abrupt("return", (_response$data$occupy = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 || (_response$data = _response$data.occupy_details) === null || _response$data === void 0 ? void 0 : _response$data[0]) !== null && _response$data$occupy !== void 0 ? _response$data$occupy : null);
2610
+ return _context36.abrupt("return", (_response$data$occupy = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.occupy_details) !== null && _response$data$occupy !== void 0 ? _response$data$occupy : []);
2611
2611
  case 12:
2612
2612
  case "end":
2613
2613
  return _context36.stop();
2614
2614
  }
2615
2615
  }, _callee36, this);
2616
2616
  }));
2617
- function fetchResourceOccupyDetailByResourceId(_x18) {
2618
- return _fetchResourceOccupyDetailByResourceId.apply(this, arguments);
2617
+ function fetchResourceOccupyDetailsByResourceId(_x18) {
2618
+ return _fetchResourceOccupyDetailsByResourceId.apply(this, arguments);
2619
2619
  }
2620
- return fetchResourceOccupyDetailByResourceId;
2620
+ return fetchResourceOccupyDetailsByResourceId;
2621
2621
  }() // 检测当前链接是否可用
2622
2622
  // 通过 resource_id + 店铺配置
2623
2623
  // hasOrderId 表示 url 上是否有 orderid,如果是的话,后续的流程会走加单
@@ -2633,6 +2633,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2633
2633
  _this$otherParams12,
2634
2634
  _this$otherParams13,
2635
2635
  _this$otherParams13$g,
2636
+ _occupyDetails$,
2636
2637
  _occupyDetail$form_re,
2637
2638
  _occupyDetail$form_re2,
2638
2639
  _this$otherParams14,
@@ -2666,10 +2667,17 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2666
2667
  occupancyMinutes,
2667
2668
  paxBounds,
2668
2669
  error,
2670
+ occupyDetails,
2669
2671
  occupyDetail,
2672
+ currentOrderId,
2673
+ orderListIds,
2674
+ multipleOrdersState,
2675
+ _availabilityInfo,
2670
2676
  resourceSelectType,
2671
2677
  resourceState,
2678
+ additionalOrderId,
2672
2679
  availabilityInfo,
2680
+ isAdditionalOrderMode,
2673
2681
  _this$store$order7,
2674
2682
  _res$data,
2675
2683
  res,
@@ -2828,15 +2836,50 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2828
2836
  });
2829
2837
  }
2830
2838
 
2831
- // Step2: 请求新的资源占用详情接口
2839
+ // Step2: 请求新的资源占用详情接口。occupy_details 第一维是资源,不是订单。
2832
2840
  _context37.next = 50;
2833
- return this.fetchResourceOccupyDetailByResourceId(normalizedResourceId);
2841
+ return this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
2834
2842
  case 50:
2835
- occupyDetail = _context37.sent;
2843
+ occupyDetails = _context37.sent;
2844
+ occupyDetail = (_occupyDetails$ = occupyDetails[0]) !== null && _occupyDetails$ !== void 0 ? _occupyDetails$ : null;
2845
+ currentOrderId = toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.order_id);
2846
+ orderListIds = (Array.isArray(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.order_list) ? (occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.order_list) || [] : []).map(function (order) {
2847
+ return toPositiveString(order === null || order === void 0 ? void 0 : order.id);
2848
+ }).filter(Boolean);
2849
+ if (!(!currentOrderId && orderListIds.length > 1)) {
2850
+ _context37.next = 60;
2851
+ break;
2852
+ }
2853
+ multipleOrdersState = _objectSpread(_objectSpread({}, this.normalizeResourceState(occupyDetail, undefined, hasOrderId)), {}, {
2854
+ mode: 'multiple_orders'
2855
+ });
2856
+ this.store.resource = multipleOrdersState;
2857
+ _availabilityInfo = {
2858
+ mode: 'multiple_orders',
2859
+ deskmate_valid: multipleOrdersState.deskmate_valid,
2860
+ relation_id: multipleOrdersState.relationId,
2861
+ table_form_id: multipleOrdersState.tableFormId,
2862
+ table_form_record: multipleOrdersState.table_form_record
2863
+ };
2864
+ this.logMethodSuccess('checkResourceAvailable', {
2865
+ resourceId: normalizedResourceId,
2866
+ mode: _availabilityInfo.mode,
2867
+ orderListCount: orderListIds.length
2868
+ });
2869
+ return _context37.abrupt("return", _availabilityInfo);
2870
+ case 60:
2836
2871
  // Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
2837
2872
  // 计算当前桌台的 resourceSelectType(single/multiple/capacity)
2838
2873
  resourceSelectType = this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id)); // Step4: 用 occupyDetail + resourceSelectType 规整为 resourceState
2839
2874
  resourceState = this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId);
2875
+ additionalOrderId = currentOrderId || orderListIds[0];
2876
+ if (additionalOrderId) {
2877
+ resourceState.mode = 'additional_order';
2878
+ resourceState.order_id = additionalOrderId;
2879
+ } else if (!currentOrderId && orderListIds.length === 0) {
2880
+ resourceState.mode = 'idle';
2881
+ resourceState.order_id = undefined;
2882
+ }
2840
2883
  this.store.resource = resourceState;
2841
2884
 
2842
2885
  // Step5: 把预约规则商品阶段暂存的 requestEntryPax 等注入 store.resource
@@ -2872,23 +2915,23 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2872
2915
 
2873
2916
  // 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
2874
2917
  if (!(availabilityInfo.mode === 'idle')) {
2875
- _context37.next = 65;
2918
+ _context37.next = 76;
2876
2919
  break;
2877
2920
  }
2878
- _context37.next = 65;
2921
+ _context37.next = 76;
2879
2922
  return this.addNewOrder();
2880
- case 65:
2881
- // 如果是加单模式,tempOrder 里 需要记录 lastOrderId,提交的时候走加单接口
2882
- if (availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code') {
2883
- tempOrder.order_id = resourceState.lastOrderId;
2923
+ case 76:
2924
+ isAdditionalOrderMode = availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code'; // 如果是加单模式,tempOrder 里需要记录目标订单 id,提交的时候走加单接口
2925
+ if (isAdditionalOrderMode) {
2926
+ tempOrder.order_id = additionalOrderId;
2884
2927
  }
2885
2928
  if (!tempOrder.order_id) {
2886
- _context37.next = 74;
2929
+ _context37.next = 86;
2887
2930
  break;
2888
2931
  }
2889
- _context37.next = 69;
2932
+ _context37.next = 81;
2890
2933
  return (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getOrderInfoByRemote(tempOrder.order_id);
2891
- case 69:
2934
+ case 81:
2892
2935
  res = _context37.sent;
2893
2936
  // 找到下单的时候输入的 entryPaxNumber
2894
2937
  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) {
@@ -2896,14 +2939,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2896
2939
  return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
2897
2940
  })) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
2898
2941
  if (!entryPaxNumber) {
2899
- _context37.next = 74;
2942
+ _context37.next = 86;
2900
2943
  break;
2901
2944
  }
2902
- _context37.next = 74;
2945
+ _context37.next = 86;
2903
2946
  return this.setEntryPaxNumber(entryPaxNumber);
2904
- case 74:
2947
+ case 86:
2905
2948
  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);
2906
- historicalItems = hasOrderId && Array.isArray(lastOrderInfo === null || lastOrderInfo === void 0 ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce(function (acc, p) {
2949
+ historicalItems = isAdditionalOrderMode && Array.isArray(lastOrderInfo === null || lastOrderInfo === void 0 ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce(function (acc, p) {
2907
2950
  if (typeof (p === null || p === void 0 ? void 0 : p.product_id) !== 'number') return acc;
2908
2951
  acc.push(_objectSpread({
2909
2952
  product_id: p.product_id,
@@ -2913,13 +2956,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2913
2956
  } : {}));
2914
2957
  return acc;
2915
2958
  }, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
2916
- _context37.next = 78;
2959
+ _context37.next = 90;
2917
2960
  return this.setItemRuleRuntimeConfig({
2918
2961
  serviceType: (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.businessCode,
2919
- submissionIndex: hasOrderId ? 1 : 0,
2962
+ submissionIndex: isAdditionalOrderMode ? 1 : 0,
2920
2963
  historicalItems: historicalItems
2921
2964
  });
2922
- case 78:
2965
+ case 90:
2923
2966
  // operating_hours 超出营业时段 + closed_behavior=show_menu_disabled:
2924
2967
  // 允许浏览商品但 UI 层需拦截“下一步”,这里覆盖最终 mode 并回传错误提示
2925
2968
  if (outsideOperatingHours && closedBehaviorValue === 'show_menu_disabled') {
@@ -2941,18 +2984,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2941
2984
  isFull: resourceState.isFull
2942
2985
  });
2943
2986
  return _context37.abrupt("return", availabilityInfo);
2944
- case 83:
2945
- _context37.prev = 83;
2987
+ case 95:
2988
+ _context37.prev = 95;
2946
2989
  _context37.t0 = _context37["catch"](3);
2947
2990
  this.logMethodError('checkResourceAvailable', _context37.t0.message, {
2948
2991
  resourceId: normalizedResourceId
2949
2992
  });
2950
2993
  throw _context37.t0;
2951
- case 87:
2994
+ case 99:
2952
2995
  case "end":
2953
2996
  return _context37.stop();
2954
2997
  }
2955
- }, _callee37, this, [[3, 83]]);
2998
+ }, _callee37, this, [[3, 95]]);
2956
2999
  }));
2957
3000
  function checkResourceAvailable(_x19) {
2958
3001
  return _checkResourceAvailable.apply(this, arguments);
@@ -34,6 +34,7 @@ export interface ScanOrderOrderProductIdentity {
34
34
  /** 参与合并/匹配;与 remove 通配语义见 isSkuOnlyDeleteIdentity */
35
35
  product_option_item?: any[];
36
36
  product_bundle?: any[];
37
+ shop_id?: number | string;
37
38
  }
38
39
  export interface ScanOrderOrderProduct extends ScanOrderOrderProductIdentity {
39
40
  order_detail_id: number | null;
@@ -185,7 +186,7 @@ export interface ScanOrderSubmitPayload extends Omit<ScanOrderTempOrder, 'platfo
185
186
  }>;
186
187
  products: ScanOrderSubmitProduct[];
187
188
  }
188
- export type ScanOrderAvailabilityMode = 'idle' | 'shop_closed' | 'submit_disabled' | 'resource_busy' | 'additional_order_with_code' | 'additional_order';
189
+ export type ScanOrderAvailabilityMode = 'idle' | 'shop_closed' | 'submit_disabled' | 'resource_busy' | 'multiple_orders' | 'additional_order_with_code' | 'additional_order';
189
190
  export interface ScanOrderTableFormRecord {
190
191
  policy?: string | null;
191
192
  partyroom_booking?: string | null;
@@ -228,6 +229,10 @@ export interface ScanOrderResourceOccupyDetail {
228
229
  form_id?: number | string | null;
229
230
  order_id?: number | string | null;
230
231
  last_order_id?: number | string | null;
232
+ order_list?: Array<{
233
+ id?: number | string | null;
234
+ [key: string]: any;
235
+ }> | null;
231
236
  resource_capacity?: ScanOrderResourceCapacity[] | null;
232
237
  form_record?: ScanOrderTableFormRecord | null;
233
238
  [key: string]: any;
@@ -7,7 +7,7 @@ import type { OpenDataAvailabilityResult } from '../../modules/OpenData';
7
7
  import type { ProductData } from '../../modules/Product/types';
8
8
  import { type CartItemSummary, type PaxInfo, type QuantityCheckResult, type QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
9
9
  import type { StrategyConfig } from '../../model/strategy/type';
10
- import type { IAppendFormRecordParams } from '../../modules/Holder/types';
10
+ import type { IAppendFormRecordParams, IRefreshAllFormRecordsParams } from '../../modules/Holder/types';
11
11
  export * from './types';
12
12
  interface VenueBookingItemRuleRuntimeConfig {
13
13
  strategyConfigs?: StrategyConfig[];
@@ -54,7 +54,6 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
54
54
  private normalizeCustomerId;
55
55
  private resolveCustomerIdFromLoginPayload;
56
56
  private resolveHolderCustomerId;
57
- private ensureProductHolderForm;
58
57
  /**
59
58
  * 按商品 holder_config 预加载表单数据到 holderMap。
60
59
  * appointment_booking 在加购时触发;venueBooking 在商品加载后预加载,避免 getHolderFormMap 为空。
@@ -206,6 +205,10 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
206
205
  * 获取 holder 表单 map
207
206
  */
208
207
  getHolderFormMap(): import("../../modules/Holder").HolderFormMap;
208
+ /**
209
+ * UI 层触发:按当前 holderMap 批量刷新所有表单的 records
210
+ */
211
+ refreshAllHolderFormRecords(params?: Pick<IRefreshAllFormRecordsParams, 'customer_id' | 'useCache' | 'recordsUrl' | 'num' | 'skip'>): Promise<import("../../modules/Holder").HolderFormMap>;
209
212
  /**
210
213
  * 添加表单记录
211
214
  */