@pisell/pisellos 2.2.244 → 2.2.245

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 (317) hide show
  1. package/dist/model/strategy/adapter/promotion/evaluator.js +3 -2
  2. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  3. package/dist/model/strategy/adapter/walletPass/utils.js +7 -4
  4. package/dist/modules/BookingContext/index.d.ts +48 -0
  5. package/dist/modules/BookingContext/index.js +566 -0
  6. package/dist/modules/BookingContext/types.d.ts +102 -0
  7. package/dist/modules/BookingContext/types.js +51 -0
  8. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  9. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +284 -0
  10. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  11. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +145 -0
  12. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
  13. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +218 -0
  14. package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
  15. package/dist/modules/BookingContext/utils/flexible.js +56 -0
  16. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  17. package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
  18. package/dist/modules/BookingContext/utils/index.d.ts +11 -0
  19. package/dist/modules/BookingContext/utils/index.js +11 -0
  20. package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
  21. package/dist/modules/BookingContext/utils/noResource.js +77 -0
  22. package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
  23. package/dist/modules/BookingContext/utils/orderLineDisplay.js +36 -0
  24. package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
  25. package/dist/modules/BookingContext/utils/productExtend.js +339 -0
  26. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  27. package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
  28. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  29. package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
  30. package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
  31. package/dist/modules/BookingContext/utils/resources.js +486 -0
  32. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  33. package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
  34. package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  35. package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
  36. package/dist/modules/Cart/utils/cartProduct.js +24 -3
  37. package/dist/modules/Cart/utils/changePrice.js +11 -11
  38. package/dist/modules/Customer/index.d.ts +20 -0
  39. package/dist/modules/Customer/index.js +172 -83
  40. package/dist/modules/Customer/types.d.ts +2 -0
  41. package/dist/modules/Discount/index.d.ts +1 -1
  42. package/dist/modules/Discount/index.js +13 -6
  43. package/dist/modules/Discount/types.d.ts +1 -0
  44. package/dist/modules/OpenData/index.d.ts +8 -0
  45. package/dist/modules/OpenData/index.js +37 -17
  46. package/dist/modules/Order/index.d.ts +275 -19
  47. package/dist/modules/Order/index.js +3493 -809
  48. package/dist/modules/Order/types.d.ts +286 -31
  49. package/dist/modules/Order/types.js +38 -0
  50. package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  51. package/dist/modules/Order/utils/manualProductDiscount.js +210 -0
  52. package/dist/modules/Order/utils.d.ts +147 -5
  53. package/dist/modules/Order/utils.js +750 -104
  54. package/dist/modules/Payment/index.d.ts +10 -13
  55. package/dist/modules/Payment/index.js +467 -837
  56. package/dist/modules/Payment/types.d.ts +2 -0
  57. package/dist/modules/Payment/utils.js +2 -1
  58. package/dist/modules/Payment/walletpass.js +41 -25
  59. package/dist/modules/ProductList/index.d.ts +16 -12
  60. package/dist/modules/ProductList/index.js +133 -59
  61. package/dist/modules/ProductList/types.d.ts +14 -0
  62. package/dist/modules/Quotation/index.d.ts +0 -1
  63. package/dist/modules/Quotation/index.js +25 -22
  64. package/dist/modules/Rules/index.d.ts +4 -0
  65. package/dist/modules/Rules/index.js +97 -70
  66. package/dist/modules/Rules/types.d.ts +1 -0
  67. package/dist/modules/SalesSummary/index.d.ts +8 -25
  68. package/dist/modules/SalesSummary/index.js +86 -35
  69. package/dist/modules/SalesSummary/types.d.ts +4 -1
  70. package/dist/modules/SalesSummary/utils.d.ts +2 -25
  71. package/dist/modules/SalesSummary/utils.js +794 -162
  72. package/dist/modules/Schedule/index.d.ts +7 -0
  73. package/dist/modules/Schedule/index.js +24 -2
  74. package/dist/modules/Summary/index.js +4 -3
  75. package/dist/modules/SurchargeList/index.d.ts +16 -0
  76. package/dist/modules/SurchargeList/index.js +162 -0
  77. package/dist/modules/SurchargeList/types.d.ts +11 -0
  78. package/dist/modules/SurchargeList/types.js +1 -0
  79. package/dist/modules/index.d.ts +2 -0
  80. package/dist/modules/index.js +3 -1
  81. package/dist/plugins/request.d.ts +1 -0
  82. package/dist/server/index.d.ts +204 -1
  83. package/dist/server/index.js +3654 -922
  84. package/dist/server/modules/index.d.ts +2 -0
  85. package/dist/server/modules/index.js +2 -0
  86. package/dist/server/modules/order/index.d.ts +120 -3
  87. package/dist/server/modules/order/index.js +1758 -448
  88. package/dist/server/modules/order/types.d.ts +32 -3
  89. package/dist/server/modules/order/types.js +8 -0
  90. package/dist/server/modules/order/utils/filterBookings.js +26 -3
  91. package/dist/server/modules/order/utils/filterOrders.js +23 -8
  92. package/dist/server/modules/payment/index.d.ts +28 -0
  93. package/dist/server/modules/payment/index.js +305 -0
  94. package/dist/server/modules/payment/types.d.ts +9 -0
  95. package/dist/server/modules/payment/types.js +1 -0
  96. package/dist/server/modules/products/index.d.ts +34 -7
  97. package/dist/server/modules/products/index.js +631 -317
  98. package/dist/server/modules/resource/index.d.ts +2 -0
  99. package/dist/server/modules/resource/index.js +29 -3
  100. package/dist/server/modules/schedule/index.d.ts +4 -4
  101. package/dist/server/modules/schedule/index.js +111 -88
  102. package/dist/server/test.json +713 -0
  103. package/dist/server/utils/small-ticket.d.ts +71 -0
  104. package/dist/server/utils/small-ticket.js +840 -0
  105. package/dist/solution/BaseSales/index.d.ts +133 -10
  106. package/dist/solution/BaseSales/index.js +1950 -447
  107. package/dist/solution/BaseSales/types.d.ts +82 -6
  108. package/dist/solution/BaseSales/types.js +5 -4
  109. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
  110. package/dist/solution/BaseSales/utils/cartPromotion.js +1438 -0
  111. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  112. package/dist/solution/BaseSales/utils/quotationPrice.js +237 -0
  113. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  114. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +105 -24
  115. package/dist/solution/BaseSales/utils.d.ts +1 -1
  116. package/dist/solution/BaseSales/utils.js +62 -21
  117. package/dist/solution/BookingByStep/index.d.ts +1 -1
  118. package/dist/solution/BookingTicket/index.d.ts +271 -11
  119. package/dist/solution/BookingTicket/index.js +1777 -242
  120. package/dist/solution/BookingTicket/types.d.ts +118 -1
  121. package/dist/solution/BookingTicket/types.js +41 -2
  122. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
  123. package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
  124. package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
  125. package/dist/solution/BookingTicket/utils/addTimeAvailability.js +95 -0
  126. package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +40 -0
  127. package/dist/solution/BookingTicket/utils/bookingStatus.js +70 -0
  128. package/dist/solution/BookingTicket/utils/cartView.d.ts +9 -1
  129. package/dist/solution/BookingTicket/utils/cartView.js +94 -7
  130. package/dist/solution/BookingTicket/utils/exampleData.d.ts +123 -0
  131. package/dist/solution/BookingTicket/utils/exampleData.js +183 -0
  132. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
  133. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +438 -0
  134. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
  135. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +400 -0
  136. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
  137. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +56 -0
  138. package/dist/solution/BookingTicket/utils/scan/index.d.ts +5 -0
  139. package/dist/solution/BookingTicket/utils/scan/index.js +20 -8
  140. package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
  141. package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +150 -0
  142. package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
  143. package/dist/solution/BookingTicket/utils/sessionCatalogStale.js +78 -0
  144. package/dist/solution/Checkout/index.d.ts +1 -0
  145. package/dist/solution/Checkout/index.js +10 -9
  146. package/dist/solution/RegisterAndLogin/config.js +2 -10
  147. package/dist/solution/ScanOrder/index.d.ts +9 -3
  148. package/dist/solution/ScanOrder/index.js +241 -134
  149. package/dist/solution/ScanOrder/types.d.ts +9 -5
  150. package/dist/solution/ScanOrder/types.js +2 -3
  151. package/dist/solution/ScanOrder/utils.d.ts +1 -1
  152. package/dist/solution/ScanOrder/utils.js +84 -22
  153. package/dist/solution/VenueBooking/index.d.ts +5 -2
  154. package/dist/solution/VenueBooking/index.js +110 -59
  155. package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -2
  156. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  157. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
  158. package/dist/types/index.d.ts +10 -0
  159. package/lib/model/strategy/adapter/promotion/evaluator.js +2 -1
  160. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  161. package/lib/model/strategy/adapter/walletPass/utils.js +3 -2
  162. package/lib/modules/BookingContext/index.d.ts +48 -0
  163. package/lib/modules/BookingContext/index.js +368 -0
  164. package/lib/modules/BookingContext/types.d.ts +102 -0
  165. package/lib/modules/BookingContext/types.js +34 -0
  166. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  167. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +276 -0
  168. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  169. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +151 -0
  170. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
  171. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +201 -0
  172. package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
  173. package/lib/modules/BookingContext/utils/flexible.js +80 -0
  174. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  175. package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
  176. package/lib/modules/BookingContext/utils/index.d.ts +11 -0
  177. package/lib/modules/BookingContext/utils/index.js +43 -0
  178. package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
  179. package/lib/modules/BookingContext/utils/noResource.js +90 -0
  180. package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
  181. package/lib/modules/BookingContext/utils/orderLineDisplay.js +56 -0
  182. package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
  183. package/lib/modules/BookingContext/utils/productExtend.js +283 -0
  184. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  185. package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
  186. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  187. package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
  188. package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
  189. package/lib/modules/BookingContext/utils/resources.js +377 -0
  190. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  191. package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
  192. package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  193. package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
  194. package/lib/modules/Cart/utils/cartProduct.js +20 -3
  195. package/lib/modules/Cart/utils/changePrice.js +12 -20
  196. package/lib/modules/Customer/index.d.ts +20 -0
  197. package/lib/modules/Customer/index.js +64 -11
  198. package/lib/modules/Customer/types.d.ts +2 -0
  199. package/lib/modules/Discount/index.d.ts +1 -1
  200. package/lib/modules/Discount/index.js +9 -1
  201. package/lib/modules/Discount/types.d.ts +1 -0
  202. package/lib/modules/OpenData/index.d.ts +8 -0
  203. package/lib/modules/OpenData/index.js +19 -5
  204. package/lib/modules/Order/index.d.ts +275 -19
  205. package/lib/modules/Order/index.js +2245 -336
  206. package/lib/modules/Order/types.d.ts +286 -31
  207. package/lib/modules/Order/types.js +1 -0
  208. package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  209. package/lib/modules/Order/utils/manualProductDiscount.js +206 -0
  210. package/lib/modules/Order/utils.d.ts +147 -5
  211. package/lib/modules/Order/utils.js +615 -46
  212. package/lib/modules/Payment/index.d.ts +10 -13
  213. package/lib/modules/Payment/index.js +18 -150
  214. package/lib/modules/Payment/types.d.ts +2 -0
  215. package/lib/modules/Payment/utils.js +2 -1
  216. package/lib/modules/Payment/walletpass.js +16 -3
  217. package/lib/modules/ProductList/index.d.ts +16 -12
  218. package/lib/modules/ProductList/index.js +41 -4
  219. package/lib/modules/ProductList/types.d.ts +14 -0
  220. package/lib/modules/Quotation/index.d.ts +0 -1
  221. package/lib/modules/Quotation/index.js +19 -16
  222. package/lib/modules/Rules/index.d.ts +4 -0
  223. package/lib/modules/Rules/index.js +137 -120
  224. package/lib/modules/Rules/types.d.ts +1 -0
  225. package/lib/modules/SalesSummary/index.d.ts +8 -25
  226. package/lib/modules/SalesSummary/index.js +30 -4
  227. package/lib/modules/SalesSummary/types.d.ts +4 -1
  228. package/lib/modules/SalesSummary/utils.d.ts +2 -25
  229. package/lib/modules/SalesSummary/utils.js +645 -91
  230. package/lib/modules/Schedule/index.d.ts +7 -0
  231. package/lib/modules/Schedule/index.js +17 -1
  232. package/lib/modules/Summary/index.js +5 -4
  233. package/lib/modules/SurchargeList/index.d.ts +16 -0
  234. package/lib/modules/SurchargeList/index.js +89 -0
  235. package/lib/modules/SurchargeList/types.d.ts +11 -0
  236. package/lib/modules/SurchargeList/types.js +17 -0
  237. package/lib/modules/index.d.ts +2 -0
  238. package/lib/modules/index.js +5 -1
  239. package/lib/plugins/request.d.ts +1 -0
  240. package/lib/server/index.d.ts +204 -1
  241. package/lib/server/index.js +1891 -59
  242. package/lib/server/modules/index.d.ts +2 -0
  243. package/lib/server/modules/index.js +3 -0
  244. package/lib/server/modules/order/index.d.ts +120 -3
  245. package/lib/server/modules/order/index.js +883 -94
  246. package/lib/server/modules/order/types.d.ts +32 -3
  247. package/lib/server/modules/order/utils/filterBookings.js +24 -5
  248. package/lib/server/modules/order/utils/filterOrders.js +15 -6
  249. package/lib/server/modules/payment/index.d.ts +28 -0
  250. package/lib/server/modules/payment/index.js +192 -0
  251. package/lib/server/modules/payment/types.d.ts +9 -0
  252. package/lib/server/modules/payment/types.js +17 -0
  253. package/lib/server/modules/products/index.d.ts +34 -7
  254. package/lib/server/modules/products/index.js +189 -54
  255. package/lib/server/modules/resource/index.d.ts +2 -0
  256. package/lib/server/modules/resource/index.js +27 -3
  257. package/lib/server/modules/schedule/index.d.ts +4 -4
  258. package/lib/server/modules/schedule/index.js +47 -40
  259. package/lib/server/test.json +713 -0
  260. package/lib/server/utils/small-ticket.d.ts +71 -0
  261. package/lib/server/utils/small-ticket.js +800 -0
  262. package/lib/solution/BaseSales/index.d.ts +133 -10
  263. package/lib/solution/BaseSales/index.js +1111 -63
  264. package/lib/solution/BaseSales/types.d.ts +82 -6
  265. package/lib/solution/BaseSales/types.js +3 -1
  266. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
  267. package/lib/solution/BaseSales/utils/cartPromotion.js +992 -0
  268. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  269. package/lib/solution/BaseSales/utils/quotationPrice.js +277 -0
  270. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  271. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +106 -18
  272. package/lib/solution/BaseSales/utils.d.ts +1 -1
  273. package/lib/solution/BaseSales/utils.js +54 -10
  274. package/lib/solution/BookingByStep/index.d.ts +1 -1
  275. package/lib/solution/BookingTicket/index.d.ts +271 -11
  276. package/lib/solution/BookingTicket/index.js +922 -29
  277. package/lib/solution/BookingTicket/types.d.ts +118 -1
  278. package/lib/solution/BookingTicket/types.js +11 -0
  279. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
  280. package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
  281. package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
  282. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +125 -0
  283. package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +40 -0
  284. package/lib/solution/BookingTicket/utils/bookingStatus.js +44 -2
  285. package/lib/solution/BookingTicket/utils/cartView.d.ts +9 -1
  286. package/lib/solution/BookingTicket/utils/cartView.js +61 -6
  287. package/lib/solution/BookingTicket/utils/exampleData.d.ts +123 -0
  288. package/lib/solution/BookingTicket/utils/exampleData.js +0 -0
  289. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
  290. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +254 -0
  291. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
  292. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +169 -0
  293. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
  294. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +51 -0
  295. package/lib/solution/BookingTicket/utils/scan/index.d.ts +5 -0
  296. package/lib/solution/BookingTicket/utils/scan/index.js +17 -3
  297. package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
  298. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +127 -0
  299. package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
  300. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +85 -0
  301. package/lib/solution/Checkout/index.d.ts +1 -0
  302. package/lib/solution/Checkout/index.js +1 -2
  303. package/lib/solution/RegisterAndLogin/config.js +2 -10
  304. package/lib/solution/ScanOrder/index.d.ts +9 -3
  305. package/lib/solution/ScanOrder/index.js +153 -70
  306. package/lib/solution/ScanOrder/types.d.ts +9 -5
  307. package/lib/solution/ScanOrder/utils.d.ts +1 -1
  308. package/lib/solution/ScanOrder/utils.js +83 -17
  309. package/lib/solution/VenueBooking/index.d.ts +5 -2
  310. package/lib/solution/VenueBooking/index.js +54 -17
  311. package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -2
  312. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  313. package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
  314. package/lib/types/index.d.ts +10 -0
  315. package/package.json +1 -1
  316. package/dist/solution/Checkout/appointmentDemo.json +0 -1
  317. package/lib/solution/Checkout/appointmentDemo.json +0 -1
@@ -2,15 +2,15 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableTo
2
2
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
3
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
4
4
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
5
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
6
5
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
7
6
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
7
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
8
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
10
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
9
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
13
10
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
11
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
14
14
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
15
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
16
16
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -37,7 +37,7 @@ import { createModule } from "../BookingByStep/types";
37
37
  import { ProductList } from "../../modules/ProductList";
38
38
  import { ScheduleModule } from "../../modules/Schedule";
39
39
  import { getDateIsInSchedule } from "../../modules/Schedule/getDateIsInSchedule";
40
- import { composeLinePrice, createUuidV4, normalizeSubmitCollectPaxValue, sumOptionUnitPrice } from "../../modules/Order/utils";
40
+ import { composeLinePrice, createUuidV4, getProductSkuOptions, normalizeSubmitCollectPaxValue, sumOptionUnitPrice } from "../../modules/Order/utils";
41
41
  import dayjs from 'dayjs';
42
42
  import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
43
43
  export * from "./types";
@@ -94,15 +94,50 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
94
94
  moduleName: 'scanOrder'
95
95
  };
96
96
  }
97
+ }, {
98
+ key: "safeStringify",
99
+ value: function safeStringify(value) {
100
+ try {
101
+ return JSON.stringify(value);
102
+ } catch (_unused) {
103
+ return undefined;
104
+ }
105
+ }
106
+ }, {
107
+ key: "pickErrorMessage",
108
+ value: function pickErrorMessage(error) {
109
+ var _error$data, _error$response, _error$error;
110
+ var candidates = [error.message, (_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.message, (_error$response = error.response) === null || _error$response === void 0 || (_error$response = _error$response.data) === null || _error$response === void 0 ? void 0 : _error$response.message, (_error$error = error.error) === null || _error$error === void 0 ? void 0 : _error$error.message];
111
+ for (var _i = 0, _candidates = candidates; _i < _candidates.length; _i++) {
112
+ var candidate = _candidates[_i];
113
+ if (typeof candidate === 'string' && candidate.trim()) return candidate;
114
+ }
115
+ return undefined;
116
+ }
97
117
  }, {
98
118
  key: "serializeError",
99
119
  value: function serializeError(error) {
100
120
  if (error instanceof Error) {
101
- return JSON.stringify({
121
+ return {
102
122
  name: error.name,
103
123
  message: error.message,
104
124
  stack: error.stack
105
- });
125
+ };
126
+ }
127
+ if (error && _typeof(error) === 'object') {
128
+ var raw = error;
129
+ var message = this.pickErrorMessage(raw) || this.safeStringify(raw) || String(error);
130
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, typeof raw.name === 'string' ? {
131
+ name: raw.name
132
+ } : {}), {}, {
133
+ message: message
134
+ }, 'code' in raw ? {
135
+ code: raw.code
136
+ } : {}), 'status' in raw ? {
137
+ status: raw.status
138
+ } : {}), this.safeStringify(raw) ? {
139
+ raw: this.safeStringify(raw)
140
+ } : {});
106
141
  }
107
142
  return {
108
143
  message: String(error)
@@ -192,6 +227,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
192
227
  })
193
228
  });
194
229
  }
230
+ }, {
231
+ key: "assertProductListLoaded",
232
+ value: function assertProductListLoaded(method, result) {
233
+ var payload = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
234
+ if (Array.isArray(result)) return result;
235
+ var error = result instanceof Error ? result : new Error('商品列表接口返回异常');
236
+ this.logMethodError(method, error, payload);
237
+ error.__scanOrderLogged = true;
238
+ throw error;
239
+ }
195
240
  }, {
196
241
  key: "addLog",
197
242
  value: function () {
@@ -228,8 +273,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
228
273
  value: function resolveCustomerIdFromLoginPayload(payload) {
229
274
  var _payload$user, _payload$user2, _payload$user3, _payload$user4, _payload$account, _payload$account2, _payload$account3, _payload$_origin;
230
275
  var candidates = [payload === null || payload === void 0 ? void 0 : payload.customerId, payload === null || payload === void 0 ? void 0 : payload.customer_id, payload === null || payload === void 0 ? void 0 : payload.id, payload === null || payload === void 0 || (_payload$user = payload.user) === null || _payload$user === void 0 ? void 0 : _payload$user.customerId, payload === null || payload === void 0 || (_payload$user2 = payload.user) === null || _payload$user2 === void 0 ? void 0 : _payload$user2.customer_id, payload === null || payload === void 0 || (_payload$user3 = payload.user) === null || _payload$user3 === void 0 ? void 0 : _payload$user3.id, payload === null || payload === void 0 || (_payload$user4 = payload.user) === null || _payload$user4 === void 0 || (_payload$user4 = _payload$user4._origin) === null || _payload$user4 === void 0 ? void 0 : _payload$user4.customer_id, payload === null || payload === void 0 || (_payload$account = payload.account) === null || _payload$account === void 0 ? void 0 : _payload$account.customerId, payload === null || payload === void 0 || (_payload$account2 = payload.account) === null || _payload$account2 === void 0 ? void 0 : _payload$account2.customer_id, payload === null || payload === void 0 || (_payload$account3 = payload.account) === null || _payload$account3 === void 0 ? void 0 : _payload$account3.id, payload === null || payload === void 0 || (_payload$_origin = payload._origin) === null || _payload$_origin === void 0 ? void 0 : _payload$_origin.customer_id];
231
- for (var _i = 0, _candidates = candidates; _i < _candidates.length; _i++) {
232
- var candidate = _candidates[_i];
276
+ for (var _i2 = 0, _candidates2 = candidates; _i2 < _candidates2.length; _i2++) {
277
+ var candidate = _candidates2[_i2];
233
278
  var customerId = this.normalizeCustomerId(candidate);
234
279
  if (customerId) return customerId;
235
280
  }
@@ -399,18 +444,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
399
444
  key: "destroyRegisteredChildModules",
400
445
  value: function () {
401
446
  var _destroyRegisteredChildModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
402
- var modules, _i2, _modules, mod;
447
+ var modules, _i3, _modules, mod;
403
448
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
404
449
  while (1) switch (_context6.prev = _context6.next) {
405
450
  case 0:
406
451
  modules = [this.store.schedule, this.store.salesSummary, this.store.order, this.store.products, this.store.scanOrderLogger];
407
- _i2 = 0, _modules = modules;
452
+ _i3 = 0, _modules = modules;
408
453
  case 2:
409
- if (!(_i2 < _modules.length)) {
454
+ if (!(_i3 < _modules.length)) {
410
455
  _context6.next = 10;
411
456
  break;
412
457
  }
413
- mod = _modules[_i2];
458
+ mod = _modules[_i3];
414
459
  if (!(mod && typeof mod.destroy === 'function')) {
415
460
  _context6.next = 7;
416
461
  break;
@@ -418,7 +463,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
418
463
  _context6.next = 7;
419
464
  return Promise.resolve(mod.destroy());
420
465
  case 7:
421
- _i2++;
466
+ _i3++;
422
467
  _context6.next = 2;
423
468
  break;
424
469
  case 10:
@@ -492,13 +537,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
492
537
  var _this4$store$order, _this4$otherParams, _this4$otherParams2, _this4$otherParams3, _this4$otherParams4;
493
538
  _this4.store[step] = targetModule;
494
539
  var initialState = step === 'salesSummary' ? {
495
- // TODO(Order types): ScanOrder runtime should read OrderState.summary instead of tempOrder.summary.
496
540
  summary: ((_this4$store$order = _this4.store.order) === null || _this4$store$order === void 0 || (_this4$store$order = _this4$store$order.getTempOrder()) === null || _this4$store$order === void 0 ? void 0 : _this4$store$order.summary) || createEmptySummary()
497
541
  } : {};
498
542
  var loggerProvider = ((_this4$otherParams = _this4.otherParams) === null || _this4$otherParams === void 0 ? void 0 : _this4$otherParams.scanOrderLoggerProvider) || 'feishu';
499
543
  var loggerConfig = ((_this4$otherParams2 = _this4.otherParams) === null || _this4$otherParams2 === void 0 ? void 0 : _this4$otherParams2.scanOrderLoggerConfig) || {
500
544
  feishu: {
501
- webhook: 'https://open.feishu.cn/open-apis/bot/v2/hook/216b3fe6-af98-424e-8706-f0471241a7ed'
545
+ webhook: 'https://open.feishu.cn/open-apis/bot/v2/hook/216b3fe6-af98-424e-8706-f0471241a7ed',
546
+ errorHook: 'https://open.feishu.cn/open-apis/bot/v2/hook/015b7c2a-dd3c-4c30-9898-ef0f5253111f'
502
547
  }
503
548
  };
504
549
  _this4.core.registerModule(targetModule, {
@@ -1153,7 +1198,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1153
1198
  totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
1154
1199
  return sum + (pd.amount || 0);
1155
1200
  }, 0);
1156
- optionSum = sumOptionUnitPrice(product.product_option_item);
1201
+ optionSum = sumOptionUnitPrice(getProductSkuOptions(product));
1157
1202
  sourcePrice = (_product$metadata$sou = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : '0';
1158
1203
  newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
1159
1204
  newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
@@ -1248,7 +1293,50 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1248
1293
  return _onCustomerLogin.apply(this, arguments);
1249
1294
  }
1250
1295
  return onCustomerLogin;
1251
- }() // ScanOrder 提交 payload enhancer:
1296
+ }()
1297
+ }, {
1298
+ key: "findReservationRuleResource",
1299
+ value: function findReservationRuleResource(formId) {
1300
+ if (formId == null) return undefined;
1301
+ var numericFormId = Number(formId);
1302
+ if (!Number.isFinite(numericFormId) || numericFormId <= 0) return undefined;
1303
+ var _iterator4 = _createForOfIteratorHelper(this.enabledReservationRuleProducts),
1304
+ _step4;
1305
+ try {
1306
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1307
+ var _product$product_reso;
1308
+ var product = _step4.value;
1309
+ 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;
1310
+ if (!Array.isArray(resources)) continue;
1311
+ var matched = resources.find(function (resource) {
1312
+ return Number(resource === null || resource === void 0 ? void 0 : resource.id) === numericFormId;
1313
+ });
1314
+ if (matched) return matched;
1315
+ }
1316
+ } catch (err) {
1317
+ _iterator4.e(err);
1318
+ } finally {
1319
+ _iterator4.f();
1320
+ }
1321
+ return undefined;
1322
+ }
1323
+ }, {
1324
+ key: "buildScanOrderResourceMetadata",
1325
+ value: function buildScanOrderResourceMetadata(params) {
1326
+ var _ruleResource$title;
1327
+ var resourceState = params.resourceState,
1328
+ resourceName = params.resourceName;
1329
+ var ruleResource = this.findReservationRuleResource(resourceState.tableFormId);
1330
+ var combined = ruleResource === null || ruleResource === void 0 ? void 0 : ruleResource.combined_resource;
1331
+ var isCombined = !!(combined && combined.status === 1 && Array.isArray(combined.resource_ids));
1332
+ return {
1333
+ form_name: (_ruleResource$title = ruleResource === null || ruleResource === void 0 ? void 0 : ruleResource.title) !== null && _ruleResource$title !== void 0 ? _ruleResource$title : '',
1334
+ resource_name: resourceName,
1335
+ combined_resource: isCombined ? combined : null
1336
+ };
1337
+ }
1338
+
1339
+ // ScanOrder 提交 payload enhancer:
1252
1340
  // - 给所有 booking 注入 appointment_status: 'started'(扫码点餐语义)
1253
1341
  // - 给所有 booking 的 metadata 注入 resource_select_type(来自预约规则商品的 resource.type)
1254
1342
  // - 给第一条 booking 补 resources 与 product_uid(仅当存在 resource / rule product)
@@ -1261,7 +1349,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1261
1349
  var resourceState = this.store.resource;
1262
1350
  var resourceSelectType = resourceState === null || resourceState === void 0 ? void 0 : resourceState.resourceSelectType;
1263
1351
 
1264
- // single 预约独占整张桌台,capacity form_record.capacity;其他情况(multiple / capacity / undefined)占 1 个容量位
1352
+ // collect_pax 时的资源占用兜底:single 独占整张桌台,其余模式占 1 个容量位。
1265
1353
  var resolveResourceCapacity = function resolveResourceCapacity() {
1266
1354
  if (resourceSelectType === 'single') {
1267
1355
  var _resourceState$table_;
@@ -1273,11 +1361,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1273
1361
  return 1;
1274
1362
  };
1275
1363
  return function (payload, _ref3) {
1276
- var _resource_id, _ref4, _pickOriginal, _resourceState$table_2, _resourceState$relati, _tempOrder$metadata, _pickFirstCustomCapac;
1364
+ var _resource_id, _tempOrder$metadata, _ref4, _pickOriginal, _resourceState$table_2, _resourceState$relati, _pickFirstCustomCapac;
1277
1365
  var bookingUuid = _ref3.bookingUuid,
1278
1366
  tempOrder = _ref3.tempOrder;
1279
- // TODO(Order types): ScanOrder resource runtime should come from ScanOrder store only.
1280
1367
  var resourceId = (_resource_id = tempOrder.resource_id) !== null && _resource_id !== void 0 ? _resource_id : resourceState === null || resourceState === void 0 ? void 0 : resourceState.relationId;
1368
+ var rawCollectPax = (_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.collect_pax;
1369
+ var hasCollectPaxForCapacity = rawCollectPax !== null && rawCollectPax !== undefined && rawCollectPax !== '';
1370
+ var resourceCapacityValue = hasCollectPaxForCapacity ? normalizeSubmitCollectPaxValue(rawCollectPax) : resolveResourceCapacity();
1281
1371
  var pickOriginal = function pickOriginal(value) {
1282
1372
  if (value && _typeof(value) === 'object' && !Array.isArray(value)) {
1283
1373
  var original = value.original;
@@ -1293,22 +1383,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1293
1383
  main_field: mainField,
1294
1384
  form_id: resourceState.tableFormId,
1295
1385
  relation_id: (_resourceState$relati = resourceState.relationId) !== null && _resourceState$relati !== void 0 ? _resourceState$relati : resourceId,
1296
- capacity: resolveResourceCapacity(),
1297
- metadata: {}
1386
+ capacity: resourceCapacityValue,
1387
+ metadata: _this5.buildScanOrderResourceMetadata({
1388
+ resourceState: resourceState,
1389
+ resourceName: mainField
1390
+ })
1298
1391
  } : undefined;
1299
1392
  var ruleProductUid = ruleProduct ? createUuidV4() : undefined;
1300
- // 默认 resolveResourceCapacity(single 为桌台容量,其余多为 1);有 collect_pax value 优先用人数
1301
- var rawCollectPax = (_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.collect_pax;
1302
- var hasCollectPaxForCapacity = rawCollectPax !== null && rawCollectPax !== undefined && rawCollectPax !== '';
1303
- var bookingCapacityValue = hasCollectPaxForCapacity ? normalizeSubmitCollectPaxValue(rawCollectPax) : resolveResourceCapacity();
1393
+ // collect_pax booking/resource capacity number 都代表本次 pax;否则使用资源占用兜底值。
1394
+ var bookingCapacityValue = resourceCapacityValue;
1304
1395
  var bookingCapacityDimensionId = (_pickFirstCustomCapac = pickFirstCustomCapacityDimensionId(_this5.enabledReservationRuleProducts)) !== null && _pickFirstCustomCapac !== void 0 ? _pickFirstCustomCapac : 0;
1305
1396
  var nextBookings = (payload.bookings || []).map(function (booking, idx) {
1306
- var _booking$metadata$hol, _booking$metadata;
1307
1397
  return _objectSpread(_objectSpread(_objectSpread({}, booking), {}, {
1398
+ number: bookingCapacityValue,
1308
1399
  appointment_status: 'started',
1309
- metadata: _objectSpread(_objectSpread(_objectSpread({}, booking.metadata || {}), {}, {
1310
- holder_id: (_booking$metadata$hol = (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.holder_id) !== null && _booking$metadata$hol !== void 0 ? _booking$metadata$hol : null
1311
- }, resourceSelectType ? {
1400
+ metadata: _objectSpread(_objectSpread(_objectSpread({}, booking.metadata || {}), resourceSelectType ? {
1312
1401
  resource_select_type: resourceSelectType
1313
1402
  } : {}), resourceSelectType ? {
1314
1403
  capacity: [{
@@ -1324,7 +1413,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1324
1413
  } : {});
1325
1414
  });
1326
1415
  var nextProducts = _toConsumableArray(payload.products || []);
1327
- // 编辑已有订单时,后端会通过 order_id 判断更新;原单已含 booking 规则行,勿再追加虚拟规则商品
1416
+ // 加餐(已有 order_id)走 scanOrderMore,原单已含 booking 规则行,勿再追加虚拟规则商品
1328
1417
  if (ruleProduct && ruleProductUid && !tempOrder.order_id) {
1329
1418
  var _ruleProduct$price, _ref5, _ruleProduct$original, _ruleProduct$is_gst;
1330
1419
  var sellingPrice = String((_ruleProduct$price = ruleProduct.price) !== null && _ruleProduct$price !== void 0 ? _ruleProduct$price : '0.00');
@@ -1337,7 +1426,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1337
1426
  original_price: originalPrice,
1338
1427
  payment_price: sellingPrice,
1339
1428
  is_charge_tax: (_ruleProduct$is_gst = ruleProduct.is_gst) !== null && _ruleProduct$is_gst !== void 0 ? _ruleProduct$is_gst : 0,
1340
- product_option_item: [],
1429
+ product_sku: {
1430
+ option: []
1431
+ },
1341
1432
  discount_list: [],
1342
1433
  product_bundle: [],
1343
1434
  booking_uid: bookingUuid,
@@ -1470,14 +1561,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1470
1561
  return addProductToOrder;
1471
1562
  }()
1472
1563
  }, {
1473
- key: "updateProductInOrder",
1564
+ key: "updateOrderProduct",
1474
1565
  value: function () {
1475
- var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
1566
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
1476
1567
  var products;
1477
1568
  return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1478
1569
  while (1) switch (_context19.prev = _context19.next) {
1479
1570
  case 0:
1480
- this.logMethodStart('updateProductInOrder', {
1571
+ this.logMethodStart('updateOrderProduct', {
1481
1572
  product_id: params.product_id,
1482
1573
  product_variant_id: params.product_variant_id
1483
1574
  });
@@ -1489,7 +1580,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1489
1580
  throw new Error('order 模块未初始化');
1490
1581
  case 4:
1491
1582
  _context19.next = 6;
1492
- return this.store.order.updateProductInOrder(params);
1583
+ return this.store.order.updateOrderProduct(params);
1493
1584
  case 6:
1494
1585
  products = _context19.sent;
1495
1586
  _context19.next = 9;
@@ -1498,14 +1589,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1498
1589
  _context19.next = 11;
1499
1590
  return this.refreshCartValidationPassed();
1500
1591
  case 11:
1501
- this.logMethodSuccess('updateProductInOrder', {
1592
+ this.logMethodSuccess('updateOrderProduct', {
1502
1593
  productCount: products.length
1503
1594
  });
1504
1595
  return _context19.abrupt("return", products);
1505
1596
  case 15:
1506
1597
  _context19.prev = 15;
1507
1598
  _context19.t0 = _context19["catch"](1);
1508
- this.logMethodError('updateProductInOrder', _context19.t0);
1599
+ this.logMethodError('updateOrderProduct', _context19.t0);
1509
1600
  throw _context19.t0;
1510
1601
  case 19:
1511
1602
  case "end":
@@ -1513,10 +1604,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1513
1604
  }
1514
1605
  }, _callee19, this, [[1, 15]]);
1515
1606
  }));
1516
- function updateProductInOrder(_x11) {
1517
- return _updateProductInOrder.apply(this, arguments);
1607
+ function updateOrderProduct(_x11) {
1608
+ return _updateOrderProduct.apply(this, arguments);
1518
1609
  }
1519
- return updateProductInOrder;
1610
+ return updateOrderProduct;
1520
1611
  }()
1521
1612
  /**
1522
1613
  * 设置单行商品备注(与整单 `updateTempOrderNote` 区分)。
@@ -1542,16 +1633,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1542
1633
  note: String(note || '')
1543
1634
  }
1544
1635
  };
1545
- if (identity.identity_key !== undefined) {
1546
- // TODO(Order types): ScanOrder identity callers should pass unique_identification_number.
1547
- params.identity_key = identity.identity_key;
1548
- }
1549
- if (identity.product_option_item !== undefined) {
1550
- params.product_option_item = identity.product_option_item;
1636
+ if (identity.identity_key !== undefined) params.identity_key = identity.identity_key;
1637
+ if (identity.product_sku !== undefined) {
1638
+ params.product_sku = identity.product_sku;
1551
1639
  }
1552
1640
  if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
1553
1641
  _context20.next = 8;
1554
- return this.updateProductInOrder(params);
1642
+ return this.updateOrderProduct(params);
1555
1643
  case 8:
1556
1644
  products = _context20.sent;
1557
1645
  this.logMethodSuccess('setOrderProductLineNote', {
@@ -1784,17 +1872,17 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1784
1872
  if (visited.has(value)) return;
1785
1873
  visited.add(value);
1786
1874
  if (Array.isArray(value)) {
1787
- var _iterator4 = _createForOfIteratorHelper(value),
1788
- _step4;
1875
+ var _iterator5 = _createForOfIteratorHelper(value),
1876
+ _step5;
1789
1877
  try {
1790
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1791
- var item = _step4.value;
1878
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
1879
+ var item = _step5.value;
1792
1880
  collectFromValue(item);
1793
1881
  }
1794
1882
  } catch (err) {
1795
- _iterator4.e(err);
1883
+ _iterator5.e(err);
1796
1884
  } finally {
1797
- _iterator4.f();
1885
+ _iterator5.f();
1798
1886
  }
1799
1887
  return;
1800
1888
  }
@@ -1810,8 +1898,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1810
1898
  sourceMap.set(key, node);
1811
1899
  }
1812
1900
  }
1813
- for (var _i3 = 0, _Object$values = Object.values(node); _i3 < _Object$values.length; _i3++) {
1814
- var childValue = _Object$values[_i3];
1901
+ for (var _i4 = 0, _Object$values = Object.values(node); _i4 < _Object$values.length; _i4++) {
1902
+ var childValue = _Object$values[_i4];
1815
1903
  if (childValue && _typeof(childValue) === 'object') {
1816
1904
  collectFromValue(childValue);
1817
1905
  }
@@ -1955,7 +2043,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1955
2043
  key: "applyPrefillByItemRule",
1956
2044
  value: function () {
1957
2045
  var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
1958
- var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator5, _step5, _prefillItem$product_, _origin2, _origin3, _origin4, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, sellingPrice, targetProduct, existedQuantity, delta, nextProduct, hasQuantityChanged, hasOriginChanged;
2046
+ var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator6, _step6, _prefillItem$product_, _origin2, _origin3, _origin4, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, sellingPrice, targetProduct, existedQuantity, delta, nextProduct, hasQuantityChanged, hasOriginChanged;
1959
2047
  return _regeneratorRuntime().wrap(function _callee29$(_context29) {
1960
2048
  while (1) switch (_context29.prev = _context29.next) {
1961
2049
  case 0:
@@ -2000,15 +2088,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2000
2088
  productSourceMap = _context29.sent;
2001
2089
  tempOrder = this.ensureTempOrder();
2002
2090
  hasChanges = false;
2003
- _iterator5 = _createForOfIteratorHelper(prefillItems);
2091
+ _iterator6 = _createForOfIteratorHelper(prefillItems);
2004
2092
  _context29.prev = 20;
2005
- _iterator5.s();
2093
+ _iterator6.s();
2006
2094
  case 22:
2007
- if ((_step5 = _iterator5.n()).done) {
2095
+ if ((_step6 = _iterator6.n()).done) {
2008
2096
  _context29.next = 47;
2009
2097
  break;
2010
2098
  }
2011
- prefillItem = _step5.value;
2099
+ prefillItem = _step6.value;
2012
2100
  productId = Number(prefillItem.product_id);
2013
2101
  productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
2014
2102
  targetQuantity = toNonNegativeInt(prefillItem.quantity);
@@ -2062,7 +2150,6 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2062
2150
  item_rule_prefill: true,
2063
2151
  item_rule_id: prefillItem.ruleId
2064
2152
  }),
2065
- // TODO(Order types): migrate ScanOrder prefill origin runtime into tempOrder._extend.
2066
2153
  _origin: sourceItem ? _objectSpread(_objectSpread({}, targetProduct._origin || {}), sourceItem) : targetProduct._origin
2067
2154
  });
2068
2155
  hasQuantityChanged = delta > 0;
@@ -2080,10 +2167,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2080
2167
  case 49:
2081
2168
  _context29.prev = 49;
2082
2169
  _context29.t0 = _context29["catch"](20);
2083
- _iterator5.e(_context29.t0);
2170
+ _iterator6.e(_context29.t0);
2084
2171
  case 52:
2085
2172
  _context29.prev = 52;
2086
- _iterator5.f();
2173
+ _iterator6.f();
2087
2174
  return _context29.finish(52);
2088
2175
  case 55:
2089
2176
  if (!hasChanges) {
@@ -2471,7 +2558,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2471
2558
  key: "checkResourceAvailable",
2472
2559
  value: function () {
2473
2560
  var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(resourceId, hasOrderId) {
2474
- var _this$otherParams10, _this$otherParams10$g, _occupyDetail$form_re, _occupyDetail$form_re2, _this$otherParams11, _this$store$order5, _this$store$order7, _this$store$order7$ge, _this$otherParams12, openData, dineInConfig, closedBehaviorValue, closedMessage, basicUnavailableMessage, pauseMessage, makeShopClosed, operatingHourIds, outsideOperatingHours, scheduleList, now, tempOrder, reservationLinkIds, pendingRequestEntryPax, pendingRequestPaxMin, pendingRequestPaxMax, reservationProductList, scheduleDate, scheduleDatetime, loaded, occupancyMinutes, paxBounds, occupyDetail, resourceSelectType, resourceState, availabilityInfo, _this$store$order6, _res$data, res, entryPaxNumber, lastOrderInfo, historicalItems;
2561
+ var _this$otherParams$bus, _this$otherParams10, _this$otherParams$cha, _this$otherParams11, _this$otherParams12, _this$otherParams12$g, _occupyDetail$form_re, _occupyDetail$form_re2, _this$otherParams13, _this$store$order5, _this$store$order7, _this$store$order7$ge, _this$otherParams14, businessCode, channel, openDataTarget, openData, dineInConfig, closedBehaviorValue, closedMessage, basicUnavailableMessage, pauseMessage, makeShopClosed, operatingHourIds, outsideOperatingHours, scheduleList, now, tempOrder, reservationLinkIds, pendingRequestEntryPax, pendingRequestPaxMin, pendingRequestPaxMax, reservationProductList, scheduleDate, scheduleDatetime, loaded, occupancyMinutes, paxBounds, error, occupyDetail, resourceSelectType, resourceState, availabilityInfo, _this$store$order6, _res$data, res, entryPaxNumber, lastOrderInfo, historicalItems;
2475
2562
  return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2476
2563
  while (1) switch (_context36.prev = _context36.next) {
2477
2564
  case 0:
@@ -2479,25 +2566,28 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2479
2566
  resourceId: resourceId
2480
2567
  });
2481
2568
  _context36.prev = 1;
2482
- _context36.next = 4;
2483
- return (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 || (_this$otherParams10$g = _this$otherParams10.getOpenData) === null || _this$otherParams10$g === void 0 ? void 0 : _this$otherParams10$g.call(_this$otherParams10, {
2569
+ businessCode = String((_this$otherParams$bus = (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.businessCode) !== null && _this$otherParams$bus !== void 0 ? _this$otherParams$bus : '').trim();
2570
+ channel = String((_this$otherParams$cha = (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.channel) !== null && _this$otherParams$cha !== void 0 ? _this$otherParams$cha : '').trim();
2571
+ openDataTarget = businessCode && channel ? "".concat(businessCode, "+").concat(channel) : 'dine_in+scan_to_order';
2572
+ _context36.next = 7;
2573
+ return (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 || (_this$otherParams12$g = _this$otherParams12.getOpenData) === null || _this$otherParams12$g === void 0 ? void 0 : _this$otherParams12$g.call(_this$otherParams12, {
2484
2574
  scope: 'board',
2485
- target: 'dine_in+scan_to_order',
2575
+ target: openDataTarget,
2486
2576
  section_code: ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow']
2487
2577
  });
2488
- case 4:
2578
+ case 7:
2489
2579
  openData = _context36.sent;
2490
2580
  if (!((openData === null || openData === void 0 ? void 0 : openData.status) === false)) {
2491
- _context36.next = 7;
2581
+ _context36.next = 10;
2492
2582
  break;
2493
2583
  }
2494
2584
  throw new Error((openData === null || openData === void 0 ? void 0 : openData.message) || '获取店铺配置失败');
2495
- case 7:
2585
+ case 10:
2496
2586
  dineInConfig = (openData === null || openData === void 0 ? void 0 : openData.data) || {};
2497
2587
  this.otherParams.dineInConfig = dineInConfig;
2498
- _context36.next = 11;
2588
+ _context36.next = 14;
2499
2589
  return this.syncItemRuleConfigsFromDineInConfig(dineInConfig);
2500
- case 11:
2590
+ case 14:
2501
2591
  closedBehaviorValue = dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.closed_behavior'];
2502
2592
  closedMessage = (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.closed_message']) || (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.message']) || (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.closed_message']);
2503
2593
  basicUnavailableMessage = (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.unavailable_message']) || closedMessage;
@@ -2514,21 +2604,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2514
2604
  };
2515
2605
  }; // 1. 基础开关 basic.enable 关闭
2516
2606
  if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.enable']) === false)) {
2517
- _context36.next = 18;
2607
+ _context36.next = 21;
2518
2608
  break;
2519
2609
  }
2520
2610
  return _context36.abrupt("return", makeShopClosed(basicUnavailableMessage));
2521
- case 18:
2611
+ case 21:
2522
2612
  if (!toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.paused'])) {
2523
- _context36.next = 21;
2613
+ _context36.next = 24;
2524
2614
  break;
2525
2615
  }
2526
2616
  if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.pause_behavior']) === 'hide_all')) {
2527
- _context36.next = 21;
2617
+ _context36.next = 24;
2528
2618
  break;
2529
2619
  }
2530
2620
  return _context36.abrupt("return", makeShopClosed(pauseMessage));
2531
- case 21:
2621
+ case 24:
2532
2622
  // 3. 营业时间 operating_hours 闸门
2533
2623
  operatingHourIds = Array.isArray(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.operating_hours']) ? dineInConfig['availability.operating_hours'].map(function (id) {
2534
2624
  return Number(id);
@@ -2544,27 +2634,27 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2544
2634
  }
2545
2635
  }
2546
2636
  if (!(outsideOperatingHours && closedBehaviorValue !== 'show_menu_disabled')) {
2547
- _context36.next = 26;
2637
+ _context36.next = 29;
2548
2638
  break;
2549
2639
  }
2550
2640
  return _context36.abrupt("return", makeShopClosed(closedMessage, closedBehaviorValue));
2551
- case 26:
2641
+ case 29:
2552
2642
  // Step1: 先加载预约规则商品,拿到 enabledReservationRuleProducts 与容量附加信息
2553
2643
  // (resourceSelectType 需要基于这些商品 + 占用接口的 form_id 计算,故必须前置)
2554
2644
  tempOrder = this.ensureTempOrder();
2555
2645
  reservationLinkIds = collectLinkProductIdsFromReservationRules(dineInConfig['fulfillment.enabled_resource_rules']);
2556
2646
  if (!(reservationLinkIds.length === 0)) {
2557
- _context36.next = 32;
2647
+ _context36.next = 35;
2558
2648
  break;
2559
2649
  }
2560
2650
  this.enabledReservationRuleProducts = [];
2561
- _context36.next = 43;
2651
+ _context36.next = 46;
2562
2652
  break;
2563
- case 32:
2653
+ case 35:
2564
2654
  tempOrder.metadata = _objectSpread({}, tempOrder.metadata || {});
2565
2655
  delete tempOrder.metadata.table_occupancy_duration;
2566
2656
  reservationProductList = new ProductList("".concat(this.name, "_reservationEnabledRules"), this.defaultVersion);
2567
- _context36.next = 37;
2657
+ _context36.next = 40;
2568
2658
  return reservationProductList.initialize(this.core, {
2569
2659
  store: {
2570
2660
  list: [],
@@ -2576,17 +2666,17 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2576
2666
  cacheId: this.cacheId
2577
2667
  })
2578
2668
  });
2579
- case 37:
2669
+ case 40:
2580
2670
  scheduleDate = dayjs().format('YYYY-MM-DD');
2581
2671
  scheduleDatetime = dayjs().format('YYYY-MM-DD HH:mm:ss');
2582
- _context36.next = 41;
2672
+ _context36.next = 44;
2583
2673
  return reservationProductList.loadProducts({
2584
2674
  product_ids: reservationLinkIds,
2585
2675
  schedule_date: scheduleDate,
2586
2676
  schedule_datetime: scheduleDatetime,
2587
2677
  cacheId: this.cacheId
2588
2678
  });
2589
- case 41:
2679
+ case 44:
2590
2680
  loaded = _context36.sent;
2591
2681
  if (Array.isArray(loaded)) {
2592
2682
  this.enabledReservationRuleProducts = loaded;
@@ -2602,19 +2692,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2602
2692
  }
2603
2693
  } else {
2604
2694
  this.enabledReservationRuleProducts = [];
2605
- void this.addScanOrderLog({
2606
- level: 'error',
2607
- title: '[ScanOrder] enabled_reservation_rules product query failed',
2608
- payload: {
2609
- linkIds: reservationLinkIds,
2610
- error: this.serializeError(loaded)
2611
- }
2695
+ error = loaded instanceof Error ? loaded : new Error('预约规则商品列表接口返回异常');
2696
+ this.logMethodError('loadReservationRuleProducts', error, {
2697
+ resourceId: resourceId,
2698
+ reservationLinkIds: reservationLinkIds,
2699
+ scheduleDate: scheduleDate,
2700
+ scheduleDatetime: scheduleDatetime,
2701
+ cacheId: this.cacheId
2612
2702
  });
2613
2703
  }
2614
- case 43:
2615
- _context36.next = 45;
2704
+ case 46:
2705
+ _context36.next = 48;
2616
2706
  return this.fetchResourceOccupyDetailByResourceId(resourceId);
2617
- case 45:
2707
+ case 48:
2618
2708
  occupyDetail = _context36.sent;
2619
2709
  // Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
2620
2710
  // 计算当前桌台的 resourceSelectType(single/multiple/capacity)
@@ -2647,31 +2737,33 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2647
2737
  requestPaxMin: this.store.resource.requestPaxMin
2648
2738
  } : {}), this.store.resource.requestPaxMax !== undefined ? {
2649
2739
  requestPaxMax: this.store.resource.requestPaxMax
2650
- } : {}); // TODO(Order types): keep ScanOrder resource runtime out of OrderTempOrder root.
2651
- tempOrder.relation_id = resourceId || ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.relation_id);
2740
+ } : {});
2741
+ tempOrder.relation_id = resourceId || ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.relation_id);
2652
2742
  tempOrder.table_form_id = resourceState.tableFormId;
2653
2743
  tempOrder.resource_id = resourceId;
2654
2744
  (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 || _this$store$order5.persistTempOrder();
2655
2745
 
2656
2746
  // 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
2657
2747
  if (!(availabilityInfo.mode === 'idle')) {
2658
- _context36.next = 60;
2748
+ _context36.next = 63;
2659
2749
  break;
2660
2750
  }
2661
- _context36.next = 60;
2751
+ _context36.next = 63;
2662
2752
  return this.addNewOrder();
2663
- case 60:
2664
- // 如果是加单模式,tempOrder 里需要记录 lastOrderId;提交仍走统一 sales checkout 接口
2753
+ case 63:
2754
+ // 如果是加单模式,tempOrder 需要记录 lastOrderId,提交的时候走加单接口
2665
2755
  if (availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code') {
2666
2756
  tempOrder.order_id = resourceState.lastOrderId;
2667
2757
  }
2668
2758
  if (!tempOrder.order_id) {
2669
- _context36.next = 69;
2759
+ _context36.next = 72;
2670
2760
  break;
2671
2761
  }
2672
- _context36.next = 64;
2673
- return (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getOrderInfoByRemote(tempOrder.order_id);
2674
- case 64:
2762
+ _context36.next = 67;
2763
+ return (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getSalesOrderByLookup({
2764
+ lookup: tempOrder.order_id
2765
+ });
2766
+ case 67:
2675
2767
  res = _context36.sent;
2676
2768
  // 找到下单的时候输入的 entryPaxNumber
2677
2769
  entryPaxNumber = res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 || (_res$data = _res$data.bookings) === null || _res$data === void 0 || (_res$data = _res$data.find(function (p) {
@@ -2679,12 +2771,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2679
2771
  return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
2680
2772
  })) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
2681
2773
  if (!entryPaxNumber) {
2682
- _context36.next = 69;
2774
+ _context36.next = 72;
2683
2775
  break;
2684
2776
  }
2685
- _context36.next = 69;
2777
+ _context36.next = 72;
2686
2778
  return this.setEntryPaxNumber(entryPaxNumber);
2687
- case 69:
2779
+ case 72:
2688
2780
  lastOrderInfo = (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 || (_this$store$order7$ge = _this$store$order7.getLastOrderInfo) === null || _this$store$order7$ge === void 0 ? void 0 : _this$store$order7$ge.call(_this$store$order7);
2689
2781
  historicalItems = hasOrderId && Array.isArray(lastOrderInfo === null || lastOrderInfo === void 0 ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce(function (acc, p) {
2690
2782
  if (typeof (p === null || p === void 0 ? void 0 : p.product_id) !== 'number') return acc;
@@ -2696,13 +2788,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2696
2788
  } : {}));
2697
2789
  return acc;
2698
2790
  }, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
2699
- _context36.next = 73;
2791
+ _context36.next = 76;
2700
2792
  return this.setItemRuleRuntimeConfig({
2701
- serviceType: (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.businessCode,
2793
+ serviceType: (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.businessCode,
2702
2794
  submissionIndex: hasOrderId ? 1 : 0,
2703
2795
  historicalItems: historicalItems
2704
2796
  });
2705
- case 73:
2797
+ case 76:
2706
2798
  // operating_hours 超出营业时段 + closed_behavior=show_menu_disabled:
2707
2799
  // 允许浏览商品但 UI 层需拦截“下一步”,这里覆盖最终 mode 并回传错误提示
2708
2800
  if (outsideOperatingHours && closedBehaviorValue === 'show_menu_disabled') {
@@ -2724,18 +2816,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2724
2816
  isFull: resourceState.isFull
2725
2817
  });
2726
2818
  return _context36.abrupt("return", availabilityInfo);
2727
- case 78:
2728
- _context36.prev = 78;
2819
+ case 81:
2820
+ _context36.prev = 81;
2729
2821
  _context36.t0 = _context36["catch"](1);
2730
2822
  this.logMethodError('checkResourceAvailable', _context36.t0.message, {
2731
2823
  resourceId: resourceId
2732
2824
  });
2733
2825
  throw _context36.t0;
2734
- case 82:
2826
+ case 85:
2735
2827
  case "end":
2736
2828
  return _context36.stop();
2737
2829
  }
2738
- }, _callee36, this, [[1, 78]]);
2830
+ }, _callee36, this, [[1, 81]]);
2739
2831
  }));
2740
2832
  function checkResourceAvailable(_x18, _x19) {
2741
2833
  return _checkResourceAvailable.apply(this, arguments);
@@ -2778,41 +2870,56 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2778
2870
  key: "getProductList",
2779
2871
  value: function () {
2780
2872
  var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
2781
- var _this$otherParams13;
2782
- var menu_list_ids, _this$store$products, res, formattedRes;
2873
+ var _this$otherParams15;
2874
+ var menu_list_ids, res, productList, formattedRes;
2783
2875
  return _regeneratorRuntime().wrap(function _callee38$(_context38) {
2784
2876
  while (1) switch (_context38.prev = _context38.next) {
2785
2877
  case 0:
2786
2878
  this.logMethodStart('getProductList');
2787
2879
  // 可以直接通过配置里的 menu 读取
2788
- menu_list_ids = ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 || (_this$otherParams13 = _this$otherParams13.dineInConfig) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13['menu.associated_menus'].map(function (n) {
2880
+ menu_list_ids = ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 || (_this$otherParams15 = _this$otherParams15.dineInConfig) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15['menu.associated_menus'].map(function (n) {
2789
2881
  return Number(n.value);
2790
2882
  })) || [];
2791
2883
  _context38.prev = 2;
2792
- _context38.next = 5;
2793
- return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
2884
+ if (this.store.products) {
2885
+ _context38.next = 5;
2886
+ break;
2887
+ }
2888
+ throw new Error('products 模块未初始化');
2889
+ case 5:
2890
+ _context38.next = 7;
2891
+ return this.store.products.loadProducts({
2794
2892
  menu_list_ids: menu_list_ids,
2795
2893
  cacheId: this.cacheId,
2796
2894
  schedule_date: dayjs().format('YYYY-MM-DD'),
2797
2895
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
2798
2896
  });
2799
- case 5:
2897
+ case 7:
2800
2898
  res = _context38.sent;
2801
- formattedRes = attachItemRuleLimitsToTopLevelProducts(res, this.store.itemRuleQuantityLimits || []);
2899
+ productList = this.assertProductListLoaded('getProductList', res, {
2900
+ menu_list_ids: menu_list_ids,
2901
+ cacheId: this.cacheId
2902
+ });
2903
+ formattedRes = attachItemRuleLimitsToTopLevelProducts(productList, this.store.itemRuleQuantityLimits || []);
2802
2904
  this.logMethodSuccess('getProductList', {
2803
2905
  menuCount: menu_list_ids.length
2804
2906
  });
2805
2907
  return _context38.abrupt("return", formattedRes);
2806
- case 11:
2807
- _context38.prev = 11;
2908
+ case 14:
2909
+ _context38.prev = 14;
2808
2910
  _context38.t0 = _context38["catch"](2);
2809
- this.logMethodError('getProductList', _context38.t0.message);
2911
+ if (!(_context38.t0 !== null && _context38.t0 !== void 0 && _context38.t0.__scanOrderLogged)) {
2912
+ this.logMethodError('getProductList', _context38.t0, {
2913
+ menu_list_ids: menu_list_ids,
2914
+ cacheId: this.cacheId
2915
+ });
2916
+ }
2810
2917
  throw _context38.t0;
2811
- case 15:
2918
+ case 18:
2812
2919
  case "end":
2813
2920
  return _context38.stop();
2814
2921
  }
2815
- }, _callee38, this, [[2, 11]]);
2922
+ }, _callee38, this, [[2, 14]]);
2816
2923
  }));
2817
2924
  function getProductList() {
2818
2925
  return _getProductList.apply(this, arguments);
@@ -2879,7 +2986,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2879
2986
  var raw = this.window.localStorage.getItem(key) || '{}';
2880
2987
  var parsed = JSON.parse(raw);
2881
2988
  return parsed && _typeof(parsed) === 'object' ? parsed : {};
2882
- } catch (_unused) {
2989
+ } catch (_unused2) {
2883
2990
  return {};
2884
2991
  }
2885
2992
  }
@@ -2988,9 +3095,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2988
3095
  }, {
2989
3096
  key: "getFulfillmentModes",
2990
3097
  value: function getFulfillmentModes() {
2991
- var _this$otherParams14;
3098
+ var _this$otherParams16;
2992
3099
  this.logMethodStart('getFulfillmentModes');
2993
- var dineInConfig = ((_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.dineInConfig) || {};
3100
+ var dineInConfig = ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.dineInConfig) || {};
2994
3101
  var result = {
2995
3102
  enablePickup: Boolean(dineInConfig['fulfillment.enable_pickup']),
2996
3103
  enableTableService: Boolean(dineInConfig['fulfillment.enable_table_service'])
@@ -3004,9 +3111,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3004
3111
  }, {
3005
3112
  key: "checkManualPickupRef",
3006
3113
  value: function checkManualPickupRef() {
3007
- var _this$otherParams15;
3114
+ var _this$otherParams17;
3008
3115
  this.logMethodStart('checkManualPickupRef');
3009
- var dineInConfig = ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.dineInConfig) || {};
3116
+ var dineInConfig = ((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.dineInConfig) || {};
3010
3117
  var refMode = dineInConfig['fulfillment.fulfillment_ref_mode'];
3011
3118
  var manualInputType = dineInConfig['fulfillment.manual_input_type'];
3012
3119
  var enabled = refMode === 'manual_input';