@pisell/pisellos 0.0.554 → 0.0.555

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.
@@ -0,0 +1,9 @@
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 } from "./examples";
@@ -2621,7 +2621,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2621
2621
  }()
2622
2622
  }, {
2623
2623
  key: "resolveAdditionalOrderFromOccupyDetail",
2624
- value: function resolveAdditionalOrderFromOccupyDetail(detail, resourceSelectType) {
2624
+ value: function resolveAdditionalOrderFromOccupyDetail(detail, resourceSelectType, allowAddItems) {
2625
2625
  var currentOrderId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.order_id);
2626
2626
  if (currentOrderId) {
2627
2627
  return {
@@ -2629,15 +2629,27 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2629
2629
  order_id: currentOrderId
2630
2630
  };
2631
2631
  }
2632
+ var orderListIds = (Array.isArray(detail === null || detail === void 0 ? void 0 : detail.order_list) ? (detail === null || detail === void 0 ? void 0 : detail.order_list) || [] : []).map(function (order) {
2633
+ return toPositiveString(order === null || order === void 0 ? void 0 : order.id);
2634
+ }).filter(Boolean);
2632
2635
  if (resourceSelectType !== 'single') {
2633
2636
  return {
2634
2637
  matched: false,
2635
2638
  reason: 'no_order'
2636
2639
  };
2637
2640
  }
2638
- var orderListIds = (Array.isArray(detail === null || detail === void 0 ? void 0 : detail.order_list) ? (detail === null || detail === void 0 ? void 0 : detail.order_list) || [] : []).map(function (order) {
2639
- return toPositiveString(order === null || order === void 0 ? void 0 : order.id);
2640
- }).filter(Boolean);
2641
+ if (!orderListIds.length) {
2642
+ return {
2643
+ matched: false,
2644
+ reason: 'no_order'
2645
+ };
2646
+ }
2647
+ if (!allowAddItems) {
2648
+ return {
2649
+ matched: false,
2650
+ reason: 'add_items_disabled'
2651
+ };
2652
+ }
2641
2653
  if (orderListIds.length === 1) {
2642
2654
  return {
2643
2655
  matched: true,
@@ -2708,6 +2720,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2708
2720
  occupyDetails,
2709
2721
  occupyDetail,
2710
2722
  resourceSelectType,
2723
+ allowAddItems,
2711
2724
  additionalOrderResult,
2712
2725
  _occupyDetail$order_l,
2713
2726
  multipleOrdersState,
@@ -2882,9 +2895,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2882
2895
  occupyDetail = (_occupyDetails$ = occupyDetails[0]) !== null && _occupyDetails$ !== void 0 ? _occupyDetails$ : null; // Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
2883
2896
  // 计算当前桌台的 resourceSelectType(single/multiple/capacity)
2884
2897
  resourceSelectType = this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id));
2885
- additionalOrderResult = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType);
2898
+ allowAddItems = toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.allow_add_items']);
2899
+ additionalOrderResult = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
2886
2900
  if (!(additionalOrderResult.reason === 'multiple_orders')) {
2887
- _context37.next = 60;
2901
+ _context37.next = 61;
2888
2902
  break;
2889
2903
  }
2890
2904
  multipleOrdersState = _objectSpread(_objectSpread({}, this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId)), {}, {
@@ -2905,13 +2919,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2905
2919
  resourceSelectType: resourceSelectType
2906
2920
  });
2907
2921
  return _context37.abrupt("return", _availabilityInfo);
2908
- case 60:
2922
+ case 61:
2909
2923
  // Step4: 用 occupyDetail + resourceSelectType 规整为 resourceState
2910
2924
  resourceState = this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId);
2911
2925
  additionalOrderId = additionalOrderResult.order_id;
2912
2926
  if (additionalOrderId) {
2913
2927
  resourceState.mode = 'additional_order';
2914
2928
  resourceState.order_id = additionalOrderId;
2929
+ } else if (additionalOrderResult.reason === 'add_items_disabled') {
2930
+ resourceState.mode = 'resource_busy';
2931
+ resourceState.order_id = '0';
2932
+ } else if (resourceSelectType === 'multiple' && resourceState.isFull) {
2933
+ resourceState.mode = 'resource_busy';
2934
+ resourceState.order_id = '0';
2915
2935
  }
2916
2936
  this.store.resource = resourceState;
2917
2937
 
@@ -2948,23 +2968,23 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2948
2968
 
2949
2969
  // 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
2950
2970
  if (!(availabilityInfo.mode === 'idle')) {
2951
- _context37.next = 75;
2971
+ _context37.next = 76;
2952
2972
  break;
2953
2973
  }
2954
- _context37.next = 75;
2974
+ _context37.next = 76;
2955
2975
  return this.addNewOrder();
2956
- case 75:
2976
+ case 76:
2957
2977
  isAdditionalOrderMode = availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code'; // 如果是加单模式,tempOrder 里需要记录目标订单 id,提交的时候走加单接口
2958
2978
  if (isAdditionalOrderMode) {
2959
2979
  tempOrder.order_id = additionalOrderId;
2960
2980
  }
2961
2981
  if (!tempOrder.order_id) {
2962
- _context37.next = 85;
2982
+ _context37.next = 86;
2963
2983
  break;
2964
2984
  }
2965
- _context37.next = 80;
2985
+ _context37.next = 81;
2966
2986
  return (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getOrderInfoByRemote(tempOrder.order_id);
2967
- case 80:
2987
+ case 81:
2968
2988
  res = _context37.sent;
2969
2989
  // 找到下单的时候输入的 entryPaxNumber
2970
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) {
@@ -2972,12 +2992,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2972
2992
  return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
2973
2993
  })) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
2974
2994
  if (!entryPaxNumber) {
2975
- _context37.next = 85;
2995
+ _context37.next = 86;
2976
2996
  break;
2977
2997
  }
2978
- _context37.next = 85;
2998
+ _context37.next = 86;
2979
2999
  return this.setEntryPaxNumber(entryPaxNumber);
2980
- case 85:
3000
+ case 86:
2981
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);
2982
3002
  historicalItems = isAdditionalOrderMode && Array.isArray(lastOrderInfo === null || lastOrderInfo === void 0 ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce(function (acc, p) {
2983
3003
  if (typeof (p === null || p === void 0 ? void 0 : p.product_id) !== 'number') return acc;
@@ -2989,13 +3009,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2989
3009
  } : {}));
2990
3010
  return acc;
2991
3011
  }, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
2992
- _context37.next = 89;
3012
+ _context37.next = 90;
2993
3013
  return this.setItemRuleRuntimeConfig({
2994
3014
  serviceType: (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.businessCode,
2995
3015
  submissionIndex: isAdditionalOrderMode ? 1 : 0,
2996
3016
  historicalItems: historicalItems
2997
3017
  });
2998
- case 89:
3018
+ case 90:
2999
3019
  // operating_hours 超出营业时段 + closed_behavior=show_menu_disabled:
3000
3020
  // 允许浏览商品但 UI 层需拦截“下一步”,这里覆盖最终 mode 并回传错误提示
3001
3021
  if (outsideOperatingHours && closedBehaviorValue === 'show_menu_disabled') {
@@ -3017,18 +3037,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3017
3037
  isFull: resourceState.isFull
3018
3038
  });
3019
3039
  return _context37.abrupt("return", availabilityInfo);
3020
- case 94:
3021
- _context37.prev = 94;
3040
+ case 95:
3041
+ _context37.prev = 95;
3022
3042
  _context37.t0 = _context37["catch"](3);
3023
3043
  this.logMethodError('checkResourceAvailable', _context37.t0.message, {
3024
3044
  resourceId: normalizedResourceId
3025
3045
  });
3026
3046
  throw _context37.t0;
3027
- case 98:
3047
+ case 99:
3028
3048
  case "end":
3029
3049
  return _context37.stop();
3030
3050
  }
3031
- }, _callee37, this, [[3, 94]]);
3051
+ }, _callee37, this, [[3, 95]]);
3032
3052
  }));
3033
3053
  function checkResourceAvailable(_x19) {
3034
3054
  return _checkResourceAvailable.apply(this, arguments);
@@ -3294,8 +3314,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3294
3314
  key: "syncAdditionalOrderFromResource",
3295
3315
  value: function () {
3296
3316
  var _syncAdditionalOrderFromResource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(resourceId) {
3297
- var _ref10, _ref11, _ref12, _this$store$resource2, _this$store$resource3, _occupyDetails$2, _this$store$resource4, _this$store$order9;
3298
- var tempOrder, normalizedResourceId, _result, occupyDetails, occupyDetail, resourceSelectType, result;
3317
+ var _ref10, _ref11, _ref12, _this$store$resource2, _this$store$resource3, _occupyDetails$2, _this$store$resource4, _this$otherParams17, _this$store$order9;
3318
+ var tempOrder, normalizedResourceId, _result, occupyDetails, occupyDetail, resourceSelectType, allowAddItems, result;
3299
3319
  return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3300
3320
  while (1) switch (_context42.prev = _context42.next) {
3301
3321
  case 0:
@@ -3321,17 +3341,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3321
3341
  occupyDetails = _context42.sent;
3322
3342
  occupyDetail = (_occupyDetails$2 = occupyDetails[0]) !== null && _occupyDetails$2 !== void 0 ? _occupyDetails$2 : null;
3323
3343
  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));
3324
- result = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType);
3344
+ 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
+ result = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
3325
3346
  if (!(!result.matched || !result.order_id)) {
3326
- _context42.next = 16;
3347
+ _context42.next = 17;
3327
3348
  break;
3328
3349
  }
3329
3350
  this.logMethodSuccess('syncAdditionalOrderFromResource', _objectSpread(_objectSpread({}, result), {}, {
3330
3351
  resourceId: normalizedResourceId,
3331
- resourceSelectType: resourceSelectType
3352
+ resourceSelectType: resourceSelectType,
3353
+ allowAddItems: allowAddItems
3332
3354
  }));
3333
3355
  return _context42.abrupt("return", result);
3334
- case 16:
3356
+ case 17:
3335
3357
  tempOrder.order_id = result.order_id;
3336
3358
  tempOrder.resource_id = normalizedResourceId;
3337
3359
  tempOrder.relation_id = toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_record_id) || normalizedResourceId || tempOrder.relation_id;
@@ -3339,10 +3361,11 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3339
3361
  (_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 || _this$store$order9.persistTempOrder();
3340
3362
  this.logMethodSuccess('syncAdditionalOrderFromResource', _objectSpread(_objectSpread({}, result), {}, {
3341
3363
  resourceId: normalizedResourceId,
3342
- resourceSelectType: resourceSelectType
3364
+ resourceSelectType: resourceSelectType,
3365
+ allowAddItems: allowAddItems
3343
3366
  }));
3344
3367
  return _context42.abrupt("return", result);
3345
- case 23:
3368
+ case 24:
3346
3369
  case "end":
3347
3370
  return _context42.stop();
3348
3371
  }
@@ -3376,9 +3399,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3376
3399
  }, {
3377
3400
  key: "checkAllowAddItems",
3378
3401
  value: function checkAllowAddItems() {
3379
- var _this$otherParams17;
3402
+ var _this$otherParams18;
3380
3403
  this.logMethodStart('checkAllowAddItems');
3381
- var dineInConfig = ((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.dineInConfig) || {};
3404
+ var dineInConfig = ((_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.dineInConfig) || {};
3382
3405
  var result = {
3383
3406
  enabled: toBoolean(dineInConfig['sale.allow_add_items'])
3384
3407
  };
@@ -3391,9 +3414,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3391
3414
  }, {
3392
3415
  key: "getFulfillmentModes",
3393
3416
  value: function getFulfillmentModes() {
3394
- var _this$otherParams18;
3417
+ var _this$otherParams19;
3395
3418
  this.logMethodStart('getFulfillmentModes');
3396
- var dineInConfig = ((_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.dineInConfig) || {};
3419
+ var dineInConfig = ((_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.dineInConfig) || {};
3397
3420
  var result = {
3398
3421
  enablePickup: Boolean(dineInConfig['fulfillment.enable_pickup']),
3399
3422
  enableTableService: Boolean(dineInConfig['fulfillment.enable_table_service'])
@@ -3407,9 +3430,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3407
3430
  }, {
3408
3431
  key: "checkManualPickupRef",
3409
3432
  value: function checkManualPickupRef() {
3410
- var _this$otherParams19;
3433
+ var _this$otherParams20;
3411
3434
  this.logMethodStart('checkManualPickupRef');
3412
- var dineInConfig = ((_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.dineInConfig) || {};
3435
+ var dineInConfig = ((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.dineInConfig) || {};
3413
3436
  var refMode = dineInConfig['fulfillment.fulfillment_ref_mode'];
3414
3437
  var manualInputType = dineInConfig['fulfillment.manual_input_type'];
3415
3438
  var enabled = refMode === 'manual_input';
@@ -255,7 +255,7 @@ export interface ScanOrderReservationResourceSelectInfo {
255
255
  export interface ScanOrderAllowAddItemsInfo {
256
256
  enabled: boolean;
257
257
  }
258
- export type ScanOrderSyncAdditionalOrderReason = 'missing_resource_id' | 'no_order' | 'multiple_orders' | 'invalid_order_id';
258
+ export type ScanOrderSyncAdditionalOrderReason = 'missing_resource_id' | 'no_order' | 'multiple_orders' | 'add_items_disabled' | 'invalid_order_id';
259
259
  export interface ScanOrderSyncAdditionalOrderResult {
260
260
  matched: boolean;
261
261
  order_id?: string;
@@ -0,0 +1,49 @@
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
+ });
@@ -1549,7 +1549,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1549
1549
  }
1550
1550
  return ((_c = response == null ? void 0 : response.data) == null ? void 0 : _c.occupy_details) ?? [];
1551
1551
  }
1552
- resolveAdditionalOrderFromOccupyDetail(detail, resourceSelectType) {
1552
+ resolveAdditionalOrderFromOccupyDetail(detail, resourceSelectType, allowAddItems) {
1553
1553
  const currentOrderId = (0, import_utils.toPositiveString)(detail == null ? void 0 : detail.order_id);
1554
1554
  if (currentOrderId) {
1555
1555
  return {
@@ -1557,13 +1557,25 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1557
1557
  order_id: currentOrderId
1558
1558
  };
1559
1559
  }
1560
+ const orderListIds = (Array.isArray(detail == null ? void 0 : detail.order_list) ? (detail == null ? void 0 : detail.order_list) || [] : []).map((order) => (0, import_utils.toPositiveString)(order == null ? void 0 : order.id)).filter(Boolean);
1560
1561
  if (resourceSelectType !== "single") {
1561
1562
  return {
1562
1563
  matched: false,
1563
1564
  reason: "no_order"
1564
1565
  };
1565
1566
  }
1566
- const orderListIds = (Array.isArray(detail == null ? void 0 : detail.order_list) ? (detail == null ? void 0 : detail.order_list) || [] : []).map((order) => (0, import_utils.toPositiveString)(order == null ? void 0 : order.id)).filter(Boolean);
1567
+ if (!orderListIds.length) {
1568
+ return {
1569
+ matched: false,
1570
+ reason: "no_order"
1571
+ };
1572
+ }
1573
+ if (!allowAddItems) {
1574
+ return {
1575
+ matched: false,
1576
+ reason: "add_items_disabled"
1577
+ };
1578
+ }
1567
1579
  if (orderListIds.length === 1) {
1568
1580
  return {
1569
1581
  matched: true,
@@ -1706,9 +1718,11 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1706
1718
  const resourceSelectType = this.resolveResourceSelectType(
1707
1719
  (0, import_utils.toPositiveString)(occupyDetail == null ? void 0 : occupyDetail.form_id)
1708
1720
  );
1721
+ const allowAddItems = (0, import_utils.toBoolean)(dineInConfig == null ? void 0 : dineInConfig["sale.allow_add_items"]);
1709
1722
  const additionalOrderResult = this.resolveAdditionalOrderFromOccupyDetail(
1710
1723
  occupyDetail,
1711
- resourceSelectType
1724
+ resourceSelectType,
1725
+ allowAddItems
1712
1726
  );
1713
1727
  if (additionalOrderResult.reason === "multiple_orders") {
1714
1728
  const multipleOrdersState = {
@@ -1740,6 +1754,12 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1740
1754
  if (additionalOrderId) {
1741
1755
  resourceState.mode = "additional_order";
1742
1756
  resourceState.order_id = additionalOrderId;
1757
+ } else if (additionalOrderResult.reason === "add_items_disabled") {
1758
+ resourceState.mode = "resource_busy";
1759
+ resourceState.order_id = "0";
1760
+ } else if (resourceSelectType === "multiple" && resourceState.isFull) {
1761
+ resourceState.mode = "resource_busy";
1762
+ resourceState.order_id = "0";
1743
1763
  }
1744
1764
  this.store.resource = resourceState;
1745
1765
  if (pendingRequestEntryPax !== void 0) {
@@ -1972,7 +1992,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1972
1992
  return this.store.entryPaxNumber;
1973
1993
  }
1974
1994
  async syncAdditionalOrderFromResource(resourceId) {
1975
- var _a, _b, _c, _d;
1995
+ var _a, _b, _c, _d, _e, _f;
1976
1996
  const tempOrder = this.ensureTempOrder();
1977
1997
  const normalizedResourceId = String(
1978
1998
  resourceId ?? tempOrder.resource_id ?? ((_a = this.store.resource) == null ? void 0 : _a.relationId) ?? ((_b = this.store.resource) == null ? void 0 : _b.relation_id) ?? ""
@@ -1991,15 +2011,20 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1991
2011
  const occupyDetails = await this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
1992
2012
  const occupyDetail = occupyDetails[0] ?? null;
1993
2013
  const resourceSelectType = ((_c = this.store.resource) == null ? void 0 : _c.resourceSelectType) || this.resolveResourceSelectType((0, import_utils.toPositiveString)(occupyDetail == null ? void 0 : occupyDetail.form_id));
2014
+ const allowAddItems = (0, import_utils.toBoolean)(
2015
+ (_e = (_d = this.otherParams) == null ? void 0 : _d.dineInConfig) == null ? void 0 : _e["sale.allow_add_items"]
2016
+ );
1994
2017
  const result = this.resolveAdditionalOrderFromOccupyDetail(
1995
2018
  occupyDetail,
1996
- resourceSelectType
2019
+ resourceSelectType,
2020
+ allowAddItems
1997
2021
  );
1998
2022
  if (!result.matched || !result.order_id) {
1999
2023
  this.logMethodSuccess("syncAdditionalOrderFromResource", {
2000
2024
  ...result,
2001
2025
  resourceId: normalizedResourceId,
2002
- resourceSelectType
2026
+ resourceSelectType,
2027
+ allowAddItems
2003
2028
  });
2004
2029
  return result;
2005
2030
  }
@@ -2007,11 +2032,12 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
2007
2032
  tempOrder.resource_id = normalizedResourceId;
2008
2033
  tempOrder.relation_id = (0, import_utils.toPositiveString)(occupyDetail == null ? void 0 : occupyDetail.form_record_id) || normalizedResourceId || tempOrder.relation_id;
2009
2034
  tempOrder.table_form_id = (0, import_utils.toPositiveString)(occupyDetail == null ? void 0 : occupyDetail.form_id) || tempOrder.table_form_id;
2010
- (_d = this.store.order) == null ? void 0 : _d.persistTempOrder();
2035
+ (_f = this.store.order) == null ? void 0 : _f.persistTempOrder();
2011
2036
  this.logMethodSuccess("syncAdditionalOrderFromResource", {
2012
2037
  ...result,
2013
2038
  resourceId: normalizedResourceId,
2014
- resourceSelectType
2039
+ resourceSelectType,
2040
+ allowAddItems
2015
2041
  });
2016
2042
  return result;
2017
2043
  }
@@ -255,7 +255,7 @@ export interface ScanOrderReservationResourceSelectInfo {
255
255
  export interface ScanOrderAllowAddItemsInfo {
256
256
  enabled: boolean;
257
257
  }
258
- export type ScanOrderSyncAdditionalOrderReason = 'missing_resource_id' | 'no_order' | 'multiple_orders' | 'invalid_order_id';
258
+ export type ScanOrderSyncAdditionalOrderReason = 'missing_resource_id' | 'no_order' | 'multiple_orders' | 'add_items_disabled' | 'invalid_order_id';
259
259
  export interface ScanOrderSyncAdditionalOrderResult {
260
260
  matched: boolean;
261
261
  order_id?: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.554",
4
+ "version": "0.0.555",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",