@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,93 +1,113 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _exportNames = {
7
- ScanOrderImpl: true
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;
8
18
  };
9
- exports.ScanOrderImpl = void 0;
10
- var _BaseModule = require("../../modules/BaseModule");
11
- var _types = require("./types");
12
- Object.keys(_types).forEach(function (key) {
13
- if (key === "default" || key === "__esModule") return;
14
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
15
- if (key in exports && exports[key] === _types[key]) return;
16
- Object.defineProperty(exports, key, {
17
- enumerable: true,
18
- get: function () {
19
- return _types[key];
20
- }
21
- });
19
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/solution/ScanOrder/index.ts
31
+ var ScanOrder_exports = {};
32
+ __export(ScanOrder_exports, {
33
+ ScanOrderImpl: () => ScanOrderImpl
22
34
  });
23
- var _Order = require("../../modules/Order");
24
- var _types2 = require("../../modules/Account/types");
25
- var _types3 = require("../RegisterAndLogin/types");
26
- var _decimal = _interopRequireDefault(require("decimal.js"));
27
- var _utils = require("./utils");
28
- var _types4 = require("../BookingByStep/types");
29
- var _ProductList = require("../../modules/ProductList");
30
- var _Schedule = require("../../modules/Schedule");
31
- var _getDateIsInSchedule = require("../../modules/Schedule/getDateIsInSchedule");
32
- var _utils2 = require("../../modules/Order/utils");
33
- var _dayjs = _interopRequireDefault(require("dayjs"));
34
- var _itemRule = require("../../model/strategy/adapter/itemRule");
35
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36
- class ScanOrderImpl extends _BaseModule.BaseModule {
37
- defaultName = 'scanOrder';
38
- defaultVersion = '1.0.0';
39
- isSolution = true;
40
- initializeOptions = {};
41
- store = {
42
- entryContext: null,
43
- status: 'idle',
44
- config: null,
45
- resource: null,
46
- flow: {},
47
- error: null,
48
- products: undefined,
49
- itemRuleQuantityLimits: [],
50
- cartValidation: {
51
- passed: null,
52
- failures: []
53
- },
54
- entryPaxNumber: 1
55
- };
56
- otherParams = {};
57
- cacheId;
58
- window;
59
- request;
60
- itemRuleEvaluator = new _itemRule.ItemRuleEvaluator();
61
- itemRuleConfigs = [];
62
- itemRuleConfigsPromise = null;
63
- itemRulePrefillApplied = false;
64
- itemRuleRuntimeConfig = {};
65
- /** 最近一次 checkResourceAvailable 从预约规则 link 拉取的商品快照 */
66
- enabledReservationRuleProducts = [];
67
- loginEffectDisposers = [];
68
- customerLoginRefreshInFlight = null;
69
- customerLoginRefreshIdInFlight = null;
70
- static PISELL1_LOGIN_SUCCESS = 'pisell1.login.success';
35
+ module.exports = __toCommonJS(ScanOrder_exports);
36
+ var import_BaseSales = require("../BaseSales");
37
+ var import_types = require("./types");
38
+ var import_Order = require("../../modules/Order");
39
+ var import_types2 = require("../../modules/Account/types");
40
+ var import_types3 = require("../RegisterAndLogin/types");
41
+ var import_decimal = __toESM(require("decimal.js"));
42
+ var import_utils = require("./utils");
43
+ var import_types4 = require("../BookingByStep/types");
44
+ var import_ProductList = require("../../modules/ProductList");
45
+ var import_getDateIsInSchedule = require("../../modules/Schedule/getDateIsInSchedule");
46
+ var import_utils2 = require("../../modules/Order/utils");
47
+ var import_dayjs = __toESM(require("dayjs"));
48
+ var import_itemRule = require("../../model/strategy/adapter/itemRule");
49
+ __reExport(ScanOrder_exports, require("./types"), module.exports);
50
+ var _ScanOrderImpl = class extends import_BaseSales.BaseSalesImpl {
51
+ constructor(name, version) {
52
+ super(name, version);
53
+ this.defaultName = "scanOrder";
54
+ this.defaultVersion = "1.0.0";
55
+ this.isSolution = true;
56
+ this.initializeOptions = {};
57
+ this.store = {
58
+ entryContext: null,
59
+ status: "idle",
60
+ config: null,
61
+ resource: null,
62
+ flow: {},
63
+ error: null,
64
+ products: void 0,
65
+ itemRuleQuantityLimits: [],
66
+ cartValidation: {
67
+ passed: null,
68
+ failures: []
69
+ },
70
+ entryPaxNumber: 1
71
+ };
72
+ this.otherParams = {};
73
+ this.itemRuleEvaluator = new import_itemRule.ItemRuleEvaluator();
74
+ this.itemRuleConfigs = [];
75
+ this.itemRuleConfigsPromise = null;
76
+ this.itemRulePrefillApplied = false;
77
+ this.itemRuleRuntimeConfig = {};
78
+ /** 最近一次 checkResourceAvailable 从预约规则 link 拉取的商品快照 */
79
+ this.enabledReservationRuleProducts = [];
80
+ this.loginEffectDisposers = [];
81
+ this.customerLoginRefreshInFlight = null;
82
+ this.customerLoginRefreshIdInFlight = null;
83
+ }
71
84
  getScanOrderLoggerContext() {
72
85
  return {
73
86
  cacheId: this.cacheId,
74
87
  solutionName: this.name,
75
- moduleName: 'scanOrder'
88
+ moduleName: "scanOrder"
76
89
  };
77
90
  }
78
91
  safeStringify(value) {
79
92
  try {
80
93
  return JSON.stringify(value);
81
94
  } catch {
82
- return undefined;
95
+ return void 0;
83
96
  }
84
97
  }
85
98
  pickErrorMessage(error) {
86
- const candidates = [error.message, error.data?.message, error.response?.data?.message, error.error?.message];
99
+ var _a, _b, _c, _d;
100
+ const candidates = [
101
+ error.message,
102
+ (_a = error.data) == null ? void 0 : _a.message,
103
+ (_c = (_b = error.response) == null ? void 0 : _b.data) == null ? void 0 : _c.message,
104
+ (_d = error.error) == null ? void 0 : _d.message
105
+ ];
87
106
  for (const candidate of candidates) {
88
- if (typeof candidate === 'string' && candidate.trim()) return candidate;
107
+ if (typeof candidate === "string" && candidate.trim())
108
+ return candidate;
89
109
  }
90
- return undefined;
110
+ return void 0;
91
111
  }
92
112
  serializeError(error) {
93
113
  if (error instanceof Error) {
@@ -97,23 +117,15 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
97
117
  stack: error.stack
98
118
  };
99
119
  }
100
- if (error && typeof error === 'object') {
120
+ if (error && typeof error === "object") {
101
121
  const raw = error;
102
122
  const message = this.pickErrorMessage(raw) || this.safeStringify(raw) || String(error);
103
123
  return {
104
- ...(typeof raw.name === 'string' ? {
105
- name: raw.name
106
- } : {}),
124
+ ...typeof raw.name === "string" ? { name: raw.name } : {},
107
125
  message,
108
- ...('code' in raw ? {
109
- code: raw.code
110
- } : {}),
111
- ...('status' in raw ? {
112
- status: raw.status
113
- } : {}),
114
- ...(this.safeStringify(raw) ? {
115
- raw: this.safeStringify(raw)
116
- } : {})
126
+ ..."code" in raw ? { code: raw.code } : {},
127
+ ..."status" in raw ? { status: raw.status } : {},
128
+ ...this.safeStringify(raw) ? { raw: this.safeStringify(raw) } : {}
117
129
  };
118
130
  }
119
131
  return {
@@ -123,19 +135,18 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
123
135
  async addScanOrderLog(params) {
124
136
  const payload = {
125
137
  cacheId: this.cacheId,
126
- ...(params.payload || {})
138
+ ...params.payload || {}
127
139
  };
128
140
  const extra = {
129
- ...(params.extra || {})
141
+ ...params.extra || {}
130
142
  };
131
143
  const logger = this.store.scanOrderLogger;
132
144
  if (!logger) {
133
- if ((params.level || 'info') === 'error') {
134
- console.error('[ScanOrder][log-fallback]', params.title, {
135
- payload,
136
- extra
137
- });
138
- } else {}
145
+ if ((params.level || "info") === "error") {
146
+ console.error("[ScanOrder][log-fallback]", params.title, { payload, extra });
147
+ } else {
148
+ console.log("[ScanOrder][log-fallback]", params.title, { payload, extra });
149
+ }
139
150
  return;
140
151
  }
141
152
  await logger.addLog({
@@ -146,7 +157,7 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
146
157
  }
147
158
  logMethodStart(method, payload = {}) {
148
159
  void this.addScanOrderLog({
149
- level: 'info',
160
+ level: "info",
150
161
  title: `[ScanOrder] ${method} start`,
151
162
  payload: {
152
163
  method,
@@ -156,7 +167,7 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
156
167
  }
157
168
  logMethodSuccess(method, payload = {}) {
158
169
  void this.addScanOrderLog({
159
- level: 'info',
170
+ level: "info",
160
171
  title: `[ScanOrder] ${method} success`,
161
172
  payload: {
162
173
  method,
@@ -166,7 +177,7 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
166
177
  }
167
178
  logMethodError(method, error, payload = {}) {
168
179
  void this.addScanOrderLog({
169
- level: 'error',
180
+ level: "error",
170
181
  title: `[ScanOrder] ${method} failed`,
171
182
  payload: {
172
183
  method,
@@ -176,8 +187,9 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
176
187
  });
177
188
  }
178
189
  assertProductListLoaded(method, result, payload = {}) {
179
- if (Array.isArray(result)) return result;
180
- const error = result instanceof Error ? result : new Error('商品列表接口返回异常');
190
+ if (Array.isArray(result))
191
+ return result;
192
+ const error = result instanceof Error ? result : new Error("商品列表接口返回异常");
181
193
  this.logMethodError(method, error, payload);
182
194
  error.__scanOrderLogged = true;
183
195
  throw error;
@@ -186,21 +198,36 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
186
198
  await this.addScanOrderLog({
187
199
  ...params,
188
200
  payload: {
189
- source: 'ui-bridge',
190
- ...(params.payload || {})
201
+ source: "ui-bridge",
202
+ ...params.payload || {}
191
203
  }
192
204
  });
193
205
  }
194
206
  normalizeCustomerId(value) {
195
207
  const customerId = Number(value);
196
- if (!Number.isFinite(customerId) || customerId <= 0) return null;
208
+ if (!Number.isFinite(customerId) || customerId <= 0)
209
+ return null;
197
210
  return customerId;
198
211
  }
199
212
  resolveCustomerIdFromLoginPayload(payload) {
200
- const candidates = [payload?.customerId, payload?.customer_id, payload?.id, payload?.user?.customerId, payload?.user?.customer_id, payload?.user?.id, payload?.user?._origin?.customer_id, payload?.account?.customerId, payload?.account?.customer_id, payload?.account?.id, payload?._origin?.customer_id];
213
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
214
+ const candidates = [
215
+ payload == null ? void 0 : payload.customerId,
216
+ payload == null ? void 0 : payload.customer_id,
217
+ payload == null ? void 0 : payload.id,
218
+ (_a = payload == null ? void 0 : payload.user) == null ? void 0 : _a.customerId,
219
+ (_b = payload == null ? void 0 : payload.user) == null ? void 0 : _b.customer_id,
220
+ (_c = payload == null ? void 0 : payload.user) == null ? void 0 : _c.id,
221
+ (_e = (_d = payload == null ? void 0 : payload.user) == null ? void 0 : _d._origin) == null ? void 0 : _e.customer_id,
222
+ (_f = payload == null ? void 0 : payload.account) == null ? void 0 : _f.customerId,
223
+ (_g = payload == null ? void 0 : payload.account) == null ? void 0 : _g.customer_id,
224
+ (_h = payload == null ? void 0 : payload.account) == null ? void 0 : _h.id,
225
+ (_i = payload == null ? void 0 : payload._origin) == null ? void 0 : _i.customer_id
226
+ ];
201
227
  for (const candidate of candidates) {
202
228
  const customerId = this.normalizeCustomerId(candidate);
203
- if (customerId) return customerId;
229
+ if (customerId)
230
+ return customerId;
204
231
  }
205
232
  return null;
206
233
  }
@@ -211,30 +238,38 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
211
238
  this.loginEffectDisposers = [];
212
239
  }
213
240
  registerLoginEffect(event, callback) {
214
- const effects = this.core?.effects;
215
- if (!effects?.on) return;
241
+ var _a;
242
+ const effects = (_a = this.core) == null ? void 0 : _a.effects;
243
+ if (!(effects == null ? void 0 : effects.on))
244
+ return;
216
245
  effects.on(event, callback);
217
246
  this.loginEffectDisposers.push(() => {
218
- if (typeof effects.off === 'function') {
247
+ if (typeof effects.off === "function") {
219
248
  effects.off(event, callback);
220
249
  }
221
250
  });
222
251
  }
223
252
  registerCustomerLoginListeners() {
224
253
  this.clearLoginEffectListeners();
225
- const createHandleLogin = () => async payload => {
254
+ const createHandleLogin = () => async (payload) => {
226
255
  const customerId = this.resolveCustomerIdFromLoginPayload(payload);
227
- if (!customerId) return;
228
- await this.refreshOrderMarketingAfterLogin({
229
- customerId
230
- });
256
+ if (!customerId)
257
+ return;
258
+ await this.refreshOrderMarketingAfterLogin({ customerId });
231
259
  };
232
- this.registerLoginEffect(ScanOrderImpl.PISELL1_LOGIN_SUCCESS, createHandleLogin());
233
- this.registerLoginEffect(_types2.AccountHooks.OnLogin, createHandleLogin());
234
- this.registerLoginEffect(_types3.RegisterAndLoginHooks.onLoginSuccess, createHandleLogin());
260
+ this.registerLoginEffect(
261
+ _ScanOrderImpl.PISELL1_LOGIN_SUCCESS,
262
+ createHandleLogin()
263
+ );
264
+ this.registerLoginEffect(import_types2.AccountHooks.OnLogin, createHandleLogin());
265
+ this.registerLoginEffect(
266
+ import_types3.RegisterAndLoginHooks.onLoginSuccess,
267
+ createHandleLogin()
268
+ );
235
269
  }
236
270
  async refreshOrderMarketingAfterLogin(params) {
237
- if (!this.store.order) throw new Error('order 模块未初始化');
271
+ if (!this.store.order)
272
+ throw new Error("order 模块未初始化");
238
273
  if (this.customerLoginRefreshInFlight) {
239
274
  if (this.customerLoginRefreshIdInFlight === params.customerId) {
240
275
  await this.customerLoginRefreshInFlight;
@@ -247,9 +282,7 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
247
282
  await this.store.order.loadDiscountConfig({
248
283
  customerId: params.customerId
249
284
  });
250
- await this.store.order.recalculateSummary({
251
- createIfMissing: true
252
- });
285
+ await this.store.order.recalculateSummary({ createIfMissing: true });
253
286
  this.store.order.persistTempOrder();
254
287
  await this.refreshItemRuleQuantityLimits();
255
288
  await this.refreshCartValidationPassed();
@@ -266,34 +299,29 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
266
299
  }
267
300
  }
268
301
  }
269
- constructor(name, version) {
270
- super(name, version);
302
+ getRegisteredModuleNames() {
303
+ return ["scanOrderLogger", "products", "order", "salesSummary", "schedule"];
304
+ }
305
+ createSubModule(moduleName) {
306
+ if (moduleName === "scanOrderLogger") {
307
+ return (0, import_types4.createModule)("scanOrderLogger", this.name);
308
+ }
309
+ return super.createSubModule(moduleName);
271
310
  }
272
-
273
311
  /** 与 `otherParams.cacheId` 一致,供宿主在 URL 变化时判断是否需要重新注册模块 */
274
312
  getCacheId() {
275
313
  return this.cacheId;
276
314
  }
277
- async destroyRegisteredChildModules() {
278
- const modules = [this.store.schedule, this.store.salesSummary, this.store.order, this.store.products, this.store.scanOrderLogger];
279
- for (const mod of modules) {
280
- if (mod && typeof mod.destroy === 'function') await Promise.resolve(mod.destroy());
281
- }
282
- }
283
315
  async initialize(core, options = {}) {
284
- this.logMethodStart('initialize');
285
- this.core = core;
286
- this.initializeOptions = options || {};
287
- this.store = {
288
- ...this.store,
289
- ...options.store
290
- };
291
- this.store.entryContext = options.otherParams?.entryContext || this.store.entryContext;
292
- this.store.status = 'initializing';
316
+ var _a, _b, _c, _d, _e, _f, _g, _h;
317
+ this.logMethodStart("initialize");
318
+ this.store = { ...this.store, ...options.store };
319
+ this.store.entryContext = ((_a = options.otherParams) == null ? void 0 : _a.entryContext) || this.store.entryContext;
320
+ this.store.status = "initializing";
293
321
  this.store.error = null;
294
322
  this.otherParams = options.otherParams || {};
295
- this.cacheId = this.otherParams?.cacheId;
296
- this.itemRuleRuntimeConfig = this.otherParams?.scanOrderItemRule || this.otherParams?.itemRule || {};
323
+ this.cacheId = (_b = this.otherParams) == null ? void 0 : _b.cacheId;
324
+ this.itemRuleRuntimeConfig = ((_c = this.otherParams) == null ? void 0 : _c.scanOrderItemRule) || ((_d = this.otherParams) == null ? void 0 : _d.itemRule) || {};
297
325
  this.itemRuleConfigs = [];
298
326
  this.itemRuleConfigsPromise = null;
299
327
  this.itemRulePrefillApplied = false;
@@ -302,391 +330,361 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
302
330
  passed: null,
303
331
  failures: []
304
332
  };
305
- this.window = core.getPlugin('window');
306
- this.request = core.getPlugin('request');
307
- if (!this.window) {
308
- this.logMethodError('initialize', 'window plugin missing');
309
- throw new Error('scanOrder解决方案需要 window 插件支持');
310
- }
311
- if (!this.request) {
312
- this.logMethodError('initialize', 'request plugin missing');
313
- throw new Error('scanOrder解决方案需要 request 插件支持');
314
- }
315
- const moduleArr = ['scanOrderLogger', 'products', 'order', 'salesSummary'];
316
- moduleArr.forEach(step => {
317
- const targetModule = (0, _types4.createModule)(step, this.name);
318
- if (targetModule) {
319
- this.store[step] = targetModule;
320
- const initialState = step === 'salesSummary' ? {
321
- summary: this.store.order?.getTempOrder()?.summary || (0, _utils.createEmptySummary)()
322
- } : {};
323
- const loggerProvider = this.otherParams?.scanOrderLoggerProvider || 'feishu';
324
- const loggerConfig = this.otherParams?.scanOrderLoggerConfig || {
333
+ await super.initialize(core, options);
334
+ if (this.store.scanOrderLogger) {
335
+ this.store.scanOrderLogger.setProvider(
336
+ ((_e = this.otherParams) == null ? void 0 : _e.scanOrderLoggerProvider) || "feishu"
337
+ );
338
+ this.store.scanOrderLogger.setProviderConfig(
339
+ ((_f = this.otherParams) == null ? void 0 : _f.scanOrderLoggerConfig) || {
325
340
  feishu: {
326
- webhook: 'https://open.feishu.cn/open-apis/bot/v2/hook/216b3fe6-af98-424e-8706-f0471241a7ed',
327
- errorHook: 'https://open.feishu.cn/open-apis/bot/v2/hook/015b7c2a-dd3c-4c30-9898-ef0f5253111f'
328
- }
329
- };
330
- this.core.registerModule(targetModule, {
331
- initialState,
332
- otherParams: {
333
- ...this.otherParams,
334
- fatherModule: this.name,
335
- openCache: this.otherParams?.cacheId ? true : false,
336
- cacheId: this.otherParams?.cacheId,
337
- salesSummaryModuleName: `${this.name}_salesSummary`,
338
- provider: loggerProvider,
339
- providerConfig: loggerConfig,
340
- context: this.getScanOrderLoggerContext()
341
+ webhook: "https://open.feishu.cn/open-apis/bot/v2/hook/216b3fe6-af98-424e-8706-f0471241a7ed",
342
+ errorHook: "https://open.feishu.cn/open-apis/bot/v2/hook/015b7c2a-dd3c-4c30-9898-ef0f5253111f"
341
343
  }
342
- });
343
- } else {
344
- this.logMethodError('initialize', `module ${step} missing`);
345
- throw new Error(`模块 ${step} 不存在`);
346
- }
347
- });
348
- if (this.store.scanOrderLogger) {
344
+ }
345
+ );
349
346
  this.store.scanOrderLogger.setContext(this.getScanOrderLoggerContext());
350
347
  }
351
- const scheduleModule = new _Schedule.ScheduleModule(`${this.name}_schedule`);
352
- this.store.schedule = scheduleModule;
353
- this.core.registerModule(scheduleModule, {
354
- otherParams: {
355
- ...this.otherParams,
356
- fatherModule: this.name
357
- }
358
- });
359
348
  this.registerCustomerLoginListeners();
349
+ console.log("[ScanOrder] 初始化开始");
360
350
  try {
361
- await this.store.order?.recalculateSummary({
362
- createIfMissing: false
363
- });
364
- this.store.order?.persistTempOrder();
351
+ await ((_g = this.store.order) == null ? void 0 : _g.recalculateSummary({ createIfMissing: false }));
352
+ (_h = this.store.order) == null ? void 0 : _h.persistTempOrder();
365
353
  await this.loadRuntimeConfigs();
366
354
  if (this.store.schedule) {
367
355
  try {
368
356
  await this.store.schedule.loadAllSchedule();
369
357
  } catch (scheduleError) {
370
- console.warn('[ScanOrder] loadAllSchedule 失败,operating_hours 判定将跳过', scheduleError);
358
+ console.warn("[ScanOrder] loadAllSchedule 失败,operating_hours 判定将跳过", scheduleError);
371
359
  }
372
360
  }
373
361
  await this.refreshItemRuleQuantityLimits();
374
- this.store.status = 'ready';
375
- await this.core.effects.emit(_types.ScanOrderHooks.onInited, {
362
+ this.store.status = "ready";
363
+ console.log("[ScanOrder] 初始化完成");
364
+ await this.core.effects.emit(import_types.ScanOrderHooks.onInited, {
376
365
  status: this.store.status
377
366
  });
378
- this.logMethodSuccess('initialize', {
367
+ this.logMethodSuccess("initialize", {
379
368
  status: this.store.status
380
369
  });
381
370
  } catch (error) {
382
- this.store.status = 'error';
383
- this.store.error = error instanceof Error ? error.message : '初始化失败';
384
- console.error('[ScanOrder] 初始化失败', error);
385
- this.logMethodError('initialize', error, {
371
+ this.store.status = "error";
372
+ this.store.error = error instanceof Error ? error.message : "初始化失败";
373
+ console.error("[ScanOrder] 初始化失败", error);
374
+ this.logMethodError("initialize", error, {
386
375
  status: this.store.status
387
376
  });
388
377
  throw error;
389
378
  }
390
379
  }
391
380
  async destroy() {
392
- this.logMethodStart('destroy');
381
+ this.logMethodStart("destroy");
393
382
  this.clearLoginEffectListeners();
394
- await this.core.effects.emit(_types.ScanOrderHooks.onDestroy, {});
395
- await this.destroyRegisteredChildModules();
383
+ await this.core.effects.emit(import_types.ScanOrderHooks.onDestroy, {});
396
384
  super.destroy();
397
- this.logMethodSuccess('destroy');
385
+ console.log("[ScanOrder] 已销毁");
386
+ this.logMethodSuccess("destroy");
398
387
  }
399
388
  async retryInit() {
400
- this.logMethodStart('retryInit');
401
- // TODO: 细化重试策略(指数退避、最大重试次数)后替换当前实现
402
-
403
- await this.core.effects.emit(_types.ScanOrderHooks.onRetryInit, {});
389
+ this.logMethodStart("retryInit");
390
+ console.log("[ScanOrder] retryInit 调用");
391
+ await this.core.effects.emit(import_types.ScanOrderHooks.onRetryInit, {});
404
392
  try {
405
393
  await this.initialize(this.core, this.initializeOptions);
406
- this.logMethodSuccess('retryInit');
394
+ this.logMethodSuccess("retryInit");
407
395
  } catch (error) {
408
- this.logMethodError('retryInit', error);
396
+ this.logMethodError("retryInit", error);
409
397
  throw error;
410
398
  }
411
399
  }
412
400
  async refresh() {
413
- this.logMethodStart('refresh');
414
- // TODO: 接入真实刷新逻辑(资源重拉取、流程重建)后替换当前实现
415
-
401
+ this.logMethodStart("refresh");
402
+ console.log("[ScanOrder] refresh 调用");
416
403
  try {
417
- this.store.status = 'initializing';
404
+ this.store.status = "initializing";
418
405
  await this.loadRuntimeConfigs();
419
406
  await this.refreshItemRuleQuantityLimits();
420
- this.store.status = 'ready';
421
- await this.core.effects.emit(_types.ScanOrderHooks.onRefresh, {
407
+ this.store.status = "ready";
408
+ await this.core.effects.emit(import_types.ScanOrderHooks.onRefresh, {
422
409
  status: this.store.status
423
410
  });
424
- this.logMethodSuccess('refresh', {
411
+ this.logMethodSuccess("refresh", {
425
412
  status: this.store.status
426
413
  });
427
414
  } catch (error) {
428
- this.logMethodError('refresh', error);
415
+ this.logMethodError("refresh", error);
429
416
  throw error;
430
417
  }
431
418
  }
432
419
  getStatus() {
433
- this.logMethodStart('getStatus');
420
+ this.logMethodStart("getStatus");
434
421
  const result = this.store.status;
435
- this.logMethodSuccess('getStatus', {
422
+ this.logMethodSuccess("getStatus", {
436
423
  status: result
437
424
  });
438
425
  return result;
439
426
  }
440
427
  getEntryContext() {
441
- this.logMethodStart('getEntryContext');
428
+ this.logMethodStart("getEntryContext");
442
429
  const result = this.store.entryContext;
443
- this.logMethodSuccess('getEntryContext', {
430
+ this.logMethodSuccess("getEntryContext", {
444
431
  hasEntryContext: Boolean(result)
445
432
  });
446
433
  return result;
447
434
  }
448
435
  getConfig() {
449
- this.logMethodStart('getConfig');
436
+ this.logMethodStart("getConfig");
450
437
  const result = this.store.config || {};
451
- this.logMethodSuccess('getConfig', {
438
+ this.logMethodSuccess("getConfig", {
452
439
  configKeys: Object.keys(result || {})
453
440
  });
454
441
  return result;
455
442
  }
456
443
  getItemRuleQuantityLimits() {
457
- this.logMethodStart('getItemRuleQuantityLimits');
444
+ this.logMethodStart("getItemRuleQuantityLimits");
458
445
  const result = this.store.itemRuleQuantityLimits || [];
459
- this.logMethodSuccess('getItemRuleQuantityLimits', {
446
+ this.logMethodSuccess("getItemRuleQuantityLimits", {
460
447
  limitCount: result.length
461
448
  });
462
449
  return result;
463
450
  }
464
451
  getCartValidationPassed() {
465
- this.logMethodStart('getCartValidationPassed');
466
- const result = this.store.cartValidation?.passed ?? null;
467
- this.logMethodSuccess('getCartValidationPassed', {
452
+ var _a;
453
+ this.logMethodStart("getCartValidationPassed");
454
+ const result = ((_a = this.store.cartValidation) == null ? void 0 : _a.passed) ?? null;
455
+ this.logMethodSuccess("getCartValidationPassed", {
468
456
  cartValidationPassed: result
469
457
  });
470
458
  return result;
471
459
  }
472
460
  getCartValidation() {
473
- this.logMethodStart('getCartValidation');
461
+ this.logMethodStart("getCartValidation");
474
462
  const result = this.store.cartValidation || {
475
463
  passed: null,
476
464
  failures: []
477
465
  };
478
- this.logMethodSuccess('getCartValidation', {
466
+ this.logMethodSuccess("getCartValidation", {
479
467
  cartValidationPassed: result.passed,
480
468
  failureCount: Array.isArray(result.failures) ? result.failures.length : 0
481
469
  });
482
470
  return result;
483
471
  }
484
472
  getTempOrder() {
485
- this.logMethodStart('getTempOrder');
486
- const result = this.store.order?.getTempOrder() || null;
487
- this.logMethodSuccess('getTempOrder', {
473
+ var _a, _b, _c;
474
+ this.logMethodStart("getTempOrder");
475
+ const result = ((_a = this.store.order) == null ? void 0 : _a.getTempOrder()) || null;
476
+ this.logMethodSuccess("getTempOrder", {
488
477
  hasTempOrder: Boolean(result),
489
- productCount: result?.products?.length || 0,
490
- noteLength: result?.note?.length || 0
478
+ productCount: ((_b = result == null ? void 0 : result.products) == null ? void 0 : _b.length) || 0,
479
+ noteLength: ((_c = result == null ? void 0 : result.note) == null ? void 0 : _c.length) || 0
491
480
  });
492
481
  return result;
493
482
  }
494
- updateTempOrderNote(note) {
495
- this.logMethodStart('updateTempOrderNote', {
496
- noteLength: String(note || '').length
483
+ updateTempOrderNote(note, sync = false) {
484
+ this.logMethodStart("updateTempOrderNote", {
485
+ noteLength: String(note || "").length
497
486
  });
498
487
  try {
499
- if (!this.store.order) throw new Error('order 模块未初始化');
500
- const result = this.store.order.updateTempOrderNote(note);
501
- this.logMethodSuccess('updateTempOrderNote', {
502
- noteLength: result.length
488
+ if (!this.store.order)
489
+ throw new Error("order 模块未初始化");
490
+ const result = this.store.order.updateTempOrderNote(note, sync);
491
+ if (result && typeof result.then === "function") {
492
+ return result.then((nextNote2) => {
493
+ this.logMethodSuccess("updateTempOrderNote", {
494
+ noteLength: nextNote2.length
495
+ });
496
+ return nextNote2;
497
+ });
498
+ }
499
+ const nextNote = result;
500
+ this.logMethodSuccess("updateTempOrderNote", {
501
+ noteLength: nextNote.length
503
502
  });
504
- return result;
503
+ return nextNote;
505
504
  } catch (error) {
506
- this.logMethodError('updateTempOrderNote', error);
505
+ this.logMethodError("updateTempOrderNote", error);
507
506
  throw error;
508
507
  }
509
508
  }
510
-
511
509
  // 存储 UI 层选择的取餐方式到 tempOrder.metadata.shop_service_data
512
510
  // service_type 在扫码点餐场景固定为 dine_in
513
511
  setPickupReferenceMode(mode) {
514
- this.logMethodStart('setPickupReferenceMode', {
515
- mode
516
- });
512
+ var _a;
513
+ this.logMethodStart("setPickupReferenceMode", { mode });
517
514
  try {
518
- if (!this.store.order) throw new Error('order 模块未初始化');
515
+ if (!this.store.order)
516
+ throw new Error("order 模块未初始化");
519
517
  const tempOrder = this.store.order.ensureTempOrder();
520
518
  tempOrder.metadata = {
521
- ...(tempOrder.metadata || {}),
519
+ ...tempOrder.metadata || {},
522
520
  shop_service_data: {
523
- ...((tempOrder.metadata || {}).shop_service_data || {}),
524
- service_type: this.otherParams?.businessCode === 'dine_in' ? 'dine_in' : '',
521
+ ...(tempOrder.metadata || {}).shop_service_data || {},
522
+ service_type: ((_a = this.otherParams) == null ? void 0 : _a.businessCode) === "dine_in" ? "dine_in" : "",
525
523
  pickup_reference_mode: mode
526
524
  }
527
525
  };
528
526
  this.store.order.persistTempOrder();
529
- this.logMethodSuccess('setPickupReferenceMode', {
527
+ this.logMethodSuccess("setPickupReferenceMode", {
530
528
  mode
531
529
  });
532
530
  return tempOrder.metadata.shop_service_data;
533
531
  } catch (error) {
534
- this.logMethodError('setPickupReferenceMode', error, {
535
- mode
536
- });
532
+ this.logMethodError("setPickupReferenceMode", error, { mode });
537
533
  throw error;
538
534
  }
539
535
  }
540
-
541
536
  // 存储用户自定义取餐标识到 tempOrder.buzzer
542
537
  setPickupRef(buzzer) {
543
- this.logMethodStart('setPickupRef', {
544
- buzzerLength: String(buzzer || '').length
538
+ this.logMethodStart("setPickupRef", {
539
+ buzzerLength: String(buzzer || "").length
545
540
  });
546
541
  try {
547
- if (!this.store.order) throw new Error('order 模块未初始化');
542
+ if (!this.store.order)
543
+ throw new Error("order 模块未初始化");
548
544
  const result = this.store.order.updateTempOrderBuzzer(buzzer);
549
- this.logMethodSuccess('setPickupRef', {
545
+ this.logMethodSuccess("setPickupRef", {
550
546
  buzzerLength: result.length
551
547
  });
552
548
  return result;
553
549
  } catch (error) {
554
- this.logMethodError('setPickupRef', error);
550
+ this.logMethodError("setPickupRef", error);
555
551
  throw error;
556
552
  }
557
553
  }
558
- ensureTempOrder() {
559
- if (!this.store.order) throw new Error('order 模块未初始化');
554
+ ensureScanOrderTempOrder() {
555
+ if (!this.store.order)
556
+ throw new Error("order 模块未初始化");
560
557
  return this.store.order.ensureTempOrder();
561
558
  }
562
-
563
559
  // 主动创建临时订单;若已存在则直接返回已有订单
564
560
  async addNewOrder() {
565
- this.logMethodStart('addNewOrder');
561
+ this.logMethodStart("addNewOrder");
566
562
  try {
567
- if (!this.store.order) throw new Error('order 模块未初始化');
563
+ if (!this.store.order)
564
+ throw new Error("order 模块未初始化");
568
565
  const tempOrder = await this.store.order.addNewOrder();
569
- this.logMethodSuccess('addNewOrder', {
566
+ this.logMethodSuccess("addNewOrder", {
570
567
  productCount: tempOrder.products.length
571
568
  });
572
569
  return tempOrder;
573
570
  } catch (error) {
574
- this.logMethodError('addNewOrder', error);
571
+ this.logMethodError("addNewOrder", error);
575
572
  throw error;
576
573
  }
577
574
  }
578
-
579
575
  // 重置 tempOrder 与与上一单强相关的运行态(resource/entryPaxNumber/enabledReservationRuleProducts),
580
576
  // 适用于从支付页通过 react-router 跳回继续下单时清理残留数据
581
577
  async restoreOrder() {
582
- this.logMethodStart('restoreOrder');
578
+ this.logMethodStart("restoreOrder");
583
579
  try {
584
580
  if (!this.store.order) {
585
- throw new Error('scanOrder 解决方案需要 order 模块支持');
581
+ throw new Error("scanOrder 解决方案需要 order 模块支持");
586
582
  }
587
583
  this.store.resource = null;
588
584
  this.store.entryPaxNumber = 1;
589
585
  this.enabledReservationRuleProducts = [];
590
586
  const tempOrder = this.store.order.restoreOrder();
591
- this.logMethodSuccess('restoreOrder');
587
+ this.logMethodSuccess("restoreOrder");
592
588
  return tempOrder;
593
589
  } catch (error) {
594
- this.logMethodError('restoreOrder', error);
590
+ this.logMethodError("restoreOrder", error);
595
591
  throw error;
596
592
  }
597
593
  }
598
594
  getOrderProducts() {
599
- this.logMethodStart('getOrderProducts');
600
- if (!this.store.order) throw new Error('order 模块未初始化');
595
+ this.logMethodStart("getOrderProducts");
596
+ if (!this.store.order)
597
+ throw new Error("order 模块未初始化");
601
598
  const products = this.store.order.getOrderProducts();
602
- this.logMethodSuccess('getOrderProducts', {
599
+ this.logMethodSuccess("getOrderProducts", {
603
600
  productCount: products.length
604
601
  });
605
602
  return products;
606
603
  }
607
604
  async getSummary() {
608
- this.logMethodStart('getSummary');
605
+ this.logMethodStart("getSummary");
609
606
  try {
610
- if (!this.store.order) throw new Error('order 模块未初始化');
611
- const summary = await this.store.order.getScanOrderSummary();
612
- this.logMethodSuccess('getSummary', {
607
+ if (!this.store.order)
608
+ throw new Error("order 模块未初始化");
609
+ const summary = await this.store.order.getOrderSummary();
610
+ this.logMethodSuccess("getSummary", {
613
611
  totalAmount: summary.total_amount
614
612
  });
615
613
  return summary;
616
614
  } catch (error) {
617
- this.logMethodError('getSummary', error);
615
+ this.logMethodError("getSummary", error);
618
616
  throw error;
619
617
  }
620
618
  }
621
619
  getDiscountList() {
622
- if (!this.store.order) return [];
620
+ if (!this.store.order)
621
+ return [];
623
622
  return this.store.order.getDiscountList();
624
623
  }
625
624
  async scanCode(code, customerId) {
626
- this.logMethodStart('scanCode', {
627
- code
628
- });
625
+ this.logMethodStart("scanCode", { code });
629
626
  try {
630
- if (!this.store.order) throw new Error('order 模块未初始化');
627
+ if (!this.store.order)
628
+ throw new Error("order 模块未初始化");
631
629
  const raw = await this.store.order.scanCode(code, customerId);
632
630
  if (raw.isAvailable) {
633
- await this.store.order.recalculateSummary({
634
- createIfMissing: true
635
- });
631
+ await this.store.order.recalculateSummary({ createIfMissing: true });
636
632
  this.store.order.persistTempOrder();
637
633
  }
638
- this.logMethodSuccess('scanCode', {
639
- isAvailable: raw.isAvailable
640
- });
634
+ this.logMethodSuccess("scanCode", { isAvailable: raw.isAvailable });
641
635
  return {
642
636
  isAvailable: raw.isAvailable,
643
637
  type: raw.type,
644
638
  unavailableReason: raw.unavailableReason
645
639
  };
646
640
  } catch (error) {
647
- this.logMethodError('scanCode', error);
641
+ this.logMethodError("scanCode", error);
648
642
  throw error;
649
643
  }
650
644
  }
651
645
  async setDiscountSelected(params) {
652
- this.logMethodStart('setDiscountSelected', params);
646
+ var _a, _b, _c, _d, _e;
647
+ this.logMethodStart("setDiscountSelected", params);
653
648
  try {
654
- if (!this.store.order) throw new Error('order 模块未初始化');
649
+ if (!this.store.order)
650
+ throw new Error("order 模块未初始化");
655
651
  const list = this.store.order.getDiscountList();
656
- const updated = list.map(d => d.id === params.discountId ? {
657
- ...d,
658
- isSelected: params.isSelected,
659
- isManualSelect: !params.isSelected
660
- } : d);
652
+ const updated = list.map(
653
+ (d) => d.id === params.discountId ? {
654
+ ...d,
655
+ isSelected: params.isSelected,
656
+ isManualSelect: !params.isSelected
657
+ } : d
658
+ );
661
659
  const tempOrder = this.store.order.ensureTempOrder();
662
660
  const orderStore = this.store.order.store || {};
663
661
  const discountModule = orderStore.discount;
664
662
  const rulesModule = orderStore.rules;
665
- const holders = tempOrder.holder?.form_record_id ? [{
666
- form_record_id: tempOrder.holder.form_record_id
667
- }] : [];
663
+ const holders = ((_a = tempOrder.holder) == null ? void 0 : _a.form_record_id) ? [{ form_record_id: tempOrder.holder.form_record_id }] : [];
668
664
  let nextDiscountList = updated;
669
- await discountModule?.setDiscountList(updated);
665
+ await (discountModule == null ? void 0 : discountModule.setDiscountList(updated));
670
666
  if (rulesModule) {
671
- const result = rulesModule.calcDiscount({
672
- productList: tempOrder.products,
673
- discountList: updated,
674
- holders,
675
- isFormSubject: !!tempOrder.holder?.type && tempOrder.holder.type === 'form'
676
- }, {
677
- discountId: params.discountId,
678
- isSelected: params.isSelected
679
- }) || {
680
- productList: tempOrder.products,
681
- discountList: updated
682
- };
683
- if (result?.productList) {
667
+ const result = rulesModule.calcDiscount(
668
+ {
669
+ productList: tempOrder.products,
670
+ discountList: updated,
671
+ holders,
672
+ isFormSubject: !!((_b = tempOrder.holder) == null ? void 0 : _b.type) && tempOrder.holder.type === "form"
673
+ },
674
+ {
675
+ discountId: params.discountId,
676
+ isSelected: params.isSelected
677
+ }
678
+ ) || { productList: tempOrder.products, discountList: updated };
679
+ if (result == null ? void 0 : result.productList) {
684
680
  tempOrder.products = result.productList;
685
681
  }
686
- if (result?.discountList) {
682
+ if (result == null ? void 0 : result.discountList) {
687
683
  nextDiscountList = result.discountList;
688
684
  if (!params.isSelected) {
689
- const beforeSelectedIds = new Set(updated.filter(d => d.isSelected).map(d => d.id));
685
+ const beforeSelectedIds = new Set(
686
+ updated.filter((d) => d.isSelected).map((d) => d.id)
687
+ );
690
688
  for (const d of nextDiscountList) {
691
689
  if (d.isSelected && !beforeSelectedIds.has(d.id)) {
692
690
  d.isSelected = false;
@@ -695,92 +693,88 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
695
693
  }
696
694
  }
697
695
  }
698
- const selectedResourceIds = new Set(nextDiscountList.filter(d => d.isSelected).map(d => d.id));
696
+ const selectedResourceIds = new Set(
697
+ nextDiscountList.filter((d) => d.isSelected).map((d) => d.id)
698
+ );
699
699
  for (const product of tempOrder.products) {
700
- if (product._origin?.isManualDiscount) continue;
701
- product.discount_list = (product.discount_list || []).filter(pd => {
702
- const rid = pd.discount?.resource_id ?? pd.id;
700
+ if ((_c = product._origin) == null ? void 0 : _c.isManualDiscount)
701
+ continue;
702
+ product.discount_list = (product.discount_list || []).filter((pd) => {
703
+ var _a2;
704
+ const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
703
705
  return rid != null && selectedResourceIds.has(rid);
704
706
  });
705
-
706
- // 券作用于 source(不含 option、不含 bundle);算出新 source 折后价后补回 options
707
- // 写入含 option 的 main_product_selling_price,再合成 composite 回写 selling_price。
708
- const totalPerUnitDiscount = (product.discount_list || []).reduce((sum, pd) => sum + (pd.amount || 0), 0);
709
- const optionSum = (0, _utils2.sumOptionUnitPrice)(product.product_option_item);
710
- const sourcePrice = product.metadata?.source_product_price ?? (product.metadata?.main_product_original_price != null ? new _decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? '0');
711
- const newSourceSellingPrice = new _decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
712
- const newMainSellingPrice = new _decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
707
+ const totalPerUnitDiscount = (product.discount_list || []).reduce(
708
+ (sum, pd) => sum + (pd.amount || 0),
709
+ 0
710
+ );
711
+ const optionSum = (0, import_utils2.sumOptionUnitPrice)((0, import_utils2.getProductSkuOptions)(product));
712
+ const sourcePrice = ((_d = product.metadata) == null ? void 0 : _d.source_product_price) ?? (((_e = product.metadata) == null ? void 0 : _e.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
713
+ const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
714
+ const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
713
715
  if (product.metadata) {
714
716
  product.metadata.main_product_selling_price = newMainSellingPrice;
715
717
  product.metadata.price_schema_version = 2;
716
718
  }
717
- product.selling_price = (0, _utils2.composeLinePrice)({
719
+ product.selling_price = (0, import_utils2.composeLinePrice)({
718
720
  mainPrice: newMainSellingPrice,
719
721
  bundle: product.product_bundle
720
722
  });
721
723
  }
722
- _Order.OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
723
- await discountModule?.setDiscountList(nextDiscountList);
724
- tempOrder.discount_list = (nextDiscountList || []).filter(d => d.isSelected);
725
- await this.store.order.recalculateSummary({
726
- createIfMissing: true
727
- });
724
+ import_Order.OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
725
+ await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
726
+ tempOrder.discount_list = (nextDiscountList || []).filter((d) => d.isSelected);
727
+ await this.store.order.recalculateSummary({ createIfMissing: true });
728
728
  this.store.order.persistTempOrder();
729
- this.logMethodSuccess('setDiscountSelected', params);
729
+ this.logMethodSuccess("setDiscountSelected", params);
730
730
  } catch (error) {
731
- this.logMethodError('setDiscountSelected', error);
731
+ this.logMethodError("setDiscountSelected", error);
732
732
  throw error;
733
733
  }
734
734
  }
735
735
  async onCustomerLogin(params) {
736
- this.logMethodStart('onCustomerLogin', {
737
- customerId: params.customerId
738
- });
736
+ this.logMethodStart("onCustomerLogin", { customerId: params.customerId });
739
737
  try {
740
738
  await this.refreshOrderMarketingAfterLogin({
741
739
  customerId: params.customerId
742
740
  });
743
- this.logMethodSuccess('onCustomerLogin', {
744
- customerId: params.customerId
745
- });
741
+ this.logMethodSuccess("onCustomerLogin", { customerId: params.customerId });
746
742
  } catch (error) {
747
- this.logMethodError('onCustomerLogin', error);
743
+ this.logMethodError("onCustomerLogin", error);
748
744
  throw error;
749
745
  }
750
746
  }
751
747
  findReservationRuleResource(formId) {
752
- if (formId == null) return undefined;
748
+ var _a;
749
+ if (formId == null)
750
+ return void 0;
753
751
  const numericFormId = Number(formId);
754
- if (!Number.isFinite(numericFormId) || numericFormId <= 0) return undefined;
752
+ if (!Number.isFinite(numericFormId) || numericFormId <= 0)
753
+ return void 0;
755
754
  for (const product of this.enabledReservationRuleProducts) {
756
- const resources = product?.product_resource?.resources;
757
- if (!Array.isArray(resources)) continue;
758
- const matched = resources.find(resource => Number(resource?.id) === numericFormId);
759
- if (matched) return matched;
755
+ const resources = (_a = product == null ? void 0 : product.product_resource) == null ? void 0 : _a.resources;
756
+ if (!Array.isArray(resources))
757
+ continue;
758
+ const matched = resources.find((resource) => Number(resource == null ? void 0 : resource.id) === numericFormId);
759
+ if (matched)
760
+ return matched;
760
761
  }
761
- return undefined;
762
+ return void 0;
762
763
  }
763
764
  buildScanOrderResourceMetadata(params) {
764
- const {
765
- resourceState,
766
- resourceName
767
- } = params;
765
+ const { resourceState, resourceName } = params;
768
766
  const ruleResource = this.findReservationRuleResource(resourceState.tableFormId);
769
- const combined = ruleResource?.combined_resource;
767
+ const combined = ruleResource == null ? void 0 : ruleResource.combined_resource;
770
768
  const isCombined = !!(combined && combined.status === 1 && Array.isArray(combined.resource_ids));
771
769
  return {
772
- form_name: ruleResource?.title ?? '',
770
+ form_name: (ruleResource == null ? void 0 : ruleResource.title) ?? "",
773
771
  resource_name: resourceName,
774
772
  combined_resource: isCombined ? combined : null
775
773
  };
776
774
  }
777
775
  async prepareRetailAvailability(params) {
778
- const {
779
- tempOrder,
780
- hasOrderId,
781
- resourceId,
782
- reason
783
- } = params;
776
+ var _a, _b;
777
+ const { tempOrder, hasOrderId, resourceId, reason } = params;
784
778
  this.enabledReservationRuleProducts = [];
785
779
  tempOrder.bookings = [];
786
780
  tempOrder.order_id = null;
@@ -788,12 +782,10 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
788
782
  delete tempOrder.table_form_id;
789
783
  delete tempOrder.resource_id;
790
784
  delete tempOrder.table_number;
791
- tempOrder.metadata = {
792
- ...(tempOrder.metadata || {})
793
- };
785
+ tempOrder.metadata = { ...tempOrder.metadata || {} };
794
786
  delete tempOrder.metadata.table_occupancy_duration;
795
787
  const resourceState = {
796
- mode: 'idle',
788
+ mode: "idle",
797
789
  deskmate_valid: false,
798
790
  allowSnack: false,
799
791
  deskmateValid: false,
@@ -802,28 +794,27 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
802
794
  raw: null
803
795
  };
804
796
  this.store.resource = resourceState;
805
- this.store.order?.persistTempOrder();
797
+ (_a = this.store.order) == null ? void 0 : _a.persistTempOrder();
806
798
  await this.addNewOrder();
807
799
  await this.setItemRuleRuntimeConfig({
808
- serviceType: this.otherParams?.businessCode,
800
+ serviceType: (_b = this.otherParams) == null ? void 0 : _b.businessCode,
809
801
  submissionIndex: hasOrderId ? 1 : 0,
810
802
  historicalItems: []
811
803
  });
812
804
  const availabilityInfo = {
813
- mode: 'idle',
805
+ mode: "idle",
814
806
  deskmate_valid: false
815
807
  };
816
- this.logMethodSuccess('checkResourceAvailable', {
808
+ this.logMethodSuccess("checkResourceAvailable", {
817
809
  resourceId,
818
810
  mode: availabilityInfo.mode,
819
811
  retailMode: true,
820
812
  retailReason: reason,
821
- persistedRelationId: tempOrder.relation_id,
822
- persistedResourceId: tempOrder.resource_id
813
+ relationId: resourceState.relationId,
814
+ persistedResourceId: resourceState.relationId
823
815
  });
824
816
  return availabilityInfo;
825
817
  }
826
-
827
818
  // ScanOrder 提交 payload enhancer:
828
819
  // - 给所有 booking 注入 appointment_status: 'started'(扫码点餐语义)
829
820
  // - 给所有 booking 的 metadata 注入 resource_select_type(来自预约规则商品的 resource.type)
@@ -832,45 +823,45 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
832
823
  buildSubmitPayloadEnhancer() {
833
824
  const ruleProduct = this.enabledReservationRuleProducts[0];
834
825
  const resourceState = this.store.resource;
835
- const resourceSelectType = resourceState?.resourceSelectType;
836
-
837
- // ScanOrder 的 booking 容量只由预约规则决定:single 占用整张桌台,multiple 占用 1 个容量位。
826
+ const resourceSelectType = resourceState == null ? void 0 : resourceState.resourceSelectType;
838
827
  const resolveBookingCapacityValue = () => {
839
- if (resourceSelectType === 'single') {
840
- const raw = resourceState?.table_form_record?.capacity;
828
+ var _a;
829
+ if (resourceSelectType === "single") {
830
+ const raw = (_a = resourceState == null ? void 0 : resourceState.table_form_record) == null ? void 0 : _a.capacity;
841
831
  const num = Number(raw);
842
- if (Number.isFinite(num) && num > 0) return Math.max(1, Math.floor(num));
832
+ if (Number.isFinite(num) && num > 0)
833
+ return Math.max(1, Math.floor(num));
843
834
  return 1;
844
835
  }
845
836
  return 1;
846
837
  };
847
- return (payload, {
848
- bookingUuid,
849
- tempOrder
850
- }) => {
851
- const resourceId = String(tempOrder.resource_id ?? resourceState?.relationId ?? '').trim();
852
- const hasReservationBookingContext = Boolean(ruleProduct && resourceState && resourceId && (tempOrder.relation_id || resourceState.relationId) && (tempOrder.table_form_id || resourceState.tableFormId));
838
+ return (payload, { bookingUuid, tempOrder }) => {
839
+ var _a, _b;
840
+ const resourceId = String((resourceState == null ? void 0 : resourceState.relationId) ?? "").trim();
841
+ const hasReservationBookingContext = Boolean(
842
+ ruleProduct && resourceState && resourceId && resourceState.relationId && resourceState.tableFormId
843
+ );
853
844
  if (!hasReservationBookingContext) {
854
845
  return {
855
846
  ...payload,
856
847
  bookings: [],
857
- products: [...(payload.products || [])]
848
+ products: [...payload.products || []]
858
849
  };
859
850
  }
860
- const rawCollectPax = tempOrder.metadata?.collect_pax;
861
- const hasExplicitCollectPax = rawCollectPax !== null && rawCollectPax !== undefined && rawCollectPax !== '';
851
+ const rawCollectPax = (_a = tempOrder.metadata) == null ? void 0 : _a.collect_pax;
852
+ const hasExplicitCollectPax = rawCollectPax !== null && rawCollectPax !== void 0 && rawCollectPax !== "";
862
853
  const bookingCapacityValue = resolveBookingCapacityValue();
863
- const pickOriginal = value => {
864
- if (value && typeof value === 'object' && !Array.isArray(value)) {
854
+ const pickOriginal = (value) => {
855
+ if (value && typeof value === "object" && !Array.isArray(value)) {
865
856
  const original = value.original;
866
- return typeof original === 'string' && original.length > 0 ? original : undefined;
857
+ return typeof original === "string" && original.length > 0 ? original : void 0;
867
858
  }
868
- return undefined;
859
+ return void 0;
869
860
  };
870
- const mainField = pickOriginal(tempOrder.table_number) ?? pickOriginal(resourceState?.table_form_record?.name) ?? '';
861
+ const mainField = pickOriginal(tempOrder.table_number) ?? pickOriginal((_b = resourceState == null ? void 0 : resourceState.table_form_record) == null ? void 0 : _b.name) ?? "";
871
862
  const resourceEntry = resourceState && resourceId ? {
872
- relation_type: 'form',
873
- like_status: 'common',
863
+ relation_type: "form",
864
+ like_status: "common",
874
865
  id: Number(resourceId),
875
866
  main_field: mainField,
876
867
  form_id: resourceState.tableFormId,
@@ -880,48 +871,43 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
880
871
  resourceState,
881
872
  resourceName: mainField
882
873
  })
883
- } : undefined;
884
- const ruleProductUid = ruleProduct ? (0, _utils2.createUuidV4)() : undefined;
885
- const bookingCapacityDimensionId = (0, _utils.pickFirstCustomCapacityDimensionId)(this.enabledReservationRuleProducts) ?? 0;
874
+ } : void 0;
875
+ const ruleProductUid = ruleProduct ? (0, import_utils2.createUuidV4)() : void 0;
876
+ const bookingCapacityDimensionId = (0, import_utils.pickFirstCustomCapacityDimensionId)(this.enabledReservationRuleProducts) ?? 0;
886
877
  const nextBookings = (payload.bookings || []).map((booking, idx) => {
887
- const metadata = {
888
- ...(booking.metadata || {})
889
- };
878
+ const metadata = { ...booking.metadata || {} };
890
879
  if (hasExplicitCollectPax) {
891
- metadata.collect_pax = (0, _utils2.normalizeSubmitCollectPaxValue)(rawCollectPax);
880
+ metadata.collect_pax = (0, import_utils2.normalizeSubmitCollectPaxValue)(rawCollectPax);
892
881
  } else {
893
882
  delete metadata.collect_pax;
894
883
  }
895
884
  return {
896
885
  ...booking,
897
886
  number: bookingCapacityValue,
898
- appointment_status: 'started',
887
+ appointment_status: "started",
899
888
  metadata: {
900
889
  ...metadata,
901
- ...(resourceSelectType ? {
902
- resource_select_type: resourceSelectType
903
- } : {}),
904
- ...(resourceSelectType ? {
905
- capacity: [{
906
- id: bookingCapacityDimensionId,
907
- value: bookingCapacityValue,
908
- name: ''
909
- }]
910
- } : {})
890
+ ...resourceSelectType ? { resource_select_type: resourceSelectType } : {},
891
+ ...resourceSelectType ? {
892
+ capacity: [
893
+ {
894
+ id: bookingCapacityDimensionId,
895
+ value: bookingCapacityValue,
896
+ name: ""
897
+ }
898
+ ]
899
+ } : {}
911
900
  },
912
- ...(idx === 0 && resourceEntry ? {
913
- resources: [resourceEntry]
914
- } : {}),
915
- ...(idx === 0 && ruleProductUid ? {
916
- product_uid: ruleProductUid
917
- } : {})
901
+ ...idx === 0 && resourceEntry ? { resources: [resourceEntry] } : {},
902
+ ...idx === 0 && ruleProductUid ? { product_uid: ruleProductUid } : {}
918
903
  };
919
904
  });
920
- const nextProducts = [...(payload.products || [])];
921
- // 加餐(已有 order_id)走 scanOrderMore,原单已含 booking 规则行,勿再追加虚拟规则商品
905
+ const nextProducts = [...payload.products || []];
922
906
  if (ruleProduct && ruleProductUid && !tempOrder.order_id) {
923
- const sellingPrice = String(ruleProduct.price ?? '0.00');
924
- const originalPrice = String(ruleProduct.original_price ?? ruleProduct.price ?? '0.00');
907
+ const sellingPrice = String(ruleProduct.price ?? "0.00");
908
+ const originalPrice = String(
909
+ ruleProduct.original_price ?? ruleProduct.price ?? "0.00"
910
+ );
925
911
  nextProducts.push({
926
912
  product_id: ruleProduct.id,
927
913
  product_variant_id: 0,
@@ -930,7 +916,7 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
930
916
  original_price: originalPrice,
931
917
  payment_price: sellingPrice,
932
918
  is_charge_tax: ruleProduct.is_gst ?? 0,
933
- product_option_item: [],
919
+ product_sku: { option: [] },
934
920
  discount_list: [],
935
921
  product_bundle: [],
936
922
  booking_uid: bookingUuid,
@@ -941,93 +927,142 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
941
927
  }
942
928
  });
943
929
  }
930
+ return { ...payload, bookings: nextBookings, products: nextProducts };
931
+ };
932
+ }
933
+ isScanOrderMoreMode(tempOrder) {
934
+ var _a, _b;
935
+ const mode = (_a = this.store.resource) == null ? void 0 : _a.mode;
936
+ return Boolean(
937
+ tempOrder.order_id && (mode === "additional_order" || mode === "additional_order_with_code" || ((_b = this.store.entryContext) == null ? void 0 : _b.mode) === "append")
938
+ );
939
+ }
940
+ async submitScanOrderMore(params) {
941
+ var _a, _b, _c, _d, _e;
942
+ if (!this.request) {
943
+ throw new Error("scanOrder解决方案需要 request 插件支持");
944
+ }
945
+ if (!this.store.order) {
946
+ throw new Error("scanOrder解决方案需要 order 模块支持");
947
+ }
948
+ const { tempOrder, enhancePayload } = params;
949
+ const latestSummary = await this.store.order.recalculateSummary({
950
+ createIfMissing: true
951
+ });
952
+ const payload = (0, import_utils2.buildSubmitPayload)({
953
+ tempOrder,
954
+ cacheId: this.cacheId,
955
+ platform: (_a = this.otherParams) == null ? void 0 : _a.platform,
956
+ businessCode: ((_b = this.otherParams) == null ? void 0 : _b.businessCode) || ((_c = this.otherParams) == null ? void 0 : _c.business_code),
957
+ channel: (_d = this.otherParams) == null ? void 0 : _d.channel,
958
+ type: (_e = this.otherParams) == null ? void 0 : _e.type,
959
+ summary: latestSummary,
960
+ enhance: enhancePayload
961
+ });
962
+ const products = (0, import_utils.filterProductsForScanOrderMore)(payload.products);
963
+ const orderId = tempOrder.order_id;
964
+ const result = await this.request.put(
965
+ `/order/order/product/${orderId}`,
966
+ {
967
+ products,
968
+ request_unique_idempotency_token: payload.request_unique_idempotency_token
969
+ },
970
+ { customToast: () => {
971
+ } }
972
+ );
973
+ if ((result == null ? void 0 : result.code) === 200 && !(result == null ? void 0 : result.data)) {
944
974
  return {
945
- ...payload,
946
- bookings: nextBookings,
947
- products: nextProducts
975
+ ...result,
976
+ data: {
977
+ order_id: orderId
978
+ }
948
979
  };
949
- };
980
+ }
981
+ return result;
950
982
  }
951
983
  async submitScanOrder() {
952
- this.logMethodStart('submitScanOrder');
984
+ var _a, _b, _c;
985
+ this.logMethodStart("submitScanOrder");
953
986
  try {
954
987
  await this.validateBeforeSubmitByItemRule();
955
988
  if (!this.store.order) {
956
- throw new Error('scanOrder解决方案需要 order 模块支持');
989
+ throw new Error("scanOrder解决方案需要 order 模块支持");
957
990
  }
991
+ const pax = (0, import_utils2.normalizeSubmitCollectPaxValue)(this.store.entryPaxNumber);
992
+ this.store.entryPaxNumber = pax;
958
993
  const tempOrderForSubmit = this.store.order.ensureTempOrder();
959
- tempOrderForSubmit.delivery_type = 'shop_service';
960
- const resourceTableName = this.store.resource?.table_form_record?.name;
961
- if (resourceTableName && typeof resourceTableName === 'object') {
994
+ tempOrderForSubmit.metadata = { ...tempOrderForSubmit.metadata, collect_pax: pax };
995
+ tempOrderForSubmit.delivery_type = "shop_service";
996
+ const resourceTableName = (_b = (_a = this.store.resource) == null ? void 0 : _a.table_form_record) == null ? void 0 : _b.name;
997
+ if (resourceTableName && typeof resourceTableName === "object") {
962
998
  tempOrderForSubmit.table_number = resourceTableName;
963
999
  } else {
964
1000
  delete tempOrderForSubmit.table_number;
965
1001
  }
966
1002
  this.store.order.persistTempOrder();
967
1003
  const enhancePayload = this.buildSubmitPayloadEnhancer();
968
- const result = await this.store.order.submitTempOrder({
969
- cacheId: this.cacheId,
970
- platform: this.otherParams?.platform,
971
- businessCode: this.otherParams?.businessCode,
972
- channel: this.otherParams?.channel,
973
- type: this.otherParams?.type,
1004
+ const result = this.isScanOrderMoreMode(tempOrderForSubmit) ? await this.submitScanOrderMore({
1005
+ tempOrder: tempOrderForSubmit,
1006
+ enhancePayload
1007
+ }) : await this.submitSalesOrder({
974
1008
  enhancePayload
975
1009
  });
976
1010
  const tempOrder = this.store.order.getTempOrder();
977
- this.logMethodSuccess('submitScanOrder', {
978
- productCount: tempOrder?.products?.length || 0
1011
+ this.logMethodSuccess("submitScanOrder", {
1012
+ productCount: ((_c = tempOrder == null ? void 0 : tempOrder.products) == null ? void 0 : _c.length) || 0
979
1013
  });
980
1014
  return result;
981
1015
  } catch (error) {
982
- this.logMethodError('submitScanOrder', error);
1016
+ this.logMethodError("submitScanOrder", error);
983
1017
  throw error;
984
1018
  }
985
1019
  }
986
1020
  async addProductToOrder(product) {
987
- this.logMethodStart('addProductToOrder', {
1021
+ this.logMethodStart("addProductToOrder", {
988
1022
  product_id: product.product_id,
989
1023
  product_variant_id: product.product_variant_id
990
1024
  });
991
1025
  try {
992
- if (!this.store.order) throw new Error('order 模块未初始化');
1026
+ if (!this.store.order)
1027
+ throw new Error("order 模块未初始化");
993
1028
  const products = await this.store.order.addProductToOrder(product);
994
1029
  await this.refreshItemRuleQuantityLimits();
995
1030
  await this.refreshCartValidationPassed();
996
- this.logMethodSuccess('addProductToOrder', {
1031
+ this.logMethodSuccess("addProductToOrder", {
997
1032
  productCount: products.length
998
1033
  });
999
1034
  return products;
1000
1035
  } catch (error) {
1001
- this.logMethodError('addProductToOrder', error);
1036
+ this.logMethodError("addProductToOrder", error);
1002
1037
  throw error;
1003
1038
  }
1004
1039
  }
1005
- async updateProductInOrder(params) {
1006
- this.logMethodStart('updateProductInOrder', {
1040
+ async updateOrderProduct(params) {
1041
+ this.logMethodStart("updateOrderProduct", {
1007
1042
  product_id: params.product_id,
1008
1043
  product_variant_id: params.product_variant_id
1009
1044
  });
1010
1045
  try {
1011
- if (!this.store.order) throw new Error('order 模块未初始化');
1012
- const products = await this.store.order.updateProductInOrder(params);
1046
+ if (!this.store.order)
1047
+ throw new Error("order 模块未初始化");
1048
+ const products = await this.store.order.updateOrderProduct(params);
1013
1049
  await this.refreshItemRuleQuantityLimits();
1014
1050
  await this.refreshCartValidationPassed();
1015
- this.logMethodSuccess('updateProductInOrder', {
1051
+ this.logMethodSuccess("updateOrderProduct", {
1016
1052
  productCount: products.length
1017
1053
  });
1018
1054
  return products;
1019
1055
  } catch (error) {
1020
- this.logMethodError('updateProductInOrder', error);
1056
+ this.logMethodError("updateOrderProduct", error);
1021
1057
  throw error;
1022
1058
  }
1023
1059
  }
1024
-
1025
1060
  /**
1026
1061
  * 设置单行商品备注(与整单 `updateTempOrderNote` 区分)。
1027
1062
  * 多行同 SKU 时必须传入与删除/更新一致的 identity(如 `identity_key`)。
1028
1063
  */
1029
1064
  async setOrderProductLineNote(identity, note) {
1030
- this.logMethodStart('setOrderProductLineNote', {
1065
+ this.logMethodStart("setOrderProductLineNote", {
1031
1066
  product_id: identity.product_id,
1032
1067
  product_variant_id: identity.product_variant_id
1033
1068
  });
@@ -1035,47 +1070,46 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
1035
1070
  const params = {
1036
1071
  product_id: identity.product_id,
1037
1072
  product_variant_id: identity.product_variant_id,
1038
- updates: {
1039
- note: String(note || '')
1040
- }
1073
+ updates: { note: String(note || "") }
1041
1074
  };
1042
- if (identity.identity_key !== undefined) params.identity_key = identity.identity_key;
1043
- if (identity.product_option_item !== undefined) {
1044
- params.product_option_item = identity.product_option_item;
1075
+ if (identity.identity_key !== void 0)
1076
+ params.identity_key = identity.identity_key;
1077
+ if (identity.product_sku !== void 0) {
1078
+ params.product_sku = identity.product_sku;
1045
1079
  }
1046
- if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
1047
- const products = await this.updateProductInOrder(params);
1048
- this.logMethodSuccess('setOrderProductLineNote', {
1049
- productCount: products.length
1050
- });
1080
+ if (identity.product_bundle !== void 0)
1081
+ params.product_bundle = identity.product_bundle;
1082
+ const products = await this.updateOrderProduct(params);
1083
+ this.logMethodSuccess("setOrderProductLineNote", { productCount: products.length });
1051
1084
  return products;
1052
1085
  } catch (error) {
1053
- this.logMethodError('setOrderProductLineNote', error);
1086
+ this.logMethodError("setOrderProductLineNote", error);
1054
1087
  throw error;
1055
1088
  }
1056
1089
  }
1057
1090
  async removeProductFromOrder(identity) {
1058
- this.logMethodStart('removeProductFromOrder', {
1091
+ this.logMethodStart("removeProductFromOrder", {
1059
1092
  product_id: identity.product_id,
1060
1093
  product_variant_id: identity.product_variant_id
1061
1094
  });
1062
1095
  try {
1063
- if (!this.store.order) throw new Error('order 模块未初始化');
1096
+ if (!this.store.order)
1097
+ throw new Error("order 模块未初始化");
1064
1098
  const products = await this.store.order.removeProductFromOrder(identity);
1065
1099
  await this.refreshItemRuleQuantityLimits();
1066
1100
  await this.refreshCartValidationPassed();
1067
- this.logMethodSuccess('removeProductFromOrder', {
1101
+ this.logMethodSuccess("removeProductFromOrder", {
1068
1102
  productCount: products.length
1069
1103
  });
1070
1104
  return products;
1071
1105
  } catch (error) {
1072
- this.logMethodError('removeProductFromOrder', error);
1106
+ this.logMethodError("removeProductFromOrder", error);
1073
1107
  throw error;
1074
1108
  }
1075
1109
  }
1076
1110
  async loadRuntimeConfigs() {
1077
1111
  const itemRuleConfigs = await this.ensureItemRuleConfigsLoaded();
1078
- this.logMethodSuccess('loadRuntimeConfigs', {
1112
+ this.logMethodSuccess("loadRuntimeConfigs", {
1079
1113
  itemRuleCount: itemRuleConfigs.length
1080
1114
  });
1081
1115
  return {
@@ -1083,24 +1117,28 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
1083
1117
  };
1084
1118
  }
1085
1119
  async syncItemRuleConfigsFromDineInConfig(dineInConfig) {
1086
- const enableItemRules = (0, _utils.toBoolean)(dineInConfig?.['sale.enable_item_rules']);
1087
- const strategyModelIds = (0, _utils.normalizeEnabledItemRuleIds)(dineInConfig?.['sale.enabled_item_rules']);
1120
+ const enableItemRules = (0, import_utils.toBoolean)(dineInConfig == null ? void 0 : dineInConfig["sale.enable_item_rules"]);
1121
+ const strategyModelIds = (0, import_utils.normalizeEnabledItemRuleIds)(
1122
+ dineInConfig == null ? void 0 : dineInConfig["sale.enabled_item_rules"]
1123
+ );
1088
1124
  if (!enableItemRules || !strategyModelIds.length) {
1089
1125
  this.itemRuleConfigs = [];
1090
1126
  this.itemRuleConfigsPromise = Promise.resolve([]);
1091
1127
  this.itemRuleEvaluator.setStrategyConfigs([]);
1092
- this.logMethodSuccess('syncItemRuleConfigsFromDineInConfig', {
1128
+ this.logMethodSuccess("syncItemRuleConfigsFromDineInConfig", {
1093
1129
  enabled: enableItemRules,
1094
1130
  strategyModelIds: [],
1095
1131
  itemRuleCount: 0
1096
1132
  });
1097
1133
  return [];
1098
1134
  }
1099
- const itemRuleConfigs = await this.fetchItemRuleConfigsByModelIds(strategyModelIds);
1135
+ const itemRuleConfigs = await this.fetchItemRuleConfigsByModelIds(
1136
+ strategyModelIds
1137
+ );
1100
1138
  this.itemRuleConfigs = itemRuleConfigs;
1101
1139
  this.itemRuleConfigsPromise = Promise.resolve(itemRuleConfigs);
1102
1140
  this.itemRuleEvaluator.setStrategyConfigs(itemRuleConfigs);
1103
- this.logMethodSuccess('syncItemRuleConfigsFromDineInConfig', {
1141
+ this.logMethodSuccess("syncItemRuleConfigsFromDineInConfig", {
1104
1142
  enabled: enableItemRules,
1105
1143
  strategyModelIds,
1106
1144
  itemRuleCount: itemRuleConfigs.length
@@ -1108,70 +1146,76 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
1108
1146
  return itemRuleConfigs;
1109
1147
  }
1110
1148
  async fetchItemRuleConfigsByModelIds(strategyModelIds) {
1111
- this.logMethodStart('fetchItemRuleConfigsByModelIds', {
1149
+ this.logMethodStart("fetchItemRuleConfigsByModelIds", {
1112
1150
  strategyModelIds
1113
1151
  });
1114
- if (!strategyModelIds.length) return [];
1152
+ if (!strategyModelIds.length)
1153
+ return [];
1115
1154
  try {
1116
- const result = await this.request.get('/promotion', {
1155
+ const result = await this.request.get("/promotion", {
1117
1156
  skip: 1,
1118
1157
  num: 99,
1119
- status: 'active',
1158
+ status: "active",
1120
1159
  ids: strategyModelIds
1121
1160
  });
1122
1161
  let configs = [];
1123
1162
  if (result.code === 200) {
1124
- configs = result.data.list.map(item => {
1163
+ configs = result.data.list.map((item) => {
1125
1164
  return item.metadata;
1126
1165
  });
1127
1166
  }
1128
- this.logMethodSuccess('fetchItemRuleConfigsByModelIds', {
1167
+ this.logMethodSuccess("fetchItemRuleConfigsByModelIds", {
1129
1168
  strategyModelIds,
1130
1169
  strategyCount: configs.length
1131
1170
  });
1132
1171
  return configs;
1133
1172
  } catch (error) {
1134
- this.logMethodError('fetchItemRuleConfigsByModelIds', error, {
1173
+ this.logMethodError("fetchItemRuleConfigsByModelIds", error, {
1135
1174
  strategyModelIds
1136
1175
  });
1137
- // A:策略加载失败时不阻塞下单
1138
1176
  return [];
1139
1177
  }
1140
1178
  }
1141
1179
  async buildPrefillProductSourceMap() {
1142
- const sourceMap = new Map();
1180
+ const sourceMap = /* @__PURE__ */ new Map();
1143
1181
  try {
1144
1182
  const productList = await this.getProductList();
1145
- if (!Array.isArray(productList)) return sourceMap;
1146
- const visited = new Set();
1147
- const collectFromValue = value => {
1148
- if (!value || typeof value !== 'object') return;
1149
- if (visited.has(value)) return;
1183
+ if (!Array.isArray(productList))
1184
+ return sourceMap;
1185
+ const visited = /* @__PURE__ */ new Set();
1186
+ const collectFromValue = (value) => {
1187
+ if (!value || typeof value !== "object")
1188
+ return;
1189
+ if (visited.has(value))
1190
+ return;
1150
1191
  visited.add(value);
1151
1192
  if (Array.isArray(value)) {
1152
- for (const item of value) collectFromValue(item);
1193
+ for (const item of value)
1194
+ collectFromValue(item);
1153
1195
  return;
1154
1196
  }
1155
1197
  const node = value;
1156
1198
  const rawProductId = node.product_id ?? node.id;
1157
1199
  const productId = Number(rawProductId);
1158
1200
  if (Number.isFinite(productId) && productId > 0) {
1159
- const productVariantId = Number(node.product_variant_id ?? node.variant_id ?? 0);
1201
+ const productVariantId = Number(
1202
+ node.product_variant_id ?? node.variant_id ?? 0
1203
+ );
1160
1204
  const normalizedVariantId = Number.isNaN(productVariantId) ? 0 : productVariantId;
1161
- const key = (0, _utils.buildProductKey)(productId, normalizedVariantId);
1205
+ const key = (0, import_utils.buildProductKey)(productId, normalizedVariantId);
1162
1206
  if (!sourceMap.has(key)) {
1163
1207
  sourceMap.set(key, node);
1164
1208
  }
1165
1209
  }
1166
1210
  for (const childValue of Object.values(node)) {
1167
- if (childValue && typeof childValue === 'object') {
1211
+ if (childValue && typeof childValue === "object") {
1168
1212
  collectFromValue(childValue);
1169
1213
  }
1170
1214
  }
1171
1215
  };
1172
1216
  collectFromValue(productList);
1173
1217
  } catch (error) {
1174
- this.logMethodError('buildPrefillProductSourceMap', error);
1218
+ this.logMethodError("buildPrefillProductSourceMap", error);
1175
1219
  }
1176
1220
  return sourceMap;
1177
1221
  }
@@ -1179,11 +1223,13 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
1179
1223
  return this.itemRuleRuntimeConfig || {};
1180
1224
  }
1181
1225
  async ensureItemRuleConfigsLoaded() {
1182
- if (this.itemRuleConfigs.length > 0) return this.itemRuleConfigs;
1183
- if (this.itemRuleConfigsPromise) return this.itemRuleConfigsPromise;
1226
+ if (this.itemRuleConfigs.length > 0)
1227
+ return this.itemRuleConfigs;
1228
+ if (this.itemRuleConfigsPromise)
1229
+ return this.itemRuleConfigsPromise;
1184
1230
  this.itemRuleConfigsPromise = (async () => {
1185
1231
  const runtimeConfig = this.getItemRuleRuntimeConfig();
1186
- const staticConfigs = (0, _utils.normalizeItemRuleStrategies)(runtimeConfig.strategyConfigs);
1232
+ const staticConfigs = (0, import_utils.normalizeItemRuleStrategies)(runtimeConfig.strategyConfigs);
1187
1233
  if (staticConfigs.length > 0) {
1188
1234
  this.itemRuleConfigs = staticConfigs;
1189
1235
  this.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
@@ -1203,30 +1249,34 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
1203
1249
  this.store.itemRuleQuantityLimits = [];
1204
1250
  return [];
1205
1251
  }
1206
- const businessData = (0, _utils.buildItemRuleBusinessData)({
1207
- tempOrder: this.ensureTempOrder(),
1252
+ const businessData = (0, import_utils.buildItemRuleBusinessData)({
1253
+ tempOrder: this.ensureScanOrderTempOrder(),
1208
1254
  runtimeConfig: this.getItemRuleRuntimeConfig(),
1209
1255
  itemRuleConfigs: this.itemRuleConfigs
1210
1256
  });
1211
1257
  const limits = this.itemRuleEvaluator.getQuantityLimits(businessData);
1212
1258
  this.store.itemRuleQuantityLimits = limits;
1213
- this.logMethodSuccess('refreshItemRuleQuantityLimits', {
1259
+ this.logMethodSuccess("refreshItemRuleQuantityLimits", {
1214
1260
  limitCount: limits.length
1215
1261
  });
1216
1262
  return limits;
1217
1263
  } catch (error) {
1218
1264
  this.store.itemRuleQuantityLimits = [];
1219
- this.logMethodError('refreshItemRuleQuantityLimits', error);
1265
+ this.logMethodError("refreshItemRuleQuantityLimits", error);
1220
1266
  return [];
1221
1267
  }
1222
1268
  }
1223
1269
  async applyPrefillByItemRule() {
1224
- if (this.itemRulePrefillApplied) return;
1225
- if (!this.store.order) return;
1270
+ var _a, _b, _c;
1271
+ if (this.itemRulePrefillApplied)
1272
+ return;
1273
+ if (!this.store.order)
1274
+ return;
1226
1275
  const strategyConfigs = await this.ensureItemRuleConfigsLoaded();
1227
- if (!strategyConfigs.length) return;
1228
- const businessData = (0, _utils.buildItemRuleBusinessData)({
1229
- tempOrder: this.ensureTempOrder(),
1276
+ if (!strategyConfigs.length)
1277
+ return;
1278
+ const businessData = (0, import_utils.buildItemRuleBusinessData)({
1279
+ tempOrder: this.ensureScanOrderTempOrder(),
1230
1280
  runtimeConfig: this.getItemRuleRuntimeConfig(),
1231
1281
  itemRuleConfigs: this.itemRuleConfigs
1232
1282
  });
@@ -1236,86 +1286,93 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
1236
1286
  return;
1237
1287
  }
1238
1288
  const productSourceMap = await this.buildPrefillProductSourceMap();
1239
- const tempOrder = this.ensureTempOrder();
1289
+ const tempOrder = this.ensureScanOrderTempOrder();
1240
1290
  let hasChanges = false;
1241
1291
  for (const prefillItem of prefillItems) {
1242
1292
  const productId = Number(prefillItem.product_id);
1243
1293
  const productVariantId = Number(prefillItem.product_variant_id ?? 0);
1244
- const targetQuantity = (0, _utils.toNonNegativeInt)(prefillItem.quantity);
1245
- if (!Number.isFinite(productId) || targetQuantity <= 0) continue;
1246
- if (Number.isNaN(productVariantId)) continue;
1247
- const sourceItem = productSourceMap.get((0, _utils.buildProductKey)(productId, productVariantId)) || productSourceMap.get((0, _utils.buildProductKey)(productId, 0)) || null;
1248
- const productIndex = (0, _utils.getProductIdentityIndex)(tempOrder.products, {
1294
+ const targetQuantity = (0, import_utils.toNonNegativeInt)(prefillItem.quantity);
1295
+ if (!Number.isFinite(productId) || targetQuantity <= 0)
1296
+ continue;
1297
+ if (Number.isNaN(productVariantId))
1298
+ continue;
1299
+ const sourceItem = productSourceMap.get(
1300
+ (0, import_utils.buildProductKey)(productId, productVariantId)
1301
+ ) || productSourceMap.get((0, import_utils.buildProductKey)(productId, 0)) || null;
1302
+ const productIndex = (0, import_utils.getProductIdentityIndex)(tempOrder.products, {
1249
1303
  product_id: productId,
1250
1304
  product_variant_id: productVariantId
1251
1305
  });
1252
1306
  if (productIndex === -1) {
1253
- const sellingPrice = (0, _utils.toPriceString)(sourceItem?.price ?? sourceItem?.selling_price, '0.00');
1254
- tempOrder.products.push((0, _utils.normalizeOrderProduct)({
1255
- ...sourceItem,
1256
- product_id: productId,
1257
- product_variant_id: productVariantId,
1258
- num: targetQuantity,
1259
- selling_price: sellingPrice,
1260
- original_price: sellingPrice,
1261
- metadata: {
1262
- item_rule_prefill: true,
1263
- item_rule_id: prefillItem.ruleId
1264
- },
1265
- _origin: {
1266
- ...(sourceItem || {}),
1267
- item_rule_prefill: true,
1268
- item_rule_id: prefillItem.ruleId
1269
- }
1270
- }));
1307
+ const sellingPrice = (0, import_utils.toPriceString)(
1308
+ (sourceItem == null ? void 0 : sourceItem.price) ?? (sourceItem == null ? void 0 : sourceItem.selling_price),
1309
+ "0.00"
1310
+ );
1311
+ tempOrder.products.push(
1312
+ (0, import_utils.normalizeOrderProduct)({
1313
+ ...sourceItem,
1314
+ product_id: productId,
1315
+ product_variant_id: productVariantId,
1316
+ num: targetQuantity,
1317
+ selling_price: sellingPrice,
1318
+ original_price: sellingPrice,
1319
+ metadata: {
1320
+ item_rule_prefill: true,
1321
+ item_rule_id: prefillItem.ruleId
1322
+ },
1323
+ _origin: {
1324
+ ...sourceItem || {},
1325
+ item_rule_prefill: true,
1326
+ item_rule_id: prefillItem.ruleId
1327
+ }
1328
+ })
1329
+ );
1271
1330
  hasChanges = true;
1272
1331
  continue;
1273
1332
  }
1274
1333
  const targetProduct = tempOrder.products[productIndex];
1275
- const existedQuantity = (0, _utils.toNonNegativeInt)(targetProduct.num);
1334
+ const existedQuantity = (0, import_utils.toNonNegativeInt)(targetProduct.num);
1276
1335
  const delta = targetQuantity - existedQuantity;
1277
1336
  const nextProduct = {
1278
1337
  ...targetProduct,
1279
- ...(delta > 0 ? {
1280
- num: (0, _utils.getSafeProductNum)(existedQuantity + delta)
1281
- } : {}),
1338
+ ...delta > 0 ? { num: (0, import_utils.getSafeProductNum)(existedQuantity + delta) } : {},
1282
1339
  metadata: {
1283
- ...(targetProduct.metadata || {}),
1340
+ ...targetProduct.metadata || {},
1284
1341
  item_rule_prefill: true,
1285
1342
  item_rule_id: prefillItem.ruleId
1286
1343
  },
1287
1344
  _origin: sourceItem ? {
1288
- ...(targetProduct._origin || {}),
1345
+ ...targetProduct._origin || {},
1289
1346
  ...sourceItem
1290
1347
  } : targetProduct._origin
1291
1348
  };
1292
1349
  const hasQuantityChanged = delta > 0;
1293
- const hasOriginChanged = Boolean(sourceItem && (!targetProduct._origin || targetProduct._origin?.name !== sourceItem?.name || targetProduct._origin?.title !== sourceItem?.title || targetProduct._origin?.price !== sourceItem?.price));
1350
+ const hasOriginChanged = Boolean(
1351
+ sourceItem && (!targetProduct._origin || ((_a = targetProduct._origin) == null ? void 0 : _a.name) !== (sourceItem == null ? void 0 : sourceItem.name) || ((_b = targetProduct._origin) == null ? void 0 : _b.title) !== (sourceItem == null ? void 0 : sourceItem.title) || ((_c = targetProduct._origin) == null ? void 0 : _c.price) !== (sourceItem == null ? void 0 : sourceItem.price))
1352
+ );
1294
1353
  if (hasQuantityChanged || hasOriginChanged) {
1295
1354
  tempOrder.products[productIndex] = nextProduct;
1296
1355
  hasChanges = true;
1297
1356
  }
1298
1357
  }
1299
1358
  if (hasChanges) {
1300
- // Prefill 属于 products CRUD 的一种形式:新增后让 Rules 重算,以支持自动应用可用优惠券。
1301
1359
  this.store.order.applyDiscount();
1302
- await this.store.order.recalculateSummary({
1303
- createIfMissing: true
1304
- });
1360
+ await this.store.order.recalculateSummary({ createIfMissing: true });
1305
1361
  this.store.order.persistTempOrder();
1306
1362
  }
1307
1363
  await this.refreshItemRuleQuantityLimits();
1308
1364
  this.itemRulePrefillApplied = true;
1309
- this.logMethodSuccess('applyPrefillByItemRule', {
1365
+ this.logMethodSuccess("applyPrefillByItemRule", {
1310
1366
  prefillCount: prefillItems.length,
1311
1367
  hasChanges
1312
1368
  });
1313
1369
  }
1314
1370
  async applyItemRulePrefill() {
1315
- if (this.store.order?.getLastOrderInfo?.()) {
1371
+ var _a, _b;
1372
+ if ((_b = (_a = this.store.order) == null ? void 0 : _a.getLastOrderInfo) == null ? void 0 : _b.call(_a)) {
1316
1373
  return;
1317
1374
  }
1318
- this.logMethodStart('applyItemRulePrefill');
1375
+ this.logMethodStart("applyItemRulePrefill");
1319
1376
  await this.applyPrefillByItemRule();
1320
1377
  await this.refreshItemRuleQuantityLimits();
1321
1378
  await this.refreshCartValidationPassed();
@@ -1328,8 +1385,8 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
1328
1385
  failures: []
1329
1386
  };
1330
1387
  }
1331
- const businessData = (0, _utils.buildItemRuleBusinessData)({
1332
- tempOrder: this.ensureTempOrder(),
1388
+ const businessData = (0, import_utils.buildItemRuleBusinessData)({
1389
+ tempOrder: this.ensureScanOrderTempOrder(),
1333
1390
  runtimeConfig: this.getItemRuleRuntimeConfig(),
1334
1391
  itemRuleConfigs: this.itemRuleConfigs
1335
1392
  });
@@ -1337,9 +1394,10 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
1337
1394
  }
1338
1395
  async validateBeforeSubmitByItemRule() {
1339
1396
  const validationResult = await this.evaluateCartValidationByItemRule();
1340
- if (validationResult.passed) return;
1397
+ if (validationResult.passed)
1398
+ return;
1341
1399
  const firstFailure = validationResult.failures[0];
1342
- const errorMessage = firstFailure?.validationMessage || '当前购物车未满足商品规则,请调整后再提交';
1400
+ const errorMessage = (firstFailure == null ? void 0 : firstFailure.validationMessage) || "当前购物车未满足商品规则,请调整后再提交";
1343
1401
  const error = new Error(String(errorMessage));
1344
1402
  error.failures = validationResult.failures;
1345
1403
  throw error;
@@ -1368,7 +1426,7 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
1368
1426
  this.store.cartValidation = nextState;
1369
1427
  const changed = previous.passed !== nextState.passed || previous.failures !== nextState.failures;
1370
1428
  if (changed) {
1371
- await this.core.effects.emit(_types.ScanOrderHooks.onCartValidationChanged, {
1429
+ await this.core.effects.emit(import_types.ScanOrderHooks.onCartValidationChanged, {
1372
1430
  cartValidation: nextState,
1373
1431
  cartValidationPassed: nextState.passed
1374
1432
  });
@@ -1376,20 +1434,21 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
1376
1434
  return nextState.passed;
1377
1435
  }
1378
1436
  async setItemRuleRuntimeConfig(config = {}) {
1379
- this.logMethodStart('setItemRuleRuntimeConfig');
1437
+ var _a, _b;
1438
+ this.logMethodStart("setItemRuleRuntimeConfig");
1380
1439
  this.itemRuleRuntimeConfig = {
1381
1440
  ...this.itemRuleRuntimeConfig,
1382
1441
  ...config,
1383
1442
  pax: {
1384
- ...(this.itemRuleRuntimeConfig?.pax || {}),
1385
- ...(config?.pax || {})
1443
+ ...((_a = this.itemRuleRuntimeConfig) == null ? void 0 : _a.pax) || {},
1444
+ ...(config == null ? void 0 : config.pax) || {}
1386
1445
  },
1387
1446
  custom: {
1388
- ...(this.itemRuleRuntimeConfig?.custom || {}),
1389
- ...(config?.custom || {})
1447
+ ...((_b = this.itemRuleRuntimeConfig) == null ? void 0 : _b.custom) || {},
1448
+ ...(config == null ? void 0 : config.custom) || {}
1390
1449
  }
1391
1450
  };
1392
- if ('strategyConfigs' in config) {
1451
+ if ("strategyConfigs" in config) {
1393
1452
  this.itemRuleConfigs = [];
1394
1453
  this.itemRuleConfigsPromise = null;
1395
1454
  this.itemRuleEvaluator.setStrategyConfigs([]);
@@ -1397,47 +1456,42 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
1397
1456
  this.itemRulePrefillApplied = false;
1398
1457
  await this.refreshItemRuleQuantityLimits();
1399
1458
  await this.refreshCartValidationPassed();
1400
- this.logMethodSuccess('setItemRuleRuntimeConfig', {
1459
+ this.logMethodSuccess("setItemRuleRuntimeConfig", {
1401
1460
  strategyCount: Array.isArray(this.itemRuleRuntimeConfig.strategyConfigs) ? this.itemRuleRuntimeConfig.strategyConfigs.length : 0
1402
1461
  });
1403
1462
  }
1404
1463
  normalizeResourceState(detail, resourceSelectType, hasOrderId) {
1405
- const currentOrderId = (0, _utils.toPositiveString)(detail?.order_id);
1406
- const lastOrderId = (0, _utils.toPositiveString)(detail?.last_order_id);
1407
- const relationId = (0, _utils.toPositiveString)(detail?.form_record_id);
1408
- const tableFormId = (0, _utils.toPositiveString)(detail?.form_id);
1409
- const formRecord = detail?.form_record ?? null;
1410
- // 是否允许加餐
1411
- const allowSnack = this.otherParams?.dineInConfig?.['sale.allow_add_items'] || false;
1412
- // 开启同桌验证 - 本期没有这个配置,默认关掉
1464
+ var _a, _b, _c, _d;
1465
+ const currentOrderId = (0, import_utils.toPositiveString)(detail == null ? void 0 : detail.order_id);
1466
+ const lastOrderId = (0, import_utils.toPositiveString)(detail == null ? void 0 : detail.last_order_id);
1467
+ const relationId = (0, import_utils.toPositiveString)(detail == null ? void 0 : detail.form_record_id);
1468
+ const tableFormId = (0, import_utils.toPositiveString)(detail == null ? void 0 : detail.form_id);
1469
+ const formRecord = (detail == null ? void 0 : detail.form_record) ?? null;
1470
+ const allowSnack = ((_b = (_a = this.otherParams) == null ? void 0 : _a.dineInConfig) == null ? void 0 : _b["sale.allow_add_items"]) || false;
1413
1471
  const deskmateValid = false;
1414
- const isExclusive = resourceSelectType === 'single';
1415
- const isFull = (0, _utils.computeResourceIsFull)({
1472
+ const isExclusive = resourceSelectType === "single";
1473
+ const isFull = (0, import_utils.computeResourceIsFull)({
1416
1474
  resourceSelectType,
1417
1475
  lastOrderId,
1418
- capacityList: detail?.resource_capacity?.[0]?.capacity_list ?? [],
1419
- capacity: formRecord?.capacity
1476
+ capacityList: ((_d = (_c = detail == null ? void 0 : detail.resource_capacity) == null ? void 0 : _c[0]) == null ? void 0 : _d.capacity_list) ?? [],
1477
+ capacity: formRecord == null ? void 0 : formRecord.capacity
1420
1478
  });
1421
1479
  let availabilityInfo = {
1422
- mode: 'idle',
1480
+ mode: "idle",
1423
1481
  deskmate_valid: deskmateValid
1424
1482
  };
1425
-
1426
- // 有currentOrderId代表是我点的单
1427
- // 如果 url 上没有 hasOrderId,则跳转到订单详情,通过返回 resource_busy 实现
1428
1483
  if (currentOrderId) {
1429
1484
  if (!hasOrderId) {
1430
1485
  availabilityInfo = {
1431
- mode: 'resource_busy',
1486
+ mode: "resource_busy",
1432
1487
  order_id: currentOrderId,
1433
1488
  relation_id: relationId,
1434
1489
  table_form_id: tableFormId,
1435
1490
  deskmate_valid: deskmateValid
1436
1491
  };
1437
1492
  } else {
1438
- // 如果有 hasOrderId,需要检测是否允许加餐,如果允许则返回additional_order,否则也是 resource_busy
1439
1493
  availabilityInfo = {
1440
- mode: allowSnack ? 'additional_order' : 'resource_busy',
1494
+ mode: allowSnack ? "additional_order" : "resource_busy",
1441
1495
  order_id: currentOrderId,
1442
1496
  relation_id: relationId,
1443
1497
  table_form_id: tableFormId,
@@ -1445,13 +1499,11 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
1445
1499
  };
1446
1500
  }
1447
1501
  } else if (lastOrderId) {
1448
- // 如果有其他人点的单
1449
- // multiple 预约且容量仍有剩余时,其他人的单不影响当前用户下单,保持 idle 走正常下单流程
1450
- const canFallthroughToIdle = resourceSelectType === 'multiple' && !isFull;
1502
+ const canFallthroughToIdle = resourceSelectType === "multiple" && !isFull;
1451
1503
  if (!canFallthroughToIdle) {
1452
1504
  availabilityInfo = {
1453
- mode: 'resource_busy',
1454
- order_id: '0',
1505
+ mode: "resource_busy",
1506
+ order_id: "0",
1455
1507
  relation_id: relationId,
1456
1508
  table_form_id: tableFormId,
1457
1509
  deskmate_valid: deskmateValid
@@ -1473,62 +1525,67 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
1473
1525
  table_form_record: formRecord
1474
1526
  };
1475
1527
  }
1476
-
1477
1528
  // 从首个预约规则商品的 product_resource.resources 中,按 form_id 匹配返回 type
1478
1529
  resolveResourceSelectType(formId) {
1530
+ var _a;
1479
1531
  const firstProduct = this.enabledReservationRuleProducts[0];
1480
- const resources = firstProduct?.product_resource?.resources || [];
1532
+ const resources = ((_a = firstProduct == null ? void 0 : firstProduct.product_resource) == null ? void 0 : _a.resources) || [];
1481
1533
  const numericFormId = Number(formId);
1482
- if (!Number.isFinite(numericFormId) || numericFormId <= 0) return undefined;
1483
- const matched = resources.find(r => Number(r?.id) === numericFormId);
1484
- return matched?.type;
1534
+ if (!Number.isFinite(numericFormId) || numericFormId <= 0)
1535
+ return void 0;
1536
+ const matched = resources.find((r) => Number(r == null ? void 0 : r.id) === numericFormId);
1537
+ return matched == null ? void 0 : matched.type;
1485
1538
  }
1486
1539
  async fetchResourceOccupyDetailsByResourceId(resourceId) {
1540
+ var _a, _b, _c;
1487
1541
  const formRecordId = Number(resourceId);
1488
1542
  if (!Number.isFinite(formRecordId) || formRecordId <= 0) {
1489
1543
  throw new Error(`[ScanOrder] 非法桌台 resourceId: ${resourceId}`);
1490
1544
  }
1491
- const shopId = this.otherParams?.getStateData?.('shop_id');
1545
+ const shopId = (_b = (_a = this.otherParams) == null ? void 0 : _a.getStateData) == null ? void 0 : _b.call(_a, "shop_id");
1492
1546
  if (!shopId) {
1493
- throw new Error('[ScanOrder] 无法获取 shop_id');
1494
- }
1495
- const response = await this.request.get('/order/resource/occupy-detail', {
1496
- shop_id: shopId,
1497
- 'form_record_ids[]': formRecordId,
1498
- with_resource_capacity_info: 1,
1499
- with_resource_order_info: 1,
1500
- with_resource_form_info: 1
1501
- });
1502
- if (!response?.status) {
1503
- throw new Error(response?.message || '获取资源占用详情失败');
1547
+ throw new Error("[ScanOrder] 无法获取 shop_id");
1548
+ }
1549
+ const response = await this.request.get(
1550
+ "/order/resource/occupy-detail",
1551
+ {
1552
+ shop_id: shopId,
1553
+ "form_record_ids[]": formRecordId,
1554
+ with_resource_capacity_info: 1,
1555
+ with_resource_order_info: 1,
1556
+ with_resource_form_info: 1
1557
+ }
1558
+ );
1559
+ if (!(response == null ? void 0 : response.status)) {
1560
+ throw new Error((response == null ? void 0 : response.message) || "获取资源占用详情失败");
1504
1561
  }
1505
- return response?.data?.occupy_details ?? [];
1562
+ return ((_c = response == null ? void 0 : response.data) == null ? void 0 : _c.occupy_details) ?? [];
1506
1563
  }
1507
1564
  resolveAdditionalOrderFromOccupyDetail(detail, resourceSelectType, allowAddItems) {
1508
- const currentOrderId = (0, _utils.toPositiveString)(detail?.order_id);
1565
+ const currentOrderId = (0, import_utils.toPositiveString)(detail == null ? void 0 : detail.order_id);
1509
1566
  if (currentOrderId) {
1510
1567
  return {
1511
1568
  matched: true,
1512
1569
  order_id: currentOrderId
1513
1570
  };
1514
1571
  }
1515
- const orderListIds = (Array.isArray(detail?.order_list) ? detail?.order_list || [] : []).map(order => (0, _utils.toPositiveString)(order?.id)).filter(Boolean);
1516
- if (resourceSelectType !== 'single') {
1572
+ const orderListIds = (Array.isArray(detail == null ? void 0 : detail.order_list) ? (detail == null ? void 0 : detail.order_list) || [] : []).map((order) => (0, import_utils.toPositiveString)(order == null ? void 0 : order.id)).filter(Boolean);
1573
+ if (resourceSelectType !== "single") {
1517
1574
  return {
1518
1575
  matched: false,
1519
- reason: 'no_order'
1576
+ reason: "no_order"
1520
1577
  };
1521
1578
  }
1522
1579
  if (!orderListIds.length) {
1523
1580
  return {
1524
1581
  matched: false,
1525
- reason: 'no_order'
1582
+ reason: "no_order"
1526
1583
  };
1527
1584
  }
1528
1585
  if (!allowAddItems) {
1529
1586
  return {
1530
1587
  matched: false,
1531
- reason: 'add_items_disabled'
1588
+ reason: "add_items_disabled"
1532
1589
  };
1533
1590
  }
1534
1591
  if (orderListIds.length === 1) {
@@ -1540,103 +1597,94 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
1540
1597
  if (orderListIds.length > 1) {
1541
1598
  return {
1542
1599
  matched: false,
1543
- reason: 'multiple_orders'
1600
+ reason: "multiple_orders"
1544
1601
  };
1545
1602
  }
1546
1603
  return {
1547
1604
  matched: false,
1548
- reason: 'no_order'
1605
+ reason: "no_order"
1549
1606
  };
1550
1607
  }
1551
-
1552
1608
  // 检测当前链接是否可用
1553
1609
  // 通过 resource_id + 店铺配置
1554
1610
  // hasOrderId 表示 url 上是否有 orderid,如果是的话,后续的流程会走加单
1555
1611
  async checkResourceAvailable(resourceId, hasOrderId = false) {
1556
- const normalizedResourceId = String(resourceId ?? '').trim();
1557
- this.logMethodStart('checkResourceAvailable', {
1612
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1613
+ const normalizedResourceId = String(resourceId ?? "").trim();
1614
+ this.logMethodStart("checkResourceAvailable", {
1558
1615
  resourceId: normalizedResourceId
1559
1616
  });
1560
1617
  try {
1561
- const businessCode = String(this.otherParams?.businessCode ?? '').trim();
1562
- const channel = String(this.otherParams?.channel ?? '').trim();
1563
- const openDataTarget = businessCode && channel ? `${businessCode}+${channel}` : 'dine_in+scan_to_order';
1564
- const openData = await this.otherParams?.getOpenData?.({
1565
- scope: 'board',
1618
+ const businessCode = String(((_a = this.otherParams) == null ? void 0 : _a.businessCode) ?? "").trim();
1619
+ const channel = String(((_b = this.otherParams) == null ? void 0 : _b.channel) ?? "").trim();
1620
+ const openDataTarget = businessCode && channel ? `${businessCode}+${channel}` : "dine_in+scan_to_order";
1621
+ const openData = await ((_d = (_c = this.otherParams) == null ? void 0 : _c.getOpenData) == null ? void 0 : _d.call(_c, {
1622
+ scope: "board",
1566
1623
  target: openDataTarget,
1567
- section_code: ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow']
1568
- });
1569
- if (openData?.status === false) {
1570
- throw new Error(openData?.message || '获取店铺配置失败');
1624
+ section_code: ["basic", "fulfillment", "reservation", "sale", "menu", "availability", "workflow"]
1625
+ }));
1626
+ if ((openData == null ? void 0 : openData.status) === false) {
1627
+ throw new Error((openData == null ? void 0 : openData.message) || "获取店铺配置失败");
1571
1628
  }
1572
- const dineInConfig = openData?.data || {};
1629
+ const dineInConfig = (openData == null ? void 0 : openData.data) || {};
1573
1630
  this.otherParams.dineInConfig = dineInConfig;
1574
1631
  await this.syncItemRuleConfigsFromDineInConfig(dineInConfig);
1575
- const closedBehaviorValue = dineInConfig?.['availability.closed_behavior'];
1576
- const closedMessage = dineInConfig?.['availability.closed_message'] || dineInConfig?.['availability.message'] || dineInConfig?.['basic.closed_message'];
1577
- const basicUnavailableMessage = dineInConfig?.['basic.unavailable_message'] || closedMessage;
1578
- const pauseMessage = dineInConfig?.['availability.pause_message'] || closedMessage;
1632
+ const closedBehaviorValue = dineInConfig == null ? void 0 : dineInConfig["availability.closed_behavior"];
1633
+ const closedMessage = (dineInConfig == null ? void 0 : dineInConfig["availability.closed_message"]) || (dineInConfig == null ? void 0 : dineInConfig["availability.message"]) || (dineInConfig == null ? void 0 : dineInConfig["basic.closed_message"]);
1634
+ const basicUnavailableMessage = (dineInConfig == null ? void 0 : dineInConfig["basic.unavailable_message"]) || closedMessage;
1635
+ const pauseMessage = (dineInConfig == null ? void 0 : dineInConfig["availability.pause_message"]) || closedMessage;
1579
1636
  const makeShopClosed = (errorTips, closed_behavior) => ({
1580
- mode: 'shop_closed',
1581
- order_id: undefined,
1582
- relation_id: undefined,
1583
- table_form_id: undefined,
1637
+ mode: "shop_closed",
1638
+ order_id: void 0,
1639
+ relation_id: void 0,
1640
+ table_form_id: void 0,
1584
1641
  deskmate_valid: false,
1585
1642
  errorTips,
1586
1643
  closed_behavior
1587
1644
  });
1588
-
1589
- // 1. 基础开关 basic.enable 关闭
1590
- if (dineInConfig?.['basic.enable'] === false) {
1645
+ if ((dineInConfig == null ? void 0 : dineInConfig["basic.enable"]) === false) {
1591
1646
  return makeShopClosed(basicUnavailableMessage);
1592
1647
  }
1593
-
1594
- // 2. 暂停营业(保留原有逻辑:仅 hide_all 才阻止进入)
1595
- if ((0, _utils.toBoolean)(dineInConfig?.['availability.paused'])) {
1596
- if (dineInConfig?.['availability.pause_behavior'] === 'hide_all') {
1648
+ if ((0, import_utils.toBoolean)(dineInConfig == null ? void 0 : dineInConfig["availability.paused"])) {
1649
+ if ((dineInConfig == null ? void 0 : dineInConfig["availability.pause_behavior"]) === "hide_all") {
1597
1650
  return makeShopClosed(pauseMessage);
1598
1651
  }
1599
1652
  }
1600
-
1601
- // 3. 营业时间 operating_hours 闸门
1602
- const operatingHourIds = Array.isArray(dineInConfig?.['availability.operating_hours']) ? dineInConfig['availability.operating_hours'].map(id => Number(id)).filter(id => Number.isFinite(id) && id > 0) : [];
1653
+ const operatingHourIds = Array.isArray(dineInConfig == null ? void 0 : dineInConfig["availability.operating_hours"]) ? dineInConfig["availability.operating_hours"].map((id) => Number(id)).filter((id) => Number.isFinite(id) && id > 0) : [];
1603
1654
  let outsideOperatingHours = false;
1604
1655
  if (operatingHourIds.length && this.store.schedule) {
1605
1656
  const scheduleList = this.store.schedule.getScheduleListByIds(operatingHourIds);
1606
1657
  if (scheduleList.length) {
1607
- const now = (0, _dayjs.default)().format('YYYY-MM-DD HH:mm:ss');
1608
- outsideOperatingHours = !(0, _getDateIsInSchedule.getDateIsInSchedule)(now, scheduleList);
1658
+ const now = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
1659
+ outsideOperatingHours = !(0, import_getDateIsInSchedule.getDateIsInSchedule)(now, scheduleList);
1609
1660
  }
1610
1661
  }
1611
- if (outsideOperatingHours && closedBehaviorValue !== 'show_menu_disabled') {
1662
+ if (outsideOperatingHours && closedBehaviorValue !== "show_menu_disabled") {
1612
1663
  return makeShopClosed(closedMessage, closedBehaviorValue);
1613
1664
  }
1614
-
1615
- // Step1: 先加载预约规则商品,拿到 enabledReservationRuleProducts 与容量附加信息
1616
- // (resourceSelectType 需要基于这些商品 + 占用接口的 form_id 计算,故必须前置)
1617
- const tempOrder = this.ensureTempOrder();
1618
- const reservationLinkIds = (0, _utils.collectLinkProductIdsFromReservationRules)(dineInConfig['fulfillment.enabled_resource_rules']);
1665
+ const tempOrder = this.ensureScanOrderTempOrder();
1666
+ const reservationLinkIds = (0, import_utils.collectLinkProductIdsFromReservationRules)(
1667
+ dineInConfig["fulfillment.enabled_resource_rules"]
1668
+ );
1619
1669
  if (!normalizedResourceId || reservationLinkIds.length === 0) {
1620
1670
  return await this.prepareRetailAvailability({
1621
1671
  tempOrder,
1622
1672
  hasOrderId,
1623
1673
  resourceId: normalizedResourceId,
1624
- reason: !normalizedResourceId ? 'missing_resource_id' : 'missing_enabled_resource_rules'
1674
+ reason: !normalizedResourceId ? "missing_resource_id" : "missing_enabled_resource_rules"
1625
1675
  });
1626
1676
  }
1627
1677
  let pendingRequestEntryPax;
1628
1678
  let pendingRequestPaxMin;
1629
1679
  let pendingRequestPaxMax;
1630
- tempOrder.metadata = {
1631
- ...(tempOrder.metadata || {})
1632
- };
1680
+ tempOrder.metadata = { ...tempOrder.metadata || {} };
1633
1681
  delete tempOrder.metadata.table_occupancy_duration;
1634
- const reservationProductList = new _ProductList.ProductList(`${this.name}_reservationEnabledRules`, this.defaultVersion);
1682
+ const reservationProductList = new import_ProductList.ProductList(
1683
+ `${this.name}_reservationEnabledRules`,
1684
+ this.defaultVersion
1685
+ );
1635
1686
  await reservationProductList.initialize(this.core, {
1636
- store: {
1637
- list: [],
1638
- selectProducts: []
1639
- },
1687
+ store: { list: [], selectProducts: [] },
1640
1688
  otherParams: {
1641
1689
  ...this.otherParams,
1642
1690
  fatherModule: this.name,
@@ -1644,8 +1692,8 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
1644
1692
  cacheId: this.cacheId
1645
1693
  }
1646
1694
  });
1647
- const scheduleDate = (0, _dayjs.default)().format('YYYY-MM-DD');
1648
- const scheduleDatetime = (0, _dayjs.default)().format('YYYY-MM-DD HH:mm:ss');
1695
+ const scheduleDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
1696
+ const scheduleDatetime = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
1649
1697
  const loaded = await reservationProductList.loadProducts({
1650
1698
  product_ids: reservationLinkIds,
1651
1699
  schedule_date: scheduleDate,
@@ -1653,85 +1701,116 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
1653
1701
  cacheId: this.cacheId
1654
1702
  });
1655
1703
  if (Array.isArray(loaded)) {
1656
- const matchedRuleProduct = (0, _utils.findReservationRuleProductByResourceId)(loaded, normalizedResourceId);
1704
+ const matchedRuleProduct = (0, import_utils.findReservationRuleProductByResourceId)(
1705
+ loaded,
1706
+ normalizedResourceId
1707
+ );
1657
1708
  const ruleProductsForResource = matchedRuleProduct ? [matchedRuleProduct] : [];
1658
1709
  this.enabledReservationRuleProducts = ruleProductsForResource;
1659
- const occupancyMinutes = (0, _utils.pickFirstDurationMinutesFromProducts)(ruleProductsForResource);
1660
- if (occupancyMinutes !== undefined) {
1710
+ const occupancyMinutes = (0, import_utils.pickFirstDurationMinutesFromProducts)(ruleProductsForResource);
1711
+ if (occupancyMinutes !== void 0) {
1661
1712
  tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
1662
1713
  }
1663
- if ((0, _utils.hasCustomCapacityProduct)(ruleProductsForResource)) {
1714
+ if ((0, import_utils.hasCustomCapacityProduct)(ruleProductsForResource)) {
1664
1715
  pendingRequestEntryPax = 1;
1665
- const paxBounds = (0, _utils.pickFirstCustomCapacityPaxBounds)(ruleProductsForResource);
1666
- if (paxBounds?.min !== undefined) pendingRequestPaxMin = paxBounds.min;
1667
- if (paxBounds?.max !== undefined) pendingRequestPaxMax = paxBounds.max;
1716
+ const paxBounds = (0, import_utils.pickFirstCustomCapacityPaxBounds)(ruleProductsForResource);
1717
+ if ((paxBounds == null ? void 0 : paxBounds.min) !== void 0)
1718
+ pendingRequestPaxMin = paxBounds.min;
1719
+ if ((paxBounds == null ? void 0 : paxBounds.max) !== void 0)
1720
+ pendingRequestPaxMax = paxBounds.max;
1668
1721
  }
1669
1722
  } else {
1670
1723
  this.enabledReservationRuleProducts = [];
1671
- const error = loaded instanceof Error ? loaded : new Error('预约规则商品列表接口返回异常');
1672
- this.logMethodError('loadReservationRuleProducts', error, {
1724
+ const error = loaded instanceof Error ? loaded : new Error("预约规则商品列表接口返回异常");
1725
+ this.logMethodError("loadReservationRuleProducts", error, {
1673
1726
  resourceId: normalizedResourceId,
1674
1727
  reservationLinkIds,
1675
1728
  scheduleDate,
1676
1729
  scheduleDatetime,
1677
1730
  cacheId: this.cacheId
1678
1731
  });
1732
+ if (Array.isArray(loaded)) {
1733
+ this.enabledReservationRuleProducts = loaded;
1734
+ const occupancyMinutes = (0, import_utils.pickFirstDurationMinutesFromProducts)(loaded);
1735
+ if (occupancyMinutes !== void 0) {
1736
+ tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
1737
+ }
1738
+ if ((0, import_utils.hasCustomCapacityProduct)(loaded)) {
1739
+ pendingRequestEntryPax = 1;
1740
+ const paxBounds = (0, import_utils.pickFirstCustomCapacityPaxBounds)(loaded);
1741
+ if ((paxBounds == null ? void 0 : paxBounds.min) !== void 0)
1742
+ pendingRequestPaxMin = paxBounds.min;
1743
+ if ((paxBounds == null ? void 0 : paxBounds.max) !== void 0)
1744
+ pendingRequestPaxMax = paxBounds.max;
1745
+ }
1746
+ } else {
1747
+ this.enabledReservationRuleProducts = [];
1748
+ const error2 = loaded instanceof Error ? loaded : new Error("预约规则商品列表接口返回异常");
1749
+ this.logMethodError("loadReservationRuleProducts", error2, {
1750
+ resourceId,
1751
+ reservationLinkIds,
1752
+ scheduleDate,
1753
+ scheduleDatetime,
1754
+ cacheId: this.cacheId
1755
+ });
1756
+ }
1679
1757
  }
1680
-
1681
- // Step2: 请求新的资源占用详情接口。occupy_details 第一维是资源,不是订单。
1682
1758
  const occupyDetails = await this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
1683
1759
  const occupyDetail = occupyDetails[0] ?? null;
1684
-
1685
- // Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
1686
- // 计算当前桌台的 resourceSelectType(single/multiple/capacity)
1687
- const resourceSelectType = this.resolveResourceSelectType((0, _utils.toPositiveString)(occupyDetail?.form_id));
1688
- const allowAddItems = (0, _utils.toBoolean)(dineInConfig?.['sale.allow_add_items']);
1689
- const additionalOrderResult = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
1690
- if (additionalOrderResult.reason === 'multiple_orders') {
1760
+ const resourceSelectType = this.resolveResourceSelectType(
1761
+ (0, import_utils.toPositiveString)(occupyDetail == null ? void 0 : occupyDetail.form_id)
1762
+ );
1763
+ const allowAddItems = (0, import_utils.toBoolean)(dineInConfig == null ? void 0 : dineInConfig["sale.allow_add_items"]);
1764
+ const additionalOrderResult = this.resolveAdditionalOrderFromOccupyDetail(
1765
+ occupyDetail,
1766
+ resourceSelectType,
1767
+ allowAddItems
1768
+ );
1769
+ if (additionalOrderResult.reason === "multiple_orders") {
1691
1770
  const multipleOrdersState = {
1692
1771
  ...this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId),
1693
- mode: 'multiple_orders'
1772
+ mode: "multiple_orders"
1694
1773
  };
1695
1774
  this.store.resource = multipleOrdersState;
1696
- const availabilityInfo = {
1697
- mode: 'multiple_orders',
1775
+ const availabilityInfo2 = {
1776
+ mode: "multiple_orders",
1698
1777
  deskmate_valid: multipleOrdersState.deskmate_valid,
1699
1778
  relation_id: multipleOrdersState.relationId,
1700
1779
  table_form_id: multipleOrdersState.tableFormId,
1701
1780
  table_form_record: multipleOrdersState.table_form_record
1702
1781
  };
1703
- this.logMethodSuccess('checkResourceAvailable', {
1782
+ this.logMethodSuccess("checkResourceAvailable", {
1704
1783
  resourceId: normalizedResourceId,
1705
- mode: availabilityInfo.mode,
1706
- orderListCount: occupyDetail?.order_list?.length || 0,
1784
+ mode: availabilityInfo2.mode,
1785
+ orderListCount: ((_e = occupyDetail == null ? void 0 : occupyDetail.order_list) == null ? void 0 : _e.length) || 0,
1707
1786
  resourceSelectType
1708
1787
  });
1709
- return availabilityInfo;
1788
+ return availabilityInfo2;
1710
1789
  }
1711
-
1712
- // Step4: 用 occupyDetail + resourceSelectType 规整为 resourceState
1713
- const resourceState = this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId);
1790
+ const resourceState = this.normalizeResourceState(
1791
+ occupyDetail,
1792
+ resourceSelectType,
1793
+ hasOrderId
1794
+ );
1714
1795
  const additionalOrderId = additionalOrderResult.order_id;
1715
1796
  if (additionalOrderId) {
1716
- resourceState.mode = 'additional_order';
1797
+ resourceState.mode = "additional_order";
1717
1798
  resourceState.order_id = additionalOrderId;
1718
- } else if (additionalOrderResult.reason === 'add_items_disabled') {
1719
- resourceState.mode = 'resource_busy';
1720
- resourceState.order_id = '0';
1721
- } else if (resourceSelectType === 'multiple' && resourceState.isFull) {
1722
- resourceState.mode = 'resource_busy';
1723
- resourceState.order_id = '0';
1799
+ } else if (additionalOrderResult.reason === "add_items_disabled") {
1800
+ resourceState.mode = "resource_busy";
1801
+ resourceState.order_id = "0";
1802
+ } else if (resourceSelectType === "multiple" && resourceState.isFull) {
1803
+ resourceState.mode = "resource_busy";
1804
+ resourceState.order_id = "0";
1724
1805
  }
1725
1806
  this.store.resource = resourceState;
1726
-
1727
- // Step5: 把预约规则商品阶段暂存的 requestEntryPax 等注入 store.resource
1728
- if (pendingRequestEntryPax !== undefined) {
1807
+ if (pendingRequestEntryPax !== void 0) {
1729
1808
  this.store.resource.requestEntryPax = pendingRequestEntryPax;
1730
1809
  }
1731
- if (pendingRequestPaxMin !== undefined) {
1810
+ if (pendingRequestPaxMin !== void 0) {
1732
1811
  this.store.resource.requestPaxMin = pendingRequestPaxMin;
1733
1812
  }
1734
- if (pendingRequestPaxMax !== undefined) {
1813
+ if (pendingRequestPaxMax !== void 0) {
1735
1814
  this.store.resource.requestPaxMax = pendingRequestPaxMax;
1736
1815
  }
1737
1816
  const availabilityInfo = {
@@ -1741,67 +1820,49 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
1741
1820
  table_form_id: resourceState.tableFormId,
1742
1821
  deskmate_valid: resourceState.deskmate_valid,
1743
1822
  table_form_record: resourceState.table_form_record,
1744
- policy: occupyDetail?.form_record?.policy,
1745
- partyroom_booking: occupyDetail?.form_record?.partyroom_booking,
1746
- ...(this.store.resource.requestEntryPax !== undefined ? {
1747
- requestEntryPax: this.store.resource.requestEntryPax
1748
- } : {}),
1749
- ...(this.store.resource.requestPaxMin !== undefined ? {
1750
- requestPaxMin: this.store.resource.requestPaxMin
1751
- } : {}),
1752
- ...(this.store.resource.requestPaxMax !== undefined ? {
1753
- requestPaxMax: this.store.resource.requestPaxMax
1754
- } : {})
1823
+ policy: (_f = occupyDetail == null ? void 0 : occupyDetail.form_record) == null ? void 0 : _f.policy,
1824
+ partyroom_booking: (_g = occupyDetail == null ? void 0 : occupyDetail.form_record) == null ? void 0 : _g.partyroom_booking,
1825
+ ...this.store.resource.requestEntryPax !== void 0 ? { requestEntryPax: this.store.resource.requestEntryPax } : {},
1826
+ ...this.store.resource.requestPaxMin !== void 0 ? { requestPaxMin: this.store.resource.requestPaxMin } : {},
1827
+ ...this.store.resource.requestPaxMax !== void 0 ? { requestPaxMax: this.store.resource.requestPaxMax } : {}
1755
1828
  };
1756
- tempOrder.relation_id = normalizedResourceId || this.otherParams?.relation_id;
1757
- tempOrder.table_form_id = resourceState.tableFormId;
1758
- tempOrder.resource_id = normalizedResourceId;
1759
- this.store.order?.persistTempOrder();
1760
-
1761
- // 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
1762
- if (availabilityInfo.mode === 'idle') {
1829
+ (_h = this.store.order) == null ? void 0 : _h.persistTempOrder();
1830
+ if (availabilityInfo.mode === "idle") {
1763
1831
  await this.addNewOrder();
1764
1832
  }
1765
- const isAdditionalOrderMode = availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code';
1766
- // 如果是加单模式,tempOrder 里需要记录目标订单 id,提交的时候走加单接口
1833
+ const isAdditionalOrderMode = availabilityInfo.mode === "additional_order" || availabilityInfo.mode === "additional_order_with_code";
1767
1834
  if (isAdditionalOrderMode) {
1768
1835
  tempOrder.order_id = additionalOrderId;
1769
1836
  }
1770
- const lastOrderInfo = this.store.order?.getLastOrderInfo?.();
1771
- const historicalItems = isAdditionalOrderMode && Array.isArray(lastOrderInfo?.products) ? lastOrderInfo.products.reduce((acc, p) => {
1772
- if (typeof p?.product_id !== 'number') return acc;
1837
+ const lastOrderInfo = (_j = (_i = this.store.order) == null ? void 0 : _i.getLastOrderInfo) == null ? void 0 : _j.call(_i);
1838
+ const historicalItems = isAdditionalOrderMode && Array.isArray(lastOrderInfo == null ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce((acc, p) => {
1839
+ if (typeof (p == null ? void 0 : p.product_id) !== "number")
1840
+ return acc;
1773
1841
  acc.push({
1774
1842
  product_id: p.product_id,
1775
1843
  quantity: Number(p.product_quantity) || 0,
1776
- ...(typeof p.product_variant_id === 'number' ? {
1777
- product_variant_id: p.product_variant_id
1778
- } : {})
1844
+ ...typeof p.product_variant_id === "number" ? { product_variant_id: p.product_variant_id } : {}
1779
1845
  });
1780
1846
  return acc;
1781
1847
  }, []) : [];
1782
-
1783
- // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
1784
1848
  await this.setItemRuleRuntimeConfig({
1785
- serviceType: this.otherParams?.businessCode,
1849
+ serviceType: (_k = this.otherParams) == null ? void 0 : _k.businessCode,
1786
1850
  submissionIndex: isAdditionalOrderMode ? 1 : 0,
1787
1851
  historicalItems
1788
1852
  });
1789
-
1790
- // operating_hours 超出营业时段 + closed_behavior=show_menu_disabled:
1791
- // 允许浏览商品但 UI 层需拦截“下一步”,这里覆盖最终 mode 并回传错误提示
1792
- if (outsideOperatingHours && closedBehaviorValue === 'show_menu_disabled') {
1793
- availabilityInfo.mode = 'submit_disabled';
1853
+ if (outsideOperatingHours && closedBehaviorValue === "show_menu_disabled") {
1854
+ availabilityInfo.mode = "submit_disabled";
1794
1855
  availabilityInfo.errorTips = closedMessage;
1795
1856
  availabilityInfo.closed_behavior = closedBehaviorValue;
1796
1857
  }
1797
- this.logMethodSuccess('checkResourceAvailable', {
1858
+ this.logMethodSuccess("checkResourceAvailable", {
1798
1859
  resourceId: normalizedResourceId,
1799
1860
  mode: availabilityInfo.mode,
1800
1861
  orderId: availabilityInfo.order_id,
1801
1862
  relationId: availabilityInfo.relation_id,
1802
1863
  tableFormId: availabilityInfo.table_form_id,
1803
- persistedRelationId: tempOrder.relation_id,
1804
- persistedResourceId: tempOrder.resource_id,
1864
+ persistedRelationId: (_l = this.store.resource) == null ? void 0 : _l.relationId,
1865
+ persistedResourceId: (_m = this.store.resource) == null ? void 0 : _m.relationId,
1805
1866
  deskmateValid: availabilityInfo.deskmate_valid,
1806
1867
  resourceSelectType: resourceState.resourceSelectType,
1807
1868
  isExclusive: resourceState.isExclusive,
@@ -1809,68 +1870,76 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
1809
1870
  });
1810
1871
  return availabilityInfo;
1811
1872
  } catch (error) {
1812
- this.logMethodError('checkResourceAvailable', error.message, {
1873
+ this.logMethodError("checkResourceAvailable", error.message, {
1813
1874
  resourceId: normalizedResourceId
1814
1875
  });
1815
1876
  throw error;
1816
1877
  }
1817
1878
  }
1818
-
1819
1879
  // 恢复之前订单的数据,读取 entrypax
1820
1880
  async restorePreviousOrderData() {
1821
- const tempOrder = this.ensureTempOrder();
1881
+ var _a, _b, _c, _d;
1882
+ const orderModule = this.store.order;
1883
+ if (!orderModule)
1884
+ return;
1885
+ const tempOrder = orderModule.ensureTempOrder();
1822
1886
  if (tempOrder.order_id) {
1823
- const res = await this.store.order?.getOrderInfoByRemote(tempOrder.order_id);
1824
- // 找到下单的时候输入的 entryPaxNumber
1825
- const entryPaxNumber = res?.data?.bookings?.find(p => p.metadata?.collect_pax)?.metadata?.collect_pax;
1887
+ const res = await orderModule.getOrderInfo(tempOrder.order_id);
1888
+ const entryPaxNumber = (_d = (_c = (_b = (_a = res == null ? void 0 : res.data) == null ? void 0 : _a.bookings) == null ? void 0 : _b.find((p) => {
1889
+ var _a2;
1890
+ return (_a2 = p.metadata) == null ? void 0 : _a2.collect_pax;
1891
+ })) == null ? void 0 : _c.metadata) == null ? void 0 : _d.collect_pax;
1826
1892
  if (entryPaxNumber) {
1827
1893
  await this.setEntryPaxNumber(entryPaxNumber);
1828
1894
  }
1829
1895
  }
1830
1896
  }
1831
-
1832
1897
  // 如果是加单的情况,提供返回当前订单相关信息的能力
1833
1898
  async getAdditionalOrderInfo() {
1834
- this.logMethodStart('getAdditionalOrderInfo');
1899
+ this.logMethodStart("getAdditionalOrderInfo");
1835
1900
  const result = {
1836
- orderId: '123567890',
1837
- orderStatus: 'pending',
1838
- orderTime: '2026-03-31 10:00:00',
1901
+ orderId: "123567890",
1902
+ orderStatus: "pending",
1903
+ orderTime: "2026-03-31 10:00:00",
1839
1904
  orderAmount: 100,
1840
1905
  orderItems: []
1841
1906
  };
1842
- this.logMethodSuccess('getAdditionalOrderInfo', {
1907
+ this.logMethodSuccess("getAdditionalOrderInfo", {
1843
1908
  orderId: result.orderId,
1844
1909
  orderStatus: result.orderStatus
1845
1910
  });
1846
1911
  return result;
1847
1912
  }
1848
-
1849
1913
  // 获取商品列表
1850
1914
  async getProductList() {
1851
- this.logMethodStart('getProductList');
1852
- // 可以直接通过配置里的 menu 读取
1853
- const menu_list_ids = this.otherParams?.dineInConfig?.['menu.associated_menus'].map(n => Number(n.value)) || [];
1915
+ var _a, _b;
1916
+ this.logMethodStart("getProductList");
1917
+ const associatedMenus = (_b = (_a = this.otherParams) == null ? void 0 : _a.dineInConfig) == null ? void 0 : _b["menu.associated_menus"];
1918
+ const menu_list_ids = associatedMenus.map((n) => Number(n.value)) || [];
1854
1919
  try {
1855
- if (!this.store.products) throw new Error('products 模块未初始化');
1920
+ if (!this.store.products)
1921
+ throw new Error("products 模块未初始化");
1856
1922
  const res = await this.store.products.loadProducts({
1857
1923
  menu_list_ids,
1858
1924
  cacheId: this.cacheId,
1859
- schedule_date: (0, _dayjs.default)().format('YYYY-MM-DD'),
1860
- schedule_datetime: (0, _dayjs.default)().format('YYYY-MM-DD HH:mm:ss')
1925
+ schedule_date: (0, import_dayjs.default)().format("YYYY-MM-DD"),
1926
+ schedule_datetime: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss")
1861
1927
  });
1862
- const productList = this.assertProductListLoaded('getProductList', res, {
1928
+ const productList = this.assertProductListLoaded("getProductList", res, {
1863
1929
  menu_list_ids,
1864
1930
  cacheId: this.cacheId
1865
1931
  });
1866
- const formattedRes = (0, _utils.attachItemRuleLimitsToTopLevelProducts)(productList, this.store.itemRuleQuantityLimits || []);
1867
- this.logMethodSuccess('getProductList', {
1932
+ const formattedRes = (0, import_utils.attachItemRuleLimitsToTopLevelProducts)(
1933
+ productList,
1934
+ this.store.itemRuleQuantityLimits || []
1935
+ );
1936
+ this.logMethodSuccess("getProductList", {
1868
1937
  menuCount: menu_list_ids.length
1869
1938
  });
1870
1939
  return formattedRes;
1871
1940
  } catch (error) {
1872
- if (!error?.__scanOrderLogged) {
1873
- this.logMethodError('getProductList', error, {
1941
+ if (!(error == null ? void 0 : error.__scanOrderLogged)) {
1942
+ this.logMethodError("getProductList", error, {
1874
1943
  menu_list_ids,
1875
1944
  cacheId: this.cacheId
1876
1945
  });
@@ -1881,107 +1950,87 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
1881
1950
  getOtherParams() {
1882
1951
  return this.otherParams;
1883
1952
  }
1884
- async setOtherParams(params, {
1885
- cover = false
1886
- } = {}) {
1953
+ async setOtherParams(params, { cover = false } = {}) {
1887
1954
  if (cover) {
1888
1955
  this.otherParams = params;
1889
1956
  } else {
1890
- this.otherParams = {
1891
- ...this.otherParams,
1892
- ...params
1893
- };
1957
+ this.otherParams = { ...this.otherParams, ...params };
1894
1958
  }
1895
1959
  }
1896
-
1897
- // ─── UI 状态缓存(按 cacheId 分桶,localStorage) ───
1898
- //
1899
- // 用于物料层持久化 UI 层面的轻量状态(如当前步骤、gate 标记、登录回跳意图等)。
1900
- // 桶键:pisell.scanOrder.uiState:<cacheId>;内部以 JSON object 形式存储多个字段。
1901
- // 无 cacheId 时所有方法自动降级为 no-op,上层不用判空。
1902
- //
1903
- // 之所以用 localStorage 而不是 sessionStorage:
1904
- // 1. 与 Order 模块 openCache 下的 tempOrder 同栈,购物车在 / UIState 在,行为对齐;
1905
- // 2. pisell1.login 整页 OAuth 跳转在 H5 壳 / iOS Safari 场景下可能丢 sessionStorage,
1906
- // 导致登录回跳后 gate 标记失效、pax 弹窗重开、落点错误;localStorage 稳定不受影响。
1907
- // 3. 失效由上层显式控制:提交成功 clearStepCache / entryContext 不一致 clearUIState /
1908
- // pendingStep 登录回调 deleteUIState,足够约束生命周期。
1909
-
1910
- static UI_STATE_KEY_PREFIX = 'pisell.scanOrder.uiState:';
1911
1960
  getUIStateBucketKey() {
1912
- if (!this.cacheId) return null;
1913
- return `${ScanOrderImpl.UI_STATE_KEY_PREFIX}${this.cacheId}`;
1961
+ if (!this.cacheId)
1962
+ return null;
1963
+ return `${_ScanOrderImpl.UI_STATE_KEY_PREFIX}${this.cacheId}`;
1914
1964
  }
1915
1965
  readUIStateBucket() {
1966
+ var _a;
1916
1967
  const key = this.getUIStateBucketKey();
1917
- if (!key || !this.window?.localStorage) return {};
1968
+ if (!key || !((_a = this.window) == null ? void 0 : _a.localStorage))
1969
+ return {};
1918
1970
  try {
1919
- const raw = this.window.localStorage.getItem(key) || '{}';
1971
+ const raw = this.window.localStorage.getItem(key) || "{}";
1920
1972
  const parsed = JSON.parse(raw);
1921
- return parsed && typeof parsed === 'object' ? parsed : {};
1973
+ return parsed && typeof parsed === "object" ? parsed : {};
1922
1974
  } catch {
1923
1975
  return {};
1924
1976
  }
1925
1977
  }
1926
1978
  writeUIStateBucket(bucket) {
1979
+ var _a;
1927
1980
  const key = this.getUIStateBucketKey();
1928
- if (!key || !this.window?.localStorage) return;
1981
+ if (!key || !((_a = this.window) == null ? void 0 : _a.localStorage))
1982
+ return;
1929
1983
  try {
1930
1984
  this.window.localStorage.setItem(key, JSON.stringify(bucket));
1931
1985
  } catch (error) {
1932
- console.warn('[ScanOrder] writeUIStateBucket failed', error);
1986
+ console.warn("[ScanOrder] writeUIStateBucket failed", error);
1933
1987
  }
1934
1988
  }
1935
1989
  setUIState(key, value) {
1936
- if (!this.getUIStateBucketKey()) return;
1990
+ if (!this.getUIStateBucketKey())
1991
+ return;
1937
1992
  const bucket = this.readUIStateBucket();
1938
1993
  bucket[key] = value;
1939
1994
  this.writeUIStateBucket(bucket);
1940
1995
  }
1941
1996
  getUIState(key) {
1942
- if (!this.getUIStateBucketKey()) return undefined;
1997
+ if (!this.getUIStateBucketKey())
1998
+ return void 0;
1943
1999
  const bucket = this.readUIStateBucket();
1944
2000
  return bucket[key];
1945
2001
  }
1946
2002
  deleteUIState(key) {
1947
- if (!this.getUIStateBucketKey()) return;
2003
+ if (!this.getUIStateBucketKey())
2004
+ return;
1948
2005
  const bucket = this.readUIStateBucket();
1949
2006
  if (key in bucket) {
1950
2007
  delete bucket[key];
1951
2008
  this.writeUIStateBucket(bucket);
1952
2009
  }
1953
2010
  }
1954
-
1955
2011
  // 整桶清空(用于扫新桌、提交成功、restoreOrder 等场景)
1956
2012
  clearUIState() {
2013
+ var _a;
1957
2014
  const key = this.getUIStateBucketKey();
1958
- if (!key || !this.window?.localStorage) return;
2015
+ if (!key || !((_a = this.window) == null ? void 0 : _a.localStorage))
2016
+ return;
1959
2017
  try {
1960
2018
  this.window.localStorage.removeItem(key);
1961
2019
  } catch (error) {
1962
- console.warn('[ScanOrder] clearUIState failed', error);
2020
+ console.warn("[ScanOrder] clearUIState failed", error);
1963
2021
  }
1964
2022
  }
1965
2023
  async setEntryPaxNumber(number) {
1966
- const pax = (0, _utils2.normalizeSubmitCollectPaxValue)(number);
2024
+ const pax = (0, import_utils2.normalizeSubmitCollectPaxValue)(number);
1967
2025
  this.store.entryPaxNumber = pax;
1968
2026
  if (this.store.order) {
1969
2027
  const t = this.store.order.ensureTempOrder();
1970
- t.metadata = {
1971
- ...t.metadata,
1972
- collect_pax: pax
1973
- };
2028
+ t.metadata = { ...t.metadata, collect_pax: pax };
1974
2029
  this.store.order.persistTempOrder();
1975
2030
  }
1976
-
1977
- // pax 变化后同步到 itemRuleRuntimeConfig,并刷新限购 / 校验
1978
2031
  this.itemRuleRuntimeConfig = {
1979
2032
  ...this.itemRuleRuntimeConfig,
1980
- pax: {
1981
- total: pax,
1982
- adult: 0,
1983
- child: 0
1984
- }
2033
+ pax: { total: pax, adult: 0, child: 0 }
1985
2034
  };
1986
2035
  this.itemRulePrefillApplied = false;
1987
2036
  await this.refreshItemRuleQuantityLimits();
@@ -1991,26 +2040,37 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
1991
2040
  return this.store.entryPaxNumber;
1992
2041
  }
1993
2042
  async syncAdditionalOrderFromResource(resourceId) {
1994
- const tempOrder = this.ensureTempOrder();
1995
- const normalizedResourceId = String(resourceId ?? tempOrder.resource_id ?? this.store.resource?.relationId ?? this.store.resource?.relation_id ?? '').trim();
1996
- this.logMethodStart('syncAdditionalOrderFromResource', {
2043
+ var _a, _b, _c, _d, _e, _f;
2044
+ if (!this.store.order)
2045
+ throw new Error("order 模块未初始化");
2046
+ const tempOrder = this.store.order.ensureTempOrder();
2047
+ const normalizedResourceId = String(
2048
+ resourceId ?? tempOrder.resource_id ?? ((_a = this.store.resource) == null ? void 0 : _a.relationId) ?? ((_b = this.store.resource) == null ? void 0 : _b.relation_id) ?? ""
2049
+ ).trim();
2050
+ this.logMethodStart("syncAdditionalOrderFromResource", {
1997
2051
  resourceId: normalizedResourceId
1998
2052
  });
1999
2053
  if (!normalizedResourceId) {
2000
- const result = {
2054
+ const result2 = {
2001
2055
  matched: false,
2002
- reason: 'missing_resource_id'
2056
+ reason: "missing_resource_id"
2003
2057
  };
2004
- this.logMethodSuccess('syncAdditionalOrderFromResource', result);
2005
- return result;
2058
+ this.logMethodSuccess("syncAdditionalOrderFromResource", result2);
2059
+ return result2;
2006
2060
  }
2007
2061
  const occupyDetails = await this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
2008
2062
  const occupyDetail = occupyDetails[0] ?? null;
2009
- const resourceSelectType = this.store.resource?.resourceSelectType || this.resolveResourceSelectType((0, _utils.toPositiveString)(occupyDetail?.form_id));
2010
- const allowAddItems = (0, _utils.toBoolean)(this.otherParams?.dineInConfig?.['sale.allow_add_items']);
2011
- const result = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
2063
+ const resourceSelectType = ((_c = this.store.resource) == null ? void 0 : _c.resourceSelectType) || this.resolveResourceSelectType((0, import_utils.toPositiveString)(occupyDetail == null ? void 0 : occupyDetail.form_id));
2064
+ const allowAddItems = (0, import_utils.toBoolean)(
2065
+ (_e = (_d = this.otherParams) == null ? void 0 : _d.dineInConfig) == null ? void 0 : _e["sale.allow_add_items"]
2066
+ );
2067
+ const result = this.resolveAdditionalOrderFromOccupyDetail(
2068
+ occupyDetail,
2069
+ resourceSelectType,
2070
+ allowAddItems
2071
+ );
2012
2072
  if (!result.matched || !result.order_id) {
2013
- this.logMethodSuccess('syncAdditionalOrderFromResource', {
2073
+ this.logMethodSuccess("syncAdditionalOrderFromResource", {
2014
2074
  ...result,
2015
2075
  resourceId: normalizedResourceId,
2016
2076
  resourceSelectType,
@@ -2020,10 +2080,10 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
2020
2080
  }
2021
2081
  tempOrder.order_id = result.order_id;
2022
2082
  tempOrder.resource_id = normalizedResourceId;
2023
- tempOrder.relation_id = (0, _utils.toPositiveString)(occupyDetail?.form_record_id) || normalizedResourceId || tempOrder.relation_id;
2024
- tempOrder.table_form_id = (0, _utils.toPositiveString)(occupyDetail?.form_id) || tempOrder.table_form_id;
2025
- this.store.order?.persistTempOrder();
2026
- this.logMethodSuccess('syncAdditionalOrderFromResource', {
2083
+ tempOrder.relation_id = (0, import_utils.toPositiveString)(occupyDetail == null ? void 0 : occupyDetail.form_record_id) || normalizedResourceId || tempOrder.relation_id;
2084
+ tempOrder.table_form_id = (0, import_utils.toPositiveString)(occupyDetail == null ? void 0 : occupyDetail.form_id) || tempOrder.table_form_id;
2085
+ (_f = this.store.order) == null ? void 0 : _f.persistTempOrder();
2086
+ this.logMethodSuccess("syncAdditionalOrderFromResource", {
2027
2087
  ...result,
2028
2088
  resourceId: normalizedResourceId,
2029
2089
  resourceSelectType,
@@ -2031,68 +2091,80 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
2031
2091
  });
2032
2092
  return result;
2033
2093
  }
2034
-
2035
2094
  // 读取预约规则商品的资源选择类型:single=单个预约,multiple=多个预约,capacity=容量型预约
2036
2095
  // 依赖 checkResourceAvailable 已根据预约规则商品与 occupy-detail 的 form_id 计算并缓存 store.resource
2037
2096
  getReservationResourceSelectType() {
2038
- this.logMethodStart('getReservationResourceSelectType');
2039
- const resourceSelectType = this.store.resource?.resourceSelectType;
2097
+ var _a;
2098
+ this.logMethodStart("getReservationResourceSelectType");
2099
+ const resourceSelectType = (_a = this.store.resource) == null ? void 0 : _a.resourceSelectType;
2040
2100
  const result = {
2041
- ...(resourceSelectType ? {
2042
- resourceSelectType
2043
- } : {}),
2044
- isSingleReservation: resourceSelectType === 'single',
2045
- isMultipleReservation: resourceSelectType === 'multiple',
2046
- isCapacityReservation: resourceSelectType === 'capacity'
2101
+ ...resourceSelectType ? { resourceSelectType } : {},
2102
+ isSingleReservation: resourceSelectType === "single",
2103
+ isMultipleReservation: resourceSelectType === "multiple",
2104
+ isCapacityReservation: resourceSelectType === "capacity"
2047
2105
  };
2048
- this.logMethodSuccess('getReservationResourceSelectType', result);
2106
+ this.logMethodSuccess("getReservationResourceSelectType", result);
2049
2107
  return result;
2050
2108
  }
2051
-
2052
2109
  // 判定后台是否开启允许加餐
2053
2110
  // 依赖 checkResourceAvailable 已缓存的 dineInConfig
2054
2111
  checkAllowAddItems() {
2055
- this.logMethodStart('checkAllowAddItems');
2056
- const dineInConfig = this.otherParams?.dineInConfig || {};
2112
+ var _a;
2113
+ this.logMethodStart("checkAllowAddItems");
2114
+ const dineInConfig = ((_a = this.otherParams) == null ? void 0 : _a.dineInConfig) || {};
2057
2115
  const result = {
2058
- enabled: (0, _utils.toBoolean)(dineInConfig['sale.allow_add_items'])
2116
+ enabled: (0, import_utils.toBoolean)(dineInConfig["sale.allow_add_items"])
2059
2117
  };
2060
- this.logMethodSuccess('checkAllowAddItems', result);
2118
+ this.logMethodSuccess("checkAllowAddItems", result);
2061
2119
  return result;
2062
2120
  }
2063
-
2064
2121
  // 读取取餐/送餐开关
2065
2122
  // 依赖 checkResourceAvailable 已缓存的 dineInConfig
2066
2123
  getFulfillmentModes() {
2067
- this.logMethodStart('getFulfillmentModes');
2068
- const dineInConfig = this.otherParams?.dineInConfig || {};
2124
+ var _a;
2125
+ this.logMethodStart("getFulfillmentModes");
2126
+ const dineInConfig = ((_a = this.otherParams) == null ? void 0 : _a.dineInConfig) || {};
2069
2127
  const result = {
2070
- enablePickup: Boolean(dineInConfig['fulfillment.enable_pickup']),
2071
- enableTableService: Boolean(dineInConfig['fulfillment.enable_table_service'])
2128
+ enablePickup: Boolean(dineInConfig["fulfillment.enable_pickup"]),
2129
+ enableTableService: Boolean(dineInConfig["fulfillment.enable_table_service"])
2072
2130
  };
2073
- this.logMethodSuccess('getFulfillmentModes', result);
2131
+ this.logMethodSuccess("getFulfillmentModes", result);
2074
2132
  return result;
2075
2133
  }
2076
-
2077
2134
  // 判定后台是否开启客户自定义取餐标识
2078
2135
  // 依赖 checkResourceAvailable 已缓存的 dineInConfig
2079
2136
  checkManualPickupRef() {
2080
- this.logMethodStart('checkManualPickupRef');
2081
- const dineInConfig = this.otherParams?.dineInConfig || {};
2082
- const refMode = dineInConfig['fulfillment.fulfillment_ref_mode'];
2083
- const manualInputType = dineInConfig['fulfillment.manual_input_type'];
2084
- const enabled = refMode === 'manual_input';
2085
- const result = enabled ? {
2086
- enabled: true,
2087
- manualInputType
2088
- } : {
2089
- enabled: false
2090
- };
2091
- this.logMethodSuccess('checkManualPickupRef', {
2137
+ var _a;
2138
+ this.logMethodStart("checkManualPickupRef");
2139
+ const dineInConfig = ((_a = this.otherParams) == null ? void 0 : _a.dineInConfig) || {};
2140
+ const refMode = dineInConfig["fulfillment.fulfillment_ref_mode"];
2141
+ const manualInputType = dineInConfig["fulfillment.manual_input_type"];
2142
+ const enabled = refMode === "manual_input";
2143
+ const result = enabled ? { enabled: true, manualInputType } : { enabled: false };
2144
+ this.logMethodSuccess("checkManualPickupRef", {
2092
2145
  enabled,
2093
- manualInputType: enabled ? manualInputType : undefined
2146
+ manualInputType: enabled ? manualInputType : void 0
2094
2147
  });
2095
2148
  return result;
2096
2149
  }
2097
- }
2098
- exports.ScanOrderImpl = ScanOrderImpl;
2150
+ };
2151
+ var ScanOrderImpl = _ScanOrderImpl;
2152
+ ScanOrderImpl.PISELL1_LOGIN_SUCCESS = "pisell1.login.success";
2153
+ // ─── UI 状态缓存(按 cacheId 分桶,localStorage) ───
2154
+ //
2155
+ // 用于物料层持久化 UI 层面的轻量状态(如当前步骤、gate 标记、登录回跳意图等)。
2156
+ // 桶键:pisell.scanOrder.uiState:<cacheId>;内部以 JSON object 形式存储多个字段。
2157
+ // 无 cacheId 时所有方法自动降级为 no-op,上层不用判空。
2158
+ //
2159
+ // 之所以用 localStorage 而不是 sessionStorage:
2160
+ // 1. 与 Order 模块 openCache 下的 tempOrder 同栈,购物车在 / UIState 在,行为对齐;
2161
+ // 2. pisell1.login 整页 OAuth 跳转在 H5 壳 / iOS Safari 场景下可能丢 sessionStorage,
2162
+ // 导致登录回跳后 gate 标记失效、pax 弹窗重开、落点错误;localStorage 稳定不受影响。
2163
+ // 3. 失效由上层显式控制:提交成功 clearStepCache / entryContext 不一致 clearUIState /
2164
+ // pendingStep 登录回调 deleteUIState,足够约束生命周期。
2165
+ ScanOrderImpl.UI_STATE_KEY_PREFIX = "pisell.scanOrder.uiState:";
2166
+ // Annotate the CommonJS export names for ESM import in node:
2167
+ 0 && (module.exports = {
2168
+ ScanOrderImpl,
2169
+ ...require("./types")
2170
+ });