@pisell/pisellos 2.2.314 → 2.2.315

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 (214) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +3 -1
  3. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
  4. package/dist/model/strategy/adapter/itemRule/adapter.js +74 -7
  5. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
  6. package/dist/model/strategy/adapter/itemRule/evaluator.js +13 -0
  7. package/dist/model/strategy/adapter/itemRule/type.d.ts +40 -1
  8. package/dist/model/strategy/adapter/itemRule/type.js +10 -0
  9. package/dist/modules/BookingContext/utils/productExtend.d.ts +7 -0
  10. package/dist/modules/BookingContext/utils/productExtend.js +62 -18
  11. package/dist/modules/BookingContext/utils/resources.js +1 -1
  12. package/dist/modules/BusinessAvailability/index.d.ts +30 -0
  13. package/dist/modules/BusinessAvailability/index.js +204 -0
  14. package/dist/modules/Cart/index.js +4 -3
  15. package/dist/modules/Cart/types.d.ts +2 -0
  16. package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
  17. package/dist/modules/Cart/utils/cartProduct.js +59 -32
  18. package/dist/modules/FulfillmentTiming/index.d.ts +11 -0
  19. package/dist/modules/FulfillmentTiming/index.js +407 -0
  20. package/dist/modules/FulfillmentTiming/types.d.ts +67 -0
  21. package/dist/modules/FulfillmentTiming/types.js +1 -0
  22. package/dist/modules/OpenData/types.d.ts +14 -0
  23. package/dist/modules/Order/index.d.ts +14 -2
  24. package/dist/modules/Order/index.js +856 -486
  25. package/dist/modules/Order/localEftposState.d.ts +13 -0
  26. package/dist/modules/Order/localEftposState.js +39 -0
  27. package/dist/modules/Order/pickupTiming.d.ts +46 -0
  28. package/dist/modules/Order/pickupTiming.js +53 -0
  29. package/dist/modules/Order/types.d.ts +30 -2
  30. package/dist/modules/Order/utils.js +25 -7
  31. package/dist/modules/Payment/index.js +9 -10
  32. package/dist/modules/Product/types.d.ts +11 -0
  33. package/dist/modules/ProductList/index.js +1 -1
  34. package/dist/modules/ResourcePlanner/planner.d.ts +2 -0
  35. package/dist/modules/ResourcePlanner/planner.js +332 -23
  36. package/dist/modules/ResourcePlanner/types.d.ts +29 -0
  37. package/dist/modules/Schedule/index.d.ts +8 -0
  38. package/dist/modules/Schedule/index.js +141 -39
  39. package/dist/modules/index.d.ts +1 -0
  40. package/dist/modules/index.js +1 -0
  41. package/dist/plugins/request.d.ts +7 -0
  42. package/dist/server/index.d.ts +1 -0
  43. package/dist/server/index.js +1536 -1309
  44. package/dist/server/modules/form/index.d.ts +19 -0
  45. package/dist/server/modules/form/index.js +205 -0
  46. package/dist/server/modules/form/types.d.ts +13 -0
  47. package/dist/server/modules/form/types.js +3 -0
  48. package/dist/server/modules/index.d.ts +3 -0
  49. package/dist/server/modules/index.js +4 -0
  50. package/dist/server/modules/order/index.d.ts +15 -0
  51. package/dist/server/modules/order/index.js +920 -688
  52. package/dist/server/modules/order/types.d.ts +1 -0
  53. package/dist/server/test.json +1 -1
  54. package/dist/server/utils/small-ticket.d.ts +1 -85
  55. package/dist/server/utils/small-ticket.js +2 -2542
  56. package/dist/shared/payment/loadPaymentMethods.d.ts +9 -0
  57. package/dist/shared/payment/loadPaymentMethods.js +66 -0
  58. package/dist/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
  59. package/dist/shared/receipt/customerInvoiceLanguages.js +60 -0
  60. package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
  61. package/dist/shared/receipt/loadCustomerInvoiceLayout.js +184 -0
  62. package/dist/shared/receipt/small-ticket.d.ts +96 -0
  63. package/dist/shared/receipt/small-ticket.js +2751 -0
  64. package/dist/shared/receipt/templateVisibility.d.ts +23 -0
  65. package/dist/shared/receipt/templateVisibility.js +64 -0
  66. package/dist/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
  67. package/dist/shared/sales/loadSalesOrderSnapshot.js +21 -0
  68. package/dist/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
  69. package/dist/solution/BaseSales/fulfillmentItemRules.js +750 -0
  70. package/dist/solution/BaseSales/index.d.ts +39 -16
  71. package/dist/solution/BaseSales/index.js +1754 -1154
  72. package/dist/solution/BaseSales/pickupTiming.d.ts +47 -0
  73. package/dist/solution/BaseSales/pickupTiming.js +616 -0
  74. package/dist/solution/BaseSales/types.d.ts +11 -0
  75. package/dist/solution/BaseSales/utils/parseSalesResponse.js +3 -0
  76. package/dist/solution/BookingByStep/index.d.ts +3 -1
  77. package/dist/solution/BookingByStep/index.js +8 -3
  78. package/dist/solution/BookingTicket/index.d.ts +8 -2
  79. package/dist/solution/BookingTicket/index.js +513 -436
  80. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -1
  81. package/dist/solution/BookingTicket/utils/addProductDecision.js +1 -1
  82. package/dist/solution/BookingTicket/utils/cartView.js +3 -1
  83. package/dist/solution/OrderInvoicePreview/index.d.ts +66 -0
  84. package/dist/solution/OrderInvoicePreview/index.js +340 -0
  85. package/dist/solution/RegisterAndLogin/config.js +54 -11
  86. package/dist/solution/RegisterAndLogin/index.d.ts +2 -0
  87. package/dist/solution/RegisterAndLogin/index.js +1 -1
  88. package/dist/solution/RegisterAndLogin/utils.d.ts +12 -4
  89. package/dist/solution/RegisterAndLogin/utils.js +36 -16
  90. package/dist/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
  91. package/dist/solution/UnifiedBookingSales/businessAvailability.js +292 -0
  92. package/dist/solution/UnifiedBookingSales/index.d.ts +36 -4
  93. package/dist/solution/UnifiedBookingSales/index.js +1714 -905
  94. package/dist/solution/UnifiedBookingSales/types.d.ts +16 -2
  95. package/dist/solution/VenueBooking/index.d.ts +15 -2
  96. package/dist/solution/VenueBooking/index.js +1062 -785
  97. package/dist/solution/VenueBooking/types.d.ts +2 -1
  98. package/dist/solution/VenueBooking/types.js +1 -0
  99. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  100. package/dist/solution/VenueBooking/utils/dateSummary.js +7 -4
  101. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
  102. package/dist/solution/VenueBooking/utils/smartPricing.js +273 -0
  103. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
  104. package/dist/solution/VenueBooking/utils/timeSlot.js +6 -3
  105. package/dist/solution/index.d.ts +1 -0
  106. package/dist/solution/index.js +2 -1
  107. package/lib/index.d.ts +2 -0
  108. package/lib/index.js +21 -1
  109. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
  110. package/lib/model/strategy/adapter/itemRule/adapter.js +54 -4
  111. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
  112. package/lib/model/strategy/adapter/itemRule/evaluator.js +9 -0
  113. package/lib/model/strategy/adapter/itemRule/type.d.ts +40 -1
  114. package/lib/model/strategy/adapter/itemRule/type.js +10 -0
  115. package/lib/model/strategy/adapter/promotion/index.js +46 -1
  116. package/lib/modules/BookingContext/utils/productExtend.d.ts +7 -0
  117. package/lib/modules/BookingContext/utils/productExtend.js +45 -2
  118. package/lib/modules/BookingContext/utils/resources.js +1 -1
  119. package/lib/modules/BusinessAvailability/index.d.ts +30 -0
  120. package/lib/modules/BusinessAvailability/index.js +146 -0
  121. package/lib/modules/Cart/index.js +4 -2
  122. package/lib/modules/Cart/types.d.ts +2 -0
  123. package/lib/modules/Cart/utils/cartProduct.d.ts +3 -1
  124. package/lib/modules/Cart/utils/cartProduct.js +39 -20
  125. package/lib/modules/FulfillmentTiming/index.d.ts +11 -0
  126. package/lib/modules/FulfillmentTiming/index.js +359 -0
  127. package/lib/modules/FulfillmentTiming/types.d.ts +67 -0
  128. package/lib/modules/FulfillmentTiming/types.js +5 -0
  129. package/lib/modules/OpenData/types.d.ts +14 -0
  130. package/lib/modules/Order/index.d.ts +14 -2
  131. package/lib/modules/Order/index.js +240 -38
  132. package/lib/modules/Order/localEftposState.d.ts +13 -0
  133. package/lib/modules/Order/localEftposState.js +44 -0
  134. package/lib/modules/Order/pickupTiming.d.ts +46 -0
  135. package/lib/modules/Order/pickupTiming.js +61 -0
  136. package/lib/modules/Order/types.d.ts +30 -2
  137. package/lib/modules/Order/utils.js +21 -5
  138. package/lib/modules/Payment/index.js +3 -4
  139. package/lib/modules/Product/types.d.ts +11 -0
  140. package/lib/modules/ProductList/index.js +1 -1
  141. package/lib/modules/ResourcePlanner/planner.d.ts +2 -0
  142. package/lib/modules/ResourcePlanner/planner.js +252 -8
  143. package/lib/modules/ResourcePlanner/types.d.ts +29 -0
  144. package/lib/modules/Schedule/index.d.ts +8 -0
  145. package/lib/modules/Schedule/index.js +68 -12
  146. package/lib/modules/index.d.ts +1 -0
  147. package/lib/modules/index.js +11 -0
  148. package/lib/plugins/request.d.ts +7 -0
  149. package/lib/server/index.d.ts +1 -0
  150. package/lib/server/index.js +158 -37
  151. package/lib/server/modules/form/index.d.ts +19 -0
  152. package/lib/server/modules/form/index.js +73 -0
  153. package/lib/server/modules/form/types.d.ts +13 -0
  154. package/lib/server/modules/form/types.js +9 -0
  155. package/lib/server/modules/index.d.ts +3 -0
  156. package/lib/server/modules/index.js +15 -1
  157. package/lib/server/modules/order/index.d.ts +15 -0
  158. package/lib/server/modules/order/index.js +114 -3
  159. package/lib/server/modules/order/types.d.ts +1 -0
  160. package/lib/server/test.json +1 -1
  161. package/lib/server/utils/small-ticket.d.ts +1 -85
  162. package/lib/server/utils/small-ticket.js +9 -2305
  163. package/lib/shared/payment/loadPaymentMethods.d.ts +9 -0
  164. package/lib/shared/payment/loadPaymentMethods.js +40 -0
  165. package/lib/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
  166. package/lib/shared/receipt/customerInvoiceLanguages.js +58 -0
  167. package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
  168. package/lib/shared/receipt/loadCustomerInvoiceLayout.js +124 -0
  169. package/lib/shared/receipt/small-ticket.d.ts +96 -0
  170. package/lib/shared/receipt/small-ticket.js +2546 -0
  171. package/lib/shared/receipt/templateVisibility.d.ts +23 -0
  172. package/lib/shared/receipt/templateVisibility.js +63 -0
  173. package/lib/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
  174. package/lib/shared/sales/loadSalesOrderSnapshot.js +22 -0
  175. package/lib/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
  176. package/lib/solution/BaseSales/fulfillmentItemRules.js +259 -0
  177. package/lib/solution/BaseSales/index.d.ts +39 -16
  178. package/lib/solution/BaseSales/index.js +333 -31
  179. package/lib/solution/BaseSales/pickupTiming.d.ts +47 -0
  180. package/lib/solution/BaseSales/pickupTiming.js +290 -0
  181. package/lib/solution/BaseSales/types.d.ts +11 -0
  182. package/lib/solution/BaseSales/utils/parseSalesResponse.js +3 -0
  183. package/lib/solution/BookingByStep/index.d.ts +3 -1
  184. package/lib/solution/BookingByStep/index.js +7 -3
  185. package/lib/solution/BookingTicket/index.d.ts +8 -2
  186. package/lib/solution/BookingTicket/index.js +65 -6
  187. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -1
  188. package/lib/solution/BookingTicket/utils/addProductDecision.js +1 -1
  189. package/lib/solution/BookingTicket/utils/cartView.js +3 -1
  190. package/lib/solution/OrderInvoicePreview/index.d.ts +66 -0
  191. package/lib/solution/OrderInvoicePreview/index.js +246 -0
  192. package/lib/solution/RegisterAndLogin/config.js +57 -11
  193. package/lib/solution/RegisterAndLogin/index.d.ts +2 -0
  194. package/lib/solution/RegisterAndLogin/index.js +9 -1
  195. package/lib/solution/RegisterAndLogin/utils.d.ts +12 -4
  196. package/lib/solution/RegisterAndLogin/utils.js +24 -17
  197. package/lib/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
  198. package/lib/solution/UnifiedBookingSales/businessAvailability.js +138 -0
  199. package/lib/solution/UnifiedBookingSales/index.d.ts +36 -4
  200. package/lib/solution/UnifiedBookingSales/index.js +561 -74
  201. package/lib/solution/UnifiedBookingSales/types.d.ts +16 -2
  202. package/lib/solution/VenueBooking/index.d.ts +15 -2
  203. package/lib/solution/VenueBooking/index.js +243 -96
  204. package/lib/solution/VenueBooking/types.d.ts +2 -1
  205. package/lib/solution/VenueBooking/types.js +1 -0
  206. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  207. package/lib/solution/VenueBooking/utils/dateSummary.js +7 -4
  208. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
  209. package/lib/solution/VenueBooking/utils/smartPricing.js +224 -0
  210. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
  211. package/lib/solution/VenueBooking/utils/timeSlot.js +5 -2
  212. package/lib/solution/index.d.ts +1 -0
  213. package/lib/solution/index.js +11 -0
  214. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -10,3 +10,5 @@ export * from './model';
10
10
  export { PisellOSCore } from './core';
11
11
  import PisellOSCore from './core';
12
12
  export default PisellOSCore;
13
+ export * from './shared/receipt/small-ticket';
14
+ export { loadSalesOrderSnapshot } from './shared/sales/loadSalesOrderSnapshot';
package/dist/index.js CHANGED
@@ -15,4 +15,6 @@ export { PisellOSCore } from "./core";
15
15
 
16
16
  // 导出框架主类
17
17
  import PisellOSCore from "./core";
18
- export default PisellOSCore;
18
+ export default PisellOSCore;
19
+ export * from "./shared/receipt/small-ticket";
20
+ export { loadSalesOrderSnapshot } from "./shared/sales/loadSalesOrderSnapshot";
@@ -1,6 +1,6 @@
1
1
  import type { EvaluationResult, RuntimeContext, ActionEffect } from '../../type';
2
2
  import type { BusinessAdapter } from '../type';
3
- import { type ItemRuleBusinessData, type QuantityCheckResult, type PrefillItemResult, type QuantityLimitResult, type AllergyRequirement } from './type';
3
+ import { type ItemRuleBusinessData, type ItemRuleCartAction, type QuantityCheckResult, type PrefillItemResult, type QuantityLimitResult, type AllergyRequirement } from './type';
4
4
  /**
5
5
  * ItemRule 适配器
6
6
  *
@@ -14,6 +14,7 @@ export declare class ItemRuleAdapter implements BusinessAdapter {
14
14
  transformResult(result: EvaluationResult, businessData?: ItemRuleBusinessData): {
15
15
  quantityChecks: QuantityCheckResult[];
16
16
  prefillItems: PrefillItemResult[];
17
+ cartActions: ItemRuleCartAction[];
17
18
  allergyRequirements: AllergyRequirement[];
18
19
  };
19
20
  private processAllergyCheck;
@@ -66,5 +67,6 @@ export declare class ItemRuleAdapter implements BusinessAdapter {
66
67
  * 根据 quantityFrom 计算预填数量
67
68
  */
68
69
  private resolvePrefillQuantity;
70
+ private processDeleteProduct;
69
71
  }
70
72
  export default ItemRuleAdapter;
@@ -73,11 +73,13 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
73
73
  value: function transformResult(result, businessData) {
74
74
  var quantityChecks = [];
75
75
  var prefillItems = [];
76
+ var cartActions = [];
76
77
  var allergyRequirements = [];
77
78
  if (!result.applicable || !businessData) {
78
79
  return {
79
80
  quantityChecks: quantityChecks,
80
81
  prefillItems: prefillItems,
82
+ cartActions: cartActions,
81
83
  allergyRequirements: allergyRequirements
82
84
  };
83
85
  }
@@ -93,7 +95,31 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
93
95
  }
94
96
  } else if (action.type === ITEM_RULE_ACTION_TYPES.PREFILL_CART) {
95
97
  var items = this.processPrefillCart(action, businessData);
96
- prefillItems.push.apply(prefillItems, _toConsumableArray(items));
98
+ prefillItems.push.apply(prefillItems, _toConsumableArray(items.filter(function (item) {
99
+ return item.quantity > 0;
100
+ })));
101
+ if (items.length) {
102
+ var _action$priority;
103
+ cartActions.push({
104
+ type: ITEM_RULE_ACTION_TYPES.PREFILL_CART,
105
+ strategyId: result.config.metadata.id,
106
+ ruleId: action.id,
107
+ priority: (_action$priority = action.priority) !== null && _action$priority !== void 0 ? _action$priority : 0,
108
+ products: items
109
+ });
110
+ }
111
+ } else if (action.type === ITEM_RULE_ACTION_TYPES.DELETE_PRODUCT) {
112
+ var products = this.processDeleteProduct(action, businessData);
113
+ if (products.length) {
114
+ var _action$priority2;
115
+ cartActions.push({
116
+ type: ITEM_RULE_ACTION_TYPES.DELETE_PRODUCT,
117
+ strategyId: result.config.metadata.id,
118
+ ruleId: action.id,
119
+ priority: (_action$priority2 = action.priority) !== null && _action$priority2 !== void 0 ? _action$priority2 : 0,
120
+ products: products
121
+ });
122
+ }
97
123
  } else if (action.type === ITEM_RULE_ACTION_TYPES.ALLERGY_CHECK) {
98
124
  var requirement = this.processAllergyCheck(action, result, businessData);
99
125
  if (requirement) allergyRequirements.push(requirement);
@@ -107,6 +133,7 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
107
133
  return {
108
134
  quantityChecks: quantityChecks,
109
135
  prefillItems: prefillItems,
136
+ cartActions: cartActions,
110
137
  allergyRequirements: allergyRequirements
111
138
  };
112
139
  }
@@ -117,7 +144,7 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
117
144
  }, {
118
145
  key: "processAllergyCheck",
119
146
  value: function processAllergyCheck(action, result, businessData) {
120
- var _currentProduct$produ, _productTargets$find, _target$dataSource, _action$priority, _target$product_varia;
147
+ var _currentProduct$produ, _productTargets$find, _target$dataSource, _action$priority3, _target$product_varia;
121
148
  var config = action.config;
122
149
  var currentProduct = businessData.currentProduct;
123
150
  if (!config || config.targetType !== 'product' || config.promptScope !== 'once_per_order_product' || !Array.isArray(config.targets) || !currentProduct) {
@@ -142,7 +169,7 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
142
169
  return _objectSpread(_objectSpread({
143
170
  strategyId: result.config.metadata.id,
144
171
  ruleId: action.id,
145
- priority: (_action$priority = action.priority) !== null && _action$priority !== void 0 ? _action$priority : 0,
172
+ priority: (_action$priority3 = action.priority) !== null && _action$priority3 !== void 0 ? _action$priority3 : 0,
146
173
  targetType: 'product',
147
174
  product_id: currentProductId
148
175
  }, Number((_target$product_varia = target.product_variant_id) !== null && _target$product_varia !== void 0 ? _target$product_varia : 0) > 0 ? {
@@ -536,7 +563,9 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
536
563
  key: "processPrefillCart",
537
564
  value: function processPrefillCart(action, businessData) {
538
565
  var config = action.config;
539
- if (!(config !== null && config !== void 0 && config.products)) return [];
566
+ if (!Array.isArray(config === null || config === void 0 ? void 0 : config.products)) return [];
567
+ if (config.scope !== businessData.executionScope) return [];
568
+ if (config.scope === 'set_handover' && action.target !== 'cart') return [];
540
569
  var results = [];
541
570
  var _iterator7 = _createForOfIteratorHelper(config.products),
542
571
  _step7;
@@ -544,13 +573,18 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
544
573
  for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
545
574
  var prefillProduct = _step7.value;
546
575
  var quantity = this.resolvePrefillQuantity(prefillProduct.quantityFrom, prefillProduct.quantity, businessData);
547
- if (quantity <= 0) continue;
548
- results.push({
576
+ var shouldSyncZero = config.scope === 'set_handover' && prefillProduct.repeat_skip === true;
577
+ if (!Number.isFinite(quantity) || quantity < 0 || quantity === 0 && !shouldSyncZero) {
578
+ continue;
579
+ }
580
+ results.push(_objectSpread({
549
581
  ruleId: action.id,
550
582
  product_id: prefillProduct.product_id,
551
583
  product_variant_id: prefillProduct.product_variant_id,
552
584
  quantity: quantity
553
- });
585
+ }, prefillProduct.repeat_skip !== undefined ? {
586
+ repeat_skip: prefillProduct.repeat_skip === true
587
+ } : {}));
554
588
  }
555
589
  } catch (err) {
556
590
  _iterator7.e(err);
@@ -573,10 +607,43 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
573
607
  return businessData.pax.adult;
574
608
  case 'fixed':
575
609
  return fixedValue !== null && fixedValue !== void 0 ? fixedValue : 0;
610
+ case 'main_product_number':
611
+ {
612
+ var _businessData$mainPro;
613
+ var mainProductNumber = (_businessData$mainPro = businessData.mainProductNumber) !== null && _businessData$mainPro !== void 0 ? _businessData$mainPro : 0;
614
+ return Number.isFinite(mainProductNumber) ? Math.max(0, mainProductNumber) : 0;
615
+ }
576
616
  default:
577
617
  return fixedValue !== null && fixedValue !== void 0 ? fixedValue : 0;
578
618
  }
579
619
  }
620
+ }, {
621
+ key: "processDeleteProduct",
622
+ value: function processDeleteProduct(action, businessData) {
623
+ var config = action.config;
624
+ if (action.target !== 'cart' || (config === null || config === void 0 ? void 0 : config.scope) !== 'set_handover' || config.scope !== businessData.executionScope || !Array.isArray(config.products)) {
625
+ return [];
626
+ }
627
+ var productIds = new Set();
628
+ var _iterator8 = _createForOfIteratorHelper(config.products),
629
+ _step8;
630
+ try {
631
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
632
+ var product = _step8.value;
633
+ var productId = Number(product === null || product === void 0 ? void 0 : product.product_id);
634
+ if (Number.isInteger(productId) && productId > 0) productIds.add(productId);
635
+ }
636
+ } catch (err) {
637
+ _iterator8.e(err);
638
+ } finally {
639
+ _iterator8.f();
640
+ }
641
+ return Array.from(productIds, function (product_id) {
642
+ return {
643
+ product_id: product_id
644
+ };
645
+ });
646
+ }
580
647
  }]);
581
648
  return ItemRuleAdapter;
582
649
  }();
@@ -1,5 +1,5 @@
1
1
  import type { StrategyConfig } from '../../type';
2
- import { type ItemRuleBusinessData, type ItemRuleEvaluationResult, type QuantityCheckResult, type QuantityLimitResult, type PrefillItemResult, type AllergyRequirement } from './type';
2
+ import { type ItemRuleBusinessData, type ItemRuleEvaluationResult, type QuantityCheckResult, type QuantityLimitResult, type PrefillItemResult, type ItemRuleCartAction, type AllergyRequirement } from './type';
3
3
  /**
4
4
  * ItemRule 评估器
5
5
  *
@@ -47,4 +47,6 @@ export declare class ItemRuleEvaluator {
47
47
  * 便捷方法:仅获取需要预填到购物车的商品
48
48
  */
49
49
  getPrefillItems(businessData: ItemRuleBusinessData): PrefillItemResult[];
50
+ /** 获取按优先级排序的购物车动作,交由销售业务层执行。 */
51
+ getCartActions(businessData: ItemRuleBusinessData): ItemRuleCartAction[];
50
52
  }
@@ -63,6 +63,7 @@ export var ItemRuleEvaluator = /*#__PURE__*/function () {
63
63
  }) : this.strategyConfigs;
64
64
  var allQuantityChecks = [];
65
65
  var allPrefillItems = [];
66
+ var allCartActions = [];
66
67
  var allAllergyRequirements = [];
67
68
  var rawResults = [];
68
69
  var context = this.adapter.prepareContext(businessData);
@@ -76,9 +77,11 @@ export var ItemRuleEvaluator = /*#__PURE__*/function () {
76
77
  var _this$adapter$transfo = this.adapter.transformResult(evalResult, businessData),
77
78
  quantityChecks = _this$adapter$transfo.quantityChecks,
78
79
  prefillItems = _this$adapter$transfo.prefillItems,
80
+ cartActions = _this$adapter$transfo.cartActions,
79
81
  allergyRequirements = _this$adapter$transfo.allergyRequirements;
80
82
  allQuantityChecks.push.apply(allQuantityChecks, _toConsumableArray(quantityChecks));
81
83
  allPrefillItems.push.apply(allPrefillItems, _toConsumableArray(prefillItems));
84
+ allCartActions.push.apply(allCartActions, _toConsumableArray(cartActions));
82
85
  allAllergyRequirements.push.apply(allAllergyRequirements, _toConsumableArray(allergyRequirements));
83
86
  }
84
87
  } catch (err) {
@@ -92,6 +95,9 @@ export var ItemRuleEvaluator = /*#__PURE__*/function () {
92
95
  return {
93
96
  quantityChecks: allQuantityChecks,
94
97
  prefillItems: allPrefillItems,
98
+ cartActions: allCartActions.sort(function (left, right) {
99
+ return right.priority - left.priority;
100
+ }),
95
101
  allergyRequirements: allAllergyRequirements,
96
102
  allPassed: failedChecks.length === 0,
97
103
  failedChecks: failedChecks,
@@ -188,6 +194,13 @@ export var ItemRuleEvaluator = /*#__PURE__*/function () {
188
194
  var result = this.evaluate(businessData);
189
195
  return result.prefillItems;
190
196
  }
197
+
198
+ /** 获取按优先级排序的购物车动作,交由销售业务层执行。 */
199
+ }, {
200
+ key: "getCartActions",
201
+ value: function getCartActions(businessData) {
202
+ return this.evaluate(businessData).cartActions;
203
+ }
191
204
  }]);
192
205
  return ItemRuleEvaluator;
193
206
  }();
@@ -4,6 +4,8 @@ export declare const ITEM_RULE_ACTION_TYPES: {
4
4
  readonly QUANTITY_CHECK: "QUANTITY_CHECK";
5
5
  /** 预填购物车 */
6
6
  readonly PREFILL_CART: "PREFILL_CART";
7
+ /** 按商品 ID 删除购物车商品 */
8
+ readonly DELETE_PRODUCT: "DELETE_PRODUCT";
7
9
  /** 加购前过敏信息确认 */
8
10
  readonly ALLERGY_CHECK: "ALLERGY_CHECK";
9
11
  };
@@ -101,6 +103,10 @@ export interface AllergyRequirement {
101
103
  promptScope: AllergyPromptScope;
102
104
  allowNote: boolean;
103
105
  }
106
+ /** 购物车动作触发时机,与数量校验的提交范围相互独立。 */
107
+ export type ItemRuleExecutionScope = 'set_handover';
108
+ /** 预填数量来源;主商品数量不扩展到 QUANTITY_CHECK。 */
109
+ export type PrefillQuantitySource = QuantitySource | 'main_product_number';
104
110
  /**
105
111
  * 预填商品项
106
112
  */
@@ -110,9 +116,11 @@ export interface PrefillProduct {
110
116
  /** 变体 ID(可选,0 或不填表示无变体/默认) */
111
117
  product_variant_id?: number;
112
118
  /** 数量来源 */
113
- quantityFrom: QuantitySource;
119
+ quantityFrom: PrefillQuantitySource;
114
120
  /** 固定数量(当 quantityFrom 为 'fixed' 时使用) */
115
121
  quantity?: number;
122
+ /** 设置取餐方式时同步自动附加行的数量,重复执行不累加。 */
123
+ repeat_skip?: boolean;
116
124
  }
117
125
  /**
118
126
  * Prefill Cart Action 的详细配置
@@ -120,9 +128,18 @@ export interface PrefillProduct {
120
128
  * 存储在 ActionEffect.config 中
121
129
  */
122
130
  export interface PrefillCartConfig {
131
+ /** 不填时保持原有预填时机;set_handover 仅在设置取餐方式时执行。 */
132
+ scope?: ItemRuleExecutionScope;
123
133
  /** 要预填的商品列表 */
124
134
  products: PrefillProduct[];
125
135
  }
136
+ /** 删除指定商品的全部购物车行,不区分变体或是否为自动添加。 */
137
+ export interface DeleteProductConfig {
138
+ scope: ItemRuleExecutionScope;
139
+ products: Array<{
140
+ product_id: number;
141
+ }>;
142
+ }
126
143
  /**
127
144
  * 购物车商品摘要
128
145
  */
@@ -157,6 +174,10 @@ export interface ItemRuleBusinessData {
157
174
  historicalItems?: CartItemSummary[];
158
175
  /** 服务类型(如 'dine-in', 'takeaway') */
159
176
  serviceType?: string;
177
+ /** 当前购物车动作触发时机;未填时不评估 set_handover 动作。 */
178
+ executionScope?: ItemRuleExecutionScope;
179
+ /** 由销售业务层提供的主商品总数量,不包含附加费用商品。 */
180
+ mainProductNumber?: number;
160
181
  /** 当前业务渠道(如 'kiosk', 'pos', 'online_store') */
161
182
  channel?: string;
162
183
  /** 当前正在加入购物车的商品;ALLERGY_CHECK 只读取该商品的 Target。 */
@@ -209,7 +230,23 @@ export interface PrefillItemResult {
209
230
  product_variant_id?: number;
210
231
  /** 应添加的数量 */
211
232
  quantity: number;
233
+ /** true 时执行器同步自动附加行数量;quantity=0 表示移除该自动行。 */
234
+ repeat_skip?: boolean;
212
235
  }
236
+ /** 保留不同购物车动作之间的优先级与执行顺序。 */
237
+ export type ItemRuleCartAction = {
238
+ strategyId: string;
239
+ ruleId: string;
240
+ priority: number;
241
+ } & ({
242
+ type: 'PREFILL_CART';
243
+ products: PrefillItemResult[];
244
+ } | {
245
+ type: 'DELETE_PRODUCT';
246
+ products: Array<{
247
+ product_id: number;
248
+ }>;
249
+ });
213
250
  /**
214
251
  * 单条规则的数量限制(不含校验结果,仅描述配置中的约束)
215
252
  */
@@ -258,6 +295,8 @@ export interface ItemRuleEvaluationResult {
258
295
  quantityChecks: QuantityCheckResult[];
259
296
  /** 需要预填的商品列表 */
260
297
  prefillItems: PrefillItemResult[];
298
+ /** 按 priority 降序排列的购物车动作;同优先级保持策略与动作顺序。 */
299
+ cartActions: ItemRuleCartAction[];
261
300
  /** 当前商品命中的过敏门禁要求;不同 Action/商品不会合并。 */
262
301
  allergyRequirements: AllergyRequirement[];
263
302
  /** 所有校验是否全部通过 */
@@ -7,6 +7,8 @@ export var ITEM_RULE_ACTION_TYPES = {
7
7
  QUANTITY_CHECK: 'QUANTITY_CHECK',
8
8
  /** 预填购物车 */
9
9
  PREFILL_CART: 'PREFILL_CART',
10
+ /** 按商品 ID 删除购物车商品 */
11
+ DELETE_PRODUCT: 'DELETE_PRODUCT',
10
12
  /** 加购前过敏信息确认 */
11
13
  ALLERGY_CHECK: 'ALLERGY_CHECK'
12
14
  };
@@ -72,6 +74,10 @@ export var ITEM_RULE_TEMPLATES = {
72
74
  // Prefill Cart 相关类型
73
75
  // ============================================
74
76
 
77
+ /** 购物车动作触发时机,与数量校验的提交范围相互独立。 */
78
+
79
+ /** 预填数量来源;主商品数量不扩展到 QUANTITY_CHECK。 */
80
+
75
81
  /**
76
82
  * 预填商品项
77
83
  */
@@ -82,6 +88,8 @@ export var ITEM_RULE_TEMPLATES = {
82
88
  * 存储在 ActionEffect.config 中
83
89
  */
84
90
 
91
+ /** 删除指定商品的全部购物车行,不区分变体或是否为自动添加。 */
92
+
85
93
  // ============================================
86
94
  // 业务数据类型(Evaluator 输入)
87
95
  // ============================================
@@ -110,6 +118,8 @@ export var ITEM_RULE_TEMPLATES = {
110
118
  * 单个 Prefill Cart 的预填结果
111
119
  */
112
120
 
121
+ /** 保留不同购物车动作之间的优先级与执行顺序。 */
122
+
113
123
  /**
114
124
  * 单条规则的数量限制(不含校验结果,仅描述配置中的约束)
115
125
  */
@@ -7,6 +7,13 @@ import { TimeSlicesResult, TimeSlice, DurationSlice } from './timeSlices';
7
7
  * 让 OS 这层完全可在 Node 单测下运行(dayjs 在 Node 也是纯函数)。
8
8
  */
9
9
  export interface BookingCalcContext {
10
+ /** Sales channel; remembered duration starts are accepted only by POS. */
11
+ channel?: string;
12
+ /** Start-only device preference for this decision; never reuse a cached end/resource. */
13
+ rememberedTime?: {
14
+ businessDate: string;
15
+ startAt: string;
16
+ };
10
17
  /** 来自 `/core/board/management/config` 的整套配置;常用路径见 sliceTimeSlices / appointmentTimingPreference。 */
11
18
  bookingConfig?: any;
12
19
  /** 资源 origin map(id → resource origin)。 */
@@ -1,4 +1,3 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
1
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
2
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
3
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -10,6 +9,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
10
9
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
10
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
11
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
12
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
13
13
  import dayjs from 'dayjs';
14
14
  import { formatResources, getResourceByIds, getSumCapacity, getUsableTime, setDefaultCapacitys, setDefaultResource } from "./resources";
15
15
  import { hasActualResourceSelection, productNeedsResourceExtend } from "./resourceSelection";
@@ -24,6 +24,46 @@ import { flexibleObj, getDurationValue, isProductFlexibleDuration } from "./flex
24
24
  * 让 OS 这层完全可在 Node 单测下运行(dayjs 在 Node 也是纯函数)。
25
25
  */
26
26
 
27
+ /** Rebuild only the derived booking fields; SKU, quantity, notes and Holder stay intact. */
28
+ function seedRememberedBookingStart(cacheItem, ctx) {
29
+ var _cacheItem$cartDetail, _cacheItem$_extend;
30
+ var remembered = ctx.rememberedTime;
31
+ var invalid = function invalid() {
32
+ return Object.assign(new Error('Remembered time requires a valid POS duration start.'), {
33
+ code: 'INVALID_REMEMBERED_TIME'
34
+ });
35
+ };
36
+ var duration = cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.duration;
37
+ var durationType = _typeof(duration) === 'object' && duration ? String(duration.type || '').toLowerCase() : '';
38
+ var durationValue = _typeof(duration) === 'object' && duration ? duration.value : duration;
39
+ var isDuration = isProductFlexibleDuration(duration) || ['', 'fixed', 'minute', 'minutes', 'hour', 'hours'].includes(durationType) && Number.isFinite(Number(durationValue)) && Number(durationValue) > 0;
40
+ var isCalendarDate = function isCalendarDate(value) {
41
+ if (typeof value !== 'string' || !/^\d{4}-\d{2}-\d{2}$/.test(value)) return false;
42
+ var date = new Date("".concat(value, "T00:00:00.000Z"));
43
+ return Number.isFinite(date.getTime()) && date.toISOString().slice(0, 10) === value;
44
+ };
45
+ var parts = typeof (remembered === null || remembered === void 0 ? void 0 : remembered.startAt) === 'string' ? /^(\d{4}-\d{2}-\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,3})?)?(?:Z|[+-](\d{2}):(\d{2}))?$/.exec(remembered.startAt) : null;
46
+ if (String(ctx.channel || '').trim().toLowerCase() !== 'pos' || !isDuration || isMultiDayProduct(cacheItem) || isSessionProduct(cacheItem) || cacheItem !== null && cacheItem !== void 0 && (_cacheItem$cartDetail = cacheItem.cartDetailValue) !== null && _cacheItem$cartDetail !== void 0 && _cacheItem$cartDetail.session || cacheItem !== null && cacheItem !== void 0 && (_cacheItem$_extend = cacheItem._extend) !== null && _cacheItem$_extend !== void 0 && (_cacheItem$_extend = _cacheItem$_extend.other) !== null && _cacheItem$_extend !== void 0 && _cacheItem$_extend.session || !isCalendarDate(remembered === null || remembered === void 0 ? void 0 : remembered.businessDate) || !parts || !isCalendarDate(parts[1]) || Number(parts[2]) > 23 || Number(parts[3]) > 59 || Number(parts[4] || 0) > 59 || Number(parts[5] || 0) > 23 || Number(parts[6] || 0) > 59) throw invalid();
47
+ // Parse the actual instant with the same runtime clock used by the legacy booking helpers.
48
+ // The business-day label must not replace the calendar date of an overnight start.
49
+ var start = dayjs(remembered.startAt);
50
+ if (!start.isValid()) throw invalid();
51
+ var extend = _objectSpread({}, (cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem._extend) || {});
52
+ for (var _i = 0, _arr = ['start_date', 'startDate', 'start_time', 'end_date', 'endDate', 'end_time', 'duration', 'resource', 'resources', 'capacity', 'booking', 'availabilitySelection']; _i < _arr.length; _i++) {
53
+ var key = _arr[_i];
54
+ delete extend[key];
55
+ }
56
+ return _objectSpread(_objectSpread({}, cacheItem), {}, {
57
+ new: 1,
58
+ autoClose: false,
59
+ _data: {},
60
+ _extend: _objectSpread(_objectSpread({}, extend), {}, {
61
+ start_date: start.format('YYYY-MM-DD'),
62
+ start_time: start.format(start.millisecond() ? 'HH:mm:ss.SSS' : start.second() ? 'HH:mm:ss' : 'HH:mm')
63
+ })
64
+ });
65
+ }
66
+
27
67
  /** 从 BookingContext.date 提取 HH:mm(仅当日期带有效时分时)。 */
28
68
  export function derivePresetStartTimeFromDate(date) {
29
69
  if (date == null) return undefined;
@@ -46,12 +86,12 @@ function getAppointmentTimingPreference(ctx) {
46
86
  * 灵活时长选项(cacheItem.duration.type === 'flexible' 时)。
47
87
  */
48
88
  function getFlexibleOption(params) {
49
- var _cacheItem$_extend, _cacheItem$_extend2, _usable$_extend, _params$ctx;
89
+ var _cacheItem$_extend2, _cacheItem$_extend3, _usable$_extend, _params$ctx;
50
90
  var cacheItem = params.cacheItem,
51
91
  useStartTime = params.useStartTime;
52
92
  var duration = getDurationValue(cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.duration);
53
93
  if (duration !== 'flexible') return null;
54
- var startDate = dayjs("".concat(dayjs(cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.start_date).format('YYYY-MM-DD'), " ").concat(useStartTime || (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 ? void 0 : _cacheItem$_extend2.start_time) || '00:00'));
94
+ var startDate = dayjs("".concat(dayjs(cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 ? void 0 : _cacheItem$_extend2.start_date).format('YYYY-MM-DD'), " ").concat(useStartTime || (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend3 = cacheItem._extend) === null || _cacheItem$_extend3 === void 0 ? void 0 : _cacheItem$_extend3.start_time) || '00:00'));
55
95
  var usable = getUsableTime(cacheItem);
56
96
  var usableEndAt = usable !== null && usable !== void 0 && (_usable$_extend = usable._extend) !== null && _usable$_extend !== void 0 && (_usable$_extend = _usable$_extend.usableTime) !== null && _usable$_extend !== void 0 && _usable$_extend.end_at ? dayjs(usable._extend.usableTime.end_at) : null;
57
97
  var endDate = getEndDate(startDate, 'flexible', usableEndAt, (_params$ctx = params.ctx) === null || _params$ctx === void 0 ? void 0 : _params$ctx.shopOpeningHours);
@@ -105,7 +145,7 @@ export function getTimeObj(params) {
105
145
  * - cacheItem.isCustomItem → 直接返回 `{ duration: null }`。
106
146
  */
107
147
  export function getServiceStartTimeAndEndTime(params) {
108
- var _cacheItem$_extend3;
148
+ var _cacheItem$_extend4;
109
149
  var cacheItem = params.cacheItem,
110
150
  timeObj = params.timeObj,
111
151
  ctx = params.ctx;
@@ -163,7 +203,7 @@ export function getServiceStartTimeAndEndTime(params) {
163
203
  _extend.start_date = (_extend$start_date = _extend.start_date) !== null && _extend$start_date !== void 0 ? _extend$start_date : startDate;
164
204
  _extend.end_date = (_extend$end_date = _extend.end_date) !== null && _extend$end_date !== void 0 ? _extend$end_date : endDate;
165
205
  }
166
- var session = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend3 = cacheItem._extend) === null || _cacheItem$_extend3 === void 0 || (_cacheItem$_extend3 = _cacheItem$_extend3.other) === null || _cacheItem$_extend3 === void 0 ? void 0 : _cacheItem$_extend3.session;
206
+ var session = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend4 = cacheItem._extend) === null || _cacheItem$_extend4 === void 0 || (_cacheItem$_extend4 = _cacheItem$_extend4.other) === null || _cacheItem$_extend4 === void 0 ? void 0 : _cacheItem$_extend4.session;
167
207
  if (isSessionProduct(cacheItem) && session) {
168
208
  var baseDate = ctx.date ? dayjs(ctx.date) : dayjs();
169
209
  var startAt = dayjs("".concat(baseDate.format('YYYY-MM-DD'), " ").concat(dayjs(session.start_at).format('HH:mm:ss')));
@@ -188,18 +228,22 @@ export function getServiceStartTimeAndEndTime(params) {
188
228
  * 入参 ctx 必须至少给:bookingConfig / resourcesOriginMap / resourcesOrigin / date。
189
229
  */
190
230
  export function getProductExtend(params) {
191
- var _cacheItem$_extend4;
192
- var cacheItem = params.cacheItem,
193
- ctx = params.ctx,
194
- isDisabledTime = params.isDisabledTime;
195
- var isNew = cacheItem.new || !((_cacheItem$_extend4 = cacheItem._extend) !== null && _cacheItem$_extend4 !== void 0 && _cacheItem$_extend4.endDate);
231
+ var _cacheItem$_extend5;
232
+ var isDisabledTime = params.isDisabledTime;
233
+ var hasRememberedTime = params.ctx.rememberedTime !== undefined;
234
+ var cacheItem = hasRememberedTime ? seedRememberedBookingStart(params.cacheItem, params.ctx) : params.cacheItem;
235
+ var ctx = hasRememberedTime ? _objectSpread(_objectSpread({}, params.ctx), {}, {
236
+ previousService: undefined,
237
+ presetStartTime: undefined
238
+ }) : params.ctx;
239
+ var isNew = cacheItem.new || !((_cacheItem$_extend5 = cacheItem._extend) !== null && _cacheItem$_extend5 !== void 0 && _cacheItem$_extend5.endDate);
196
240
  var _cacheItem = _objectSpread({}, cacheItem);
197
241
  var resourcesOriginMap = ctx.resourcesOriginMap || {};
198
242
  _cacheItem._data = {};
199
243
  if (isMultiDayProduct(cacheItem)) {
200
- var _cacheItem$_extend5;
244
+ var _cacheItem$_extend6;
201
245
  _cacheItem._extend = _cacheItem._extend || {};
202
- _cacheItem._extend.holder_id = (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend5 = cacheItem._extend) === null || _cacheItem$_extend5 === void 0 ? void 0 : _cacheItem$_extend5.holder_id) || [];
246
+ _cacheItem._extend.holder_id = (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend6 = cacheItem._extend) === null || _cacheItem$_extend6 === void 0 ? void 0 : _cacheItem$_extend6.holder_id) || [];
203
247
  _cacheItem._extend.sub_type = 'days';
204
248
  }
205
249
  if (isNew) {
@@ -260,14 +304,14 @@ export function getProductExtend(params) {
260
304
  _cacheItem._time = new Date().getTime();
261
305
  }
262
306
  } else {
263
- var _cacheItem$_extend7;
307
+ var _cacheItem$_extend8;
264
308
  if (!_cacheItem._data.capacitys) {
265
309
  _cacheItem._data.capacitys = cacheItem.capacity;
266
310
  }
267
311
  if (!_cacheItem._data.resourcesOrigin) {
268
- var _cacheItem$_extend6, _ctx$bookingConfig4;
312
+ var _cacheItem$_extend7, _ctx$bookingConfig4;
269
313
  var extraResources = [];
270
- if (Array.isArray((_cacheItem$_extend6 = _cacheItem._extend) === null || _cacheItem$_extend6 === void 0 ? void 0 : _cacheItem$_extend6.event_resources)) {
314
+ if (Array.isArray((_cacheItem$_extend7 = _cacheItem._extend) === null || _cacheItem$_extend7 === void 0 ? void 0 : _cacheItem$_extend7.event_resources)) {
271
315
  _cacheItem._extend.event_resources.forEach(function (er) {
272
316
  extraResources.push({
273
317
  form_id: er.form_id,
@@ -293,7 +337,7 @@ export function getProductExtend(params) {
293
337
  }
294
338
  _cacheItem._data.timeObj = getTimeObj({
295
339
  cacheItem: _cacheItem,
296
- useStartTime: (_cacheItem$_extend7 = _cacheItem._extend) === null || _cacheItem$_extend7 === void 0 ? void 0 : _cacheItem$_extend7.start_time,
340
+ useStartTime: (_cacheItem$_extend8 = _cacheItem._extend) === null || _cacheItem$_extend8 === void 0 ? void 0 : _cacheItem$_extend8.start_time,
297
341
  ctx: ctx
298
342
  });
299
343
  }
@@ -306,7 +350,7 @@ export function getProductExtend(params) {
306
350
  * `getAutoAllocationStorage` 抽象为入参 `isAutoAllocationOn(formId)`。
307
351
  */
308
352
  export function getIsAutoClose(cacheItem, isAutoAllocationOn) {
309
- var _cacheItem$_data, _cacheItem$_extend8;
353
+ var _cacheItem$_data, _cacheItem$_extend9;
310
354
  if (productNeedsResourceExtend(cacheItem) && !hasActualResourceSelection(cacheItem)) {
311
355
  return false;
312
356
  }
@@ -321,7 +365,7 @@ export function getIsAutoClose(cacheItem, isAutoAllocationOn) {
321
365
  }
322
366
  }
323
367
  }
324
- var entries = Object.entries(((_cacheItem$_extend8 = cacheItem._extend) === null || _cacheItem$_extend8 === void 0 ? void 0 : _cacheItem$_extend8.resource) || {});
368
+ var entries = Object.entries(((_cacheItem$_extend9 = cacheItem._extend) === null || _cacheItem$_extend9 === void 0 ? void 0 : _cacheItem$_extend9.resource) || {});
325
369
  if (entries.length === 0) {
326
370
  return !productNeedsResourceExtend(cacheItem);
327
371
  }
@@ -260,7 +260,7 @@ function getResourceMaxFreeTime(resource, isAutoAllocationOn) {
260
260
  return d.usable && d.id !== 0;
261
261
  });
262
262
  var defaultResource = [];
263
- var maxFreeTime = 0;
263
+ var maxFreeTime = -1;
264
264
  usableList.forEach(function (d) {
265
265
  var _d$times = d.times,
266
266
  times = _d$times === void 0 ? [] : _d$times;
@@ -0,0 +1,30 @@
1
+ import type { MultiLangObject } from '../OpenData/types';
2
+ import type { ScheduleItem } from '../Schedule/types';
3
+ export type BusinessClosedBehavior = 'show_menu_disabled' | 'hide_all';
4
+ export interface BusinessAvailability {
5
+ status: 'open' | 'paused' | 'closed' | 'error';
6
+ behavior: BusinessClosedBehavior | null;
7
+ message: string | MultiLangObject | null;
8
+ /** Epoch milliseconds. Re-evaluate the cached configuration at this time. */
9
+ nextChangeAt: number;
10
+ requirePaymentOnSubmit: boolean;
11
+ error?: string;
12
+ }
13
+ export interface BusinessAvailabilityConfig {
14
+ paused: boolean;
15
+ pauseBehavior: BusinessClosedBehavior;
16
+ closedBehavior: BusinessClosedBehavior;
17
+ pauseMessage: BusinessAvailability['message'];
18
+ closedMessage: BusinessAvailability['message'];
19
+ scheduleIds: number[];
20
+ invalidScheduleIds: boolean;
21
+ requirePaymentOnSubmit: boolean;
22
+ }
23
+ export declare function normalizeBusinessAvailabilityConfig(data: Record<string, unknown>): BusinessAvailabilityConfig;
24
+ /** Business ordering is independent of reservation switches and Pickup slot availability. */
25
+ export declare function computeBusinessAvailability(input: {
26
+ config: BusinessAvailabilityConfig;
27
+ schedules: ScheduleItem[];
28
+ timezone: string;
29
+ now: Date;
30
+ }): BusinessAvailability;