@pisell/pisellos 0.10.88 → 0.10.91

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 (227) hide show
  1. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
  2. package/dist/model/strategy/adapter/itemRule/adapter.js +74 -7
  3. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
  4. package/dist/model/strategy/adapter/itemRule/evaluator.js +13 -0
  5. package/dist/model/strategy/adapter/itemRule/type.d.ts +40 -1
  6. package/dist/model/strategy/adapter/itemRule/type.js +10 -0
  7. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
  8. package/dist/model/strategy/adapter/promotion/evaluator.js +103 -112
  9. package/dist/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
  10. package/dist/modules/BookingContext/utils/calendarBooking.js +207 -0
  11. package/dist/modules/BookingContext/utils/index.d.ts +1 -0
  12. package/dist/modules/BookingContext/utils/index.js +1 -0
  13. package/dist/modules/BookingContext/utils/productExtend.d.ts +21 -0
  14. package/dist/modules/BookingContext/utils/productExtend.js +132 -33
  15. package/dist/modules/BookingContext/utils/resources.js +1 -1
  16. package/dist/modules/Cart/index.js +4 -3
  17. package/dist/modules/Cart/types.d.ts +2 -0
  18. package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
  19. package/dist/modules/Cart/utils/cartProduct.js +59 -32
  20. package/dist/modules/Date/index.d.ts +1 -1
  21. package/dist/modules/Date/index.js +60 -14
  22. package/dist/modules/Date/types.d.ts +5 -0
  23. package/dist/modules/OpenData/salesSettings.js +1 -1
  24. package/dist/modules/OpenData/types.d.ts +9 -0
  25. package/dist/modules/OpenData/utils.d.ts +1 -1
  26. package/dist/modules/OpenData/utils.js +3 -2
  27. package/dist/modules/Order/index.d.ts +22 -7
  28. package/dist/modules/Order/index.js +1565 -1161
  29. package/dist/modules/Order/localEftposState.d.ts +13 -0
  30. package/dist/modules/Order/localEftposState.js +39 -0
  31. package/dist/modules/Order/types.d.ts +33 -11
  32. package/dist/modules/Order/types.js +2 -2
  33. package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
  34. package/dist/modules/Order/unpaidAmountGap.js +72 -0
  35. package/dist/modules/Order/utils.d.ts +4 -1
  36. package/dist/modules/Order/utils.js +185 -129
  37. package/dist/modules/Payment/walletpass.js +32 -6
  38. package/dist/modules/Product/types.d.ts +16 -0
  39. package/dist/modules/ProductList/index.js +1 -1
  40. package/dist/modules/ResourcePlanner/planner.d.ts +2 -0
  41. package/dist/modules/ResourcePlanner/planner.js +383 -24
  42. package/dist/modules/ResourcePlanner/types.d.ts +42 -0
  43. package/dist/modules/Rules/index.js +86 -54
  44. package/dist/modules/Schedule/index.d.ts +7 -1
  45. package/dist/modules/Schedule/index.js +155 -39
  46. package/dist/modules/Schedule/types.d.ts +2 -0
  47. package/dist/modules/bookingReadValidation.d.ts +6 -0
  48. package/dist/modules/bookingReadValidation.js +72 -0
  49. package/dist/plugins/request.d.ts +2 -0
  50. package/dist/server/index.d.ts +9 -0
  51. package/dist/server/index.js +1928 -1462
  52. package/dist/server/modules/form/index.d.ts +19 -0
  53. package/dist/server/modules/form/index.js +205 -0
  54. package/dist/server/modules/form/types.d.ts +13 -0
  55. package/dist/server/modules/form/types.js +3 -0
  56. package/dist/server/modules/index.d.ts +3 -0
  57. package/dist/server/modules/index.js +4 -0
  58. package/dist/server/modules/order/index.d.ts +21 -0
  59. package/dist/server/modules/order/index.js +1399 -831
  60. package/dist/server/modules/order/types.d.ts +3 -0
  61. package/dist/server/modules/order/utils/filterOrders.js +20 -0
  62. package/dist/server/modules/products/index.d.ts +28 -7
  63. package/dist/server/modules/products/index.js +1295 -769
  64. package/dist/server/modules/products/replication.d.ts +8 -0
  65. package/dist/server/modules/products/replication.js +69 -0
  66. package/dist/server/modules/products/types.d.ts +12 -1
  67. package/dist/server/modules/products/types.js +4 -0
  68. package/dist/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
  69. package/dist/shared/receipt/customerInvoiceLanguages.js +5 -3
  70. package/dist/shared/receipt/small-ticket.d.ts +1 -0
  71. package/dist/shared/receipt/small-ticket.js +58 -26
  72. package/dist/shared/receipt/templateVisibility.d.ts +3 -0
  73. package/dist/shared/receipt/templateVisibility.js +6 -2
  74. package/dist/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
  75. package/dist/solution/BaseSales/fulfillmentItemRules.js +750 -0
  76. package/dist/solution/BaseSales/index.d.ts +22 -6
  77. package/dist/solution/BaseSales/index.js +1881 -1347
  78. package/dist/solution/BaseSales/pickupTiming.d.ts +4 -0
  79. package/dist/solution/BaseSales/pickupTiming.js +35 -8
  80. package/dist/solution/BaseSales/types.d.ts +4 -0
  81. package/dist/solution/BaseSales/types.js +1 -0
  82. package/dist/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
  83. package/dist/solution/BaseSales/utils/posDurationPricing.js +174 -0
  84. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
  85. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -8
  86. package/dist/solution/BookingByStep/index.d.ts +19 -3
  87. package/dist/solution/BookingByStep/index.js +681 -361
  88. package/dist/solution/BookingByStep/utils/resources.d.ts +10 -0
  89. package/dist/solution/BookingByStep/utils/resources.js +117 -76
  90. package/dist/solution/BookingTicket/index.d.ts +6 -0
  91. package/dist/solution/BookingTicket/index.js +666 -593
  92. package/dist/solution/BookingTicket/types.d.ts +1 -1
  93. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
  94. package/dist/solution/BookingTicket/utils/addProductDecision.js +35 -8
  95. package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +7 -7
  96. package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
  97. package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.js +188 -0
  98. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +58 -94
  99. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -3
  100. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +33 -62
  101. package/dist/solution/OrderInvoicePreview/index.js +4 -3
  102. package/dist/solution/Sales/index.js +1 -1
  103. package/dist/solution/ScanOrder/index.d.ts +2 -0
  104. package/dist/solution/ScanOrder/index.js +230 -97
  105. package/dist/solution/ScanOrder/menuAvailability.d.ts +24 -0
  106. package/dist/solution/ScanOrder/menuAvailability.js +363 -0
  107. package/dist/solution/ScanOrder/types.d.ts +3 -0
  108. package/dist/solution/UnifiedBookingSales/index.d.ts +42 -10
  109. package/dist/solution/UnifiedBookingSales/index.js +2493 -1496
  110. package/dist/solution/UnifiedBookingSales/salesSettings.js +1 -1
  111. package/dist/solution/UnifiedBookingSales/types.d.ts +20 -5
  112. package/dist/utils/pos-receipt-auto-print.d.ts +4 -0
  113. package/dist/utils/pos-receipt-auto-print.js +14 -0
  114. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
  115. package/lib/model/strategy/adapter/itemRule/adapter.js +54 -4
  116. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
  117. package/lib/model/strategy/adapter/itemRule/evaluator.js +9 -0
  118. package/lib/model/strategy/adapter/itemRule/type.d.ts +40 -1
  119. package/lib/model/strategy/adapter/itemRule/type.js +10 -0
  120. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
  121. package/lib/model/strategy/adapter/promotion/evaluator.js +22 -21
  122. package/lib/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
  123. package/lib/modules/BookingContext/utils/calendarBooking.js +156 -0
  124. package/lib/modules/BookingContext/utils/index.d.ts +1 -0
  125. package/lib/modules/BookingContext/utils/index.js +11 -0
  126. package/lib/modules/BookingContext/utils/productExtend.d.ts +21 -0
  127. package/lib/modules/BookingContext/utils/productExtend.js +104 -5
  128. package/lib/modules/BookingContext/utils/resources.js +1 -1
  129. package/lib/modules/Cart/index.js +4 -2
  130. package/lib/modules/Cart/types.d.ts +2 -0
  131. package/lib/modules/Cart/utils/cartProduct.d.ts +3 -1
  132. package/lib/modules/Cart/utils/cartProduct.js +39 -20
  133. package/lib/modules/Date/index.d.ts +1 -1
  134. package/lib/modules/Date/index.js +28 -5
  135. package/lib/modules/Date/types.d.ts +5 -0
  136. package/lib/modules/OpenData/salesSettings.js +1 -1
  137. package/lib/modules/OpenData/types.d.ts +9 -0
  138. package/lib/modules/OpenData/utils.d.ts +1 -1
  139. package/lib/modules/OpenData/utils.js +3 -2
  140. package/lib/modules/Order/index.d.ts +22 -7
  141. package/lib/modules/Order/index.js +457 -174
  142. package/lib/modules/Order/localEftposState.d.ts +13 -0
  143. package/lib/modules/Order/localEftposState.js +44 -0
  144. package/lib/modules/Order/types.d.ts +33 -11
  145. package/lib/modules/Order/types.js +2 -2
  146. package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
  147. package/lib/modules/Order/unpaidAmountGap.js +60 -0
  148. package/lib/modules/Order/utils.d.ts +4 -1
  149. package/lib/modules/Order/utils.js +51 -3
  150. package/lib/modules/Payment/walletpass.js +23 -1
  151. package/lib/modules/Product/types.d.ts +16 -0
  152. package/lib/modules/ProductList/index.js +1 -1
  153. package/lib/modules/ResourcePlanner/planner.d.ts +2 -0
  154. package/lib/modules/ResourcePlanner/planner.js +299 -9
  155. package/lib/modules/ResourcePlanner/types.d.ts +42 -0
  156. package/lib/modules/Rules/index.js +32 -3
  157. package/lib/modules/Schedule/index.d.ts +7 -1
  158. package/lib/modules/Schedule/index.js +68 -4
  159. package/lib/modules/Schedule/types.d.ts +2 -0
  160. package/lib/modules/bookingReadValidation.d.ts +6 -0
  161. package/lib/modules/bookingReadValidation.js +56 -0
  162. package/lib/plugins/request.d.ts +2 -0
  163. package/lib/server/index.d.ts +9 -0
  164. package/lib/server/index.js +279 -30
  165. package/lib/server/modules/form/index.d.ts +19 -0
  166. package/lib/server/modules/form/index.js +73 -0
  167. package/lib/server/modules/form/types.d.ts +13 -0
  168. package/lib/server/modules/form/types.js +9 -0
  169. package/lib/server/modules/index.d.ts +3 -0
  170. package/lib/server/modules/index.js +15 -1
  171. package/lib/server/modules/order/index.d.ts +21 -0
  172. package/lib/server/modules/order/index.js +344 -35
  173. package/lib/server/modules/order/types.d.ts +3 -0
  174. package/lib/server/modules/order/utils/filterOrders.js +18 -0
  175. package/lib/server/modules/products/index.d.ts +28 -7
  176. package/lib/server/modules/products/index.js +224 -62
  177. package/lib/server/modules/products/replication.d.ts +8 -0
  178. package/lib/server/modules/products/replication.js +30 -0
  179. package/lib/server/modules/products/types.d.ts +12 -1
  180. package/lib/server/modules/products/types.js +3 -0
  181. package/lib/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
  182. package/lib/shared/receipt/customerInvoiceLanguages.js +5 -3
  183. package/lib/shared/receipt/small-ticket.d.ts +1 -0
  184. package/lib/shared/receipt/small-ticket.js +53 -25
  185. package/lib/shared/receipt/templateVisibility.d.ts +3 -0
  186. package/lib/shared/receipt/templateVisibility.js +6 -2
  187. package/lib/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
  188. package/lib/solution/BaseSales/fulfillmentItemRules.js +259 -0
  189. package/lib/solution/BaseSales/index.d.ts +22 -6
  190. package/lib/solution/BaseSales/index.js +347 -59
  191. package/lib/solution/BaseSales/pickupTiming.d.ts +4 -0
  192. package/lib/solution/BaseSales/pickupTiming.js +24 -3
  193. package/lib/solution/BaseSales/types.d.ts +4 -0
  194. package/lib/solution/BaseSales/types.js +1 -0
  195. package/lib/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
  196. package/lib/solution/BaseSales/utils/posDurationPricing.js +133 -0
  197. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
  198. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
  199. package/lib/solution/BookingByStep/index.d.ts +19 -3
  200. package/lib/solution/BookingByStep/index.js +229 -17
  201. package/lib/solution/BookingByStep/utils/resources.d.ts +10 -0
  202. package/lib/solution/BookingByStep/utils/resources.js +25 -15
  203. package/lib/solution/BookingTicket/index.d.ts +6 -0
  204. package/lib/solution/BookingTicket/index.js +40 -5
  205. package/lib/solution/BookingTicket/types.d.ts +1 -1
  206. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
  207. package/lib/solution/BookingTicket/utils/addProductDecision.js +34 -4
  208. package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +7 -7
  209. package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
  210. package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.js +136 -0
  211. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +2 -14
  212. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -3
  213. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +17 -34
  214. package/lib/solution/OrderInvoicePreview/index.js +1 -0
  215. package/lib/solution/Sales/index.js +1 -1
  216. package/lib/solution/ScanOrder/index.d.ts +2 -0
  217. package/lib/solution/ScanOrder/index.js +131 -22
  218. package/lib/solution/ScanOrder/menuAvailability.d.ts +24 -0
  219. package/lib/solution/ScanOrder/menuAvailability.js +203 -0
  220. package/lib/solution/ScanOrder/types.d.ts +3 -0
  221. package/lib/solution/UnifiedBookingSales/index.d.ts +42 -10
  222. package/lib/solution/UnifiedBookingSales/index.js +717 -144
  223. package/lib/solution/UnifiedBookingSales/salesSettings.js +1 -1
  224. package/lib/solution/UnifiedBookingSales/types.d.ts +20 -5
  225. package/lib/utils/pos-receipt-auto-print.d.ts +4 -0
  226. package/lib/utils/pos-receipt-auto-print.js +13 -0
  227. package/package.json +1 -1
@@ -55,7 +55,7 @@ export function resolveDefaultBookingStart(_ref5) {
55
55
  var bookings = _ref5.bookings,
56
56
  holderIds = _ref5.holderIds,
57
57
  _ref5$mode = _ref5.mode,
58
- mode = _ref5$mode === void 0 ? 'one_after_another' : _ref5$mode,
58
+ mode = _ref5$mode === void 0 ? 'same_start_time' : _ref5$mode,
59
59
  fallback = _ref5.fallback;
60
60
  var holders = new Set(normalizeBookingHolderIds(holderIds));
61
61
  var related = bookings.flatMap(function (booking) {
@@ -127,6 +127,12 @@ export interface UnifiedBookingSalesPrepareAvailabilityProjectionParams {
127
127
  }
128
128
  export interface AvailabilityContextRef {
129
129
  contextId: string;
130
+ /** POS/Kiosk duration protocol capability and business-day default. */
131
+ durationTimeSelection?: {
132
+ version: 2;
133
+ currentBusinessDate: string;
134
+ orderSessionId: string | null;
135
+ };
130
136
  }
131
137
  export interface ContextualProductTimeRange extends ProductTimeRange {
132
138
  availabilityContextId: string;
@@ -135,7 +141,7 @@ export interface ContextualProductTimeRange extends ProductTimeRange {
135
141
  export interface ContextualProductTimeRangeGroup extends Omit<ProductTimeRangeGroup, 'ranges'> {
136
142
  ranges: ContextualProductTimeRange[];
137
143
  }
138
- export type ContextualAvailabilityQuery = Omit<Extract<AvailabilityQuery, {
144
+ export type ContextualAvailabilityQuery = (Omit<Extract<AvailabilityQuery, {
139
145
  target: 'product';
140
146
  }>, never> | Omit<Extract<AvailabilityQuery, {
141
147
  target: 'date';
@@ -147,9 +153,14 @@ export type ContextualAvailabilityQuery = Omit<Extract<AvailabilityQuery, {
147
153
  target: 'resource';
148
154
  }>, 'selectedRanges'> & {
149
155
  selectedRanges: ContextualProductTimeRange[];
150
- /** PC/H5 and explicitly enabled Venue Kiosk templates retain the already-selected time. */
156
+ /** Venue storefront/Kiosk keeps the time already selected by the customer. */
151
157
  customerSelectionSnapshot?: boolean;
152
- });
158
+ })) & {
159
+ /** Automatic remembered selection must not inherit POS manual exceptions. */
160
+ selectionIntent?: 'remembered' | 'manual';
161
+ rememberedTimeByProductId?: GetProductTimeRangesRequest['rememberedTimeByProductId'];
162
+ orderSessionId?: string;
163
+ };
153
164
  export type ContextualTimeAvailabilityItem = Omit<TimeAvailabilityItem, keyof ProductTimeRange> & ContextualProductTimeRange;
154
165
  export interface ContextualTimeAvailabilityGroup extends Omit<TimeAvailabilityGroup, 'times'> {
155
166
  times: ContextualTimeAvailabilityItem[];
@@ -213,9 +224,13 @@ export interface UnifiedBookingSalesAddRetailProductParams {
213
224
  availabilityCommitGuard?: () => void;
214
225
  }
215
226
  export interface ContextualCommitAvailabilitySelectionParams {
216
- mode: 'add' | 'edit' | 'replace';
217
- /** PC/H5 and enabled Venue Kiosk templates write the selected snapshot; checkout is authoritative. */
227
+ /** Venue customer selection is retained until authoritative checkout validation. */
218
228
  customerSelectionSnapshot?: boolean;
229
+ mode: 'add' | 'edit' | 'replace';
230
+ /** Only POS duration add supports automatic remembered-time commits. */
231
+ selectionIntent?: 'remembered' | 'manual';
232
+ /** v2 remembered commits must still belong to the order that saved the interval. */
233
+ orderSessionId?: string;
219
234
  /** Local UI intent guard, checked again immediately before the Order mutation. */
220
235
  availabilityCommitGuard?: () => void;
221
236
  productLineUid?: string;
@@ -0,0 +1,4 @@
1
+ export declare const OS_POS_RECEIPT_AUTO_PRINT_PAYMENT_STATUSES_FIELD = "_os_pos_receipt_auto_print_payment_statuses";
2
+ export type PosReceiptAutoPrintPaymentStatus = 'paid' | 'partially_paid' | 'payment_processing';
3
+ /** Missing/invalid configuration preserves legacy behavior; an empty array disables auto receipts. */
4
+ export declare function normalizePosReceiptAutoPrintPaymentStatuses(value: unknown): PosReceiptAutoPrintPaymentStatus[] | undefined;
@@ -0,0 +1,14 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
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); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
7
+ export var OS_POS_RECEIPT_AUTO_PRINT_PAYMENT_STATUSES_FIELD = '_os_pos_receipt_auto_print_payment_statuses';
8
+ /** Missing/invalid configuration preserves legacy behavior; an empty array disables auto receipts. */
9
+ export function normalizePosReceiptAutoPrintPaymentStatuses(value) {
10
+ if (!Array.isArray(value)) return undefined;
11
+ return _toConsumableArray(new Set(value.filter(function (status) {
12
+ return status === 'paid' || status === 'partially_paid' || status === 'payment_processing';
13
+ })));
14
+ }
@@ -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;
@@ -50,11 +50,13 @@ class ItemRuleAdapter {
50
50
  transformResult(result, businessData) {
51
51
  const quantityChecks = [];
52
52
  const prefillItems = [];
53
+ const cartActions = [];
53
54
  const allergyRequirements = [];
54
55
  if (!result.applicable || !businessData) {
55
56
  return {
56
57
  quantityChecks,
57
58
  prefillItems,
59
+ cartActions,
58
60
  allergyRequirements
59
61
  };
60
62
  }
@@ -66,7 +68,27 @@ class ItemRuleAdapter {
66
68
  }
67
69
  } else if (action.type === _type.ITEM_RULE_ACTION_TYPES.PREFILL_CART) {
68
70
  const items = this.processPrefillCart(action, businessData);
69
- prefillItems.push(...items);
71
+ prefillItems.push(...items.filter(item => item.quantity > 0));
72
+ if (items.length) {
73
+ cartActions.push({
74
+ type: _type.ITEM_RULE_ACTION_TYPES.PREFILL_CART,
75
+ strategyId: result.config.metadata.id,
76
+ ruleId: action.id,
77
+ priority: action.priority ?? 0,
78
+ products: items
79
+ });
80
+ }
81
+ } else if (action.type === _type.ITEM_RULE_ACTION_TYPES.DELETE_PRODUCT) {
82
+ const products = this.processDeleteProduct(action, businessData);
83
+ if (products.length) {
84
+ cartActions.push({
85
+ type: _type.ITEM_RULE_ACTION_TYPES.DELETE_PRODUCT,
86
+ strategyId: result.config.metadata.id,
87
+ ruleId: action.id,
88
+ priority: action.priority ?? 0,
89
+ products
90
+ });
91
+ }
70
92
  } else if (action.type === _type.ITEM_RULE_ACTION_TYPES.ALLERGY_CHECK) {
71
93
  const requirement = this.processAllergyCheck(action, result, businessData);
72
94
  if (requirement) allergyRequirements.push(requirement);
@@ -75,6 +97,7 @@ class ItemRuleAdapter {
75
97
  return {
76
98
  quantityChecks,
77
99
  prefillItems,
100
+ cartActions,
78
101
  allergyRequirements
79
102
  };
80
103
  }
@@ -423,16 +446,24 @@ class ItemRuleAdapter {
423
446
 
424
447
  processPrefillCart(action, businessData) {
425
448
  const config = action.config;
426
- if (!config?.products) return [];
449
+ if (!Array.isArray(config?.products)) return [];
450
+ if (config.scope !== businessData.executionScope) return [];
451
+ if (config.scope === 'set_handover' && action.target !== 'cart') return [];
427
452
  const results = [];
428
453
  for (const prefillProduct of config.products) {
429
454
  const quantity = this.resolvePrefillQuantity(prefillProduct.quantityFrom, prefillProduct.quantity, businessData);
430
- if (quantity <= 0) continue;
455
+ const shouldSyncZero = config.scope === 'set_handover' && prefillProduct.repeat_skip === true;
456
+ if (!Number.isFinite(quantity) || quantity < 0 || quantity === 0 && !shouldSyncZero) {
457
+ continue;
458
+ }
431
459
  results.push({
432
460
  ruleId: action.id,
433
461
  product_id: prefillProduct.product_id,
434
462
  product_variant_id: prefillProduct.product_variant_id,
435
- quantity
463
+ quantity,
464
+ ...(prefillProduct.repeat_skip !== undefined ? {
465
+ repeat_skip: prefillProduct.repeat_skip === true
466
+ } : {})
436
467
  });
437
468
  }
438
469
  return results;
@@ -449,10 +480,29 @@ class ItemRuleAdapter {
449
480
  return businessData.pax.adult;
450
481
  case 'fixed':
451
482
  return fixedValue ?? 0;
483
+ case 'main_product_number':
484
+ {
485
+ const mainProductNumber = businessData.mainProductNumber ?? 0;
486
+ return Number.isFinite(mainProductNumber) ? Math.max(0, mainProductNumber) : 0;
487
+ }
452
488
  default:
453
489
  return fixedValue ?? 0;
454
490
  }
455
491
  }
492
+ processDeleteProduct(action, businessData) {
493
+ const config = action.config;
494
+ if (action.target !== 'cart' || config?.scope !== 'set_handover' || config.scope !== businessData.executionScope || !Array.isArray(config.products)) {
495
+ return [];
496
+ }
497
+ const productIds = new Set();
498
+ for (const product of config.products) {
499
+ const productId = Number(product?.product_id);
500
+ if (Number.isInteger(productId) && productId > 0) productIds.add(productId);
501
+ }
502
+ return Array.from(productIds, product_id => ({
503
+ product_id
504
+ }));
505
+ }
456
506
  }
457
507
  exports.ItemRuleAdapter = ItemRuleAdapter;
458
508
  var _default = exports.default = ItemRuleAdapter;
@@ -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
  }
@@ -43,6 +43,7 @@ class ItemRuleEvaluator {
43
43
  const configs = businessData.strategyConfigs ? businessData.strategyConfigs.filter(c => c.metadata.type === 'item_rule') : this.strategyConfigs;
44
44
  const allQuantityChecks = [];
45
45
  const allPrefillItems = [];
46
+ const allCartActions = [];
46
47
  const allAllergyRequirements = [];
47
48
  const rawResults = [];
48
49
  const context = this.adapter.prepareContext(businessData);
@@ -52,16 +53,19 @@ class ItemRuleEvaluator {
52
53
  const {
53
54
  quantityChecks,
54
55
  prefillItems,
56
+ cartActions,
55
57
  allergyRequirements
56
58
  } = this.adapter.transformResult(evalResult, businessData);
57
59
  allQuantityChecks.push(...quantityChecks);
58
60
  allPrefillItems.push(...prefillItems);
61
+ allCartActions.push(...cartActions);
59
62
  allAllergyRequirements.push(...allergyRequirements);
60
63
  }
61
64
  const failedChecks = allQuantityChecks.filter(c => !c.passed);
62
65
  return {
63
66
  quantityChecks: allQuantityChecks,
64
67
  prefillItems: allPrefillItems,
68
+ cartActions: allCartActions.sort((left, right) => right.priority - left.priority),
65
69
  allergyRequirements: allAllergyRequirements,
66
70
  allPassed: failedChecks.length === 0,
67
71
  failedChecks,
@@ -130,5 +134,10 @@ class ItemRuleEvaluator {
130
134
  const result = this.evaluate(businessData);
131
135
  return result.prefillItems;
132
136
  }
137
+
138
+ /** 获取按优先级排序的购物车动作,交由销售业务层执行。 */
139
+ getCartActions(businessData) {
140
+ return this.evaluate(businessData).cartActions;
141
+ }
133
142
  }
134
143
  exports.ItemRuleEvaluator = ItemRuleEvaluator;
@@ -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
  /** 所有校验是否全部通过 */
@@ -13,6 +13,8 @@ const ITEM_RULE_ACTION_TYPES = exports.ITEM_RULE_ACTION_TYPES = {
13
13
  QUANTITY_CHECK: 'QUANTITY_CHECK',
14
14
  /** 预填购物车 */
15
15
  PREFILL_CART: 'PREFILL_CART',
16
+ /** 按商品 ID 删除购物车商品 */
17
+ DELETE_PRODUCT: 'DELETE_PRODUCT',
16
18
  /** 加购前过敏信息确认 */
17
19
  ALLERGY_CHECK: 'ALLERGY_CHECK'
18
20
  };
@@ -78,6 +80,10 @@ const ITEM_RULE_TEMPLATES = exports.ITEM_RULE_TEMPLATES = {
78
80
  // Prefill Cart 相关类型
79
81
  // ============================================
80
82
 
83
+ /** 购物车动作触发时机,与数量校验的提交范围相互独立。 */
84
+
85
+ /** 预填数量来源;主商品数量不扩展到 QUANTITY_CHECK。 */
86
+
81
87
  /**
82
88
  * 预填商品项
83
89
  */
@@ -88,6 +94,8 @@ const ITEM_RULE_TEMPLATES = exports.ITEM_RULE_TEMPLATES = {
88
94
  * 存储在 ActionEffect.config 中
89
95
  */
90
96
 
97
+ /** 删除指定商品的全部购物车行,不区分变体或是否为自动添加。 */
98
+
91
99
  // ============================================
92
100
  // 业务数据类型(Evaluator 输入)
93
101
  // ============================================
@@ -116,6 +124,8 @@ const ITEM_RULE_TEMPLATES = exports.ITEM_RULE_TEMPLATES = {
116
124
  * 单个 Prefill Cart 的预填结果
117
125
  */
118
126
 
127
+ /** 保留不同购物车动作之间的优先级与执行顺序。 */
128
+
119
129
  /**
120
130
  * 单条规则的数量限制(不含校验结果,仅描述配置中的约束)
121
131
  */
@@ -180,7 +180,8 @@ export declare class PromotionEvaluator {
180
180
  */
181
181
  private processItemReward;
182
182
  private normalizePositiveInteger;
183
- private getAvailablePromotionQuantity;
183
+ /** 仅放开 X件Y元处理过的触发数量,奖励目标仍按全部已处理数量互斥。 */
184
+ private getItemRewardTriggerQuantity;
184
185
  private buildItemRewardTargetUnits;
185
186
  private resolveItemRewardFinalPrice;
186
187
  private resolveItemRewardLimit;
@@ -227,10 +227,13 @@ class PromotionEvaluator {
227
227
  const productResults = this.evaluateProducts(input);
228
228
 
229
229
  // 2. 收集所有适用的促销(去重)
230
+ // strategyId is metadata and is not guaranteed to be unique. Use the actual
231
+ // configuration as the key so one strategy cannot overwrite another strategy's
232
+ // label/action when their IDs happen to be the same.
230
233
  const promotionMap = new Map();
231
234
  for (const productResult of productResults) {
232
235
  for (const promo of productResult.applicablePromotions) {
233
- const existing = promotionMap.get(promo.strategyId);
236
+ const existing = promotionMap.get(promo.strategyConfig);
234
237
  const product = productResult.product;
235
238
 
236
239
  // 计算促销数量:如果是 bundle 子商品匹配,数量 = 主商品数量 × 子商品数量
@@ -253,7 +256,7 @@ class PromotionEvaluator {
253
256
  // 新促销
254
257
  const productMatchedBundleIndexMap = new Map();
255
258
  productMatchedBundleIndexMap.set(product.id, promo.matchedBundleIndex);
256
- promotionMap.set(promo.strategyId, {
259
+ promotionMap.set(promo.strategyConfig, {
257
260
  ...promo,
258
261
  applicableProducts: [product],
259
262
  totalQuantity: promoQuantity,
@@ -305,11 +308,13 @@ class PromotionEvaluator {
305
308
  const cartResult = this.evaluateCart(input);
306
309
 
307
310
  // 2. 按 action priority 排序促销组(从 strategyConfig 获取 priority)
308
- const sortedGroups = this.sortPromotionGroupsByPriority(cartResult.promotionGroups, cartResult.applicablePromotions);
311
+ const sortedGroups = this.sortPromotionGroupsByPriority(cartResult.promotionGroups);
309
312
 
310
313
  // 3. 追踪已处理的商品(避免重复处理)
311
314
  // key: `${product_id}_${product_variant_id}`
312
315
  const processedQuantityMap = new Map();
316
+ // X件Y元处理过的数量仍可作为商品奖励的触发条件。
317
+ const xItemsProcessedQuantityMap = new Map();
313
318
 
314
319
  // 4. 处理每个促销组,收集结果
315
320
  const pricedProducts = [];
@@ -325,7 +330,7 @@ class PromotionEvaluator {
325
330
  const matchedBundleIndexMap = group.productMatchedBundleIndexMap || new Map();
326
331
  if (actionType === _type.PROMOTION_ACTION_TYPES.X_ITEMS_FOR_Y_PRICE) {
327
332
  // X件Y元处理
328
- const result = this.processXItemsForYPrice(group, processedQuantityMap, matchedBundleIndexMap);
333
+ const result = this.processXItemsForYPrice(group, processedQuantityMap, xItemsProcessedQuantityMap, matchedBundleIndexMap);
329
334
  pricedProducts.push(...result.products);
330
335
  totalOriginalAmount = totalOriginalAmount.plus(result.originalAmount);
331
336
  totalFinalAmount = totalFinalAmount.plus(result.finalAmount);
@@ -342,7 +347,7 @@ class PromotionEvaluator {
342
347
  }
343
348
  } else if (actionType === _type.PROMOTION_ACTION_TYPES.ITEM_REWARD) {
344
349
  // 商品奖励处理:条件商品触发,目标商品行享优惠,不自动新增商品
345
- const result = this.processItemReward(group, processedQuantityMap, products, matchedBundleIndexMap);
350
+ const result = this.processItemReward(group, processedQuantityMap, products, xItemsProcessedQuantityMap, matchedBundleIndexMap);
346
351
  pricedProducts.push(...result.products);
347
352
  totalOriginalAmount = totalOriginalAmount.plus(result.originalAmount);
348
353
  totalFinalAmount = totalFinalAmount.plus(result.finalAmount);
@@ -544,19 +549,11 @@ class PromotionEvaluator {
544
549
  * 按优先级排序促销组
545
550
  * 优先级从 strategyConfig.actions[0].priority 获取,数值越小优先级越高
546
551
  */
547
- sortPromotionGroupsByPriority(groups, promotions) {
548
- // 创建策略ID到优先级的映射
549
- const priorityMap = new Map();
550
- for (const promo of promotions) {
551
- const actions = promo.strategyConfig?.actions || [];
552
- const priority = actions[0]?.priority ?? 999;
553
- priorityMap.set(promo.strategyId, priority);
554
- }
555
-
552
+ sortPromotionGroupsByPriority(groups) {
556
553
  // 按优先级排序(数值越小优先级越高)
557
554
  return [...groups].sort((a, b) => {
558
- const priorityA = priorityMap.get(a.strategyId) ?? 999;
559
- const priorityB = priorityMap.get(b.strategyId) ?? 999;
555
+ const priorityA = a.strategyConfig?.actions?.[0]?.priority ?? 999;
556
+ const priorityB = b.strategyConfig?.actions?.[0]?.priority ?? 999;
560
557
  return priorityA - priorityB;
561
558
  });
562
559
  }
@@ -571,7 +568,7 @@ class PromotionEvaluator {
571
568
  *
572
569
  * 注意:每个商品按 id 独立处理,不会合并不同 id 的商品
573
570
  */
574
- processXItemsForYPrice(group, processedQuantityMap, matchedBundleIndexMap) {
571
+ processXItemsForYPrice(group, processedQuantityMap, xItemsProcessedQuantityMap, matchedBundleIndexMap) {
575
572
  const {
576
573
  strategyId,
577
574
  strategyMetadata,
@@ -764,6 +761,7 @@ class PromotionEvaluator {
764
761
 
765
762
  // 更新已处理数量
766
763
  processedQuantityMap.set(key, processedQty + availableQty);
764
+ xItemsProcessedQuantityMap.set(key, (xItemsProcessedQuantityMap.get(key) || 0) + availableQty);
767
765
  }
768
766
 
769
767
  // 8. 尾差调整:只补实际组价的舍入差额,不将高于原价的组价补到某一件。
@@ -927,7 +925,7 @@ class PromotionEvaluator {
927
925
  * 4. 按消费者最优(可节省金额从高到低)选择目标单位
928
926
  * 5. 对目标商品拆分并写入 finalPrice,触发商品本身不改价
929
927
  */
930
- processItemReward(group, processedQuantityMap, allProducts, matchedBundleIndexMap) {
928
+ processItemReward(group, processedQuantityMap, allProducts, xItemsProcessedQuantityMap, matchedBundleIndexMap) {
931
929
  const {
932
930
  strategyId,
933
931
  strategyMetadata,
@@ -937,7 +935,7 @@ class PromotionEvaluator {
937
935
  const detail = actionDetail;
938
936
  const triggerQuantity = this.normalizePositiveInteger(detail.triggerQuantity, 1);
939
937
  const rewardQuantity = this.normalizePositiveInteger(detail.rewardQuantity, 1);
940
- const conditionQuantity = this.getAvailablePromotionQuantity(triggerProducts, processedQuantityMap, matchedBundleIndexMap);
938
+ const conditionQuantity = this.getItemRewardTriggerQuantity(triggerProducts, processedQuantityMap, xItemsProcessedQuantityMap, matchedBundleIndexMap);
941
939
  if (conditionQuantity < triggerQuantity) {
942
940
  return {
943
941
  products: [],
@@ -1033,12 +1031,15 @@ class PromotionEvaluator {
1033
1031
  const n = Math.floor(Number(value));
1034
1032
  return Number.isFinite(n) && n > 0 ? n : fallback;
1035
1033
  }
1036
- getAvailablePromotionQuantity(products, processedQuantityMap, matchedBundleIndexMap) {
1034
+
1035
+ /** 仅放开 X件Y元处理过的触发数量,奖励目标仍按全部已处理数量互斥。 */
1036
+ getItemRewardTriggerQuantity(products, processedQuantityMap, xItemsProcessedQuantityMap, matchedBundleIndexMap) {
1037
1037
  let total = 0;
1038
1038
  for (const product of products) {
1039
1039
  const key = this.getProductKey(product);
1040
1040
  const processedQty = processedQuantityMap.get(key) || 0;
1041
- const availableQty = product.quantity - processedQty;
1041
+ const xItemsProcessedQty = xItemsProcessedQuantityMap.get(key) || 0;
1042
+ const availableQty = product.quantity - processedQty + xItemsProcessedQty;
1042
1043
  if (availableQty <= 0) continue;
1043
1044
  const matchedBundleIndex = matchedBundleIndexMap?.get(product.id);
1044
1045
  if (matchedBundleIndex !== undefined && product.bundle) {
@@ -0,0 +1,15 @@
1
+ import dayjs from 'dayjs';
2
+ import type { BookingCalcContext } from './productExtend';
3
+ export declare function isManualBookingProduct(product: any): boolean;
4
+ export declare function getCalendarBookingRange(product: any, ctx?: BookingCalcContext): {
5
+ startAt: string;
6
+ endAt: string;
7
+ duration: number;
8
+ startDate: dayjs.Dayjs;
9
+ endDate: dayjs.Dayjs;
10
+ } | undefined;
11
+ /** A prepared calendar cache is reused after SKU input; no availability-driven replacement is allowed. */
12
+ export declare function prepareCalendarBookingCacheItem(cacheItem: any, ctx: BookingCalcContext): any;
13
+ export declare function calendarBookingEntryKey(ctx: BookingCalcContext): string;
14
+ export declare function calendarBookingNeedsInput(cacheItem: any): boolean;
15
+ export declare function calendarBookingPreparationKey(cacheItem: any, ctx: BookingCalcContext): string;