@pisell/pisellos 0.0.568 → 0.10.1

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 (588) hide show
  1. package/dist/core/index.js +10 -6
  2. package/dist/index.d.ts +0 -1
  3. package/dist/index.js +0 -3
  4. package/dist/model/strategy/adapter/promotion/evaluator.js +3 -2
  5. package/dist/model/strategy/adapter/walletPass/evaluator.js +7 -5
  6. package/dist/model/strategy/adapter/walletPass/example.js +26 -3
  7. package/dist/model/strategy/adapter/walletPass/index.js +5 -5
  8. package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -3
  9. package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -26
  10. package/dist/model/strategy/adapter/walletPass/utils.js +24 -96
  11. package/dist/model/strategy/strategy-example.js +19 -5
  12. package/dist/modules/BaseModule.d.ts +2 -2
  13. package/dist/modules/BaseModule.js +12 -14
  14. package/dist/modules/BookingContext/index.d.ts +48 -0
  15. package/dist/modules/BookingContext/index.js +566 -0
  16. package/dist/modules/BookingContext/types.d.ts +102 -0
  17. package/dist/modules/BookingContext/types.js +51 -0
  18. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  19. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +302 -0
  20. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  21. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +149 -0
  22. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
  23. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +249 -0
  24. package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
  25. package/dist/modules/BookingContext/utils/flexible.js +56 -0
  26. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  27. package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
  28. package/dist/modules/BookingContext/utils/index.d.ts +11 -0
  29. package/dist/modules/BookingContext/utils/index.js +11 -0
  30. package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
  31. package/dist/modules/BookingContext/utils/noResource.js +77 -0
  32. package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
  33. package/dist/modules/BookingContext/utils/orderLineDisplay.js +36 -0
  34. package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
  35. package/dist/modules/BookingContext/utils/productExtend.js +339 -0
  36. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  37. package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
  38. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  39. package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
  40. package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
  41. package/dist/modules/BookingContext/utils/resources.js +486 -0
  42. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  43. package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
  44. package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  45. package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
  46. package/dist/modules/Cart/index.js +3 -0
  47. package/dist/modules/Cart/utils/cartProduct.js +27 -5
  48. package/dist/modules/Cart/utils/cartResource.js +0 -2
  49. package/dist/modules/Cart/utils/changePrice.js +11 -11
  50. package/dist/modules/Customer/index.d.ts +20 -0
  51. package/dist/modules/Customer/index.js +172 -83
  52. package/dist/modules/Customer/types.d.ts +2 -0
  53. package/dist/modules/Date/index.js +5 -1
  54. package/dist/modules/Discount/index.d.ts +2 -2
  55. package/dist/modules/Discount/index.js +43 -30
  56. package/dist/modules/Discount/types.d.ts +1 -1
  57. package/dist/modules/OpenData/index.d.ts +8 -0
  58. package/dist/modules/OpenData/index.js +38 -16
  59. package/dist/modules/Order/index.d.ts +449 -24
  60. package/dist/modules/Order/index.js +5460 -574
  61. package/dist/modules/Order/types.d.ts +693 -88
  62. package/dist/modules/Order/types.js +68 -1
  63. package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
  64. package/dist/modules/Order/utils/bundleDiscountHydration.js +144 -0
  65. package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  66. package/dist/modules/Order/utils/manualProductDiscount.js +210 -0
  67. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  68. package/dist/modules/Order/utils/orderCollectionIdentity.js +405 -0
  69. package/dist/modules/Order/utils.d.ts +167 -18
  70. package/dist/modules/Order/utils.js +960 -165
  71. package/dist/modules/Payment/index.d.ts +10 -9
  72. package/dist/modules/Payment/index.js +573 -746
  73. package/dist/modules/Payment/types.d.ts +44 -24
  74. package/dist/modules/Payment/utils.d.ts +1 -1
  75. package/dist/modules/Payment/utils.js +4 -3
  76. package/dist/modules/Payment/walletpass.d.ts +0 -2
  77. package/dist/modules/Payment/walletpass.js +49 -33
  78. package/dist/modules/Product/types.d.ts +29 -7
  79. package/dist/modules/ProductList/index.d.ts +17 -13
  80. package/dist/modules/ProductList/index.js +182 -81
  81. package/dist/modules/ProductList/types.d.ts +16 -0
  82. package/dist/modules/Quotation/index.d.ts +22 -2
  83. package/dist/modules/Quotation/index.js +108 -42
  84. package/dist/modules/Quotation/types.d.ts +19 -0
  85. package/dist/modules/ResourcePlanner/index.d.ts +24 -0
  86. package/dist/modules/ResourcePlanner/index.js +181 -0
  87. package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
  88. package/dist/modules/ResourcePlanner/planner.js +1069 -0
  89. package/dist/modules/ResourcePlanner/types.d.ts +227 -0
  90. package/dist/modules/ResourcePlanner/types.js +1 -0
  91. package/dist/modules/Rules/index.d.ts +8 -10
  92. package/dist/modules/Rules/index.js +324 -513
  93. package/dist/modules/Rules/types.d.ts +14 -3
  94. package/dist/modules/SalesSummary/index.d.ts +23 -26
  95. package/dist/modules/SalesSummary/index.js +152 -46
  96. package/dist/modules/SalesSummary/types.d.ts +9 -1
  97. package/dist/modules/SalesSummary/utils.d.ts +3 -22
  98. package/dist/modules/SalesSummary/utils.js +804 -165
  99. package/dist/modules/Schedule/getDateIsInSchedule.js +14 -12
  100. package/dist/modules/Schedule/index.d.ts +18 -5
  101. package/dist/modules/Schedule/index.js +79 -24
  102. package/dist/modules/Schedule/types.d.ts +2 -0
  103. package/dist/modules/Schedule/utils.js +1 -0
  104. package/dist/modules/Step/index.js +1 -0
  105. package/dist/modules/Summary/index.js +4 -3
  106. package/dist/modules/Summary/utils.js +22 -43
  107. package/dist/modules/SurchargeList/index.d.ts +18 -0
  108. package/dist/modules/SurchargeList/index.js +185 -0
  109. package/dist/modules/SurchargeList/types.d.ts +15 -0
  110. package/dist/modules/SurchargeList/types.js +1 -0
  111. package/dist/modules/index.d.ts +3 -0
  112. package/dist/modules/index.js +4 -1
  113. package/dist/plugins/app.d.ts +2 -0
  114. package/dist/plugins/request.d.ts +1 -0
  115. package/dist/plugins/request.js +4 -1
  116. package/dist/plugins/window.js +6 -2
  117. package/dist/server/index.d.ts +462 -8
  118. package/dist/server/index.js +6168 -680
  119. package/dist/server/modules/floor-plan/index.d.ts +39 -0
  120. package/dist/server/modules/floor-plan/index.js +595 -0
  121. package/dist/server/modules/floor-plan/types.d.ts +43 -0
  122. package/dist/server/modules/floor-plan/types.js +13 -0
  123. package/dist/server/modules/index.d.ts +7 -2
  124. package/dist/server/modules/index.js +6 -0
  125. package/dist/server/modules/menu/index.js +41 -32
  126. package/dist/server/modules/order/index.d.ts +207 -14
  127. package/dist/server/modules/order/index.js +2328 -379
  128. package/dist/server/modules/order/types.d.ts +76 -5
  129. package/dist/server/modules/order/types.js +14 -1
  130. package/dist/server/modules/order/utils/filterBookings.d.ts +7 -1
  131. package/dist/server/modules/order/utils/filterBookings.js +118 -11
  132. package/dist/server/modules/order/utils/filterOrders.js +242 -14
  133. package/dist/server/modules/payment/index.d.ts +28 -0
  134. package/dist/server/modules/payment/index.js +305 -0
  135. package/dist/server/modules/payment/types.d.ts +9 -0
  136. package/dist/server/modules/payment/types.js +1 -0
  137. package/dist/server/modules/products/index.d.ts +105 -14
  138. package/dist/server/modules/products/index.js +1416 -521
  139. package/dist/server/modules/products/types.d.ts +34 -1
  140. package/dist/server/modules/products/types.js +4 -0
  141. package/dist/server/modules/quotation/index.d.ts +39 -0
  142. package/dist/server/modules/quotation/index.js +298 -77
  143. package/dist/server/modules/resource/index.d.ts +2 -3
  144. package/dist/server/modules/resource/index.js +109 -86
  145. package/dist/server/modules/schedule/index.d.ts +6 -4
  146. package/dist/server/modules/schedule/index.js +145 -106
  147. package/dist/server/test.json +713 -0
  148. package/dist/server/types.d.ts +2 -0
  149. package/dist/server/utils/product.js +3 -2
  150. package/dist/server/utils/small-ticket.d.ts +71 -0
  151. package/dist/server/utils/small-ticket.js +963 -0
  152. package/dist/solution/BaseSales/index.d.ts +378 -0
  153. package/dist/solution/BaseSales/index.js +4009 -0
  154. package/dist/solution/BaseSales/types.d.ts +394 -0
  155. package/dist/solution/BaseSales/types.js +40 -0
  156. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
  157. package/dist/solution/BaseSales/utils/cartPromotion.js +1450 -0
  158. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +144 -0
  159. package/dist/solution/BaseSales/utils/parseSalesResponse.js +157 -0
  160. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +18 -0
  161. package/dist/solution/BaseSales/utils/quotationPrice.js +250 -0
  162. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +63 -0
  163. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +218 -0
  164. package/dist/solution/BaseSales/utils.d.ts +40 -0
  165. package/dist/solution/BaseSales/utils.js +263 -0
  166. package/dist/solution/BookingByStep/index.d.ts +1 -1
  167. package/dist/solution/BookingByStep/index.js +60 -11
  168. package/dist/solution/BookingByStep/utils/capacity.js +11 -1
  169. package/dist/solution/BookingByStep/utils/resources.js +3 -1
  170. package/dist/solution/BookingByStep/utils/timeslots.js +43 -2
  171. package/dist/solution/BookingTicket/index.d.ts +393 -24
  172. package/dist/solution/BookingTicket/index.js +2508 -443
  173. package/dist/solution/BookingTicket/types.d.ts +191 -6
  174. package/dist/solution/BookingTicket/types.js +83 -10
  175. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
  176. package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
  177. package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
  178. package/dist/solution/BookingTicket/utils/addTimeAvailability.js +95 -0
  179. package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
  180. package/dist/solution/BookingTicket/utils/bookingStatus.js +136 -0
  181. package/dist/solution/BookingTicket/utils/cartView.d.ts +29 -0
  182. package/dist/solution/BookingTicket/utils/cartView.js +209 -0
  183. package/dist/solution/BookingTicket/utils/exampleData.d.ts +123 -0
  184. package/dist/solution/BookingTicket/utils/exampleData.js +183 -0
  185. package/dist/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
  186. package/dist/solution/BookingTicket/utils/orderCustomer.js +31 -0
  187. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
  188. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +438 -0
  189. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
  190. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +400 -0
  191. package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +4 -0
  192. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +42 -1
  193. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
  194. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +56 -0
  195. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  196. package/dist/solution/BookingTicket/utils/scan/handleScan.js +42 -28
  197. package/dist/solution/BookingTicket/utils/scan/index.d.ts +5 -0
  198. package/dist/solution/BookingTicket/utils/scan/index.js +30 -14
  199. package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
  200. package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +150 -0
  201. package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
  202. package/dist/solution/BookingTicket/utils/sessionCatalogStale.js +78 -0
  203. package/dist/solution/BuyTickets/index.js +12 -9
  204. package/dist/solution/Checkout/index.d.ts +1 -0
  205. package/dist/solution/Checkout/index.js +275 -209
  206. package/dist/solution/Checkout/utils/index.js +20 -8
  207. package/dist/solution/RegisterAndLogin/config.js +2 -10
  208. package/dist/solution/RegisterAndLogin/index.js +76 -30
  209. package/dist/solution/Sales/index.d.ts +50 -5
  210. package/dist/solution/Sales/index.js +484 -92
  211. package/dist/solution/Sales/types.d.ts +26 -2
  212. package/dist/solution/ScanOrder/index.d.ts +27 -21
  213. package/dist/solution/ScanOrder/index.js +519 -444
  214. package/dist/solution/ScanOrder/types.d.ts +33 -11
  215. package/dist/solution/ScanOrder/types.js +4 -5
  216. package/dist/solution/ScanOrder/utils.d.ts +4 -1
  217. package/dist/solution/ScanOrder/utils.js +109 -34
  218. package/dist/solution/ShopDiscount/index.js +18 -19
  219. package/dist/solution/ShopDiscount/types.d.ts +4 -5
  220. package/dist/solution/ShopDiscount/utils.d.ts +0 -9
  221. package/dist/solution/ShopDiscount/utils.js +0 -9
  222. package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
  223. package/dist/solution/UnifiedBookingSales/index.js +1871 -0
  224. package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
  225. package/dist/solution/UnifiedBookingSales/types.js +11 -0
  226. package/dist/solution/VenueBooking/index.d.ts +32 -51
  227. package/dist/solution/VenueBooking/index.js +741 -808
  228. package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -2
  229. package/dist/solution/VenueBooking/types.d.ts +1 -3
  230. package/dist/solution/VenueBooking/types.js +0 -1
  231. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  232. package/dist/solution/VenueBooking/utils/dateSummary.js +25 -12
  233. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
  234. package/dist/solution/VenueBooking/utils/slotMerge.js +9 -3
  235. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
  236. package/dist/solution/VenueBooking/utils/timeSlot.js +4 -9
  237. package/dist/solution/index.d.ts +2 -0
  238. package/dist/solution/index.js +3 -1
  239. package/dist/types/index.d.ts +12 -2
  240. package/dist/utils/task.js +18 -15
  241. package/dist/utils/watch.js +1 -0
  242. package/lib/apis/picoding.js +0 -2
  243. package/lib/core/index.js +132 -130
  244. package/lib/effects/index.js +57 -46
  245. package/lib/index.d.ts +0 -1
  246. package/lib/index.js +50 -92
  247. package/lib/model/index.js +21 -14
  248. package/lib/model/strategy/adapter/dataVariant/adapter.js +50 -38
  249. package/lib/model/strategy/adapter/dataVariant/evaluator.js +236 -162
  250. package/lib/model/strategy/adapter/dataVariant/examples.js +237 -229
  251. package/lib/model/strategy/adapter/dataVariant/index.js +34 -39
  252. package/lib/model/strategy/adapter/dataVariant/type.js +28 -57
  253. package/lib/model/strategy/adapter/index.js +64 -100
  254. package/lib/model/strategy/adapter/itemRule/adapter.js +144 -156
  255. package/lib/model/strategy/adapter/itemRule/evaluator.js +48 -36
  256. package/lib/model/strategy/adapter/itemRule/examples.js +225 -295
  257. package/lib/model/strategy/adapter/itemRule/index.js +57 -83
  258. package/lib/model/strategy/adapter/itemRule/type.js +36 -97
  259. package/lib/model/strategy/adapter/promotion/adapter.js +63 -84
  260. package/lib/model/strategy/adapter/promotion/evaluator.js +233 -382
  261. package/lib/model/strategy/adapter/promotion/examples.js +159 -139
  262. package/lib/model/strategy/adapter/promotion/index.js +0 -1
  263. package/lib/model/strategy/adapter/promotion/type.js +35 -199
  264. package/lib/model/strategy/adapter/type.js +16 -4
  265. package/lib/model/strategy/adapter/walletPass/evaluator.js +152 -180
  266. package/lib/model/strategy/adapter/walletPass/example.js +190 -217
  267. package/lib/model/strategy/adapter/walletPass/index.js +51 -75
  268. package/lib/model/strategy/adapter/walletPass/locales.js +58 -36
  269. package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -3
  270. package/lib/model/strategy/adapter/walletPass/type.js +16 -4
  271. package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -26
  272. package/lib/model/strategy/adapter/walletPass/utils.js +383 -676
  273. package/lib/model/strategy/engine.js +168 -270
  274. package/lib/model/strategy/index.js +34 -49
  275. package/lib/model/strategy/strategy-example.js +239 -243
  276. package/lib/model/strategy/type.js +40 -100
  277. package/lib/modules/Account/index.js +53 -39
  278. package/lib/modules/Account/types.js +33 -20
  279. package/lib/modules/AccountList/index.js +154 -116
  280. package/lib/modules/AccountList/types.js +31 -30
  281. package/lib/modules/AccountList/utils.js +30 -18
  282. package/lib/modules/BaseModule.d.ts +2 -2
  283. package/lib/modules/BaseModule.js +50 -29
  284. package/lib/modules/BookingContext/index.d.ts +48 -0
  285. package/lib/modules/BookingContext/index.js +368 -0
  286. package/lib/modules/BookingContext/types.d.ts +102 -0
  287. package/lib/modules/BookingContext/types.js +34 -0
  288. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  289. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +298 -0
  290. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  291. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +155 -0
  292. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
  293. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +222 -0
  294. package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
  295. package/lib/modules/BookingContext/utils/flexible.js +80 -0
  296. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  297. package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
  298. package/lib/modules/BookingContext/utils/index.d.ts +11 -0
  299. package/lib/modules/BookingContext/utils/index.js +43 -0
  300. package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
  301. package/lib/modules/BookingContext/utils/noResource.js +90 -0
  302. package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
  303. package/lib/modules/BookingContext/utils/orderLineDisplay.js +56 -0
  304. package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
  305. package/lib/modules/BookingContext/utils/productExtend.js +283 -0
  306. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  307. package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
  308. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  309. package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
  310. package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
  311. package/lib/modules/BookingContext/utils/resources.js +377 -0
  312. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  313. package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
  314. package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  315. package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
  316. package/lib/modules/Cart/index.js +124 -170
  317. package/lib/modules/Cart/types.js +51 -46
  318. package/lib/modules/Cart/utils/cartAccount.js +39 -40
  319. package/lib/modules/Cart/utils/cartDate.js +61 -56
  320. package/lib/modules/Cart/utils/cartDiscount.js +33 -28
  321. package/lib/modules/Cart/utils/cartNote.js +32 -27
  322. package/lib/modules/Cart/utils/cartProduct.js +261 -309
  323. package/lib/modules/Cart/utils/cartRelationForms.js +35 -29
  324. package/lib/modules/Cart/utils/cartResource.js +78 -72
  325. package/lib/modules/Cart/utils/changePrice.js +59 -31
  326. package/lib/modules/Cart/utils/index.js +48 -106
  327. package/lib/modules/Customer/constants.js +34 -13
  328. package/lib/modules/Customer/index.d.ts +20 -0
  329. package/lib/modules/Customer/index.js +207 -217
  330. package/lib/modules/Customer/types.d.ts +2 -0
  331. package/lib/modules/Customer/types.js +35 -38
  332. package/lib/modules/Date/index.js +115 -116
  333. package/lib/modules/Date/types.js +28 -16
  334. package/lib/modules/Date/utils.js +123 -174
  335. package/lib/modules/Discount/index.d.ts +2 -2
  336. package/lib/modules/Discount/index.js +133 -119
  337. package/lib/modules/Discount/types.d.ts +1 -1
  338. package/lib/modules/Discount/types.js +31 -9
  339. package/lib/modules/Guests/index.js +56 -30
  340. package/lib/modules/Guests/types.js +33 -23
  341. package/lib/modules/Holder/index.js +189 -209
  342. package/lib/modules/Holder/types.js +16 -4
  343. package/lib/modules/Holder/utils.js +49 -20
  344. package/lib/modules/OpenData/index.d.ts +8 -0
  345. package/lib/modules/OpenData/index.js +88 -63
  346. package/lib/modules/OpenData/types.js +16 -4
  347. package/lib/modules/OpenData/utils.js +78 -44
  348. package/lib/modules/Order/index.d.ts +449 -24
  349. package/lib/modules/Order/index.js +4184 -514
  350. package/lib/modules/Order/types.d.ts +693 -88
  351. package/lib/modules/Order/types.js +35 -24
  352. package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
  353. package/lib/modules/Order/utils/bundleDiscountHydration.js +139 -0
  354. package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  355. package/lib/modules/Order/utils/manualProductDiscount.js +206 -0
  356. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  357. package/lib/modules/Order/utils/orderCollectionIdentity.js +415 -0
  358. package/lib/modules/Order/utils.d.ts +167 -18
  359. package/lib/modules/Order/utils.js +1085 -414
  360. package/lib/modules/Payment/cash.js +33 -20
  361. package/lib/modules/Payment/cashRecommendationAlgorithm.js +76 -145
  362. package/lib/modules/Payment/eftpos.js +30 -16
  363. package/lib/modules/Payment/index.d.ts +10 -9
  364. package/lib/modules/Payment/index.js +402 -636
  365. package/lib/modules/Payment/mx51.js +0 -1
  366. package/lib/modules/Payment/types.d.ts +44 -24
  367. package/lib/modules/Payment/types.js +107 -216
  368. package/lib/modules/Payment/utils.d.ts +1 -1
  369. package/lib/modules/Payment/utils.js +50 -52
  370. package/lib/modules/Payment/walletpass.d.ts +0 -2
  371. package/lib/modules/Payment/walletpass.js +216 -221
  372. package/lib/modules/Product/index.js +46 -51
  373. package/lib/modules/Product/types.d.ts +29 -7
  374. package/lib/modules/Product/types.js +16 -4
  375. package/lib/modules/Product/utils.js +33 -32
  376. package/lib/modules/ProductList/index.d.ts +17 -13
  377. package/lib/modules/ProductList/index.js +161 -120
  378. package/lib/modules/ProductList/types.d.ts +16 -0
  379. package/lib/modules/ProductList/types.js +31 -9
  380. package/lib/modules/Quotation/index.d.ts +22 -2
  381. package/lib/modules/Quotation/index.js +154 -64
  382. package/lib/modules/Quotation/types.d.ts +19 -0
  383. package/lib/modules/Quotation/types.js +16 -4
  384. package/lib/modules/Resource/index.js +59 -27
  385. package/lib/modules/Resource/types.js +32 -22
  386. package/lib/modules/Resource/utils.js +38 -30
  387. package/lib/modules/ResourcePlanner/index.d.ts +24 -0
  388. package/lib/modules/ResourcePlanner/index.js +148 -0
  389. package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
  390. package/lib/modules/ResourcePlanner/planner.js +933 -0
  391. package/lib/modules/ResourcePlanner/types.d.ts +227 -0
  392. package/lib/modules/ResourcePlanner/types.js +17 -0
  393. package/lib/modules/Rules/index.d.ts +8 -10
  394. package/lib/modules/Rules/index.js +960 -1440
  395. package/lib/modules/Rules/types.d.ts +14 -3
  396. package/lib/modules/Rules/types.js +40 -17
  397. package/lib/modules/SalesSummary/index.d.ts +23 -26
  398. package/lib/modules/SalesSummary/index.js +134 -61
  399. package/lib/modules/SalesSummary/types.d.ts +9 -1
  400. package/lib/modules/SalesSummary/types.js +16 -4
  401. package/lib/modules/SalesSummary/utils.d.ts +3 -22
  402. package/lib/modules/SalesSummary/utils.js +814 -233
  403. package/lib/modules/ScanOrderLogger/index.js +79 -59
  404. package/lib/modules/ScanOrderLogger/providers/feishu.js +78 -54
  405. package/lib/modules/ScanOrderLogger/providers/grafana.js +36 -13
  406. package/lib/modules/ScanOrderLogger/types.js +16 -4
  407. package/lib/modules/Schedule/getDateIsInSchedule.js +169 -338
  408. package/lib/modules/Schedule/index.d.ts +18 -5
  409. package/lib/modules/Schedule/index.js +153 -104
  410. package/lib/modules/Schedule/type.js +16 -4
  411. package/lib/modules/Schedule/types.d.ts +2 -0
  412. package/lib/modules/Schedule/types.js +16 -4
  413. package/lib/modules/Schedule/utils.js +291 -433
  414. package/lib/modules/Step/index.js +52 -40
  415. package/lib/modules/Step/tyeps.js +16 -4
  416. package/lib/modules/Summary/index.js +71 -66
  417. package/lib/modules/Summary/types.js +16 -4
  418. package/lib/modules/Summary/utils.js +418 -791
  419. package/lib/modules/SurchargeList/index.d.ts +18 -0
  420. package/lib/modules/SurchargeList/index.js +109 -0
  421. package/lib/modules/SurchargeList/types.d.ts +15 -0
  422. package/lib/modules/SurchargeList/types.js +17 -0
  423. package/lib/modules/index.d.ts +3 -0
  424. package/lib/modules/index.js +63 -212
  425. package/lib/plugins/app.d.ts +2 -0
  426. package/lib/plugins/app.js +16 -4
  427. package/lib/plugins/index.js +25 -36
  428. package/lib/plugins/request.d.ts +1 -0
  429. package/lib/plugins/request.js +126 -137
  430. package/lib/plugins/shopStore.js +16 -4
  431. package/lib/plugins/user.js +16 -4
  432. package/lib/plugins/window.js +179 -171
  433. package/lib/server/index.d.ts +462 -8
  434. package/lib/server/index.js +4520 -1162
  435. package/lib/server/modules/floor-plan/index.d.ts +39 -0
  436. package/lib/server/modules/floor-plan/index.js +327 -0
  437. package/lib/server/modules/floor-plan/types.d.ts +43 -0
  438. package/lib/server/modules/floor-plan/types.js +34 -0
  439. package/lib/server/modules/index.d.ts +7 -2
  440. package/lib/server/modules/index.js +67 -84
  441. package/lib/server/modules/menu/index.js +122 -146
  442. package/lib/server/modules/menu/types.js +31 -18
  443. package/lib/server/modules/order/index.d.ts +207 -14
  444. package/lib/server/modules/order/index.js +1543 -285
  445. package/lib/server/modules/order/types.d.ts +76 -5
  446. package/lib/server/modules/order/types.js +32 -107
  447. package/lib/server/modules/order/utils/filterBookings.d.ts +7 -1
  448. package/lib/server/modules/order/utils/filterBookings.js +259 -176
  449. package/lib/server/modules/order/utils/filterOrders.js +293 -94
  450. package/lib/server/modules/payment/index.d.ts +28 -0
  451. package/lib/server/modules/payment/index.js +192 -0
  452. package/lib/server/modules/payment/types.d.ts +9 -0
  453. package/lib/server/modules/payment/types.js +17 -0
  454. package/lib/server/modules/products/index.d.ts +105 -14
  455. package/lib/server/modules/products/index.js +850 -475
  456. package/lib/server/modules/products/types.d.ts +34 -1
  457. package/lib/server/modules/products/types.js +34 -41
  458. package/lib/server/modules/quotation/index.d.ts +39 -0
  459. package/lib/server/modules/quotation/index.js +254 -75
  460. package/lib/server/modules/quotation/types.js +31 -21
  461. package/lib/server/modules/resource/index.d.ts +2 -3
  462. package/lib/server/modules/resource/index.js +240 -243
  463. package/lib/server/modules/resource/types.js +33 -42
  464. package/lib/server/modules/schedule/index.d.ts +6 -4
  465. package/lib/server/modules/schedule/index.js +146 -147
  466. package/lib/server/modules/schedule/types.js +21 -14
  467. package/lib/server/modules/schedule/utils.js +163 -334
  468. package/lib/server/test.json +713 -0
  469. package/lib/server/types.d.ts +2 -0
  470. package/lib/server/types.js +16 -4
  471. package/lib/server/utils/index.js +23 -25
  472. package/lib/server/utils/product.js +140 -197
  473. package/lib/server/utils/schedule.js +41 -34
  474. package/lib/server/utils/small-ticket.d.ts +71 -0
  475. package/lib/server/utils/small-ticket.js +904 -0
  476. package/lib/server/utils/time.js +49 -40
  477. package/lib/solution/BaseSales/index.d.ts +378 -0
  478. package/lib/solution/BaseSales/index.js +2533 -0
  479. package/lib/solution/BaseSales/types.d.ts +394 -0
  480. package/lib/solution/BaseSales/types.js +43 -0
  481. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
  482. package/lib/solution/BaseSales/utils/cartPromotion.js +1004 -0
  483. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +144 -0
  484. package/lib/solution/BaseSales/utils/parseSalesResponse.js +160 -0
  485. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +18 -0
  486. package/lib/solution/BaseSales/utils/quotationPrice.js +289 -0
  487. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +63 -0
  488. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +256 -0
  489. package/lib/solution/BaseSales/utils.d.ts +40 -0
  490. package/lib/solution/BaseSales/utils.js +244 -0
  491. package/lib/solution/BookingByStep/index.d.ts +1 -1
  492. package/lib/solution/BookingByStep/index.js +1340 -1530
  493. package/lib/solution/BookingByStep/types.js +99 -40
  494. package/lib/solution/BookingByStep/utils/capacity.js +160 -192
  495. package/lib/solution/BookingByStep/utils/products.js +52 -42
  496. package/lib/solution/BookingByStep/utils/resources.js +330 -527
  497. package/lib/solution/BookingByStep/utils/stock.js +44 -65
  498. package/lib/solution/BookingByStep/utils/timeslots.js +131 -129
  499. package/lib/solution/BookingTicket/index.d.ts +393 -24
  500. package/lib/solution/BookingTicket/index.js +1374 -184
  501. package/lib/solution/BookingTicket/types.d.ts +191 -6
  502. package/lib/solution/BookingTicket/types.js +79 -40
  503. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
  504. package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
  505. package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
  506. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +125 -0
  507. package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
  508. package/lib/solution/BookingTicket/utils/bookingStatus.js +107 -0
  509. package/lib/solution/BookingTicket/utils/cartView.d.ts +29 -0
  510. package/lib/solution/BookingTicket/utils/cartView.js +184 -0
  511. package/lib/solution/BookingTicket/utils/exampleData.d.ts +123 -0
  512. package/lib/solution/BookingTicket/utils/exampleData.js +0 -0
  513. package/lib/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
  514. package/lib/solution/BookingTicket/utils/orderCustomer.js +58 -0
  515. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
  516. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +254 -0
  517. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
  518. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +169 -0
  519. package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +4 -0
  520. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +97 -64
  521. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
  522. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +51 -0
  523. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  524. package/lib/solution/BookingTicket/utils/scan/handleScan.js +81 -82
  525. package/lib/solution/BookingTicket/utils/scan/index.d.ts +5 -0
  526. package/lib/solution/BookingTicket/utils/scan/index.js +109 -91
  527. package/lib/solution/BookingTicket/utils/scan/scanCache.js +43 -90
  528. package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
  529. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +127 -0
  530. package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
  531. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +85 -0
  532. package/lib/solution/BuyTickets/index.js +70 -67
  533. package/lib/solution/BuyTickets/types.js +38 -22
  534. package/lib/solution/Checkout/index.d.ts +1 -0
  535. package/lib/solution/Checkout/index.js +1169 -1463
  536. package/lib/solution/Checkout/types.js +61 -91
  537. package/lib/solution/Checkout/utils/index.js +156 -228
  538. package/lib/solution/PlaceOrder/index.js +0 -55
  539. package/lib/solution/RegisterAndLogin/config.js +462 -503
  540. package/lib/solution/RegisterAndLogin/index.js +630 -633
  541. package/lib/solution/RegisterAndLogin/types.js +76 -189
  542. package/lib/solution/RegisterAndLogin/utils.js +125 -183
  543. package/lib/solution/Sales/index.d.ts +50 -5
  544. package/lib/solution/Sales/index.js +498 -238
  545. package/lib/solution/Sales/types.d.ts +26 -2
  546. package/lib/solution/Sales/types.js +33 -27
  547. package/lib/solution/ScanOrder/index.d.ts +27 -21
  548. package/lib/solution/ScanOrder/index.js +936 -864
  549. package/lib/solution/ScanOrder/types.d.ts +33 -11
  550. package/lib/solution/ScanOrder/types.js +34 -34
  551. package/lib/solution/ScanOrder/utils.d.ts +4 -1
  552. package/lib/solution/ScanOrder/utils.js +422 -385
  553. package/lib/solution/ShopDiscount/index.js +233 -235
  554. package/lib/solution/ShopDiscount/types.d.ts +4 -5
  555. package/lib/solution/ShopDiscount/types.js +37 -15
  556. package/lib/solution/ShopDiscount/utils.d.ts +0 -9
  557. package/lib/solution/ShopDiscount/utils.js +172 -309
  558. package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
  559. package/lib/solution/UnifiedBookingSales/index.js +1076 -0
  560. package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
  561. package/lib/solution/UnifiedBookingSales/types.js +33 -0
  562. package/lib/solution/VenueBooking/index.d.ts +32 -51
  563. package/lib/solution/VenueBooking/index.js +1008 -984
  564. package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -2
  565. package/lib/solution/VenueBooking/types.d.ts +1 -3
  566. package/lib/solution/VenueBooking/types.js +39 -20
  567. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  568. package/lib/solution/VenueBooking/utils/dateSummary.js +62 -25
  569. package/lib/solution/VenueBooking/utils/resource.js +54 -31
  570. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
  571. package/lib/solution/VenueBooking/utils/slotMerge.js +109 -90
  572. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
  573. package/lib/solution/VenueBooking/utils/timeSlot.js +133 -138
  574. package/lib/solution/VenueBooking/utils.js +67 -130
  575. package/lib/solution/index.d.ts +2 -0
  576. package/lib/solution/index.js +41 -102
  577. package/lib/store/createStore.js +29 -32
  578. package/lib/types/index.d.ts +12 -2
  579. package/lib/types/index.js +16 -4
  580. package/lib/utils/task.js +36 -36
  581. package/lib/utils/watch.js +47 -81
  582. package/package.json +2 -4
  583. package/dist/solution/Checkout/appointmentDemo.json +0 -1
  584. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  585. package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
  586. package/lib/solution/Checkout/appointmentDemo.json +0 -1
  587. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  588. package/lib/solution/VenueBooking/utils/smartPricing.js +0 -192
@@ -1,114 +1,126 @@
1
- "use strict";
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
2
28
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
29
+ // src/solution/ScanOrder/utils.ts
30
+ var utils_exports = {};
31
+ __export(utils_exports, {
32
+ aggregateItemRuleLimit: () => aggregateItemRuleLimit,
33
+ attachItemRuleLimitsToTopLevelProducts: () => attachItemRuleLimitsToTopLevelProducts,
34
+ buildItemRuleBusinessData: () => buildItemRuleBusinessData,
35
+ buildProductKey: () => buildProductKey,
36
+ buildProductLineFingerprint: () => buildProductLineFingerprint,
37
+ buildQuantityLimitIndex: () => buildQuantityLimitIndex,
38
+ collectLinkProductIdsFromReservationRules: () => collectLinkProductIdsFromReservationRules,
39
+ computeResourceIsFull: () => computeResourceIsFull,
40
+ createEmptySummary: () => createEmptySummary,
41
+ extractStrategyModelIdsFromTableConfig: () => extractStrategyModelIdsFromTableConfig,
42
+ filterProductsForScanOrderMore: () => filterProductsForScanOrderMore,
43
+ findReservationRuleProductByResourceId: () => findReservationRuleProductByResourceId,
44
+ getProductIdentityIndex: () => getProductIdentityIndex,
45
+ getSafeProductNum: () => getSafeProductNum,
46
+ getTopLevelProductId: () => getTopLevelProductId,
47
+ getTopLevelVariantId: () => getTopLevelVariantId,
48
+ hasCustomCapacityProduct: () => hasCustomCapacityProduct,
49
+ isIdentityMatch: () => isIdentityMatch,
50
+ isSkuOnlyDeleteIdentity: () => isSkuOnlyDeleteIdentity,
51
+ normalizeEnabledItemRuleIds: () => normalizeEnabledItemRuleIds,
52
+ normalizeItemRuleStrategies: () => normalizeItemRuleStrategies,
53
+ normalizeOrderProduct: () => normalizeOrderProduct,
54
+ pickFirstCustomCapacityDimensionId: () => pickFirstCustomCapacityDimensionId,
55
+ pickFirstCustomCapacityPaxBounds: () => pickFirstCustomCapacityPaxBounds,
56
+ pickFirstDurationMinutesFromProducts: () => pickFirstDurationMinutesFromProducts,
57
+ resolveSkuMatchedQuantityLimits: () => resolveSkuMatchedQuantityLimits,
58
+ toBoolean: () => toBoolean,
59
+ toNonNegativeInt: () => toNonNegativeInt,
60
+ toNonNegativeNumber: () => toNonNegativeNumber,
61
+ toPositiveString: () => toPositiveString,
62
+ toPriceString: () => toPriceString
5
63
  });
6
- exports.aggregateItemRuleLimit = aggregateItemRuleLimit;
7
- exports.attachItemRuleLimitsToTopLevelProducts = attachItemRuleLimitsToTopLevelProducts;
8
- exports.buildItemRuleBusinessData = buildItemRuleBusinessData;
9
- exports.buildProductKey = buildProductKey;
10
- exports.buildProductLineFingerprint = buildProductLineFingerprint;
11
- exports.buildQuantityLimitIndex = buildQuantityLimitIndex;
12
- exports.collectLinkProductIdsFromReservationRules = collectLinkProductIdsFromReservationRules;
13
- exports.computeResourceIsFull = computeResourceIsFull;
14
- exports.createEmptySummary = createEmptySummary;
15
- exports.extractStrategyModelIdsFromTableConfig = extractStrategyModelIdsFromTableConfig;
16
- exports.findReservationRuleProductByResourceId = findReservationRuleProductByResourceId;
17
- exports.getProductIdentityIndex = getProductIdentityIndex;
18
- exports.getSafeProductNum = getSafeProductNum;
19
- exports.getTopLevelProductId = getTopLevelProductId;
20
- exports.getTopLevelVariantId = getTopLevelVariantId;
21
- exports.hasCustomCapacityProduct = hasCustomCapacityProduct;
22
- exports.isIdentityMatch = isIdentityMatch;
23
- exports.isSkuOnlyDeleteIdentity = isSkuOnlyDeleteIdentity;
24
- exports.normalizeEnabledItemRuleIds = normalizeEnabledItemRuleIds;
25
- exports.normalizeItemRuleStrategies = normalizeItemRuleStrategies;
26
- exports.normalizeOrderProduct = normalizeOrderProduct;
27
- exports.pickFirstCustomCapacityDimensionId = pickFirstCustomCapacityDimensionId;
28
- exports.pickFirstCustomCapacityPaxBounds = pickFirstCustomCapacityPaxBounds;
29
- exports.pickFirstDurationMinutesFromProducts = pickFirstDurationMinutesFromProducts;
30
- exports.resolveSkuMatchedQuantityLimits = resolveSkuMatchedQuantityLimits;
31
- exports.toBoolean = toBoolean;
32
- exports.toNonNegativeInt = toNonNegativeInt;
33
- exports.toNonNegativeNumber = toNonNegativeNumber;
34
- exports.toPositiveString = toPositiveString;
35
- exports.toPriceString = toPriceString;
36
- var _dayjs = _interopRequireDefault(require("dayjs"));
37
- var _decimal = _interopRequireDefault(require("decimal.js"));
38
- var _utils = require("../../modules/Order/utils");
39
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
40
- /**
41
- * 构建金额全为 0 的空 summary。
42
- * 作为尚未计算金额时的兜底默认值,避免下游因 undefined 报错。
43
- */
64
+ module.exports = __toCommonJS(utils_exports);
65
+ var import_dayjs = __toESM(require("dayjs"));
66
+ var import_decimal = __toESM(require("decimal.js"));
67
+ var import_utils = require("../../modules/Order/utils");
68
+ var import_manualProductDiscount = require("../../modules/Order/utils/manualProductDiscount");
44
69
  function createEmptySummary() {
45
70
  return {
46
71
  product_quantity: 0,
47
- product_original_amount: '0.00',
48
- product_amount: '0.00',
49
- product_expect_amount: '0.00',
50
- product_tax_fee: '0.00',
51
- shipping_fee: '0.00',
52
- shipping_tax_fee: '0.00',
53
- tax_fee: '0.00',
54
- surcharge_fee: '0.00',
55
- discount_amount: '0.00',
56
- deposit_amount: '0.00',
57
- expect_amount: '0.00',
58
- total_amount: '0.00',
59
- amount_gap: '0.00',
60
- rounding_amount: '0.00',
61
- pay_service_charge_amount: '0.00'
72
+ product_original_amount: "0.00",
73
+ product_amount: "0.00",
74
+ product_expect_amount: "0.00",
75
+ product_tax_fee: "0.00",
76
+ shipping_fee: "0.00",
77
+ shipping_tax_fee: "0.00",
78
+ tax_fee: "0.00",
79
+ surcharge_fee: "0.00",
80
+ surcharges: [],
81
+ discount_amount: "0.00",
82
+ deposit_amount: "0.00",
83
+ expect_amount: "0.00",
84
+ total_amount: "0.00",
85
+ total_refund_amount: "0.00",
86
+ customer_paid_amount: "0.00",
87
+ order_paid_amount: "0.00",
88
+ amount_gap: "0.00",
89
+ rounding_amount: "0.00",
90
+ pay_service_charge_amount: "0.00"
62
91
  };
63
92
  }
64
-
65
- /**
66
- * 商品数量安全取值。
67
- * - NaN / undefined / < 1 均视作 1(最低起订量)
68
- * - 有值时取整(不支持小数数量)
69
- */
70
93
  function getSafeProductNum(num) {
71
- if (!num || Number.isNaN(num)) return 1;
72
- if (num < 1) return 1;
94
+ if (!num || Number.isNaN(num))
95
+ return 1;
96
+ if (num < 1)
97
+ return 1;
73
98
  return Math.floor(num);
74
99
  }
75
-
76
- /**
77
- * 宽松布尔值转换。
78
- * 兼容后端/配置中心常见的 boolean / number / string 表达,统一归一成 true/false。
79
- */
80
100
  function toBoolean(value) {
81
- if (typeof value === 'boolean') return value;
82
- if (typeof value === 'number') return value !== 0;
83
- if (typeof value === 'string') {
101
+ if (typeof value === "boolean")
102
+ return value;
103
+ if (typeof value === "number")
104
+ return value !== 0;
105
+ if (typeof value === "string") {
84
106
  const normalized = value.trim().toLowerCase();
85
- return ['1', 'true', 'yes', 'y', 'on'].includes(normalized);
107
+ return ["1", "true", "yes", "y", "on"].includes(normalized);
86
108
  }
87
109
  return false;
88
110
  }
89
-
90
- /**
91
- * 将值归一化为有效的正向字符串。
92
- * null / undefined / 空串 / '0' / 'null' 统一视为无效值并返回 undefined。
93
- */
94
111
  function toPositiveString(value) {
95
- if (value === null || value === undefined || value === '') return undefined;
112
+ if (value === null || value === void 0 || value === "")
113
+ return void 0;
96
114
  const normalized = String(value).trim();
97
- if (!normalized || normalized === '0' || normalized.toLowerCase() === 'null') {
98
- return undefined;
115
+ if (!normalized || normalized === "0" || normalized.toLowerCase() === "null") {
116
+ return void 0;
99
117
  }
100
118
  return normalized;
101
119
  }
102
-
103
- /**
104
- * 归一化 item rule 策略模型 ID 列表。
105
- * - 支持 string / number 混合输入
106
- * - 仅保留 > 0 的合法数字
107
- * - 自动去重
108
- */
109
120
  function normalizeEnabledItemRuleIds(rawIds) {
110
- if (!Array.isArray(rawIds)) return [];
111
- const uniqueIds = new Set();
121
+ if (!Array.isArray(rawIds))
122
+ return [];
123
+ const uniqueIds = /* @__PURE__ */ new Set();
112
124
  for (const item of rawIds) {
113
125
  const strategyId = Number(item);
114
126
  if (Number.isFinite(strategyId) && strategyId > 0) {
@@ -117,27 +129,27 @@ function normalizeEnabledItemRuleIds(rawIds) {
117
129
  }
118
130
  return Array.from(uniqueIds);
119
131
  }
120
-
121
- /**
122
- * 从 tableConfig 中提取合法策略模型 ID 列表。
123
- */
124
132
  function extractStrategyModelIdsFromTableConfig(tableConfig) {
125
- const rawIds = Array.isArray(tableConfig?.strategy_model_ids) ? tableConfig.strategy_model_ids : [];
126
- return rawIds.map(id => Number(id)).filter(id => Number.isFinite(id) && id > 0);
133
+ const rawIds = Array.isArray(tableConfig == null ? void 0 : tableConfig.strategy_model_ids) ? tableConfig.strategy_model_ids : [];
134
+ return rawIds.map((id) => Number(id)).filter((id) => Number.isFinite(id) && id > 0);
127
135
  }
128
-
129
- /**
130
- * 仅保留 item_rule 类型策略。
131
- */
132
136
  function normalizeItemRuleStrategies(configs) {
133
- if (!Array.isArray(configs)) return [];
134
- return configs.filter(config => Boolean(config && typeof config === 'object' && config?.metadata?.type === 'item_rule'));
137
+ if (!Array.isArray(configs))
138
+ return [];
139
+ return configs.filter(
140
+ (config) => {
141
+ var _a;
142
+ return Boolean(
143
+ config && typeof config === "object" && ((_a = config == null ? void 0 : config.metadata) == null ? void 0 : _a.type) === "item_rule"
144
+ );
145
+ }
146
+ );
135
147
  }
136
148
  function toNonNegativeNumber(value) {
137
- if (typeof value === 'number') {
149
+ if (typeof value === "number") {
138
150
  return Number.isFinite(value) && value >= 0 ? value : 0;
139
151
  }
140
- if (typeof value === 'string') {
152
+ if (typeof value === "string") {
141
153
  const parsed = Number(value);
142
154
  return Number.isFinite(parsed) && parsed >= 0 ? parsed : 0;
143
155
  }
@@ -146,40 +158,49 @@ function toNonNegativeNumber(value) {
146
158
  function toNonNegativeInt(value) {
147
159
  return Math.floor(toNonNegativeNumber(value));
148
160
  }
149
- function toPriceString(value, fallback = '0.00') {
161
+ function toPriceString(value, fallback = "0.00") {
150
162
  const parsedValue = Number(value);
151
- if (Number.isNaN(parsedValue)) return fallback;
163
+ if (Number.isNaN(parsedValue))
164
+ return fallback;
152
165
  return parsedValue.toFixed(2);
153
166
  }
154
167
  function buildProductKey(productId, productVariantId) {
155
168
  return `${productId}_${productVariantId}`;
156
169
  }
170
+ function filterProductsForScanOrderMore(products = []) {
171
+ return products.filter((product) => {
172
+ var _a;
173
+ return ((_a = product.metadata) == null ? void 0 : _a.is_rule) !== true;
174
+ });
175
+ }
157
176
  function getTopLevelProductId(product) {
158
177
  const rawProductId = product.product_id ?? product.id;
159
178
  const productId = Number(rawProductId);
160
- if (!Number.isFinite(productId) || productId <= 0) return null;
179
+ if (!Number.isFinite(productId) || productId <= 0)
180
+ return null;
161
181
  return productId;
162
182
  }
163
183
  function getTopLevelVariantId(product) {
164
184
  const rawVariantId = product.product_variant_id ?? product.variant_id;
165
- if (rawVariantId === undefined || rawVariantId === null || rawVariantId === '') {
185
+ if (rawVariantId === void 0 || rawVariantId === null || rawVariantId === "") {
166
186
  return null;
167
187
  }
168
188
  const variantId = Number(rawVariantId);
169
- if (!Number.isFinite(variantId) || variantId <= 0) return null;
189
+ if (!Number.isFinite(variantId) || variantId <= 0)
190
+ return null;
170
191
  return variantId;
171
192
  }
172
193
  function buildQuantityLimitIndex(limits) {
173
- const exactLimitMap = new Map();
174
- const productLimitMap = new Map();
194
+ const exactLimitMap = /* @__PURE__ */ new Map();
195
+ const productLimitMap = /* @__PURE__ */ new Map();
175
196
  for (const limit of limits) {
176
197
  const targets = limit.targets || [];
177
- // 多目标规则(OR 组)只做购物车聚合校验,不下发到单品维度,
178
- // 避免 UI 把「组内至少 1 份」误当作每款商品各自的 min,锁死减号按钮。
179
- if (targets.length !== 1) continue;
198
+ if (targets.length !== 1)
199
+ continue;
180
200
  const target = targets[0];
181
201
  const productId = Number(target.product_id);
182
- if (!Number.isFinite(productId) || productId <= 0) continue;
202
+ if (!Number.isFinite(productId) || productId <= 0)
203
+ continue;
183
204
  const variantId = Number(target.product_variant_id);
184
205
  const hasVariant = Number.isFinite(variantId) && variantId > 0;
185
206
  if (hasVariant) {
@@ -197,53 +218,44 @@ function buildQuantityLimitIndex(limits) {
197
218
  };
198
219
  }
199
220
  function resolveSkuMatchedQuantityLimits(params) {
200
- const {
201
- productId,
202
- variantId,
203
- limitIndex
204
- } = params;
221
+ const { productId, variantId, limitIndex } = params;
205
222
  const exactMatched = variantId && variantId > 0 ? limitIndex.exactLimitMap.get(buildProductKey(productId, variantId)) || [] : [];
206
223
  const productMatched = limitIndex.productLimitMap.get(productId) || [];
207
224
  return [...exactMatched, ...productMatched];
208
225
  }
209
226
  function aggregateItemRuleLimit(matchedLimits) {
210
- if (!matchedLimits.length) return null;
227
+ if (!matchedLimits.length)
228
+ return null;
211
229
  let min;
212
230
  let max;
213
231
  let remainingMax;
214
232
  let exact;
215
233
  let mustInclude = false;
216
-
217
- // 聚合 validationMessage 按 min / max 两个方向分别输出:
218
- // - maxValidationMessage:触发"当前 max / remainingMax / exact"的那条规则的文案
219
- // - minValidationMessage:触发"当前 min / exact"的那条规则的文案
220
- // 各自再回退到其他带文案的规则(最后回退到第一条非空 validationMessage)。
221
- // 前端可根据"加号/减号被拦"的方向取对应文案。
222
234
  let maxSourceLimit;
223
235
  let remainingMaxSourceLimit;
224
236
  let exactSourceLimit;
225
237
  let minSourceLimit;
226
238
  let firstMessagedLimit;
227
239
  for (const limit of matchedLimits) {
228
- if (typeof limit.requiredMin === 'number' && Number.isFinite(limit.requiredMin)) {
229
- if (min === undefined || limit.requiredMin > min) {
240
+ if (typeof limit.requiredMin === "number" && Number.isFinite(limit.requiredMin)) {
241
+ if (min === void 0 || limit.requiredMin > min) {
230
242
  min = limit.requiredMin;
231
243
  minSourceLimit = limit;
232
244
  }
233
245
  }
234
- if (typeof limit.requiredMax === 'number' && Number.isFinite(limit.requiredMax)) {
235
- if (max === undefined || limit.requiredMax < max) {
246
+ if (typeof limit.requiredMax === "number" && Number.isFinite(limit.requiredMax)) {
247
+ if (max === void 0 || limit.requiredMax < max) {
236
248
  max = limit.requiredMax;
237
249
  maxSourceLimit = limit;
238
250
  }
239
251
  }
240
- if (typeof limit.remainingMax === 'number' && Number.isFinite(limit.remainingMax)) {
241
- if (remainingMax === undefined || limit.remainingMax < remainingMax) {
252
+ if (typeof limit.remainingMax === "number" && Number.isFinite(limit.remainingMax)) {
253
+ if (remainingMax === void 0 || limit.remainingMax < remainingMax) {
242
254
  remainingMax = limit.remainingMax;
243
255
  remainingMaxSourceLimit = limit;
244
256
  }
245
257
  }
246
- if (typeof limit.requiredExact === 'number' && Number.isFinite(limit.requiredExact)) {
258
+ if (typeof limit.requiredExact === "number" && Number.isFinite(limit.requiredExact)) {
247
259
  exact = limit.requiredExact;
248
260
  exactSourceLimit = limit;
249
261
  }
@@ -252,19 +264,16 @@ function aggregateItemRuleLimit(matchedLimits) {
252
264
  firstMessagedLimit = limit;
253
265
  }
254
266
  }
255
- if (typeof exact === 'number' && Number.isFinite(exact)) {
267
+ if (typeof exact === "number" && Number.isFinite(exact)) {
256
268
  min = exact;
257
269
  max = exact;
258
270
  }
259
271
  const maxMessageSource = maxSourceLimit || remainingMaxSourceLimit || exactSourceLimit || firstMessagedLimit;
260
272
  const minMessageSource = minSourceLimit || exactSourceLimit || firstMessagedLimit;
261
- const maxValidationMessage = maxMessageSource?.validationMessage;
262
- const rawMaxValidationMessage = maxMessageSource?.rawValidationMessage;
263
- const minValidationMessage = minMessageSource?.validationMessage;
264
- const rawMinValidationMessage = minMessageSource?.rawValidationMessage;
265
-
266
- // validationMessage / rawValidationMessage 保留为"最严格限制"的聚合文案,
267
- // 便于旧消费者(只关心 max 侧)不破坏。优先 max → min。
273
+ const maxValidationMessage = maxMessageSource == null ? void 0 : maxMessageSource.validationMessage;
274
+ const rawMaxValidationMessage = maxMessageSource == null ? void 0 : maxMessageSource.rawValidationMessage;
275
+ const minValidationMessage = minMessageSource == null ? void 0 : minMessageSource.validationMessage;
276
+ const rawMinValidationMessage = minMessageSource == null ? void 0 : minMessageSource.rawValidationMessage;
268
277
  const validationMessage = maxValidationMessage ?? minValidationMessage;
269
278
  const rawValidationMessage = rawMaxValidationMessage ?? rawMinValidationMessage;
270
279
  return {
@@ -282,34 +291,28 @@ function aggregateItemRuleLimit(matchedLimits) {
282
291
  };
283
292
  }
284
293
  function buildItemRuleBusinessData(params) {
285
- const {
286
- tempOrder,
287
- runtimeConfig,
288
- itemRuleConfigs
289
- } = params;
294
+ const { tempOrder, runtimeConfig, itemRuleConfigs } = params;
290
295
  const rawPax = runtimeConfig.pax || {};
291
296
  const adultPax = toNonNegativeInt(rawPax.adult);
292
297
  const childPax = toNonNegativeInt(rawPax.child);
293
298
  const totalPax = toNonNegativeInt(rawPax.total) || adultPax + childPax || 1;
294
299
  const cartItems = tempOrder.products.reduce((result, product) => {
295
- if (typeof product.product_id !== 'number') return result;
300
+ if (typeof product.product_id !== "number")
301
+ return result;
296
302
  result.push({
297
303
  product_id: product.product_id,
298
304
  quantity: toNonNegativeInt(product.num),
299
- ...(typeof product.product_variant_id === 'number' ? {
300
- product_variant_id: product.product_variant_id
301
- } : {})
305
+ ...typeof product.product_variant_id === "number" ? { product_variant_id: product.product_variant_id } : {}
302
306
  });
303
307
  return result;
304
308
  }, []);
305
309
  const historicalItems = Array.isArray(runtimeConfig.historicalItems) ? runtimeConfig.historicalItems.reduce((result, item) => {
306
- if (typeof item?.product_id !== 'number') return result;
310
+ if (typeof (item == null ? void 0 : item.product_id) !== "number")
311
+ return result;
307
312
  result.push({
308
313
  product_id: item.product_id,
309
314
  quantity: toNonNegativeInt(item.quantity),
310
- ...(typeof item.product_variant_id === 'number' ? {
311
- product_variant_id: item.product_variant_id
312
- } : {})
315
+ ...typeof item.product_variant_id === "number" ? { product_variant_id: item.product_variant_id } : {}
313
316
  });
314
317
  return result;
315
318
  }, []) : [];
@@ -321,20 +324,23 @@ function buildItemRuleBusinessData(params) {
321
324
  },
322
325
  cartItems,
323
326
  historicalItems,
324
- serviceType: runtimeConfig.serviceType || 'dine-in',
325
- submissionIndex: typeof runtimeConfig.submissionIndex === 'number' ? toNonNegativeInt(runtimeConfig.submissionIndex) : tempOrder.order_id ? 1 : 0,
327
+ serviceType: runtimeConfig.serviceType || "dine-in",
328
+ submissionIndex: typeof runtimeConfig.submissionIndex === "number" ? toNonNegativeInt(runtimeConfig.submissionIndex) : tempOrder.order_id ? 1 : 0,
326
329
  custom: runtimeConfig.custom || {},
327
330
  strategyConfigs: itemRuleConfigs
328
331
  };
329
332
  }
330
333
  function attachItemRuleLimitsToTopLevelProducts(productList, limits) {
331
- if (!Array.isArray(productList)) return productList;
334
+ if (!Array.isArray(productList))
335
+ return productList;
332
336
  const limitIndex = buildQuantityLimitIndex(limits || []);
333
337
  for (const item of productList) {
334
- if (!item || typeof item !== 'object') continue;
338
+ if (!item || typeof item !== "object")
339
+ continue;
335
340
  const productItem = item;
336
341
  const productId = getTopLevelProductId(productItem);
337
- if (productId === null) continue;
342
+ if (productId === null)
343
+ continue;
338
344
  const variantId = getTopLevelVariantId(productItem);
339
345
  const matchedLimits = limits.length ? resolveSkuMatchedQuantityLimits({
340
346
  productId,
@@ -344,356 +350,387 @@ function attachItemRuleLimitsToTopLevelProducts(productList, limits) {
344
350
  const aggregatedLimit = aggregateItemRuleLimit(matchedLimits);
345
351
  if (aggregatedLimit) {
346
352
  productItem.item_rule_limit = aggregatedLimit;
347
- } else if ('item_rule_limit' in productItem) {
353
+ } else if ("item_rule_limit" in productItem) {
348
354
  delete productItem.item_rule_limit;
349
355
  }
350
356
  }
351
357
  return productList;
352
358
  }
353
-
354
- /**
355
- * 将选项行 / 套餐行归一成稳定 JSON,用于「同 SKU 是否合并」判断。
356
- * 数组元素先按主键排序再序列化,避免顺序差异导致误判为不同行。
357
- */
358
359
  function buildProductLineFingerprint(productOptionItem, productBundle) {
359
360
  const optArr = Array.isArray(productOptionItem) ? productOptionItem : [];
360
- const normalizedOpts = optArr.map(item => ({
361
- product_option_item_id: Number(item?.product_option_item_id) || 0,
362
- option_group_id: Number(item?.option_group_id) || 0,
363
- num: typeof item?.num === 'number' && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
364
- price: String(item?.price ?? '')
361
+ const normalizedOpts = optArr.map((item) => ({
362
+ option_group_item_id: Number(item == null ? void 0 : item.option_group_item_id) || 0,
363
+ option_group_id: Number(item == null ? void 0 : item.option_group_id) || 0,
364
+ num: typeof (item == null ? void 0 : item.num) === "number" && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
365
+ price: String((item == null ? void 0 : item.add_price) ?? (item == null ? void 0 : item.price) ?? "")
365
366
  })).sort((p, q) => {
366
- if (p.product_option_item_id !== q.product_option_item_id) {
367
- return p.product_option_item_id - q.product_option_item_id;
367
+ if (p.option_group_item_id !== q.option_group_item_id) {
368
+ return p.option_group_item_id - q.option_group_item_id;
368
369
  }
369
- if (p.option_group_id !== q.option_group_id) return p.option_group_id - q.option_group_id;
370
- if (p.num !== q.num) return p.num - q.num;
370
+ if (p.option_group_id !== q.option_group_id)
371
+ return p.option_group_id - q.option_group_id;
372
+ if (p.num !== q.num)
373
+ return p.num - q.num;
371
374
  return p.price.localeCompare(q.price);
372
375
  });
373
376
  const bundleArr = Array.isArray(productBundle) ? productBundle : [];
374
- const normalizedBundles = bundleArr.map(item => ({
375
- bundle_id: Number(item?.bundle_id ?? item?.id ?? 0) || 0,
376
- product_id: Number(item?.product_id) || 0,
377
- num: typeof item?.num === 'number' && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1
377
+ const normalizedBundles = bundleArr.map((item) => ({
378
+ bundle_id: Number((item == null ? void 0 : item.bundle_id) ?? (item == null ? void 0 : item.id) ?? 0) || 0,
379
+ product_id: Number(item == null ? void 0 : item.product_id) || 0,
380
+ num: typeof (item == null ? void 0 : item.num) === "number" && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1
378
381
  })).sort((p, q) => {
379
- if (p.bundle_id !== q.bundle_id) return p.bundle_id - q.bundle_id;
380
- if (p.product_id !== q.product_id) return p.product_id - q.product_id;
382
+ if (p.bundle_id !== q.bundle_id)
383
+ return p.bundle_id - q.bundle_id;
384
+ if (p.product_id !== q.product_id)
385
+ return p.product_id - q.product_id;
381
386
  return p.num - q.num;
382
387
  });
383
388
  return JSON.stringify([normalizedOpts, normalizedBundles]);
384
389
  }
385
-
386
- /**
387
- * removeProductFromOrder 仅传 SKU 时的通配 identity(对象上未声明选项键)。
388
- * 与显式 `product_option_item: []` 区分:后者只匹配「无选项」行。
389
- */
390
390
  function isSkuOnlyDeleteIdentity(x) {
391
- if (x.identity_key) return false;
392
- return !('product_option_item' in x) && !('product_bundle' in x);
391
+ if (x.unique_identification_number || x.identity_key)
392
+ return false;
393
+ return !("product_sku" in x) && !("product_bundle" in x);
393
394
  }
394
395
  function fingerprintForIdentityWithOptionKeys(x) {
395
396
  const row = x;
396
- const opts = 'product_option_item' in row ? Array.isArray(row.product_option_item) ? row.product_option_item : [] : [];
397
- const buds = 'product_bundle' in row ? Array.isArray(row.product_bundle) ? row.product_bundle : [] : [];
397
+ const opts = "product_sku" in row ? (0, import_utils.getProductSkuOptions)(row) : [];
398
+ const buds = "product_bundle" in row ? Array.isArray(row.product_bundle) ? row.product_bundle : [] : [];
398
399
  return buildProductLineFingerprint(opts, buds);
399
400
  }
400
-
401
- /**
402
- * 判断两个商品 identity 是否匹配(不透明 identity 契约)。
403
- *
404
- * 调用约定:始终 `isIdentityMatch(line, callerIdentity)`。
405
- * - 若 SKU(product_id + product_variant_id)不一致 → 不匹配。
406
- * - **双方都带** `identity_key` → 严格字符串相等比较(不再猜测合成 key / metadata 桥接)。
407
- * 这是 opaque identity 契约的标准路径:UI 删改时透传 SDK 回灌的 identity_key。
408
- * - 否则(即至少一侧未声明 identity_key)→ 进入「SKU 通配 / 显式空选项 / 指纹」回退路径,
409
- * 忽略线侧 identity_key,按内容语义匹配。这给「行已 opaque、调用方却想按 SKU 通配 / 选项指纹删除」留兼容入口。
410
- */
411
401
  function isIdentityMatch(a, b) {
412
- if (a.product_id !== b.product_id || a.product_variant_id !== b.product_variant_id) return false;
413
- const aHasKey = typeof a.identity_key === 'string' && a.identity_key.length > 0;
414
- const bHasKey = typeof b.identity_key === 'string' && b.identity_key.length > 0;
415
- if (aHasKey && bHasKey) return a.identity_key === b.identity_key;
416
- if (isSkuOnlyDeleteIdentity(a) || isSkuOnlyDeleteIdentity(b)) return true;
402
+ var _a, _b;
403
+ if (a.product_id !== b.product_id || a.product_variant_id !== b.product_variant_id)
404
+ return false;
405
+ const aUid = ((_a = a.metadata) == null ? void 0 : _a.unique_identification_number) ?? a.unique_identification_number ?? a.identity_key;
406
+ const bUid = ((_b = b.metadata) == null ? void 0 : _b.unique_identification_number) ?? b.unique_identification_number ?? b.identity_key;
407
+ const aHasKey = typeof aUid === "string" && aUid.length > 0;
408
+ const bHasKey = typeof bUid === "string" && bUid.length > 0;
409
+ if (aHasKey && bHasKey)
410
+ return aUid === bUid;
411
+ if (isSkuOnlyDeleteIdentity(a) || isSkuOnlyDeleteIdentity(b))
412
+ return true;
417
413
  return fingerprintForIdentityWithOptionKeys(a) === fingerprintForIdentityWithOptionKeys(b);
418
414
  }
419
-
420
- /**
421
- * 根据 identity 在商品列表中定位下标。
422
- * 用于判断商品是否已存在(已存在则累加数量,否则新增)。
423
- */
424
415
  function getProductIdentityIndex(products, identity) {
425
- return products.findIndex(item => isIdentityMatch(item, identity));
416
+ return products.findIndex((item) => isIdentityMatch(item, identity));
426
417
  }
427
-
428
- /**
429
- * 对外部传入的商品对象做归一化(v2 composite 语义):
430
- * - 补全可选字段默认值(未传则使用兜底值,避免后续计算时因 undefined 导致异常)
431
- * - 对 num 调用 getSafeProductNum 做安全处理
432
- * - 保留 _origin 供后续业务流程(如促销规则)使用
433
- *
434
- * 价格字段语义(metadata 权威源 + composite 派生):
435
- * - `metadata.source_product_price`:主商品/variant 基础价(已应用报价单),**不含 option**、
436
- * **不含折扣**。是推导 main_product_* 的起点。variant 分支优先读 `metadata.origin.variant[vid].price`。
437
- * - `metadata.main_product_original_price`:`source + Σ(option.price × option.num)`,**含 option**、
438
- * **不含折扣**。
439
- * - `metadata.main_product_selling_price`:`main_product_original_price - 主商品券 per-unit amount`,
440
- * **含 option**、**含折扣**。
441
- * - 行级 `selling_price` = `main_product_selling_price + Σ(bundle_selling_price × num)`。
442
- * - 行级 `original_price` = `main_product_original_price + Σ(bundle 原价 × num)`。
443
- *
444
- * 迁移与幂等:
445
- * - `metadata.price_schema_version === 2` → 已新语义归一化,保留 main_product_* 原值(保留折扣)。
446
- * - 其它情况(v1 / 缺字段 / 无 metadata)→ 按"main_product_selling_price 曾是 main-only"的旧约定
447
- * 反推 legacyDiscount,再以新 source + options 基准重算。最终统一打上 `price_schema_version: 2`。
448
- * - 因此多次 normalize 不会重复叠加 option/bundle。
449
- */
450
418
  function normalizeOrderProduct(product) {
451
- const metadata = {
452
- ...(product.metadata || {})
453
- };
454
- // 不透明 identity 契约:每条订单行必须带 identity_key。
455
- // 调用方未传时由 SDK 自动生成 UUID,后续 update/remove 只做严格比对,避免猜测合成 key。
456
- const resolvedIdentityKey = product.identity_key && String(product.identity_key).length > 0 ? String(product.identity_key) : (0, _utils.createUuidV4)();
457
- if (!metadata.unique_identification_number) {
458
- metadata.unique_identification_number = resolvedIdentityKey;
419
+ var _a, _b, _c, _d, _e, _f, _g;
420
+ const metadata = { ...product.metadata || {} };
421
+ const resolvedIdentityKey = ((_a = product.metadata) == null ? void 0 : _a.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) : (0, import_utils.createUuidV4)();
422
+ metadata.unique_identification_number = resolvedIdentityKey;
423
+ const priceOverride = metadata.price_override;
424
+ const originOtherBundle = (_d = (_c = (_b = metadata.origin) == null ? void 0 : _b._extend) == null ? void 0 : _c.other) == null ? void 0 : _d.bundle;
425
+ let bundleInput = product.product_bundle || [];
426
+ if (priceOverride !== void 0 && priceOverride !== null && priceOverride !== "" && Array.isArray(originOtherBundle) && originOtherBundle.length > 0) {
427
+ const priceById = /* @__PURE__ */ new Map();
428
+ originOtherBundle.forEach((item) => {
429
+ if ((item == null ? void 0 : item.id) == null)
430
+ return;
431
+ const unit = item.price ?? item.bundle_selling_price;
432
+ if (unit === void 0 || unit === null)
433
+ return;
434
+ priceById.set(String(item.id), String(unit));
435
+ });
436
+ const base = Array.isArray(bundleInput) && bundleInput.length > 0 ? bundleInput : originOtherBundle;
437
+ bundleInput = base.map((item) => {
438
+ const unit = priceById.get(String(item == null ? void 0 : item.id));
439
+ if (unit === void 0)
440
+ return item;
441
+ return {
442
+ ...item,
443
+ price: unit,
444
+ bundle_selling_price: unit
445
+ };
446
+ });
459
447
  }
460
- const normalizedBundle = (product.product_bundle || []).map(item => ({
461
- ...item,
462
- bundle_selling_price: item.bundle_selling_price ?? item.price ?? '0.00'
463
- // custom_price: item.custom_price ?? item.bundle_selling_price ?? item.price ?? '0.00',
464
- }));
465
- const normalizedOptions = product.product_option_item || [];
466
- const optionSum = (0, _utils.sumOptionUnitPrice)(normalizedOptions);
467
-
468
- // 1) 解析 source_product_price。
469
- // 优先级:
470
- // 1) metadata.source_product_price(v2 权威)
471
- // 2) variantPrice(命中 variant_id,从 metadata.origin.variant[vid].price 读)
472
- // 3) _origin.price / _origin.base_price(后端语义的基础价)
473
- // 4) v1 兼容:无 v2 标记但存在 metadata.main_product_original_price(v1 main-only,即旧 source)
474
- // 5) 入参 original_price(v1 addProduct 约定:original_price 为 pre-discount 基础价)
475
- // 6) 入参 selling_price(最末兜底,新添加路径 caller 只给 selling_price)
476
- const isV2 = metadata.price_schema_version === 2 || metadata.price_schema_version === '2';
448
+ const normalizedBundle = bundleInput.map((item) => {
449
+ const magnitudeSource = {
450
+ ...item,
451
+ // 计算 markdown 净额时,只把真实毛价交给 helper;若只有 bundle_selling_price,
452
+ // helper 会按历史净额兜底,避免 option 二次扣减。
453
+ price: item.price ?? item.custom_price
454
+ };
455
+ const normalizedItem = {
456
+ ...item,
457
+ bundle_id: item.bundle_id ?? item.id,
458
+ bundle_product_id: item.bundle_product_id ?? item._bundle_product_id,
459
+ bundle_group_id: item.bundle_group_id ?? item.group_id,
460
+ // price 保留毛价(markdown 仍为 5),由 price_type 决定符号。
461
+ price: item.price ?? item.custom_price ?? item.bundle_selling_price ?? "0.00",
462
+ price_type: item.price_type ?? item.custom_price_type ?? "",
463
+ price_type_ext: item.price_type_ext ?? item.custom_price_type_ext ?? ""
464
+ };
465
+ normalizedItem.bundle_selling_price = (0, import_utils.getBundleSellingMagnitude)(magnitudeSource).toFixed(2);
466
+ if (normalizedItem.price_type === "markdown" && (normalizedItem.price_type_ext === "" || normalizedItem.price_type_ext === void 0 || normalizedItem.price_type_ext === null)) {
467
+ normalizedItem.custom_price = normalizedItem.custom_price ?? normalizedItem.price;
468
+ normalizedItem.price = normalizedItem.bundle_selling_price;
469
+ }
470
+ if ((normalizedItem.price_type === "markdown" || normalizedItem.price_type === "markup") && (normalizedItem.price_type_ext === "" || normalizedItem.price_type_ext === void 0 || normalizedItem.price_type_ext === null)) {
471
+ delete normalizedItem.original_total;
472
+ }
473
+ return normalizedItem;
474
+ });
475
+ const normalizedOptions = (0, import_utils.normalizeProductSkuOptions)((_e = product.product_sku) == null ? void 0 : _e.option);
476
+ const optionSum = (0, import_utils.sumOptionUnitPrice)(normalizedOptions);
477
+ const productSku = {
478
+ ...(0, import_utils.ensureProductSku)(product),
479
+ option: normalizedOptions
480
+ };
481
+ const isV2 = metadata.price_schema_version === 2 || metadata.price_schema_version === "2";
477
482
  const variantId = Number(product.product_variant_id || 0);
478
- const variantList = variantId ? metadata?.origin?.variant : null;
479
- const variantPrice = Array.isArray(variantList) ? variantList.find(v => Number(v?.id) === variantId)?.price : undefined;
483
+ const variantList = variantId ? (_f = metadata == null ? void 0 : metadata.origin) == null ? void 0 : _f.variant : null;
484
+ const variantPrice = Array.isArray(variantList) ? (_g = variantList.find((v) => Number(v == null ? void 0 : v.id) === variantId)) == null ? void 0 : _g.price : void 0;
480
485
  const resolvedSource = (() => {
481
- if (metadata.source_product_price !== undefined) {
486
+ var _a2, _b2;
487
+ if (metadata.source_product_price !== void 0) {
482
488
  return String(metadata.source_product_price);
483
489
  }
484
- if (variantPrice !== undefined && variantPrice !== null) {
490
+ if (variantPrice !== void 0 && variantPrice !== null) {
485
491
  return String(variantPrice);
486
492
  }
487
- const originPrice = product._origin?.price;
488
- if (originPrice !== undefined && originPrice !== null) {
493
+ const originPrice = (_a2 = product._origin) == null ? void 0 : _a2.price;
494
+ if (originPrice !== void 0 && originPrice !== null) {
489
495
  return String(originPrice);
490
496
  }
491
- const originBasePrice = product._origin?.base_price;
492
- if (originBasePrice !== undefined && originBasePrice !== null) {
497
+ const originBasePrice = (_b2 = product._origin) == null ? void 0 : _b2.base_price;
498
+ if (originBasePrice !== void 0 && originBasePrice !== null) {
493
499
  return String(originBasePrice);
494
500
  }
495
- if (!isV2 && metadata.main_product_original_price !== undefined) {
501
+ if (!isV2 && metadata.main_product_original_price !== void 0) {
496
502
  return String(metadata.main_product_original_price);
497
503
  }
498
- return product.original_price ?? product.selling_price ?? '0.00';
504
+ return product.original_price ?? product.selling_price ?? "0.00";
499
505
  })();
500
-
501
- // 2) 派生 main_product_original_price(含 option、不含折扣)
502
- const mainOriginalDec = new _decimal.default(Number(resolvedSource) || 0).plus(optionSum);
506
+ const mainOriginalDec = new import_decimal.default(Number(resolvedSource) || 0).plus(optionSum);
503
507
  const mainOriginalStr = mainOriginalDec.toDecimalPlaces(2).toFixed(2);
504
-
505
- // 3) 派生 main_product_selling_price(含 option、含主商品折扣)
506
- // - v2 数据:直接沿用 metadata.main_product_selling_price(保留折扣)
507
- // - v1 metadata:main_product_selling_price 旧语义是 main-only(≈ source-level 折后价),
508
- // 反推 legacyDiscount = main_original(旧) - main_selling(旧),再用新 main_original - legacyDiscount
509
- // - v1 addProduct 入参:top-level selling_price < original_price 表示主商品折扣;
510
- // 用差额作为 legacyDiscount 映射到新 main_selling
511
- // - 其它:视为无折扣,main_selling = main_original
512
508
  let mainSellingDec;
513
509
  if (isV2 && metadata.main_product_selling_price != null) {
514
- mainSellingDec = new _decimal.default(Number(metadata.main_product_selling_price) || 0);
510
+ mainSellingDec = new import_decimal.default(Number(metadata.main_product_selling_price) || 0);
515
511
  } else if (metadata.main_product_selling_price != null && metadata.main_product_original_price != null) {
516
- const legacyOriginal = new _decimal.default(Number(metadata.main_product_original_price) || 0);
517
- const legacySelling = new _decimal.default(Number(metadata.main_product_selling_price) || 0);
512
+ const legacyOriginal = new import_decimal.default(Number(metadata.main_product_original_price) || 0);
513
+ const legacySelling = new import_decimal.default(Number(metadata.main_product_selling_price) || 0);
518
514
  const legacyDiscount = legacyOriginal.minus(legacySelling);
519
515
  mainSellingDec = mainOriginalDec.minus(legacyDiscount);
520
- } else if (product.original_price != null && product.selling_price != null && new _decimal.default(Number(product.original_price) || 0).greaterThan(new _decimal.default(Number(product.selling_price) || 0))) {
521
- const topOriginal = new _decimal.default(Number(product.original_price) || 0);
522
- const topSelling = new _decimal.default(Number(product.selling_price) || 0);
516
+ } else if (product.original_price != null && product.selling_price != null && new import_decimal.default(Number(product.original_price) || 0).greaterThan(
517
+ new import_decimal.default(Number(product.selling_price) || 0)
518
+ )) {
519
+ const topOriginal = new import_decimal.default(Number(product.original_price) || 0);
520
+ const topSelling = new import_decimal.default(Number(product.selling_price) || 0);
523
521
  const legacyDiscount = topOriginal.minus(topSelling);
524
522
  mainSellingDec = mainOriginalDec.minus(legacyDiscount);
525
523
  } else {
526
524
  mainSellingDec = mainOriginalDec;
527
525
  }
528
526
  const mainSellingStr = mainSellingDec.toDecimalPlaces(2).toFixed(2);
529
-
530
- // 4) 落盘 metadata:三字段 + schema 版本 sentinel
531
527
  metadata.source_product_price = resolvedSource;
532
528
  metadata.main_product_original_price = mainOriginalStr;
533
529
  metadata.main_product_selling_price = mainSellingStr;
534
530
  metadata.price_schema_version = 2;
535
-
536
- // 5) 合成行级 composite(main 已含 option,本步只叠 bundle)
537
- const composedSellingPrice = (0, _utils.composeLinePrice)({
531
+ const composedSellingPrice = (0, import_utils.composeLinePrice)({
538
532
  mainPrice: mainSellingStr,
539
533
  bundle: normalizedBundle
540
534
  });
541
- const composedOriginalPrice = (0, _utils.composeLinePrice)({
535
+ const composedOriginalPrice = (0, import_utils.composeLinePrice)({
542
536
  mainPrice: mainOriginalStr,
543
537
  bundle: normalizedBundle,
544
538
  useOriginalBundle: true
545
539
  });
540
+ const finalOriginalPrice = (0, import_utils.resolveManualOverrideLineOriginalPrice)(
541
+ { num: product.num, metadata, lineOriginalPrice: product.original_price },
542
+ composedOriginalPrice
543
+ );
544
+ const hasManualProductDiscount = (product.discount_list || []).some(
545
+ (item) => (item == null ? void 0 : item.type) === "product"
546
+ );
547
+ const manualOriginalPrice = hasManualProductDiscount && product.original_price != null ? String(product.original_price) : finalOriginalPrice;
548
+ const discountList = (0, import_manualProductDiscount.ensureManualProductDiscountList)({
549
+ discountList: product.discount_list,
550
+ metadata,
551
+ originalPrice: manualOriginalPrice,
552
+ sellingPrice: composedSellingPrice,
553
+ quantity: getSafeProductNum(product.num)
554
+ });
546
555
  return {
547
556
  order_detail_id: product.order_detail_id || null,
548
557
  product_id: product.product_id,
549
558
  num: getSafeProductNum(product.num),
550
559
  product_variant_id: product.product_variant_id,
551
- identity_key: resolvedIdentityKey,
552
- product_option_item: normalizedOptions,
560
+ product_sku: productSku,
553
561
  selling_price: composedSellingPrice,
554
- original_price: composedOriginalPrice,
555
- tax_fee: product.tax_fee || '0.00',
562
+ original_price: manualOriginalPrice,
563
+ tax_fee: product.tax_fee || "0.00",
556
564
  is_charge_tax: product.is_charge_tax ?? 0,
557
- discount_list: product.discount_list || [],
565
+ discount_list: discountList,
558
566
  product_bundle: normalizedBundle,
559
567
  metadata,
560
- note: product.note != null ? String(product.note) : '',
561
- _origin: product._origin
568
+ note: product.note != null ? String(product.note) : ""
562
569
  };
563
570
  }
564
-
565
- /**
566
- * 从 reservation.enabled_reservation_rules 中收集 type=link 的商品 id。
567
- */
568
571
  function collectLinkProductIdsFromReservationRules(rules) {
569
- if (!Array.isArray(rules)) return [];
572
+ if (!Array.isArray(rules))
573
+ return [];
570
574
  const ids = [];
571
575
  for (const entry of rules) {
572
- if (!entry || typeof entry !== 'object') continue;
576
+ if (!entry || typeof entry !== "object")
577
+ continue;
573
578
  const rec = entry;
574
- if (rec.type !== 'link') continue;
575
- if (!Array.isArray(rec.value)) continue;
579
+ if (rec.type !== "link")
580
+ continue;
581
+ if (!Array.isArray(rec.value))
582
+ continue;
576
583
  for (const v of rec.value) {
577
584
  const n = Number(v);
578
- if (Number.isFinite(n) && n > 0) ids.push(Math.floor(n));
585
+ if (Number.isFinite(n) && n > 0)
586
+ ids.push(Math.floor(n));
579
587
  }
580
588
  }
581
589
  return [...new Set(ids)];
582
590
  }
583
-
584
- /**
585
- * 找到第一个归属指定桌台的预约规则商品。
586
- * 归属判断基于商品资源中的 default_resource / optional_resource。
587
- */
588
591
  function findReservationRuleProductByResourceId(products, resourceId) {
592
+ var _a;
589
593
  const numericResourceId = Number(resourceId);
590
- if (!Number.isFinite(numericResourceId) || numericResourceId <= 0) return undefined;
594
+ if (!Number.isFinite(numericResourceId) || numericResourceId <= 0)
595
+ return void 0;
591
596
  for (const product of products) {
592
- const resources = product?.product_resource?.resources;
593
- if (!Array.isArray(resources)) continue;
594
- const hasMatchedResource = resources.some(resource => {
595
- const defaultResources = Array.isArray(resource?.default_resource) ? resource.default_resource : [];
596
- const optionalResources = Array.isArray(resource?.optional_resource) ? resource.optional_resource : [];
597
- return [...defaultResources, ...optionalResources].some(id => Number(id) === numericResourceId);
597
+ const resources = (_a = product == null ? void 0 : product.product_resource) == null ? void 0 : _a.resources;
598
+ if (!Array.isArray(resources))
599
+ continue;
600
+ const hasMatchedResource = resources.some((resource) => {
601
+ const defaultResources = Array.isArray(resource == null ? void 0 : resource.default_resource) ? resource.default_resource : [];
602
+ const optionalResources = Array.isArray(resource == null ? void 0 : resource.optional_resource) ? resource.optional_resource : [];
603
+ return [...defaultResources, ...optionalResources].some(
604
+ (id) => Number(id) === numericResourceId
605
+ );
598
606
  });
599
- if (hasMatchedResource) return product;
607
+ if (hasMatchedResource)
608
+ return product;
600
609
  }
601
- return undefined;
610
+ return void 0;
602
611
  }
603
-
604
- /**
605
- * 返回列表中第一个带有效 duration.value(分钟)的商品时长。
606
- */
607
612
  function pickFirstDurationMinutesFromProducts(products) {
613
+ var _a;
608
614
  for (const product of products) {
609
- const value = product?.duration?.value;
615
+ const value = (_a = product == null ? void 0 : product.duration) == null ? void 0 : _a.value;
610
616
  const n = Number(value);
611
- if (Number.isFinite(n) && n > 0) return Math.floor(n);
617
+ if (Number.isFinite(n) && n > 0)
618
+ return Math.floor(n);
612
619
  }
613
- return undefined;
620
+ return void 0;
614
621
  }
615
-
616
- /** 是否存在 capacity.type === 'custom' 的商品 */
617
622
  function hasCustomCapacityProduct(products) {
618
- return products.some(p => p?.capacity?.type === 'custom');
623
+ return products.some((p) => {
624
+ var _a;
625
+ return ((_a = p == null ? void 0 : p.capacity) == null ? void 0 : _a.type) === "custom";
626
+ });
619
627
  }
620
-
621
- /**
622
- * 根据预约规则商品的 resource.type 计算桌台是否已被"占满"。
623
- * - single:只要有 `lastOrderId` 即视为占用
624
- * - multiple:当前时间落在 `capacity_list[i]` 的 `[start_at, end_at]`(inclusive)内的 pax 之和 >= 总容量
625
- * - 其他('capacity' / undefined):返回 false,不施加限制
626
- */
627
628
  function computeResourceIsFull(params) {
628
- const {
629
- resourceSelectType,
630
- lastOrderId,
631
- capacityList,
632
- capacity
633
- } = params;
634
- if (resourceSelectType === 'single') return Boolean(lastOrderId);
635
- if (resourceSelectType !== 'multiple') return false;
629
+ const { resourceSelectType, lastOrderId, capacityList, capacity } = params;
630
+ if (resourceSelectType === "single")
631
+ return Boolean(lastOrderId);
632
+ if (resourceSelectType !== "multiple")
633
+ return false;
636
634
  const totalCapacity = Number(capacity);
637
- if (!Number.isFinite(totalCapacity) || totalCapacity <= 0) return false;
638
- const now = (0, _dayjs.default)();
635
+ if (!Number.isFinite(totalCapacity) || totalCapacity <= 0)
636
+ return false;
637
+ const now = (0, import_dayjs.default)();
639
638
  let occupied = 0;
640
639
  for (const slot of capacityList || []) {
641
- const start = (0, _dayjs.default)(slot?.start_at);
642
- const end = (0, _dayjs.default)(slot?.end_at);
643
- if (!start.isValid() || !end.isValid()) continue;
640
+ const start = (0, import_dayjs.default)(slot == null ? void 0 : slot.start_at);
641
+ const end = (0, import_dayjs.default)(slot == null ? void 0 : slot.end_at);
642
+ if (!start.isValid() || !end.isValid())
643
+ continue;
644
644
  if ((now.isAfter(start) || now.isSame(start)) && (now.isBefore(end) || now.isSame(end))) {
645
- const pax = Number(slot?.pax);
646
- if (Number.isFinite(pax) && pax > 0) occupied += pax;
645
+ const pax = Number(slot == null ? void 0 : slot.pax);
646
+ if (Number.isFinite(pax) && pax > 0)
647
+ occupied += pax;
647
648
  }
648
649
  }
649
650
  return occupied >= totalCapacity;
650
651
  }
651
-
652
- /**
653
- * 在商品列表中找到第一个 `capacity.type === 'custom'` 的商品,取其 `custom` 数组第一项的 min/max。
654
- * 仅返回有限数字字段;若均无法解析则返回 `undefined`。
655
- */
656
652
  function pickFirstCustomCapacityPaxBounds(products) {
657
653
  for (const p of products) {
658
- const cap = p?.capacity;
659
- if (!cap || cap.type !== 'custom') continue;
660
- if (!Array.isArray(cap.custom) || cap.custom.length === 0) continue;
654
+ const cap = p == null ? void 0 : p.capacity;
655
+ if (!cap || cap.type !== "custom")
656
+ continue;
657
+ if (!Array.isArray(cap.custom) || cap.custom.length === 0)
658
+ continue;
661
659
  const row = cap.custom[0];
662
- if (!row || typeof row !== 'object') continue;
660
+ if (!row || typeof row !== "object")
661
+ continue;
663
662
  const raw = row;
664
663
  const out = {};
665
- if (raw.min !== null && raw.min !== undefined && raw.min !== '') {
664
+ if (raw.min !== null && raw.min !== void 0 && raw.min !== "") {
666
665
  const min = Number(raw.min);
667
- if (Number.isFinite(min)) out.min = min;
666
+ if (Number.isFinite(min))
667
+ out.min = min;
668
668
  }
669
- if (raw.max !== null && raw.max !== undefined && raw.max !== '') {
669
+ if (raw.max !== null && raw.max !== void 0 && raw.max !== "") {
670
670
  const max = Number(raw.max);
671
- if (Number.isFinite(max)) out.max = max;
671
+ if (Number.isFinite(max))
672
+ out.max = max;
672
673
  }
673
- if (out.min !== undefined || out.max !== undefined) return out;
674
+ if (out.min !== void 0 || out.max !== void 0)
675
+ return out;
674
676
  }
675
- return undefined;
677
+ return void 0;
676
678
  }
677
-
678
- /**
679
- * 第一个 `capacity.type === 'custom'` 的商品,取其 `custom[0].id`(提交 booking metadata.capacity 维度 id)。
680
- * 无匹配时返回 `undefined`,调用方应回退为 `0`。
681
- */
682
679
  function pickFirstCustomCapacityDimensionId(products) {
683
680
  for (const p of products) {
684
- const cap = p?.capacity;
685
- if (!cap || cap.type !== 'custom') continue;
686
- if (!Array.isArray(cap.custom) || cap.custom.length === 0) continue;
681
+ const cap = p == null ? void 0 : p.capacity;
682
+ if (!cap || cap.type !== "custom")
683
+ continue;
684
+ if (!Array.isArray(cap.custom) || cap.custom.length === 0)
685
+ continue;
687
686
  const row = cap.custom[0];
688
- if (!row || typeof row !== 'object') continue;
687
+ if (!row || typeof row !== "object")
688
+ continue;
689
689
  const id = row.id;
690
- if (id === null || id === undefined || id === '') continue;
691
- if (typeof id === 'number' && Number.isFinite(id)) return id;
692
- if (typeof id === 'string') {
690
+ if (id === null || id === void 0 || id === "")
691
+ continue;
692
+ if (typeof id === "number" && Number.isFinite(id))
693
+ return id;
694
+ if (typeof id === "string") {
693
695
  const trimmed = id.trim();
694
- if (!trimmed) continue;
696
+ if (!trimmed)
697
+ continue;
695
698
  return trimmed;
696
699
  }
697
700
  }
698
- return undefined;
699
- }
701
+ return void 0;
702
+ }
703
+ // Annotate the CommonJS export names for ESM import in node:
704
+ 0 && (module.exports = {
705
+ aggregateItemRuleLimit,
706
+ attachItemRuleLimitsToTopLevelProducts,
707
+ buildItemRuleBusinessData,
708
+ buildProductKey,
709
+ buildProductLineFingerprint,
710
+ buildQuantityLimitIndex,
711
+ collectLinkProductIdsFromReservationRules,
712
+ computeResourceIsFull,
713
+ createEmptySummary,
714
+ extractStrategyModelIdsFromTableConfig,
715
+ filterProductsForScanOrderMore,
716
+ findReservationRuleProductByResourceId,
717
+ getProductIdentityIndex,
718
+ getSafeProductNum,
719
+ getTopLevelProductId,
720
+ getTopLevelVariantId,
721
+ hasCustomCapacityProduct,
722
+ isIdentityMatch,
723
+ isSkuOnlyDeleteIdentity,
724
+ normalizeEnabledItemRuleIds,
725
+ normalizeItemRuleStrategies,
726
+ normalizeOrderProduct,
727
+ pickFirstCustomCapacityDimensionId,
728
+ pickFirstCustomCapacityPaxBounds,
729
+ pickFirstDurationMinutesFromProducts,
730
+ resolveSkuMatchedQuantityLimits,
731
+ toBoolean,
732
+ toNonNegativeInt,
733
+ toNonNegativeNumber,
734
+ toPositiveString,
735
+ toPriceString
736
+ });