@pisell/pisellos 2.2.278 → 2.2.280

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 (188) hide show
  1. package/dist/modules/BaseModule.d.ts +1 -0
  2. package/dist/modules/BaseModule.js +24 -28
  3. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +7 -3
  4. package/dist/modules/BookingContext/utils/productExtend.js +5 -9
  5. package/dist/modules/BookingContext/utils/timeSlices.js +24 -3
  6. package/dist/modules/Customer/index.d.ts +4 -0
  7. package/dist/modules/Customer/index.js +91 -59
  8. package/dist/modules/Customer/types.d.ts +2 -0
  9. package/dist/modules/Discount/index.d.ts +1 -0
  10. package/dist/modules/Discount/index.js +40 -11
  11. package/dist/modules/Discount/types.d.ts +1 -0
  12. package/dist/modules/Holder/index.d.ts +48 -0
  13. package/dist/modules/Holder/index.js +640 -0
  14. package/dist/modules/Holder/types.d.ts +123 -0
  15. package/dist/modules/Holder/types.js +1 -0
  16. package/dist/modules/Holder/utils.d.ts +13 -0
  17. package/dist/modules/Holder/utils.js +34 -0
  18. package/dist/modules/OpenData/index.js +2 -2
  19. package/dist/modules/Order/index.d.ts +32 -4
  20. package/dist/modules/Order/index.js +868 -675
  21. package/dist/modules/Order/types.d.ts +22 -1
  22. package/dist/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
  23. package/dist/modules/Order/utils/discountProductLineIdentity.js +227 -0
  24. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
  25. package/dist/modules/Order/utils/orderCollectionIdentity.js +75 -0
  26. package/dist/modules/Order/utils.d.ts +10 -0
  27. package/dist/modules/Order/utils.js +71 -34
  28. package/dist/modules/Payment/index.d.ts +4 -0
  29. package/dist/modules/Payment/index.js +14 -4
  30. package/dist/modules/Payment/walletpass.js +21 -7
  31. package/dist/modules/Product/types.d.ts +1 -0
  32. package/dist/modules/ProductList/index.js +33 -13
  33. package/dist/modules/Quotation/index.d.ts +1 -1
  34. package/dist/modules/Quotation/index.js +2 -2
  35. package/dist/modules/ResourcePlanner/index.d.ts +24 -0
  36. package/dist/modules/ResourcePlanner/index.js +181 -0
  37. package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
  38. package/dist/modules/ResourcePlanner/planner.js +1069 -0
  39. package/dist/modules/ResourcePlanner/types.d.ts +227 -0
  40. package/dist/modules/ResourcePlanner/types.js +1 -0
  41. package/dist/modules/Rules/index.js +153 -56
  42. package/dist/modules/SalesSummary/index.js +12 -13
  43. package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
  44. package/dist/modules/ScanOrderLogger/index.js +15 -2
  45. package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
  46. package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
  47. package/dist/modules/Schedule/index.d.ts +3 -1
  48. package/dist/modules/Schedule/index.js +21 -16
  49. package/dist/modules/Summary/utils.js +38 -13
  50. package/dist/modules/index.d.ts +2 -0
  51. package/dist/modules/index.js +3 -1
  52. package/dist/plugins/window.d.ts +1 -0
  53. package/dist/server/index.d.ts +20 -0
  54. package/dist/server/index.js +1101 -909
  55. package/dist/server/modules/order/index.d.ts +2 -0
  56. package/dist/server/modules/order/index.js +261 -96
  57. package/dist/server/modules/order/types.d.ts +1 -1
  58. package/dist/solution/BaseSales/index.d.ts +20 -1
  59. package/dist/solution/BaseSales/index.js +989 -881
  60. package/dist/solution/BaseSales/utils/cartPromotion.js +19 -1
  61. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
  62. package/dist/solution/BaseSales/utils.js +31 -20
  63. package/dist/solution/BookingByStep/index.d.ts +17 -2
  64. package/dist/solution/BookingByStep/index.js +294 -215
  65. package/dist/solution/BookingByStep/types.d.ts +2 -1
  66. package/dist/solution/BookingByStep/types.js +3 -1
  67. package/dist/solution/BookingByStep/utils/capacity.js +17 -1
  68. package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  69. package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
  70. package/dist/solution/BookingTicket/index.d.ts +21 -3
  71. package/dist/solution/BookingTicket/index.js +312 -226
  72. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  73. package/dist/solution/BookingTicket/utils/scan/handleScan.js +10 -2
  74. package/dist/solution/ScanOrder/index.d.ts +26 -14
  75. package/dist/solution/ScanOrder/index.js +1142 -739
  76. package/dist/solution/ScanOrder/types.d.ts +21 -1
  77. package/dist/solution/ScanOrder/utils.d.ts +8 -0
  78. package/dist/solution/ScanOrder/utils.js +97 -45
  79. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  80. package/dist/solution/ShopDiscount/index.js +125 -87
  81. package/dist/solution/UnifiedBookingSales/index.d.ts +204 -0
  82. package/dist/solution/UnifiedBookingSales/index.js +2211 -0
  83. package/dist/solution/UnifiedBookingSales/types.d.ts +150 -0
  84. package/dist/solution/UnifiedBookingSales/types.js +11 -0
  85. package/dist/solution/VenueBooking/index.d.ts +39 -11
  86. package/dist/solution/VenueBooking/index.js +1167 -841
  87. package/dist/solution/VenueBooking/types.d.ts +3 -0
  88. package/dist/solution/VenueBooking/utils/resource.js +1 -0
  89. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  90. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
  91. package/dist/solution/index.d.ts +1 -0
  92. package/dist/solution/index.js +2 -1
  93. package/dist/types/index.d.ts +1 -0
  94. package/lib/model/strategy/adapter/promotion/index.js +0 -51
  95. package/lib/modules/BaseModule.d.ts +1 -0
  96. package/lib/modules/BaseModule.js +24 -37
  97. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -0
  98. package/lib/modules/BookingContext/utils/productExtend.js +4 -3
  99. package/lib/modules/BookingContext/utils/timeSlices.js +18 -3
  100. package/lib/modules/Customer/index.d.ts +4 -0
  101. package/lib/modules/Customer/index.js +11 -0
  102. package/lib/modules/Customer/types.d.ts +2 -0
  103. package/lib/modules/Discount/index.d.ts +1 -0
  104. package/lib/modules/Discount/index.js +9 -0
  105. package/lib/modules/Discount/types.d.ts +1 -0
  106. package/lib/modules/Holder/index.d.ts +48 -0
  107. package/lib/modules/Holder/index.js +402 -0
  108. package/lib/modules/Holder/types.d.ts +123 -0
  109. package/lib/modules/Holder/types.js +17 -0
  110. package/lib/modules/Holder/utils.d.ts +13 -0
  111. package/lib/modules/Holder/utils.js +71 -0
  112. package/lib/modules/OpenData/index.js +1 -1
  113. package/lib/modules/Order/index.d.ts +32 -4
  114. package/lib/modules/Order/index.js +372 -156
  115. package/lib/modules/Order/types.d.ts +22 -1
  116. package/lib/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
  117. package/lib/modules/Order/utils/discountProductLineIdentity.js +170 -0
  118. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
  119. package/lib/modules/Order/utils/orderCollectionIdentity.js +70 -0
  120. package/lib/modules/Order/utils.d.ts +10 -0
  121. package/lib/modules/Order/utils.js +39 -6
  122. package/lib/modules/Payment/index.d.ts +4 -0
  123. package/lib/modules/Payment/index.js +7 -0
  124. package/lib/modules/Payment/walletpass.js +12 -0
  125. package/lib/modules/Product/types.d.ts +1 -0
  126. package/lib/modules/ProductList/index.js +49 -31
  127. package/lib/modules/Quotation/index.d.ts +1 -1
  128. package/lib/modules/Quotation/index.js +2 -2
  129. package/lib/modules/ResourcePlanner/index.d.ts +24 -0
  130. package/lib/modules/ResourcePlanner/index.js +148 -0
  131. package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
  132. package/lib/modules/ResourcePlanner/planner.js +933 -0
  133. package/lib/modules/ResourcePlanner/types.d.ts +227 -0
  134. package/lib/modules/ResourcePlanner/types.js +17 -0
  135. package/lib/modules/Rules/index.js +117 -25
  136. package/lib/modules/SalesSummary/index.js +6 -7
  137. package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
  138. package/lib/modules/ScanOrderLogger/index.js +13 -1
  139. package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
  140. package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
  141. package/lib/modules/Schedule/index.d.ts +3 -1
  142. package/lib/modules/Schedule/index.js +10 -8
  143. package/lib/modules/Summary/utils.js +21 -1
  144. package/lib/modules/index.d.ts +2 -0
  145. package/lib/modules/index.js +5 -1
  146. package/lib/plugins/window.d.ts +1 -0
  147. package/lib/server/index.d.ts +20 -0
  148. package/lib/server/index.js +124 -19
  149. package/lib/server/modules/order/index.d.ts +2 -0
  150. package/lib/server/modules/order/index.js +75 -5
  151. package/lib/server/modules/order/types.d.ts +1 -1
  152. package/lib/solution/BaseSales/index.d.ts +20 -1
  153. package/lib/solution/BaseSales/index.js +105 -31
  154. package/lib/solution/BaseSales/utils/cartPromotion.js +18 -0
  155. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -0
  156. package/lib/solution/BaseSales/utils.js +29 -18
  157. package/lib/solution/BookingByStep/index.d.ts +17 -2
  158. package/lib/solution/BookingByStep/index.js +60 -18
  159. package/lib/solution/BookingByStep/types.d.ts +2 -1
  160. package/lib/solution/BookingByStep/types.js +5 -0
  161. package/lib/solution/BookingByStep/utils/capacity.js +20 -1
  162. package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  163. package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
  164. package/lib/solution/BookingTicket/index.d.ts +21 -3
  165. package/lib/solution/BookingTicket/index.js +75 -16
  166. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  167. package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
  168. package/lib/solution/ScanOrder/index.d.ts +26 -14
  169. package/lib/solution/ScanOrder/index.js +449 -182
  170. package/lib/solution/ScanOrder/types.d.ts +21 -1
  171. package/lib/solution/ScanOrder/utils.d.ts +8 -0
  172. package/lib/solution/ScanOrder/utils.js +60 -18
  173. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  174. package/lib/solution/ShopDiscount/index.js +14 -0
  175. package/lib/solution/UnifiedBookingSales/index.d.ts +204 -0
  176. package/lib/solution/UnifiedBookingSales/index.js +1273 -0
  177. package/lib/solution/UnifiedBookingSales/types.d.ts +150 -0
  178. package/lib/solution/UnifiedBookingSales/types.js +33 -0
  179. package/lib/solution/VenueBooking/index.d.ts +39 -11
  180. package/lib/solution/VenueBooking/index.js +322 -110
  181. package/lib/solution/VenueBooking/types.d.ts +3 -0
  182. package/lib/solution/VenueBooking/utils/resource.js +1 -0
  183. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  184. package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
  185. package/lib/solution/index.d.ts +1 -0
  186. package/lib/solution/index.js +3 -1
  187. package/lib/types/index.d.ts +1 -0
  188. package/package.json +1 -1
@@ -35,6 +35,7 @@ export interface ScanOrderOrderProductIdentity {
35
35
  /** 参与合并/匹配;与 remove 通配语义见 isSkuOnlyDeleteIdentity */
36
36
  product_sku?: ScanOrderProductSku;
37
37
  product_bundle?: any[];
38
+ shop_id?: number | string;
38
39
  }
39
40
  export interface ScanOrderProductSku {
40
41
  option: any[];
@@ -207,7 +208,7 @@ export interface ScanOrderSubmitPayload extends Omit<ScanOrderTempOrder, 'platfo
207
208
  }>;
208
209
  products: ScanOrderSubmitProduct[];
209
210
  }
210
- export type ScanOrderAvailabilityMode = 'idle' | 'shop_closed' | 'submit_disabled' | 'resource_busy' | 'additional_order_with_code' | 'additional_order';
211
+ export type ScanOrderAvailabilityMode = 'idle' | 'shop_closed' | 'submit_disabled' | 'resource_busy' | 'multiple_orders' | 'additional_order_with_code' | 'additional_order';
211
212
  export interface ScanOrderTableFormRecord {
212
213
  policy?: string | null;
213
214
  partyroom_booking?: string | null;
@@ -250,6 +251,10 @@ export interface ScanOrderResourceOccupyDetail {
250
251
  form_id?: number | string | null;
251
252
  order_id?: number | string | null;
252
253
  last_order_id?: number | string | null;
254
+ order_list?: Array<{
255
+ id?: number | string | null;
256
+ [key: string]: any;
257
+ }> | null;
253
258
  resource_capacity?: ScanOrderResourceCapacity[] | null;
254
259
  form_record?: ScanOrderTableFormRecord | null;
255
260
  [key: string]: any;
@@ -263,6 +268,21 @@ export interface ScanOrderResourceOccupyDetailApiResponse {
263
268
  } | null;
264
269
  }
265
270
  export type ScanOrderResourceSelectType = 'single' | 'multiple' | 'capacity';
271
+ export interface ScanOrderReservationResourceSelectInfo {
272
+ resourceSelectType?: ScanOrderResourceSelectType;
273
+ isSingleReservation: boolean;
274
+ isMultipleReservation: boolean;
275
+ isCapacityReservation: boolean;
276
+ }
277
+ export interface ScanOrderAllowAddItemsInfo {
278
+ enabled: boolean;
279
+ }
280
+ export type ScanOrderSyncAdditionalOrderReason = 'missing_resource_id' | 'no_order' | 'multiple_orders' | 'add_items_disabled' | 'invalid_order_id';
281
+ export interface ScanOrderSyncAdditionalOrderResult {
282
+ matched: boolean;
283
+ order_id?: string;
284
+ reason?: ScanOrderSyncAdditionalOrderReason;
285
+ }
266
286
  export interface ScanOrderResourceState extends ScanOrderAvailabilityInfo {
267
287
  relationId?: string;
268
288
  tableFormId?: string;
@@ -2,6 +2,7 @@ import { ScanOrderOrderProduct, ScanOrderOrderProductIdentity, ScanOrderResource
2
2
  import type { CartItemSummary, ItemRuleBusinessData, PaxInfo, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
3
3
  import type { StrategyConfig } from '../../model/strategy/type';
4
4
  import type { ProductData } from '../../modules/Product/types';
5
+ import type { OrderSubmitProduct } from '../../modules/Order/types';
5
6
  /**
6
7
  * 构建金额全为 0 的空 summary。
7
8
  * 作为尚未计算金额时的兜底默认值,避免下游因 undefined 报错。
@@ -42,6 +43,8 @@ export declare function toNonNegativeNumber(value: unknown): number;
42
43
  export declare function toNonNegativeInt(value: unknown): number;
43
44
  export declare function toPriceString(value: unknown, fallback?: string): string;
44
45
  export declare function buildProductKey(productId: number, productVariantId: number): string;
46
+ /** 加餐接口只提交本次新增商品,过滤掉首单预约占位规则行。 */
47
+ export declare function filterProductsForScanOrderMore<T extends OrderSubmitProduct>(products?: T[]): T[];
45
48
  export declare function getTopLevelProductId(product: Record<string, any>): number | null;
46
49
  export declare function getTopLevelVariantId(product: Record<string, any>): number | null;
47
50
  export declare function buildQuantityLimitIndex(limits: QuantityLimitResult[]): {
@@ -134,6 +137,11 @@ export declare function normalizeOrderProduct(product: Partial<ScanOrderOrderPro
134
137
  * 从 reservation.enabled_reservation_rules 中收集 type=link 的商品 id。
135
138
  */
136
139
  export declare function collectLinkProductIdsFromReservationRules(rules: unknown): number[];
140
+ /**
141
+ * 找到第一个归属指定桌台的预约规则商品。
142
+ * 归属判断基于商品资源中的 default_resource / optional_resource。
143
+ */
144
+ export declare function findReservationRuleProductByResourceId(products: ProductData[], resourceId: string | number | null | undefined): ProductData | undefined;
137
145
  /**
138
146
  * 返回列表中第一个带有效 duration.value(分钟)的商品时长。
139
147
  */
@@ -154,6 +154,15 @@ export function toPriceString(value) {
154
154
  export function buildProductKey(productId, productVariantId) {
155
155
  return "".concat(productId, "_").concat(productVariantId);
156
156
  }
157
+
158
+ /** 加餐接口只提交本次新增商品,过滤掉首单预约占位规则行。 */
159
+ export function filterProductsForScanOrderMore() {
160
+ var products = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
161
+ return products.filter(function (product) {
162
+ var _product$metadata;
163
+ return ((_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.is_rule) !== true;
164
+ });
165
+ }
157
166
  export function getTopLevelProductId(product) {
158
167
  var _product$product_id;
159
168
  var rawProductId = (_product$product_id = product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : product.id;
@@ -379,35 +388,46 @@ export function attachItemRuleLimitsToTopLevelProducts(productList, limits) {
379
388
  * 数组元素先按主键排序再序列化,避免顺序差异导致误判为不同行。
380
389
  */
381
390
  export function buildProductLineFingerprint(productOptionItem, productBundle) {
382
- var optArr = Array.isArray(productOptionItem) ? productOptionItem : [];
383
- var normalizedOpts = optArr.map(function (item) {
384
- var _ref, _item$add_price;
385
- return {
386
- option_group_item_id: Number(item === null || item === void 0 ? void 0 : item.option_group_item_id) || 0,
387
- option_group_id: Number(item === null || item === void 0 ? void 0 : item.option_group_id) || 0,
388
- num: typeof (item === null || item === void 0 ? void 0 : item.num) === 'number' && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
389
- price: String((_ref = (_item$add_price = item === null || item === void 0 ? void 0 : item.add_price) !== null && _item$add_price !== void 0 ? _item$add_price : item === null || item === void 0 ? void 0 : item.price) !== null && _ref !== void 0 ? _ref : '')
390
- };
391
- }).sort(function (p, q) {
392
- if (p.option_group_item_id !== q.option_group_item_id) {
393
- return p.option_group_item_id - q.option_group_item_id;
394
- }
395
- if (p.option_group_id !== q.option_group_id) return p.option_group_id - q.option_group_id;
396
- if (p.num !== q.num) return p.num - q.num;
397
- return p.price.localeCompare(q.price);
398
- });
391
+ var normalizeOptions = function normalizeOptions(options) {
392
+ var optionArr = Array.isArray(options) ? options : [];
393
+ return optionArr.map(function (item) {
394
+ var _ref, _item$add_price;
395
+ return {
396
+ option_group_item_id: Number(item === null || item === void 0 ? void 0 : item.option_group_item_id) || 0,
397
+ option_group_id: Number(item === null || item === void 0 ? void 0 : item.option_group_id) || 0,
398
+ num: typeof (item === null || item === void 0 ? void 0 : item.num) === 'number' && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
399
+ price: String((_ref = (_item$add_price = item === null || item === void 0 ? void 0 : item.add_price) !== null && _item$add_price !== void 0 ? _item$add_price : item === null || item === void 0 ? void 0 : item.price) !== null && _ref !== void 0 ? _ref : '')
400
+ };
401
+ }).sort(function (p, q) {
402
+ if (p.option_group_item_id !== q.option_group_item_id) {
403
+ return p.option_group_item_id - q.option_group_item_id;
404
+ }
405
+ if (p.option_group_id !== q.option_group_id) {
406
+ return p.option_group_id - q.option_group_id;
407
+ }
408
+ if (p.num !== q.num) return p.num - q.num;
409
+ return p.price.localeCompare(q.price);
410
+ });
411
+ };
412
+ var normalizedOpts = normalizeOptions(productOptionItem);
399
413
  var bundleArr = Array.isArray(productBundle) ? productBundle : [];
400
414
  var normalizedBundles = bundleArr.map(function (item) {
401
- var _ref2, _item$bundle_id;
415
+ var _ref2, _item$bundle_id, _item$bundle_variant_;
402
416
  return {
403
417
  bundle_id: Number((_ref2 = (_item$bundle_id = item === null || item === void 0 ? void 0 : item.bundle_id) !== null && _item$bundle_id !== void 0 ? _item$bundle_id : item === null || item === void 0 ? void 0 : item.id) !== null && _ref2 !== void 0 ? _ref2 : 0) || 0,
404
418
  product_id: Number(item === null || item === void 0 ? void 0 : item.product_id) || 0,
405
- num: typeof (item === null || item === void 0 ? void 0 : item.num) === 'number' && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1
419
+ product_variant_id: Number((_item$bundle_variant_ = item === null || item === void 0 ? void 0 : item.bundle_variant_id) !== null && _item$bundle_variant_ !== void 0 ? _item$bundle_variant_ : item === null || item === void 0 ? void 0 : item.product_variant_id) || 0,
420
+ num: typeof (item === null || item === void 0 ? void 0 : item.num) === 'number' && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
421
+ option: normalizeOptions(item === null || item === void 0 ? void 0 : item.option)
406
422
  };
407
423
  }).sort(function (p, q) {
408
424
  if (p.bundle_id !== q.bundle_id) return p.bundle_id - q.bundle_id;
409
425
  if (p.product_id !== q.product_id) return p.product_id - q.product_id;
410
- return p.num - q.num;
426
+ if (p.product_variant_id !== q.product_variant_id) {
427
+ return p.product_variant_id - q.product_variant_id;
428
+ }
429
+ if (p.num !== q.num) return p.num - q.num;
430
+ return JSON.stringify(p.option).localeCompare(JSON.stringify(q.option));
411
431
  });
412
432
  return JSON.stringify([normalizedOpts, normalizedBundles]);
413
433
  }
@@ -482,11 +502,11 @@ export function getProductIdentityIndex(products, identity) {
482
502
  * - 因此多次 normalize 不会重复叠加 option/bundle。
483
503
  */
484
504
  export function normalizeOrderProduct(product) {
485
- var _product$metadata, _metadata$origin, _product$product_sku, _metadata$origin2, _variantList$find, _product$is_charge_ta;
505
+ var _product$metadata2, _metadata$origin, _product$product_sku, _metadata$origin2, _variantList$find, _product$is_charge_ta;
486
506
  var metadata = _objectSpread({}, product.metadata || {});
487
507
  // 不透明 identity 契约:每条订单行必须带 identity_key。
488
508
  // 调用方未传时由 SDK 自动生成 UUID,后续 update/remove 只做严格比对,避免猜测合成 key。
489
- var resolvedIdentityKey = (_product$metadata = product.metadata) !== null && _product$metadata !== void 0 && _product$metadata.unique_identification_number ? String(product.metadata.unique_identification_number) : product.unique_identification_number && String(product.unique_identification_number).length > 0 ? String(product.unique_identification_number) : product.identity_key && String(product.identity_key).length > 0 ? String(product.identity_key) : createUuidV4();
509
+ var resolvedIdentityKey = (_product$metadata2 = product.metadata) !== null && _product$metadata2 !== void 0 && _product$metadata2.unique_identification_number ? String(product.metadata.unique_identification_number) : product.unique_identification_number && String(product.unique_identification_number).length > 0 ? String(product.unique_identification_number) : product.identity_key && String(product.identity_key).length > 0 ? String(product.identity_key) : createUuidV4();
490
510
  metadata.unique_identification_number = resolvedIdentityKey;
491
511
  var priceOverride = metadata.price_override;
492
512
  var originOtherBundle = (_metadata$origin = metadata.origin) === null || _metadata$origin === void 0 || (_metadata$origin = _metadata$origin._extend) === null || _metadata$origin === void 0 || (_metadata$origin = _metadata$origin.other) === null || _metadata$origin === void 0 ? void 0 : _metadata$origin.bundle;
@@ -695,23 +715,55 @@ export function collectLinkProductIdsFromReservationRules(rules) {
695
715
  }
696
716
 
697
717
  /**
698
- * 返回列表中第一个带有效 duration.value(分钟)的商品时长。
718
+ * 找到第一个归属指定桌台的预约规则商品。
719
+ * 归属判断基于商品资源中的 default_resource / optional_resource。
699
720
  */
700
- export function pickFirstDurationMinutesFromProducts(products) {
721
+ export function findReservationRuleProductByResourceId(products, resourceId) {
722
+ var numericResourceId = Number(resourceId);
723
+ if (!Number.isFinite(numericResourceId) || numericResourceId <= 0) return undefined;
701
724
  var _iterator7 = _createForOfIteratorHelper(products),
702
725
  _step7;
703
726
  try {
704
727
  for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
705
- var _product$duration;
728
+ var _product$product_reso;
706
729
  var product = _step7.value;
730
+ var resources = product === null || product === void 0 || (_product$product_reso = product.product_resource) === null || _product$product_reso === void 0 ? void 0 : _product$product_reso.resources;
731
+ if (!Array.isArray(resources)) continue;
732
+ var hasMatchedResource = resources.some(function (resource) {
733
+ var defaultResources = Array.isArray(resource === null || resource === void 0 ? void 0 : resource.default_resource) ? resource.default_resource : [];
734
+ var optionalResources = Array.isArray(resource === null || resource === void 0 ? void 0 : resource.optional_resource) ? resource.optional_resource : [];
735
+ return [].concat(_toConsumableArray(defaultResources), _toConsumableArray(optionalResources)).some(function (id) {
736
+ return Number(id) === numericResourceId;
737
+ });
738
+ });
739
+ if (hasMatchedResource) return product;
740
+ }
741
+ } catch (err) {
742
+ _iterator7.e(err);
743
+ } finally {
744
+ _iterator7.f();
745
+ }
746
+ return undefined;
747
+ }
748
+
749
+ /**
750
+ * 返回列表中第一个带有效 duration.value(分钟)的商品时长。
751
+ */
752
+ export function pickFirstDurationMinutesFromProducts(products) {
753
+ var _iterator8 = _createForOfIteratorHelper(products),
754
+ _step8;
755
+ try {
756
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
757
+ var _product$duration;
758
+ var product = _step8.value;
707
759
  var value = product === null || product === void 0 || (_product$duration = product.duration) === null || _product$duration === void 0 ? void 0 : _product$duration.value;
708
760
  var n = Number(value);
709
761
  if (Number.isFinite(n) && n > 0) return Math.floor(n);
710
762
  }
711
763
  } catch (err) {
712
- _iterator7.e(err);
764
+ _iterator8.e(err);
713
765
  } finally {
714
- _iterator7.f();
766
+ _iterator8.f();
715
767
  }
716
768
  return undefined;
717
769
  }
@@ -741,11 +793,11 @@ export function computeResourceIsFull(params) {
741
793
  if (!Number.isFinite(totalCapacity) || totalCapacity <= 0) return false;
742
794
  var now = dayjs();
743
795
  var occupied = 0;
744
- var _iterator8 = _createForOfIteratorHelper(capacityList || []),
745
- _step8;
796
+ var _iterator9 = _createForOfIteratorHelper(capacityList || []),
797
+ _step9;
746
798
  try {
747
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
748
- var slot = _step8.value;
799
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
800
+ var slot = _step9.value;
749
801
  var start = dayjs(slot === null || slot === void 0 ? void 0 : slot.start_at);
750
802
  var end = dayjs(slot === null || slot === void 0 ? void 0 : slot.end_at);
751
803
  if (!start.isValid() || !end.isValid()) continue;
@@ -755,9 +807,9 @@ export function computeResourceIsFull(params) {
755
807
  }
756
808
  }
757
809
  } catch (err) {
758
- _iterator8.e(err);
810
+ _iterator9.e(err);
759
811
  } finally {
760
- _iterator8.f();
812
+ _iterator9.f();
761
813
  }
762
814
  return occupied >= totalCapacity;
763
815
  }
@@ -767,11 +819,11 @@ export function computeResourceIsFull(params) {
767
819
  * 仅返回有限数字字段;若均无法解析则返回 `undefined`。
768
820
  */
769
821
  export function pickFirstCustomCapacityPaxBounds(products) {
770
- var _iterator9 = _createForOfIteratorHelper(products),
771
- _step9;
822
+ var _iterator10 = _createForOfIteratorHelper(products),
823
+ _step10;
772
824
  try {
773
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
774
- var p = _step9.value;
825
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
826
+ var p = _step10.value;
775
827
  var cap = p === null || p === void 0 ? void 0 : p.capacity;
776
828
  if (!cap || cap.type !== 'custom') continue;
777
829
  if (!Array.isArray(cap.custom) || cap.custom.length === 0) continue;
@@ -790,9 +842,9 @@ export function pickFirstCustomCapacityPaxBounds(products) {
790
842
  if (out.min !== undefined || out.max !== undefined) return out;
791
843
  }
792
844
  } catch (err) {
793
- _iterator9.e(err);
845
+ _iterator10.e(err);
794
846
  } finally {
795
- _iterator9.f();
847
+ _iterator10.f();
796
848
  }
797
849
  return undefined;
798
850
  }
@@ -802,11 +854,11 @@ export function pickFirstCustomCapacityPaxBounds(products) {
802
854
  * 无匹配时返回 `undefined`,调用方应回退为 `0`。
803
855
  */
804
856
  export function pickFirstCustomCapacityDimensionId(products) {
805
- var _iterator10 = _createForOfIteratorHelper(products),
806
- _step10;
857
+ var _iterator11 = _createForOfIteratorHelper(products),
858
+ _step11;
807
859
  try {
808
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
809
- var p = _step10.value;
860
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
861
+ var p = _step11.value;
810
862
  var cap = p === null || p === void 0 ? void 0 : p.capacity;
811
863
  if (!cap || cap.type !== 'custom') continue;
812
864
  if (!Array.isArray(cap.custom) || cap.custom.length === 0) continue;
@@ -822,9 +874,9 @@ export function pickFirstCustomCapacityDimensionId(products) {
822
874
  }
823
875
  }
824
876
  } catch (err) {
825
- _iterator10.e(err);
877
+ _iterator11.e(err);
826
878
  } finally {
827
- _iterator10.f();
879
+ _iterator11.f();
828
880
  }
829
881
  return undefined;
830
882
  }
@@ -40,6 +40,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
40
40
  discountList: Discount[];
41
41
  };
42
42
  setProductList(productList: Record<string, any>[]): void;
43
+ batchSearchByProductIds(productIds: number[]): Promise<Discount[]>;
43
44
  scanCode(code: string, customerId?: number): Promise<{
44
45
  isAvailable: boolean;
45
46
  productList: Record<string, any>[];