@pisell/pisellos 0.0.568 → 0.0.569

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 (413) hide show
  1. package/dist/model/strategy/adapter/promotion/evaluator.js +3 -2
  2. package/dist/model/strategy/adapter/walletPass/utils.js +7 -4
  3. package/dist/modules/BaseModule.d.ts +2 -2
  4. package/dist/modules/BaseModule.js +4 -4
  5. package/dist/modules/BookingContext/index.d.ts +48 -0
  6. package/dist/modules/BookingContext/index.js +566 -0
  7. package/dist/modules/BookingContext/types.d.ts +102 -0
  8. package/dist/modules/BookingContext/types.js +51 -0
  9. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  10. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +302 -0
  11. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  12. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +149 -0
  13. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
  14. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +249 -0
  15. package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
  16. package/dist/modules/BookingContext/utils/flexible.js +56 -0
  17. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  18. package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
  19. package/dist/modules/BookingContext/utils/index.d.ts +11 -0
  20. package/dist/modules/BookingContext/utils/index.js +11 -0
  21. package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
  22. package/dist/modules/BookingContext/utils/noResource.js +77 -0
  23. package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
  24. package/dist/modules/BookingContext/utils/orderLineDisplay.js +36 -0
  25. package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
  26. package/dist/modules/BookingContext/utils/productExtend.js +339 -0
  27. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  28. package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
  29. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  30. package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
  31. package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
  32. package/dist/modules/BookingContext/utils/resources.js +486 -0
  33. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  34. package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
  35. package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  36. package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
  37. package/dist/modules/Cart/utils/cartProduct.js +26 -5
  38. package/dist/modules/Cart/utils/changePrice.js +27 -20
  39. package/dist/modules/Customer/index.d.ts +20 -0
  40. package/dist/modules/Customer/index.js +172 -83
  41. package/dist/modules/Customer/types.d.ts +2 -0
  42. package/dist/modules/Discount/index.d.ts +2 -1
  43. package/dist/modules/Discount/index.js +37 -9
  44. package/dist/modules/Discount/types.d.ts +1 -0
  45. package/dist/modules/OpenData/index.d.ts +8 -0
  46. package/dist/modules/OpenData/index.js +36 -16
  47. package/dist/modules/Order/index.d.ts +448 -23
  48. package/dist/modules/Order/index.js +5417 -561
  49. package/dist/modules/Order/types.d.ts +693 -88
  50. package/dist/modules/Order/types.js +68 -1
  51. package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
  52. package/dist/modules/Order/utils/bundleDiscountHydration.js +144 -0
  53. package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  54. package/dist/modules/Order/utils/manualProductDiscount.js +210 -0
  55. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  56. package/dist/modules/Order/utils/orderCollectionIdentity.js +405 -0
  57. package/dist/modules/Order/utils.d.ts +167 -18
  58. package/dist/modules/Order/utils.js +960 -165
  59. package/dist/modules/Payment/index.d.ts +10 -9
  60. package/dist/modules/Payment/index.js +465 -703
  61. package/dist/modules/Payment/types.d.ts +40 -16
  62. package/dist/modules/Payment/utils.d.ts +1 -1
  63. package/dist/modules/Payment/utils.js +4 -3
  64. package/dist/modules/Payment/walletpass.js +44 -29
  65. package/dist/modules/Product/types.d.ts +29 -7
  66. package/dist/modules/ProductList/index.d.ts +17 -13
  67. package/dist/modules/ProductList/index.js +184 -74
  68. package/dist/modules/ProductList/types.d.ts +17 -0
  69. package/dist/modules/Quotation/index.d.ts +22 -2
  70. package/dist/modules/Quotation/index.js +108 -42
  71. package/dist/modules/Quotation/types.d.ts +19 -0
  72. package/dist/modules/ResourcePlanner/index.d.ts +24 -0
  73. package/dist/modules/ResourcePlanner/index.js +181 -0
  74. package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
  75. package/dist/modules/ResourcePlanner/planner.js +1069 -0
  76. package/dist/modules/ResourcePlanner/types.d.ts +227 -0
  77. package/dist/modules/ResourcePlanner/types.js +1 -0
  78. package/dist/modules/Rules/index.d.ts +8 -10
  79. package/dist/modules/Rules/index.js +221 -109
  80. package/dist/modules/Rules/types.d.ts +14 -3
  81. package/dist/modules/SalesSummary/index.d.ts +23 -26
  82. package/dist/modules/SalesSummary/index.js +152 -46
  83. package/dist/modules/SalesSummary/types.d.ts +9 -1
  84. package/dist/modules/SalesSummary/utils.d.ts +3 -22
  85. package/dist/modules/SalesSummary/utils.js +803 -163
  86. package/dist/modules/Schedule/getDateIsInSchedule.js +14 -7
  87. package/dist/modules/Schedule/index.d.ts +18 -5
  88. package/dist/modules/Schedule/index.js +78 -24
  89. package/dist/modules/Schedule/types.d.ts +2 -0
  90. package/dist/modules/Summary/index.js +4 -3
  91. package/dist/modules/SurchargeList/index.d.ts +18 -0
  92. package/dist/modules/SurchargeList/index.js +185 -0
  93. package/dist/modules/SurchargeList/types.d.ts +15 -0
  94. package/dist/modules/SurchargeList/types.js +1 -0
  95. package/dist/modules/index.d.ts +3 -0
  96. package/dist/modules/index.js +4 -1
  97. package/dist/plugins/app.d.ts +2 -0
  98. package/dist/plugins/request.d.ts +1 -0
  99. package/dist/server/index.d.ts +462 -8
  100. package/dist/server/index.js +6112 -656
  101. package/dist/server/modules/floor-plan/index.d.ts +39 -0
  102. package/dist/server/modules/floor-plan/index.js +595 -0
  103. package/dist/server/modules/floor-plan/types.d.ts +43 -0
  104. package/dist/server/modules/floor-plan/types.js +13 -0
  105. package/dist/server/modules/index.d.ts +7 -2
  106. package/dist/server/modules/index.js +6 -0
  107. package/dist/server/modules/order/index.d.ts +207 -14
  108. package/dist/server/modules/order/index.js +2326 -379
  109. package/dist/server/modules/order/types.d.ts +76 -5
  110. package/dist/server/modules/order/types.js +14 -1
  111. package/dist/server/modules/order/utils/filterBookings.d.ts +7 -1
  112. package/dist/server/modules/order/utils/filterBookings.js +118 -11
  113. package/dist/server/modules/order/utils/filterOrders.js +242 -14
  114. package/dist/server/modules/payment/index.d.ts +28 -0
  115. package/dist/server/modules/payment/index.js +305 -0
  116. package/dist/server/modules/payment/types.d.ts +9 -0
  117. package/dist/server/modules/payment/types.js +1 -0
  118. package/dist/server/modules/products/index.d.ts +105 -14
  119. package/dist/server/modules/products/index.js +1393 -516
  120. package/dist/server/modules/products/types.d.ts +34 -1
  121. package/dist/server/modules/products/types.js +4 -0
  122. package/dist/server/modules/quotation/index.d.ts +39 -0
  123. package/dist/server/modules/quotation/index.js +278 -66
  124. package/dist/server/modules/resource/index.d.ts +2 -3
  125. package/dist/server/modules/resource/index.js +108 -86
  126. package/dist/server/modules/schedule/index.d.ts +6 -4
  127. package/dist/server/modules/schedule/index.js +116 -85
  128. package/dist/server/test.json +713 -0
  129. package/dist/server/types.d.ts +2 -0
  130. package/dist/server/utils/product.js +2 -2
  131. package/dist/server/utils/small-ticket.d.ts +71 -0
  132. package/dist/server/utils/small-ticket.js +963 -0
  133. package/dist/solution/BaseSales/index.d.ts +378 -0
  134. package/dist/solution/BaseSales/index.js +4006 -0
  135. package/dist/solution/BaseSales/types.d.ts +394 -0
  136. package/dist/solution/BaseSales/types.js +40 -0
  137. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
  138. package/dist/solution/BaseSales/utils/cartPromotion.js +1450 -0
  139. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +144 -0
  140. package/dist/solution/BaseSales/utils/parseSalesResponse.js +157 -0
  141. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +18 -0
  142. package/dist/solution/BaseSales/utils/quotationPrice.js +250 -0
  143. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +63 -0
  144. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +218 -0
  145. package/dist/solution/BaseSales/utils.d.ts +40 -0
  146. package/dist/solution/BaseSales/utils.js +263 -0
  147. package/dist/solution/BookingByStep/index.d.ts +1 -1
  148. package/dist/solution/BookingTicket/index.d.ts +394 -25
  149. package/dist/solution/BookingTicket/index.js +2506 -443
  150. package/dist/solution/BookingTicket/types.d.ts +191 -6
  151. package/dist/solution/BookingTicket/types.js +83 -10
  152. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
  153. package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
  154. package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
  155. package/dist/solution/BookingTicket/utils/addTimeAvailability.js +95 -0
  156. package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
  157. package/dist/solution/BookingTicket/utils/bookingStatus.js +136 -0
  158. package/dist/solution/BookingTicket/utils/cartView.d.ts +29 -0
  159. package/dist/solution/BookingTicket/utils/cartView.js +209 -0
  160. package/dist/solution/BookingTicket/utils/exampleData.d.ts +123 -0
  161. package/dist/solution/BookingTicket/utils/exampleData.js +183 -0
  162. package/dist/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
  163. package/dist/solution/BookingTicket/utils/orderCustomer.js +31 -0
  164. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
  165. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +438 -0
  166. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
  167. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +400 -0
  168. package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +4 -0
  169. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +41 -1
  170. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
  171. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +56 -0
  172. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  173. package/dist/solution/BookingTicket/utils/scan/handleScan.js +11 -3
  174. package/dist/solution/BookingTicket/utils/scan/index.d.ts +5 -0
  175. package/dist/solution/BookingTicket/utils/scan/index.js +20 -8
  176. package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
  177. package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +150 -0
  178. package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
  179. package/dist/solution/BookingTicket/utils/sessionCatalogStale.js +78 -0
  180. package/dist/solution/Checkout/index.d.ts +1 -0
  181. package/dist/solution/Checkout/index.js +25 -34
  182. package/dist/solution/Checkout/utils/index.js +4 -4
  183. package/dist/solution/RegisterAndLogin/config.js +2 -10
  184. package/dist/solution/Sales/index.d.ts +50 -5
  185. package/dist/solution/Sales/index.js +484 -92
  186. package/dist/solution/Sales/types.d.ts +26 -2
  187. package/dist/solution/ScanOrder/index.d.ts +27 -21
  188. package/dist/solution/ScanOrder/index.js +499 -434
  189. package/dist/solution/ScanOrder/types.d.ts +33 -11
  190. package/dist/solution/ScanOrder/types.js +4 -5
  191. package/dist/solution/ScanOrder/utils.d.ts +4 -1
  192. package/dist/solution/ScanOrder/utils.js +109 -34
  193. package/dist/solution/ShopDiscount/index.js +4 -4
  194. package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
  195. package/dist/solution/UnifiedBookingSales/index.js +1871 -0
  196. package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
  197. package/dist/solution/UnifiedBookingSales/types.js +11 -0
  198. package/dist/solution/VenueBooking/index.d.ts +29 -20
  199. package/dist/solution/VenueBooking/index.js +301 -213
  200. package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -2
  201. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
  202. package/dist/solution/VenueBooking/utils/slotMerge.js +9 -3
  203. package/dist/solution/index.d.ts +2 -0
  204. package/dist/solution/index.js +3 -1
  205. package/dist/types/index.d.ts +11 -1
  206. package/lib/model/strategy/adapter/promotion/evaluator.js +3 -2
  207. package/lib/model/strategy/adapter/walletPass/utils.js +6 -4
  208. package/lib/modules/BaseModule.d.ts +2 -2
  209. package/lib/modules/BaseModule.js +4 -4
  210. package/lib/modules/BookingContext/index.d.ts +48 -0
  211. package/lib/modules/BookingContext/index.js +390 -0
  212. package/lib/modules/BookingContext/types.d.ts +102 -0
  213. package/lib/modules/BookingContext/types.js +48 -0
  214. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  215. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +286 -0
  216. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  217. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +148 -0
  218. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
  219. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +242 -0
  220. package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
  221. package/lib/modules/BookingContext/utils/flexible.js +63 -0
  222. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  223. package/lib/modules/BookingContext/utils/formatResourceList.js +35 -0
  224. package/lib/modules/BookingContext/utils/index.d.ts +11 -0
  225. package/lib/modules/BookingContext/utils/index.js +126 -0
  226. package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
  227. package/lib/modules/BookingContext/utils/noResource.js +78 -0
  228. package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
  229. package/lib/modules/BookingContext/utils/orderLineDisplay.js +29 -0
  230. package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
  231. package/lib/modules/BookingContext/utils/productExtend.js +330 -0
  232. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  233. package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
  234. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  235. package/lib/modules/BookingContext/utils/resourceSelection.js +24 -0
  236. package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
  237. package/lib/modules/BookingContext/utils/resources.js +419 -0
  238. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  239. package/lib/modules/BookingContext/utils/serviceTimes.js +161 -0
  240. package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  241. package/lib/modules/BookingContext/utils/timeSlices.js +114 -0
  242. package/lib/modules/Cart/utils/cartProduct.js +27 -5
  243. package/lib/modules/Cart/utils/changePrice.js +20 -14
  244. package/lib/modules/Customer/index.d.ts +20 -0
  245. package/lib/modules/Customer/index.js +63 -10
  246. package/lib/modules/Customer/types.d.ts +2 -0
  247. package/lib/modules/Discount/index.d.ts +2 -1
  248. package/lib/modules/Discount/index.js +18 -2
  249. package/lib/modules/Discount/types.d.ts +1 -0
  250. package/lib/modules/OpenData/index.d.ts +8 -0
  251. package/lib/modules/OpenData/index.js +21 -3
  252. package/lib/modules/Order/index.d.ts +448 -23
  253. package/lib/modules/Order/index.js +3641 -308
  254. package/lib/modules/Order/types.d.ts +693 -88
  255. package/lib/modules/Order/types.js +55 -1
  256. package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
  257. package/lib/modules/Order/utils/bundleDiscountHydration.js +106 -0
  258. package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  259. package/lib/modules/Order/utils/manualProductDiscount.js +207 -0
  260. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  261. package/lib/modules/Order/utils/orderCollectionIdentity.js +353 -0
  262. package/lib/modules/Order/utils.d.ts +167 -18
  263. package/lib/modules/Order/utils.js +974 -138
  264. package/lib/modules/Payment/index.d.ts +10 -9
  265. package/lib/modules/Payment/index.js +30 -124
  266. package/lib/modules/Payment/types.d.ts +40 -16
  267. package/lib/modules/Payment/utils.d.ts +1 -1
  268. package/lib/modules/Payment/utils.js +4 -3
  269. package/lib/modules/Payment/walletpass.js +16 -6
  270. package/lib/modules/Product/types.d.ts +29 -7
  271. package/lib/modules/ProductList/index.d.ts +17 -13
  272. package/lib/modules/ProductList/index.js +92 -51
  273. package/lib/modules/ProductList/types.d.ts +17 -0
  274. package/lib/modules/Quotation/index.d.ts +22 -2
  275. package/lib/modules/Quotation/index.js +76 -20
  276. package/lib/modules/Quotation/types.d.ts +19 -0
  277. package/lib/modules/ResourcePlanner/index.d.ts +24 -0
  278. package/lib/modules/ResourcePlanner/index.js +147 -0
  279. package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
  280. package/lib/modules/ResourcePlanner/planner.js +895 -0
  281. package/lib/modules/ResourcePlanner/types.d.ts +227 -0
  282. package/lib/modules/ResourcePlanner/types.js +5 -0
  283. package/lib/modules/Rules/index.d.ts +8 -10
  284. package/lib/modules/Rules/index.js +152 -60
  285. package/lib/modules/Rules/types.d.ts +14 -3
  286. package/lib/modules/SalesSummary/index.d.ts +23 -26
  287. package/lib/modules/SalesSummary/index.js +84 -16
  288. package/lib/modules/SalesSummary/types.d.ts +9 -1
  289. package/lib/modules/SalesSummary/utils.d.ts +3 -22
  290. package/lib/modules/SalesSummary/utils.js +616 -111
  291. package/lib/modules/Schedule/getDateIsInSchedule.js +14 -7
  292. package/lib/modules/Schedule/index.d.ts +18 -5
  293. package/lib/modules/Schedule/index.js +49 -14
  294. package/lib/modules/Schedule/types.d.ts +2 -0
  295. package/lib/modules/Summary/index.js +2 -2
  296. package/lib/modules/SurchargeList/index.d.ts +18 -0
  297. package/lib/modules/SurchargeList/index.js +95 -0
  298. package/lib/modules/SurchargeList/types.d.ts +15 -0
  299. package/lib/modules/SurchargeList/types.js +5 -0
  300. package/lib/modules/index.d.ts +3 -0
  301. package/lib/modules/index.js +33 -0
  302. package/lib/plugins/app.d.ts +2 -0
  303. package/lib/plugins/request.d.ts +1 -0
  304. package/lib/server/index.d.ts +462 -8
  305. package/lib/server/index.js +3901 -205
  306. package/lib/server/modules/floor-plan/index.d.ts +39 -0
  307. package/lib/server/modules/floor-plan/index.js +306 -0
  308. package/lib/server/modules/floor-plan/types.d.ts +43 -0
  309. package/lib/server/modules/floor-plan/types.js +19 -0
  310. package/lib/server/modules/index.d.ts +7 -2
  311. package/lib/server/modules/index.js +21 -0
  312. package/lib/server/modules/order/index.d.ts +207 -14
  313. package/lib/server/modules/order/index.js +1324 -141
  314. package/lib/server/modules/order/types.d.ts +76 -5
  315. package/lib/server/modules/order/types.js +11 -1
  316. package/lib/server/modules/order/utils/filterBookings.d.ts +7 -1
  317. package/lib/server/modules/order/utils/filterBookings.js +119 -11
  318. package/lib/server/modules/order/utils/filterOrders.js +238 -13
  319. package/lib/server/modules/payment/index.d.ts +28 -0
  320. package/lib/server/modules/payment/index.js +168 -0
  321. package/lib/server/modules/payment/types.d.ts +9 -0
  322. package/lib/server/modules/payment/types.js +5 -0
  323. package/lib/server/modules/products/index.d.ts +105 -14
  324. package/lib/server/modules/products/index.js +588 -97
  325. package/lib/server/modules/products/types.d.ts +34 -1
  326. package/lib/server/modules/products/types.js +3 -0
  327. package/lib/server/modules/quotation/index.d.ts +39 -0
  328. package/lib/server/modules/quotation/index.js +145 -1
  329. package/lib/server/modules/resource/index.d.ts +2 -3
  330. package/lib/server/modules/resource/index.js +71 -45
  331. package/lib/server/modules/schedule/index.d.ts +6 -4
  332. package/lib/server/modules/schedule/index.js +55 -44
  333. package/lib/server/test.json +713 -0
  334. package/lib/server/types.d.ts +2 -0
  335. package/lib/server/utils/product.js +2 -2
  336. package/lib/server/utils/small-ticket.d.ts +71 -0
  337. package/lib/server/utils/small-ticket.js +926 -0
  338. package/lib/solution/BaseSales/index.d.ts +378 -0
  339. package/lib/solution/BaseSales/index.js +2367 -0
  340. package/lib/solution/BaseSales/types.d.ts +394 -0
  341. package/lib/solution/BaseSales/types.js +47 -0
  342. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
  343. package/lib/solution/BaseSales/utils/cartPromotion.js +1155 -0
  344. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +144 -0
  345. package/lib/solution/BaseSales/utils/parseSalesResponse.js +140 -0
  346. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +18 -0
  347. package/lib/solution/BaseSales/utils/quotationPrice.js +231 -0
  348. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +63 -0
  349. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +215 -0
  350. package/lib/solution/BaseSales/utils.d.ts +40 -0
  351. package/lib/solution/BaseSales/utils.js +259 -0
  352. package/lib/solution/BookingByStep/index.d.ts +1 -1
  353. package/lib/solution/BookingTicket/index.d.ts +394 -25
  354. package/lib/solution/BookingTicket/index.js +1350 -76
  355. package/lib/solution/BookingTicket/types.d.ts +191 -6
  356. package/lib/solution/BookingTicket/types.js +71 -10
  357. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
  358. package/lib/solution/BookingTicket/utils/addProductDecision.js +353 -0
  359. package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
  360. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +94 -0
  361. package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
  362. package/lib/solution/BookingTicket/utils/bookingStatus.js +136 -0
  363. package/lib/solution/BookingTicket/utils/cartView.d.ts +29 -0
  364. package/lib/solution/BookingTicket/utils/cartView.js +200 -0
  365. package/lib/solution/BookingTicket/utils/exampleData.d.ts +123 -0
  366. package/lib/solution/BookingTicket/utils/exampleData.js +185 -0
  367. package/lib/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
  368. package/lib/solution/BookingTicket/utils/orderCustomer.js +35 -0
  369. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
  370. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +387 -0
  371. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
  372. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +220 -0
  373. package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +4 -0
  374. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +24 -3
  375. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
  376. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +64 -0
  377. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  378. package/lib/solution/BookingTicket/utils/scan/handleScan.js +4 -2
  379. package/lib/solution/BookingTicket/utils/scan/index.d.ts +5 -0
  380. package/lib/solution/BookingTicket/utils/scan/index.js +14 -2
  381. package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
  382. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +115 -0
  383. package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
  384. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +83 -0
  385. package/lib/solution/Checkout/index.d.ts +1 -0
  386. package/lib/solution/Checkout/index.js +18 -19
  387. package/lib/solution/Checkout/utils/index.js +4 -4
  388. package/lib/solution/RegisterAndLogin/config.js +2 -10
  389. package/lib/solution/Sales/index.d.ts +50 -5
  390. package/lib/solution/Sales/index.js +296 -39
  391. package/lib/solution/Sales/types.d.ts +26 -2
  392. package/lib/solution/ScanOrder/index.d.ts +27 -21
  393. package/lib/solution/ScanOrder/index.js +144 -103
  394. package/lib/solution/ScanOrder/types.d.ts +33 -11
  395. package/lib/solution/ScanOrder/types.js +4 -5
  396. package/lib/solution/ScanOrder/utils.d.ts +4 -1
  397. package/lib/solution/ScanOrder/utils.js +98 -26
  398. package/lib/solution/ShopDiscount/index.js +3 -3
  399. package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
  400. package/lib/solution/UnifiedBookingSales/index.js +1050 -0
  401. package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
  402. package/lib/solution/UnifiedBookingSales/types.js +14 -0
  403. package/lib/solution/VenueBooking/index.d.ts +29 -20
  404. package/lib/solution/VenueBooking/index.js +169 -94
  405. package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -2
  406. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
  407. package/lib/solution/VenueBooking/utils/slotMerge.js +9 -3
  408. package/lib/solution/index.d.ts +2 -0
  409. package/lib/solution/index.js +22 -0
  410. package/lib/types/index.d.ts +11 -1
  411. package/package.json +1 -1
  412. package/dist/solution/Checkout/appointmentDemo.json +0 -1
  413. package/lib/solution/Checkout/appointmentDemo.json +0 -1
@@ -1,12 +1,24 @@
1
+ var _excluded = ["id"],
2
+ _excluded2 = ["product_id"],
3
+ _excluded3 = ["product_id"];
1
4
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
5
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
6
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
7
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
2
8
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
9
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
6
10
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
11
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
12
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
15
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
16
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
7
17
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
18
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
9
19
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
20
+ function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
21
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
10
22
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
11
23
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12
24
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
@@ -14,16 +26,137 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
14
26
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
15
27
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
16
28
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
29
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
30
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
31
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
32
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
19
33
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
20
- import { BaseModule } from "../../modules/BaseModule";
21
- import { createModule } from "./types";
34
+ import dayjs from 'dayjs';
35
+ import { createBookingTicketModule } from "./types";
36
+ import { getProductExtend as getProductExtendUtil, getResourceByIds as getResourceByIdsUtil, getResourceErrors as getResourceErrorsUtil, derivePresetStartTimeFromDate } from "../../modules/BookingContext";
37
+ import { BaseSalesImpl } from "../BaseSales";
22
38
  import Scan from "./utils/scan";
39
+ import { formatOrderCustomerPatch } from "./utils/orderCustomer";
23
40
  import { handleGlobalScan, handleCustomerScan, handleUniversalScan } from "./utils/scan/handleScan";
24
41
  import scanCache from "./utils/scan/scanCache";
25
- export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
26
- _inherits(BookingTicketImpl, _BaseModule);
42
+ import { formatGlobalScanResult } from "./utils/scan/formatGlobalScan";
43
+ import { applyGlobalScan } from "./utils/scan/applyGlobalScan";
44
+ import { buildCartView } from "./utils/cartView";
45
+ import { buildCacheItemFromCartDetail, buildCacheItemFromDetail, buildRequiresDetailPayload as _buildRequiresDetailPayload, decideAddProduct as decideAddProductUtil, decideAfterDetail as decideAfterDetailUtil, decideAutoClose as decideAutoCloseUtil, getIsEject as getIsEjectUtil, getIsOnlySession as getIsOnlySessionUtil, transformDetailToProductAndBooking as transformDetailToProductAndBookingUtil } from "./utils/addProductDecision";
46
+ import { buildCacheItemFromOrderLine as buildCacheItemFromOrderLineUtil } from "../../modules/BookingContext/utils/buildCacheItemFromOrderLine";
47
+ import { buildSessionCatalogStaleInfo, isSessionCatalogDateStale } from "./utils/sessionCatalogStale";
48
+ import { buildNormalProductCacheItemFromOrderLine as buildNormalProductCacheItemFromOrderLineUtil } from "../../modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine";
49
+ import { buildProductOptionStringFromOrderLine } from "../../modules/BookingContext/utils/orderLineDisplay";
50
+ import { applyBookingsStatus, applyChildBookingStatus, resolveScheduleId, resolveStatusAfterTransition, restoreBookingsStatus, restoreChildBookingStatus } from "./utils/bookingStatus";
51
+ import { resolveBestAddTimePlan as _resolveBestAddTimePlan } from "./utils/resolveBestAddTimePlan";
52
+ import { createUuidV4 } from "../../modules/Order/utils";
53
+ var OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow'];
54
+ var OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
55
+
56
+ /**
57
+ * 读取已有 booking 的协议唯一值,用于加时商品行绑定原预约。
58
+ *
59
+ * @example
60
+ * const bookingUid = resolveBookingUidForAddTime(booking);
61
+ */
62
+ function resolveBookingUidForAddTime(booking) {
63
+ var _booking$metadata;
64
+ var uid = booking === null || booking === void 0 || (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.unique_identification_number;
65
+ return uid === undefined || uid === null ? '' : String(uid);
66
+ }
67
+
68
+ /**
69
+ * 规范化加车数量,避免非法值进入 OrderModule。
70
+ *
71
+ * @example
72
+ * const quantity = normalizeAddTimeQuantity(product.num);
73
+ */
74
+ function normalizeAddTimeQuantity(value) {
75
+ var parsed = Math.floor(Number(value));
76
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : 1;
77
+ }
78
+
79
+ /**
80
+ * 解析加时时长,优先使用显式入参,其次回退商品字段。
81
+ *
82
+ * @example
83
+ * const minutes = resolveAddTimeScheduleMinutes(input.product_add_schedule_time, product);
84
+ */
85
+ function resolveAddTimeScheduleMinutes(explicitValue, product) {
86
+ var raw = explicitValue !== null && explicitValue !== void 0 ? explicitValue : product === null || product === void 0 ? void 0 : product.product_add_schedule_time;
87
+ if (raw === undefined || raw === null || raw === '') return undefined;
88
+ var parsed = Number(raw);
89
+ return Number.isFinite(parsed) ? parsed : undefined;
90
+ }
91
+
92
+ /**
93
+ * 计算加时商品行价格字段,保持 `price` 与 `selling_price` 输入口径一致。
94
+ *
95
+ * @example
96
+ * const price = resolveAddTimeProductPrice(input.price, product);
97
+ */
98
+ function resolveAddTimeProductPrice(explicitValue, product) {
99
+ var _ref, _ref2;
100
+ return (_ref = (_ref2 = explicitValue !== null && explicitValue !== void 0 ? explicitValue : product === null || product === void 0 ? void 0 : product.price) !== null && _ref2 !== void 0 ? _ref2 : product === null || product === void 0 ? void 0 : product.selling_price) !== null && _ref !== void 0 ? _ref : product === null || product === void 0 ? void 0 : product.base_price;
101
+ }
102
+
103
+ /**
104
+ * 规范化加时覆盖分钟数。
105
+ *
106
+ * @example
107
+ * const minutes = normalizeCoveredMinutes(input.coveredMinutes);
108
+ */
109
+ function normalizeCoveredMinutes(value) {
110
+ var parsed = Math.ceil(Number(value));
111
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : 0;
112
+ }
113
+
114
+ /**
115
+ * 计算 booking 加时后的结束时间与时长。
116
+ *
117
+ * @example
118
+ * const updates = buildAddTimeBookingTimePatch(booking, 30);
119
+ */
120
+ function buildAddTimeBookingTimePatch(booking, coveredMinutes) {
121
+ if (coveredMinutes <= 0) return null;
122
+ var endDate = booking === null || booking === void 0 ? void 0 : booking.end_date;
123
+ var endTime = booking === null || booking === void 0 ? void 0 : booking.end_time;
124
+ if (!endDate || !endTime) {
125
+ throw new Error('[BookingTicket] addAddTimeProductsToBooking: booking.end_date/end_time 缺失');
126
+ }
127
+ var currentEnd = dayjs("".concat(endDate, " ").concat(endTime));
128
+ if (!currentEnd.isValid()) {
129
+ throw new Error('[BookingTicket] addAddTimeProductsToBooking: booking.end_date/end_time 无效');
130
+ }
131
+ var nextEnd = currentEnd.add(coveredMinutes, 'minute');
132
+ var currentDuration = Number(booking === null || booking === void 0 ? void 0 : booking.duration);
133
+ var duration = Number.isFinite(currentDuration) ? currentDuration + coveredMinutes : coveredMinutes;
134
+ if (booking !== null && booking !== void 0 && booking.start_date && booking !== null && booking !== void 0 && booking.start_time) {
135
+ var start = dayjs("".concat(booking.start_date, " ").concat(booking.start_time));
136
+ if (start.isValid()) {
137
+ var diffMinutes = nextEnd.diff(start, 'minute');
138
+ duration = diffMinutes > 0 ? diffMinutes : duration;
139
+ }
140
+ }
141
+ return {
142
+ end_date: nextEnd.format('YYYY-MM-DD'),
143
+ end_time: nextEnd.format('HH:mm'),
144
+ duration: duration
145
+ };
146
+ }
147
+ function withProductOptionString(cacheItem) {
148
+ var _cacheItem$_extend;
149
+ var productOptionString = buildProductOptionStringFromOrderLine(cacheItem);
150
+ if (!productOptionString) return cacheItem;
151
+ return _objectSpread(_objectSpread({}, cacheItem), {}, {
152
+ product_option_string: (cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.product_option_string) || productOptionString,
153
+ _extend: _objectSpread(_objectSpread({}, (cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem._extend) || {}), {}, {
154
+ product_option_string: (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.product_option_string) || productOptionString
155
+ })
156
+ });
157
+ }
158
+ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
159
+ _inherits(BookingTicketImpl, _BaseSalesImpl);
27
160
  var _super = _createSuper(BookingTicketImpl);
28
161
  function BookingTicketImpl() {
29
162
  var _this;
@@ -34,339 +167,1476 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
34
167
  _this = _super.call.apply(_super, [this].concat(args));
35
168
  _defineProperty(_assertThisInitialized(_this), "defaultName", 'bookingTicket');
36
169
  _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
37
- _defineProperty(_assertThisInitialized(_this), "isSolution", true);
38
- _defineProperty(_assertThisInitialized(_this), "request", void 0);
39
- _defineProperty(_assertThisInitialized(_this), "window", void 0);
40
- _defineProperty(_assertThisInitialized(_this), "shopStore", void 0);
41
- _defineProperty(_assertThisInitialized(_this), "store", void 0);
42
- _defineProperty(_assertThisInitialized(_this), "otherParams", {});
43
- _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
170
+ /**
171
+ * 子类覆盖 store 类型为 BookingTicket 子模块清单(在父类基础上追加 customer)。
172
+ * 父类按 `getRegisteredModuleNames` 注入成员到该 store。
173
+ */
174
+ _defineProperty(_assertThisInitialized(_this), "store", {});
44
175
  _defineProperty(_assertThisInitialized(_this), "platform", void 0);
45
- // 平台类型,用于判断是 PC / H5
46
176
  _defineProperty(_assertThisInitialized(_this), "scan", void 0);
177
+ _defineProperty(_assertThisInitialized(_this), "productCatalog", []);
178
+ _defineProperty(_assertThisInitialized(_this), "addTimeProductsCatalog", []);
179
+ _defineProperty(_assertThisInitialized(_this), "orderCustomerDiscountRefreshInFlight", null);
180
+ _defineProperty(_assertThisInitialized(_this), "orderCustomerDiscountRefreshCustomerId", null);
181
+ _defineProperty(_assertThisInitialized(_this), "loadOpenDataConfigInFlight", null);
47
182
  return _this;
48
183
  }
49
184
  _createClass(BookingTicketImpl, [{
185
+ key: "getRegisteredModuleNames",
186
+ value:
187
+ /**
188
+ * 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer + bookingContext。
189
+ * bookingContext 是 SalesSdk 加车下沉所需的「预约 UI 上下文」(bookingConfig / resourcesOrigin / date)。
190
+ */
191
+ function getRegisteredModuleNames() {
192
+ return [].concat(_toConsumableArray(_get(_getPrototypeOf(BookingTicketImpl.prototype), "getRegisteredModuleNames", this).call(this)), ['customer', 'bookingContext', 'openData']);
193
+ }
194
+ }, {
195
+ key: "getSubmitOrderSalesChannel",
196
+ value: function getSubmitOrderSalesChannel() {
197
+ var _this$core, _this$core$getChannel;
198
+ var channel = (_this$core = this.core) === null || _this$core === void 0 || (_this$core = _this$core.context) === null || _this$core === void 0 || (_this$core$getChannel = _this$core.getChannel) === null || _this$core$getChannel === void 0 ? void 0 : _this$core$getChannel.call(_this$core);
199
+ return !channel || channel === 'system' ? 'pos' : channel;
200
+ }
201
+
202
+ /**
203
+ * 业务侧子模块工厂:BookingTicket 自带的 createBookingTicketModule 优先匹配;
204
+ * 未识别的模块名(如 BookingByStep 公共类型)回退到父类工厂。
205
+ */
206
+ }, {
207
+ key: "createSubModule",
208
+ value: function createSubModule(moduleName) {
209
+ var localModule = createBookingTicketModule(moduleName, this.name);
210
+ if (localModule) return localModule;
211
+ return _get(_getPrototypeOf(BookingTicketImpl.prototype), "createSubModule", this).call(this, moduleName);
212
+ }
213
+ }, {
50
214
  key: "initialize",
51
215
  value: function () {
52
- var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
53
- var _this$otherParams,
54
- _this$otherParams2,
55
- _this$otherParams3,
56
- _this2 = this;
57
- var targetCacheData, sessionData, _data, moduleArr;
216
+ var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core) {
217
+ var _this$otherParams;
218
+ var options,
219
+ _args = arguments;
58
220
  return _regeneratorRuntime().wrap(function _callee$(_context) {
59
221
  while (1) switch (_context.prev = _context.next) {
60
222
  case 0:
61
- this.core = core;
62
- this.store = options.store || {};
63
- this.otherParams = options.otherParams || {};
64
- // 获取依赖的插件
65
- this.request = core.getPlugin('request');
66
- this.window = core.getPlugin('window');
67
- this.shopStore = core.getPlugin('shopStore');
223
+ options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
224
+ this.scan = new Scan(this, "BOOKING_TICKET_SCAN:".concat(this.name));
225
+ _context.next = 4;
226
+ return _get(_getPrototypeOf(BookingTicketImpl.prototype), "initialize", this).call(this, core, options);
227
+ case 4:
68
228
  if (this.request) {
69
- _context.next = 8;
229
+ _context.next = 6;
70
230
  break;
71
231
  }
72
232
  throw new Error('bookingTicket解决方案需要 request 插件支持');
73
- case 8:
74
- if (this.shopStore) {
75
- _context.next = 10;
76
- break;
77
- }
78
- throw new Error('bookingTicket解决方案需要 shopStore 插件支持');
79
- case 10:
80
- // 如果有传 cacheid,默认需要收集上面这些模块里用户操作选中的数据
81
- targetCacheData = {};
82
- this.cacheId = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.cacheId;
83
- this.platform = (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.platform;
84
- this.scan = new Scan(this, 'BOOKING_TICKET_SCAN');
85
- if ((_this$otherParams3 = this.otherParams) !== null && _this$otherParams3 !== void 0 && _this$otherParams3.cacheId) {
86
- sessionData = this.window.sessionStorage.getItem(this.name);
87
- if (sessionData) {
88
- _data = JSON.parse(sessionData);
89
- targetCacheData = _data[this.otherParams.cacheId];
90
- }
91
- }
92
- moduleArr = ['cart', 'products', 'accountList', 'customer', 'order'];
93
- moduleArr.forEach(function (step) {
94
- var targetModule = createModule(step, _this2.name);
95
- if (targetModule) {
96
- var _targetCacheData, _this2$otherParams, _this2$otherParams2;
97
- _this2.store[step] = targetModule;
98
- _this2.core.registerModule(targetModule, {
99
- initialState: (_targetCacheData = targetCacheData) === null || _targetCacheData === void 0 ? void 0 : _targetCacheData[targetModule.name],
100
- otherParams: _objectSpread(_objectSpread({}, _this2.otherParams), {}, {
101
- fatherModule: _this2.name,
102
- openCache: (_this2$otherParams = _this2.otherParams) !== null && _this2$otherParams !== void 0 && _this2$otherParams.cacheId ? true : false,
103
- cacheId: (_this2$otherParams2 = _this2.otherParams) === null || _this2$otherParams2 === void 0 ? void 0 : _this2$otherParams2.cacheId
104
- })
105
- });
106
- } else {
107
- throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
108
- }
109
- });
110
- this.core.effects.emit("".concat(this.name, ":onInited"), {});
111
- case 18:
233
+ case 6:
234
+ this.platform = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.platform;
235
+ _context.next = 9;
236
+ return this.configureIdGeneratorFromOpenData();
237
+ case 9:
112
238
  case "end":
113
239
  return _context.stop();
114
240
  }
115
241
  }, _callee, this);
116
242
  }));
117
- function initialize(_x, _x2) {
243
+ function initialize(_x) {
118
244
  return _initialize.apply(this, arguments);
119
245
  }
120
246
  return initialize;
121
247
  }()
122
- /**
123
- * 获取商品列表
124
- * @param params 包含 schedule_date 的参数
125
- * @returns 商品列表
126
- */
127
248
  }, {
128
- key: "loadProducts",
129
- value: (function () {
130
- var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
131
- var params,
132
- options,
133
- schedule_date,
134
- customer_id,
135
- menu_list_ids,
136
- schedule_datetime,
137
- _result,
138
- _args2 = arguments;
249
+ key: "getBookingTicketBusinessCode",
250
+ value: function getBookingTicketBusinessCode() {
251
+ var _this$otherParams$bus, _this$otherParams2, _this$otherParams3;
252
+ var businessCode = (_this$otherParams$bus = (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.businessCode) !== null && _this$otherParams$bus !== void 0 ? _this$otherParams$bus : (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.business_code;
253
+ if (businessCode === undefined || businessCode === null) return null;
254
+ var normalized = String(businessCode).trim();
255
+ return normalized || null;
256
+ }
257
+ }, {
258
+ key: "getIdGeneratorPlugin",
259
+ value: function getIdGeneratorPlugin() {
260
+ var _appPlugin$getApp, _app$getPlugin;
261
+ var appPlugin = this.core.getPlugin('app');
262
+ var app = appPlugin === null || appPlugin === void 0 || (_appPlugin$getApp = appPlugin.getApp) === null || _appPlugin$getApp === void 0 ? void 0 : _appPlugin$getApp.call(appPlugin);
263
+ return (app === null || app === void 0 || (_app$getPlugin = app.getPlugin) === null || _app$getPlugin === void 0 ? void 0 : _app$getPlugin.call(app, 'idGenerator')) || null;
264
+ }
265
+ }, {
266
+ key: "loadOpenDataConfig",
267
+ value: function () {
268
+ var _loadOpenDataConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
269
+ var businessCode, lastFetchedAt, cachedData, channel, openDataConfig;
139
270
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
140
271
  while (1) switch (_context2.prev = _context2.next) {
141
272
  case 0:
142
- params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
143
- options = _args2.length > 1 ? _args2[1] : undefined;
144
- schedule_date = params.schedule_date, customer_id = params.customer_id, menu_list_ids = params.menu_list_ids, schedule_datetime = params.schedule_datetime;
145
- _context2.prev = 3;
146
- _context2.next = 6;
147
- return this.store.products.loadProducts(_objectSpread(_objectSpread({
148
- with_count: ['bundleGroup', 'optionGroup'],
149
- with_schedule: 1
150
- }, params), {}, {
151
- cacheId: this.cacheId
152
- }), options);
273
+ if (this.store.openData) {
274
+ _context2.next = 2;
275
+ break;
276
+ }
277
+ throw new Error('openData 模块未初始化');
278
+ case 2:
279
+ businessCode = this.getBookingTicketBusinessCode();
280
+ if (businessCode) {
281
+ _context2.next = 6;
282
+ break;
283
+ }
284
+ console.warn('[BookingTicket] businessCode 缺失,跳过 OpenData 配置加载,当前 module name: ', this.name);
285
+ return _context2.abrupt("return", null);
153
286
  case 6:
154
- _result = _context2.sent;
155
- this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), _result);
156
- return _context2.abrupt("return", _result);
287
+ lastFetchedAt = this.store.openData.getLastFetchedAt();
288
+ cachedData = this.store.openData.getOpenData();
289
+ if (!(cachedData && lastFetchedAt && Date.now() - lastFetchedAt < OPEN_DATA_CACHE_TTL)) {
290
+ _context2.next = 11;
291
+ break;
292
+ }
293
+ this.otherParams.openData = cachedData;
294
+ return _context2.abrupt("return", cachedData);
157
295
  case 11:
158
- _context2.prev = 11;
159
- _context2.t0 = _context2["catch"](3);
160
- console.error('Failed to load products:', _context2.t0);
161
- throw _context2.t0;
296
+ if (!this.loadOpenDataConfigInFlight) {
297
+ _context2.next = 15;
298
+ break;
299
+ }
300
+ _context2.next = 14;
301
+ return this.loadOpenDataConfigInFlight;
302
+ case 14:
303
+ return _context2.abrupt("return", _context2.sent);
162
304
  case 15:
305
+ channel = this.getSubmitOrderSalesChannel();
306
+ this.loadOpenDataConfigInFlight = this.store.openData.fetchOpenData({
307
+ scope: 'board',
308
+ target: "".concat(businessCode, "+").concat(channel),
309
+ // target: `dine_in+pos`,
310
+ section_code: [].concat(OPEN_DATA_SECTION_CODES)
311
+ });
312
+ _context2.prev = 17;
313
+ _context2.next = 20;
314
+ return this.loadOpenDataConfigInFlight;
315
+ case 20:
316
+ openDataConfig = _context2.sent;
317
+ this.otherParams.openData = openDataConfig;
318
+ return _context2.abrupt("return", openDataConfig);
319
+ case 23:
320
+ _context2.prev = 23;
321
+ this.loadOpenDataConfigInFlight = null;
322
+ return _context2.finish(23);
323
+ case 26:
163
324
  case "end":
164
325
  return _context2.stop();
165
326
  }
166
- }, _callee2, this, [[3, 11]]);
327
+ }, _callee2, this, [[17,, 23, 26]]);
167
328
  }));
168
- function loadProducts() {
169
- return _loadProducts.apply(this, arguments);
329
+ function loadOpenDataConfig() {
330
+ return _loadOpenDataConfig.apply(this, arguments);
170
331
  }
171
- return loadProducts;
332
+ return loadOpenDataConfig;
172
333
  }()
173
- /**
174
- * 取消商品查询订阅
175
- * @param subscriberId 订阅时传入的 subscriberId
176
- */
177
- )
178
- }, {
179
- key: "unsubscribeProductQuery",
180
- value: function unsubscribeProductQuery(subscriberId) {
181
- var _this$core$server;
182
- (_this$core$server = this.core.server) === null || _this$core$server === void 0 || _this$core$server.removeProductQuerySubscriber(subscriberId);
183
- }
184
-
185
- /**
186
- * 初始化外设扫码结果监听
187
- */
188
- }, {
189
- key: "initPeripheralsListener",
190
- value: function initPeripheralsListener() {
191
- this.scan.initPeripheralsListener();
192
- }
193
-
194
- /**
195
- * 获取商品列表(不加载到模块中)
196
- * @returns 商品列表
197
- */
198
334
  }, {
199
- key: "getProducts",
200
- value: (function () {
201
- var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
335
+ key: "getOpenData",
336
+ value: function () {
337
+ var _getOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
338
+ var _this$store$openData;
202
339
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
203
340
  while (1) switch (_context3.prev = _context3.next) {
204
341
  case 0:
205
- return _context3.abrupt("return", this.store.products.getProducts());
342
+ return _context3.abrupt("return", (_this$store$openData = this.store.openData) === null || _this$store$openData === void 0 ? void 0 : _this$store$openData.getOpenData());
206
343
  case 1:
207
344
  case "end":
208
345
  return _context3.stop();
209
346
  }
210
347
  }, _callee3, this);
211
348
  }));
212
- function getProducts() {
213
- return _getProducts.apply(this, arguments);
349
+ function getOpenData() {
350
+ return _getOpenData.apply(this, arguments);
214
351
  }
215
- return getProducts;
352
+ return getOpenData;
216
353
  }()
217
- /**
218
- * 获取日程时间段点
219
- * @param params 参数
220
- * @returns 日程时间段点
221
- */
222
- )
223
354
  }, {
224
- key: "getScheduleTimePoints",
225
- value: (function () {
226
- var _getScheduleTimePoints = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
227
- var result;
355
+ key: "getShortNumberOrDeviceId",
356
+ value: function () {
357
+ var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
358
+ var getAsyncIotDeviceInfo, res;
228
359
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
229
360
  while (1) switch (_context4.prev = _context4.next) {
230
361
  case 0:
231
- _context4.next = 2;
232
- return this.request.post('/menu/schedule-time-points', {
233
- menu_list_ids: params.menu_list_ids
234
- }, {
235
- osServer: true
236
- });
237
- case 2:
238
- result = _context4.sent;
239
- return _context4.abrupt("return", result.data || []);
362
+ getAsyncIotDeviceInfo = this.getAppData('async_iot_device_info');
363
+ if (!getAsyncIotDeviceInfo) {
364
+ _context4.next = 7;
365
+ break;
366
+ }
367
+ _context4.next = 4;
368
+ return getAsyncIotDeviceInfo === null || getAsyncIotDeviceInfo === void 0 ? void 0 : getAsyncIotDeviceInfo();
240
369
  case 4:
370
+ res = _context4.sent;
371
+ if (!(res !== null && res !== void 0 && res.short_number)) {
372
+ _context4.next = 7;
373
+ break;
374
+ }
375
+ return _context4.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
376
+ case 7:
377
+ return _context4.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
378
+ case 8:
241
379
  case "end":
242
380
  return _context4.stop();
243
381
  }
244
382
  }, _callee4, this);
245
383
  }));
246
- function getScheduleTimePoints(_x3) {
247
- return _getScheduleTimePoints.apply(this, arguments);
384
+ function getShortNumberOrDeviceId() {
385
+ return _getShortNumberOrDeviceId.apply(this, arguments);
248
386
  }
249
- return getScheduleTimePoints;
387
+ return getShortNumberOrDeviceId;
250
388
  }()
251
- /**
252
- * 获取客户列表
253
- * @param params 查询参数
254
- * @returns 客户列表响应
255
- */
256
- )
257
389
  }, {
258
- key: "getCustomerList",
259
- value: (function () {
260
- var _getCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
261
- var params,
262
- _result2,
263
- _args5 = arguments;
390
+ key: "configureIdGeneratorFromOpenData",
391
+ value: function () {
392
+ var _configureIdGeneratorFromOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
393
+ var _openDataConfig, _openDataConfig2, _openDataConfig3, _openDataConfig4, _openDataConfig5, _openDataConfig6;
394
+ var openDataConfig, idGenerator, receiptSequenceLength, receiptSequenceStart, prefix, shopOrderPrefix, resetReceiptSequenceDaily, operatingDayBoundary, deviceId, businessCode;
264
395
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
265
396
  while (1) switch (_context5.prev = _context5.next) {
266
397
  case 0:
267
- params = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
398
+ openDataConfig = null;
268
399
  _context5.prev = 1;
269
400
  _context5.next = 4;
270
- return this.store.customer.getCustomerList(params);
401
+ return this.loadOpenDataConfig();
271
402
  case 4:
272
- _result2 = _context5.sent;
273
- return _context5.abrupt("return", _result2);
274
- case 8:
275
- _context5.prev = 8;
403
+ openDataConfig = _context5.sent;
404
+ _context5.next = 11;
405
+ break;
406
+ case 7:
407
+ _context5.prev = 7;
276
408
  _context5.t0 = _context5["catch"](1);
277
- console.error('Failed to get customer list:', _context5.t0);
278
- throw _context5.t0;
279
- case 12:
409
+ console.warn('[BookingTicket] OpenData 配置加载失败,跳过 idGenerator 配置', _context5.t0);
410
+ return _context5.abrupt("return");
411
+ case 11:
412
+ // if (!openDataConfig) return;
413
+ idGenerator = this.getIdGeneratorPlugin();
414
+ if (idGenerator !== null && idGenerator !== void 0 && idGenerator.configure) {
415
+ _context5.next = 15;
416
+ break;
417
+ }
418
+ console.warn('[BookingTicket] idGenerator 插件不可用,跳过配置');
419
+ return _context5.abrupt("return");
420
+ case 15:
421
+ receiptSequenceLength = this.normalizePositiveInteger((_openDataConfig = openDataConfig) === null || _openDataConfig === void 0 ? void 0 : _openDataConfig['sale.short_number_digits'], 5);
422
+ receiptSequenceStart = this.normalizePositiveInteger((_openDataConfig2 = openDataConfig) === null || _openDataConfig2 === void 0 ? void 0 : _openDataConfig2['sale.short_number_start_number'], 1);
423
+ prefix = this.normalizeIdPrefix((_openDataConfig3 = openDataConfig) === null || _openDataConfig3 === void 0 ? void 0 : _openDataConfig3['sale.short_number_prefix'], '');
424
+ shopOrderPrefix = this.normalizeIdPrefix((_openDataConfig4 = openDataConfig) === null || _openDataConfig4 === void 0 ? void 0 : _openDataConfig4['sale.sale_number_prefix'], '');
425
+ resetReceiptSequenceDaily = typeof ((_openDataConfig5 = openDataConfig) === null || _openDataConfig5 === void 0 ? void 0 : _openDataConfig5['sale.short_number_daily_reset']) === 'boolean' ? (_openDataConfig6 = openDataConfig) === null || _openDataConfig6 === void 0 ? void 0 : _openDataConfig6['sale.short_number_daily_reset'] : false;
426
+ operatingDayBoundary = this.getAppData('operating_day_boundary');
427
+ _context5.next = 23;
428
+ return this.getShortNumberOrDeviceId();
429
+ case 23:
430
+ deviceId = _context5.sent;
431
+ businessCode = this.getBookingTicketBusinessCode();
432
+ if (businessCode) {
433
+ _context5.next = 28;
434
+ break;
435
+ }
436
+ console.warn('[BookingTicket] businessCode 缺失,跳过 idGenerator 配置');
437
+ return _context5.abrupt("return");
438
+ case 28:
439
+ _context5.prev = 28;
440
+ _context5.next = 31;
441
+ return idGenerator.configure({
442
+ biz: businessCode,
443
+ config: {
444
+ prefix: prefix,
445
+ deviceCode: deviceId,
446
+ // TODO 现在 picoding 没这个配置的 key
447
+ padReceiptSequence: false,
448
+ receiptSequenceLength: receiptSequenceLength,
449
+ resetReceiptSequenceDaily: resetReceiptSequenceDaily,
450
+ receiptSequenceResetTime: operatingDayBoundary.time,
451
+ receiptSequenceStart: receiptSequenceStart,
452
+ shopOrderPrefix: shopOrderPrefix
453
+ }
454
+ });
455
+ case 31:
456
+ _context5.next = 36;
457
+ break;
458
+ case 33:
459
+ _context5.prev = 33;
460
+ _context5.t1 = _context5["catch"](28);
461
+ console.warn('[BookingTicket] idGenerator 配置失败', _context5.t1);
462
+ case 36:
280
463
  case "end":
281
464
  return _context5.stop();
282
465
  }
283
- }, _callee5, this, [[1, 8]]);
466
+ }, _callee5, this, [[1, 7], [28, 33]]);
284
467
  }));
285
- function getCustomerList() {
286
- return _getCustomerList.apply(this, arguments);
468
+ function configureIdGeneratorFromOpenData() {
469
+ return _configureIdGeneratorFromOpenData.apply(this, arguments);
287
470
  }
288
- return getCustomerList;
471
+ return configureIdGeneratorFromOpenData;
289
472
  }()
290
- /**
291
- * 设置活跃客户
292
- * @param customer 客户信息
293
- */
294
- )
295
473
  }, {
296
- key: "setActiveCustomer",
297
- value: function setActiveCustomer(customer) {
298
- this.store.customer.setSelectedCustomer(customer);
299
- this.core.effects.emit("".concat(this.name, ":onCustomerSelected"), {
300
- customer: customer
301
- });
474
+ key: "normalizePositiveInteger",
475
+ value: function normalizePositiveInteger(value, fallback) {
476
+ var numeric = Number(value);
477
+ if (!Number.isInteger(numeric) || numeric <= 0) return fallback;
478
+ return numeric;
302
479
  }
303
-
304
- /**
305
- * 获取当前活跃客户
306
- * @returns 当前活跃客户
307
- */
308
480
  }, {
309
- key: "getActiveCustomer",
310
- value: function getActiveCustomer() {
311
- return this.store.customer.getSelectedCustomer();
481
+ key: "normalizeIdPrefix",
482
+ value: function normalizeIdPrefix(value, fallback) {
483
+ if (value === undefined || value === null) return fallback;
484
+ var normalized = String(value).trim().toUpperCase();
485
+ return normalized || fallback;
312
486
  }
313
487
 
314
488
  /**
315
- * 根据ID设置选中的客户
316
- * @param customerId 客户ID
489
+ * 加载销售详情,并在父类基础上把 customer 信息装配到 CustomerModule。
490
+ *
491
+ * 业务上 ticketBooking 进入「编辑/查看」时需要 active customer 状态,因此从
492
+ * sales.customer / sales.header / tempOrder 顶层字段中拼装 ICustomer 后调 setSelectedCustomer,
493
+ * 让现有 setActiveCustomer / getActiveCustomer 调用方零成本拿到详情态客户。
317
494
  */
318
495
  }, {
319
- key: "setSelectedCustomerById",
320
- value: function setSelectedCustomerById(customerId) {
321
- var customer = this.store.customer.getCustomerById(customerId);
322
- if (customer) {
323
- this.store.customer.setSelectedCustomer(customer);
324
- this.core.effects.emit("".concat(this.name, ":onCustomerSelected"), {
325
- customer: customer
326
- });
496
+ key: "loadSalesDetail",
497
+ value: (function () {
498
+ var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(orderIdOrParams) {
499
+ var _ref3;
500
+ var sales, customerModule, detailCustomer, orderCustomerSnapshot, protocolCustomerId, protocolCustomer, selectedCustomer, _selectedCustomer$nam, _ref4, detailCustomerId, detailCustomerRest, rawId, customer;
501
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
502
+ while (1) switch (_context6.prev = _context6.next) {
503
+ case 0:
504
+ _context6.next = 2;
505
+ return _get(_getPrototypeOf(BookingTicketImpl.prototype), "loadSalesDetail", this).call(this, orderIdOrParams);
506
+ case 2:
507
+ sales = _context6.sent;
508
+ customerModule = this.store.customer;
509
+ detailCustomer = sales === null || sales === void 0 ? void 0 : sales.customer;
510
+ orderCustomerSnapshot = this.store.order.getOrderCustomerSnapshot();
511
+ protocolCustomerId = sales === null || sales === void 0 ? void 0 : sales.customer_id;
512
+ protocolCustomer = protocolCustomerId !== undefined && protocolCustomerId !== null ? {
513
+ id: protocolCustomerId,
514
+ name: String((sales === null || sales === void 0 ? void 0 : sales.customer_name) || ''),
515
+ phone: sales === null || sales === void 0 ? void 0 : sales.phone,
516
+ email: sales === null || sales === void 0 ? void 0 : sales.email,
517
+ country_calling_code: sales === null || sales === void 0 ? void 0 : sales.country_calling_code
518
+ } : null;
519
+ selectedCustomer = (_ref3 = detailCustomer !== null && detailCustomer !== void 0 ? detailCustomer : orderCustomerSnapshot) !== null && _ref3 !== void 0 ? _ref3 : protocolCustomer;
520
+ if (customerModule && selectedCustomer) {
521
+ _ref4 = selectedCustomer !== null && selectedCustomer !== void 0 ? selectedCustomer : {}, detailCustomerId = _ref4.id, detailCustomerRest = _objectWithoutProperties(_ref4, _excluded);
522
+ rawId = detailCustomerId !== null && detailCustomerId !== void 0 ? detailCustomerId : '';
523
+ customer = _objectSpread(_objectSpread({}, detailCustomerRest), {}, {
524
+ id: rawId == null ? '' : rawId,
525
+ name: (_selectedCustomer$nam = selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.name) !== null && _selectedCustomer$nam !== void 0 ? _selectedCustomer$nam : '',
526
+ phone: selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.phone,
527
+ email: selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.email,
528
+ country_calling_code: selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.country_calling_code
529
+ });
530
+ customerModule.setSelectedCustomer(customer);
531
+ this.setOrderCustomer(customer);
532
+ // await this.store.order.saveDraft();
533
+ }
534
+ return _context6.abrupt("return", sales);
535
+ case 11:
536
+ case "end":
537
+ return _context6.stop();
538
+ }
539
+ }, _callee6, this);
540
+ }));
541
+ function loadSalesDetail(_x2) {
542
+ return _loadSalesDetail.apply(this, arguments);
327
543
  }
328
- }
329
-
330
- /**
331
- * 获取所有客户
332
- * @returns 客户列表
333
- */
334
- }, {
335
- key: "getCustomers",
336
- value: function getCustomers() {
337
- return this.store.customer.getCustomers();
338
- }
339
-
340
- /**
341
- * 根据ID获取客户
342
- * @param customerId 客户ID
343
- * @returns 客户信息
344
- */
345
- }, {
346
- key: "getCustomerById",
347
- value: function getCustomerById(customerId) {
348
- return this.store.customer.getCustomerById(customerId);
349
- }
350
-
351
- /**
352
- * 清空客户列表
353
- */
544
+ return loadSalesDetail;
545
+ }())
354
546
  }, {
355
- key: "clearCustomers",
356
- value: function clearCustomers() {
357
- this.store.customer.clearCustomers();
358
- }
359
-
360
- /**
361
- * 添加客户到列表第一位
362
- * @param customer 要添加的客户信息
363
- */
547
+ key: "scanPromotionCode",
548
+ value: function () {
549
+ var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(code, customerId) {
550
+ var raw, scannedList, extractedCustomerId, hasOrderCustomer, tempOrder;
551
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
552
+ while (1) switch (_context7.prev = _context7.next) {
553
+ case 0:
554
+ if (this.store.order) {
555
+ _context7.next = 2;
556
+ break;
557
+ }
558
+ throw new Error('order 模块未初始化');
559
+ case 2:
560
+ _context7.next = 4;
561
+ return this.store.order.scanCode(code, customerId);
562
+ case 4:
563
+ raw = _context7.sent;
564
+ scannedList = raw.scannedDiscountList || [];
565
+ extractedCustomerId = this.getDiscountCustomerId(scannedList);
566
+ hasOrderCustomer = Boolean(this.store.order.getOrderCustomer()); // 缺 Holder 等场景 isAvailable=false,但仍需把 Pass 归属客户带入订单,供 Holder 弹窗使用。
567
+ if (!(!hasOrderCustomer && extractedCustomerId)) {
568
+ _context7.next = 11;
569
+ break;
570
+ }
571
+ _context7.next = 11;
572
+ return this.hydrateOrderCustomerFromScanDiscounts(scannedList);
573
+ case 11:
574
+ if (!raw.isAvailable) {
575
+ _context7.next = 18;
576
+ break;
577
+ }
578
+ _context7.next = 14;
579
+ return this.store.order.recalculateSummary({
580
+ createIfMissing: true
581
+ });
582
+ case 14:
583
+ this.store.order.persistTempOrder();
584
+ tempOrder = this.store.order.ensureTempOrder();
585
+ _context7.next = 18;
586
+ return this.effectsEmit('onDiscountApplied', {
587
+ productList: tempOrder.products || [],
588
+ discountList: this.store.order.getDiscountList(),
589
+ selectedDiscountList: tempOrder.discount_list || [],
590
+ tempOrder: tempOrder
591
+ });
592
+ case 18:
593
+ return _context7.abrupt("return", {
594
+ isAvailable: raw.isAvailable,
595
+ type: raw.type,
596
+ unavailableReason: raw.unavailableReason,
597
+ scannedDiscountList: raw.scannedDiscountList
598
+ });
599
+ case 19:
600
+ case "end":
601
+ return _context7.stop();
602
+ }
603
+ }, _callee7, this);
604
+ }));
605
+ function scanPromotionCode(_x3, _x4) {
606
+ return _scanPromotionCode.apply(this, arguments);
607
+ }
608
+ return scanPromotionCode;
609
+ }()
610
+ }, {
611
+ key: "hydrateOrderCustomerFromScanDiscounts",
612
+ value: function () {
613
+ var _hydrateOrderCustomerFromScanDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(discounts) {
614
+ var currentOrderCustomer, customerId, customer;
615
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
616
+ while (1) switch (_context8.prev = _context8.next) {
617
+ case 0:
618
+ currentOrderCustomer = this.store.order.getOrderCustomer();
619
+ if (!currentOrderCustomer) {
620
+ _context8.next = 3;
621
+ break;
622
+ }
623
+ return _context8.abrupt("return");
624
+ case 3:
625
+ customerId = this.getDiscountCustomerId(discounts);
626
+ if (customerId) {
627
+ _context8.next = 6;
628
+ break;
629
+ }
630
+ return _context8.abrupt("return");
631
+ case 6:
632
+ _context8.next = 8;
633
+ return this.resolveCustomerByDiscountCustomerId(customerId);
634
+ case 8:
635
+ customer = _context8.sent;
636
+ if (customer) {
637
+ _context8.next = 11;
638
+ break;
639
+ }
640
+ return _context8.abrupt("return");
641
+ case 11:
642
+ this.store.customer.setSelectedCustomer(customer);
643
+ this.setOrderCustomer(customer);
644
+ case 13:
645
+ case "end":
646
+ return _context8.stop();
647
+ }
648
+ }, _callee8, this);
649
+ }));
650
+ function hydrateOrderCustomerFromScanDiscounts(_x5) {
651
+ return _hydrateOrderCustomerFromScanDiscounts.apply(this, arguments);
652
+ }
653
+ return hydrateOrderCustomerFromScanDiscounts;
654
+ }()
655
+ }, {
656
+ key: "getDiscountCustomerId",
657
+ value: function getDiscountCustomerId(discounts) {
658
+ var _iterator = _createForOfIteratorHelper(discounts),
659
+ _step;
660
+ try {
661
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
662
+ var item = _step.value;
663
+ var topLevelId = Number(item.customer_id);
664
+ if (Number.isFinite(topLevelId) && topLevelId > 0) {
665
+ return topLevelId;
666
+ }
667
+ }
668
+ } catch (err) {
669
+ _iterator.e(err);
670
+ } finally {
671
+ _iterator.f();
672
+ }
673
+ return null;
674
+ }
675
+ }, {
676
+ key: "resolveCustomerByDiscountCustomerId",
677
+ value: function () {
678
+ var _resolveCustomerByDiscountCustomerId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(customerId) {
679
+ var _result$list;
680
+ var localCustomers, localCustomer, normalizedLocalCustomer, result, remoteCustomer;
681
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
682
+ while (1) switch (_context9.prev = _context9.next) {
683
+ case 0:
684
+ localCustomers = this.store.customer.getCustomers();
685
+ localCustomer = this.findCustomerById(localCustomers, customerId);
686
+ normalizedLocalCustomer = localCustomer ? this.normalizeCustomer(localCustomer) : null;
687
+ if (!(normalizedLocalCustomer && this.hasUsableCustomerDetails(normalizedLocalCustomer))) {
688
+ _context9.next = 5;
689
+ break;
690
+ }
691
+ return _context9.abrupt("return", normalizedLocalCustomer);
692
+ case 5:
693
+ _context9.next = 7;
694
+ return this.store.customer.queryCustomerList({
695
+ ids: [customerId],
696
+ skip: 1,
697
+ num: 1
698
+ });
699
+ case 7:
700
+ result = _context9.sent;
701
+ remoteCustomer = this.findCustomerById((result === null || result === void 0 ? void 0 : result.list) || [], customerId) || (result === null || result === void 0 || (_result$list = result.list) === null || _result$list === void 0 ? void 0 : _result$list[0]) || null;
702
+ return _context9.abrupt("return", remoteCustomer ? this.normalizeCustomer(remoteCustomer) : null);
703
+ case 10:
704
+ case "end":
705
+ return _context9.stop();
706
+ }
707
+ }, _callee9, this);
708
+ }));
709
+ function resolveCustomerByDiscountCustomerId(_x6) {
710
+ return _resolveCustomerByDiscountCustomerId.apply(this, arguments);
711
+ }
712
+ return resolveCustomerByDiscountCustomerId;
713
+ }()
714
+ }, {
715
+ key: "findCustomerById",
716
+ value: function findCustomerById() {
717
+ var _this2 = this;
718
+ var customers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
719
+ var customerId = arguments.length > 1 ? arguments[1] : undefined;
720
+ return customers.find(function (customer) {
721
+ var rawId = _this2.getRawCustomerId(customer);
722
+ return rawId !== null && String(rawId) === String(customerId);
723
+ }) || null;
724
+ }
725
+ }, {
726
+ key: "normalizeCustomer",
727
+ value: function normalizeCustomer(customer) {
728
+ var _ref5, _ref6, _customer$phone, _ref7, _customer$email, _ref8, _customer$country_cal;
729
+ var raw = customer;
730
+ var rawId = this.getRawCustomerId(customer);
731
+ var name = customer.name || raw.display_name || raw.nickname || raw.customer_name || [raw.first_name, raw.last_name].filter(Boolean).join(' ') || '';
732
+ return _objectSpread(_objectSpread({}, customer), {}, {
733
+ id: rawId !== null && rawId !== void 0 ? rawId : customer.id,
734
+ name: name,
735
+ phone: (_ref5 = (_ref6 = (_customer$phone = customer.phone) !== null && _customer$phone !== void 0 ? _customer$phone : raw.phone) !== null && _ref6 !== void 0 ? _ref6 : raw.mobile) !== null && _ref5 !== void 0 ? _ref5 : '',
736
+ email: (_ref7 = (_customer$email = customer.email) !== null && _customer$email !== void 0 ? _customer$email : raw.email) !== null && _ref7 !== void 0 ? _ref7 : '',
737
+ country_calling_code: (_ref8 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : raw.country_calling_code) !== null && _ref8 !== void 0 ? _ref8 : ''
738
+ });
739
+ }
740
+ }, {
741
+ key: "getRawCustomerId",
742
+ value: function getRawCustomerId(customer) {
743
+ var _ref9, _ref10, _customer$id;
744
+ var raw = customer;
745
+ return (_ref9 = (_ref10 = (_customer$id = customer.id) !== null && _customer$id !== void 0 ? _customer$id : raw.customer_id) !== null && _ref10 !== void 0 ? _ref10 : raw.customerId) !== null && _ref9 !== void 0 ? _ref9 : null;
746
+ }
747
+ }, {
748
+ key: "hasUsableCustomerDetails",
749
+ value: function hasUsableCustomerDetails(customer) {
750
+ return !!(customer.name || customer.phone || customer.email || customer.display_name || customer.customer_name);
751
+ }
752
+
753
+ /**
754
+ * 更新当前预约的 appointment_status。
755
+ *
756
+ * 数据源:从 OrderModule.tempOrder 内部读取,调用方无需传 orderId / scheduleId。
757
+ * schedule id 解析优先级:
758
+ * 1. `tempOrder.metadata.appointment_booking_parent_schedule_id`
759
+ * 2. `tempOrder.bookings` 中 `parent_id === 0` 的 `schedule_event_id`
760
+ *
761
+ * 流程:先乐观更新本地 bookings 的 appointment_status,再调 PUT 接口,
762
+ * 接口成功后强制刷新销售详情;任一步失败都回滚本地状态并抛错。
763
+ *
764
+ * @param status 目标状态(如 'confirmed')
765
+ * @returns 接口返回的 data
766
+ */
767
+ }, {
768
+ key: "setBookingStatus",
769
+ value: (function () {
770
+ var _setBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(status) {
771
+ var _this$store$order, _this$store$order$get;
772
+ var tempOrder, orderId, scheduleId, bookings, previous, _data, res;
773
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
774
+ while (1) switch (_context10.prev = _context10.next) {
775
+ case 0:
776
+ tempOrder = (_this$store$order = this.store.order) === null || _this$store$order === void 0 || (_this$store$order$get = _this$store$order.getTempOrder) === null || _this$store$order$get === void 0 ? void 0 : _this$store$order$get.call(_this$store$order);
777
+ if (tempOrder) {
778
+ _context10.next = 3;
779
+ break;
780
+ }
781
+ throw new Error('setBookingStatus: tempOrder 未加载');
782
+ case 3:
783
+ orderId = tempOrder.order_id;
784
+ if (!(orderId === undefined || orderId === null)) {
785
+ _context10.next = 6;
786
+ break;
787
+ }
788
+ throw new Error('setBookingStatus: tempOrder.order_id 缺失');
789
+ case 6:
790
+ scheduleId = resolveScheduleId(tempOrder);
791
+ if (!(scheduleId === null)) {
792
+ _context10.next = 9;
793
+ break;
794
+ }
795
+ throw new Error('setBookingStatus: 无法解析 schedule id(metadata 与 root booking 均缺失)');
796
+ case 9:
797
+ bookings = Array.isArray(tempOrder.bookings) ? tempOrder.bookings : [];
798
+ previous = applyBookingsStatus(bookings, status);
799
+ _context10.prev = 11;
800
+ _context10.next = 14;
801
+ return this.request.put("/schedule/booking/appointment-status/".concat(scheduleId), {
802
+ appointment_status: status
803
+ });
804
+ case 14:
805
+ res = _context10.sent;
806
+ _context10.next = 17;
807
+ return this.refreshSalesDetail();
808
+ case 17:
809
+ this.core.effects.emit("".concat(this.name, ":onBookingStatusChange"), {
810
+ orderId: orderId,
811
+ status: status
812
+ });
813
+ return _context10.abrupt("return", (_data = res === null || res === void 0 ? void 0 : res.data) !== null && _data !== void 0 ? _data : res);
814
+ case 21:
815
+ _context10.prev = 21;
816
+ _context10.t0 = _context10["catch"](11);
817
+ restoreBookingsStatus(bookings, previous);
818
+ throw _context10.t0;
819
+ case 25:
820
+ case "end":
821
+ return _context10.stop();
822
+ }
823
+ }, _callee10, this, [[11, 21]]);
824
+ }));
825
+ function setBookingStatus(_x7) {
826
+ return _setBookingStatus.apply(this, arguments);
827
+ }
828
+ return setBookingStatus;
829
+ }()
830
+ /**
831
+ * 子预约状态机转移(POST /schedule/booking-transition/{schedule_event_id})。
832
+ *
833
+ * 与 `setBookingStatus`(父预约 PUT appointment-status)不同,本方法按子预约
834
+ * `schedule_event_id` 调用状态转移接口,body 为 `{ action }`。
835
+ *
836
+ * 流程:能解析出目标状态时先乐观更新对应子预约的 `appointment_status`,
837
+ * 再调 POST;成功后强制刷新销售详情;失败则回滚该子预约本地状态并抛错。
838
+ * `reschedule` 暂未启用状态矩阵,跳过乐观更新仅调接口。
839
+ *
840
+ * @param params.schedule_event_id 子预约 schedule_event_id
841
+ * @param params.action 转移动作:confirm | reject | arrive | start | complete | cancel | no_show | reschedule
842
+ * @returns 接口返回的 data
843
+ *
844
+ * @example
845
+ * await bookingTicket.transitionChildBooking({
846
+ * schedule_event_id: 301,
847
+ * action: 'confirm',
848
+ * });
849
+ */
850
+ )
851
+ }, {
852
+ key: "transitionChildBooking",
853
+ value: (function () {
854
+ var _transitionChildBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
855
+ var _this$store$order2, _this$store$order2$ge;
856
+ var schedule_event_id, action, tempOrder, orderId, bookings, targetStatus, previous, _data2, res;
857
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
858
+ while (1) switch (_context11.prev = _context11.next) {
859
+ case 0:
860
+ schedule_event_id = params.schedule_event_id, action = params.action;
861
+ if (!(schedule_event_id === undefined || schedule_event_id === null || schedule_event_id === '')) {
862
+ _context11.next = 3;
863
+ break;
864
+ }
865
+ throw new Error('transitionChildBooking: schedule_event_id 不能为空');
866
+ case 3:
867
+ if (action) {
868
+ _context11.next = 5;
869
+ break;
870
+ }
871
+ throw new Error('transitionChildBooking: action 不能为空');
872
+ case 5:
873
+ tempOrder = (_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || (_this$store$order2$ge = _this$store$order2.getTempOrder) === null || _this$store$order2$ge === void 0 ? void 0 : _this$store$order2$ge.call(_this$store$order2);
874
+ if (tempOrder) {
875
+ _context11.next = 8;
876
+ break;
877
+ }
878
+ throw new Error('transitionChildBooking: tempOrder 未加载');
879
+ case 8:
880
+ orderId = tempOrder.order_id;
881
+ if (!(orderId === undefined || orderId === null)) {
882
+ _context11.next = 11;
883
+ break;
884
+ }
885
+ throw new Error('transitionChildBooking: tempOrder.order_id 缺失');
886
+ case 11:
887
+ bookings = Array.isArray(tempOrder.bookings) ? tempOrder.bookings : [];
888
+ targetStatus = resolveStatusAfterTransition(action);
889
+ previous = targetStatus !== null ? applyChildBookingStatus(bookings, schedule_event_id, targetStatus) : undefined;
890
+ _context11.prev = 14;
891
+ _context11.next = 17;
892
+ return this.request.post("/schedule/booking-transition/".concat(schedule_event_id), {
893
+ action: action
894
+ });
895
+ case 17:
896
+ res = _context11.sent;
897
+ _context11.next = 20;
898
+ return this.refreshSalesDetail();
899
+ case 20:
900
+ this.core.effects.emit("".concat(this.name, ":onChildBookingStatusChange"), {
901
+ orderId: orderId,
902
+ schedule_event_id: schedule_event_id,
903
+ action: action,
904
+ status: targetStatus
905
+ });
906
+ return _context11.abrupt("return", (_data2 = res === null || res === void 0 ? void 0 : res.data) !== null && _data2 !== void 0 ? _data2 : res);
907
+ case 24:
908
+ _context11.prev = 24;
909
+ _context11.t0 = _context11["catch"](14);
910
+ if (previous !== undefined) {
911
+ restoreChildBookingStatus(bookings, schedule_event_id, previous);
912
+ }
913
+ throw _context11.t0;
914
+ case 28:
915
+ case "end":
916
+ return _context11.stop();
917
+ }
918
+ }, _callee11, this, [[14, 24]]);
919
+ }));
920
+ function transitionChildBooking(_x8) {
921
+ return _transitionChildBooking.apply(this, arguments);
922
+ }
923
+ return transitionChildBooking;
924
+ }()
925
+ /**
926
+ * 基于当前 tempOrder.order_id 强制从远端重新拉取销售详情。
927
+ *
928
+ * 适用场景:在 BookingTicket 内执行了「修改服务端订单状态」的动作(如改预约状态、
929
+ * 改下单客户、改商品行等)后,统一刷新本地销售详情,保证 UI 与服务端一致。
930
+ *
931
+ * 约束:调用前必须已有 tempOrder 且 order_id 存在,否则视为非法调用并抛错。
932
+ *
933
+ * @returns loadSalesDetail 的返回值
934
+ */
935
+ )
936
+ }, {
937
+ key: "refreshSalesDetail",
938
+ value: (function () {
939
+ var _refreshSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
940
+ var _this$store$order3, _this$store$order3$ge;
941
+ var params,
942
+ tempOrder,
943
+ orderId,
944
+ _args12 = arguments;
945
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
946
+ while (1) switch (_context12.prev = _context12.next) {
947
+ case 0:
948
+ params = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
949
+ tempOrder = (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 || (_this$store$order3$ge = _this$store$order3.getTempOrder) === null || _this$store$order3$ge === void 0 ? void 0 : _this$store$order3$ge.call(_this$store$order3);
950
+ if (tempOrder) {
951
+ _context12.next = 4;
952
+ break;
953
+ }
954
+ throw new Error('refreshSalesDetail: tempOrder 未加载');
955
+ case 4:
956
+ debugger;
957
+ orderId = tempOrder.order_id || tempOrder.external_sale_number;
958
+ if (!(orderId === undefined || orderId === null)) {
959
+ _context12.next = 8;
960
+ break;
961
+ }
962
+ return _context12.abrupt("return", {});
963
+ case 8:
964
+ return _context12.abrupt("return", this.loadSalesDetail({
965
+ orderId: orderId,
966
+ // merge: true
967
+ forceRemote: params.forceRemote
968
+ }));
969
+ case 9:
970
+ case "end":
971
+ return _context12.stop();
972
+ }
973
+ }, _callee12, this);
974
+ }));
975
+ function refreshSalesDetail() {
976
+ return _refreshSalesDetail.apply(this, arguments);
977
+ }
978
+ return refreshSalesDetail;
979
+ }()
980
+ /**
981
+ * 获取商品列表
982
+ * @param params 包含 schedule_date 的参数
983
+ * @returns 商品列表
984
+ */
985
+ )
986
+ }, {
987
+ key: "loadProducts",
988
+ value: (function () {
989
+ var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
990
+ var params,
991
+ options,
992
+ schedule_date,
993
+ customer_id,
994
+ menu_list_ids,
995
+ schedule_datetime,
996
+ bookingDate,
997
+ _result,
998
+ _args13 = arguments;
999
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1000
+ while (1) switch (_context13.prev = _context13.next) {
1001
+ case 0:
1002
+ params = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
1003
+ options = _args13.length > 1 ? _args13[1] : undefined;
1004
+ schedule_date = params.schedule_date, customer_id = params.customer_id, menu_list_ids = params.menu_list_ids, schedule_datetime = params.schedule_datetime; // 优先写入 schedule_datetime(含时分),供加购 presetStartTime 与 TimeBar 对齐;
1005
+ // requiresDetail 弹窗仍通过 formatBookingDateForUI 只取日历日 YYYY-MM-DD。
1006
+ bookingDate = schedule_datetime || schedule_date || '';
1007
+ if (bookingDate) {
1008
+ this.setBookingDate(bookingDate);
1009
+ }
1010
+ _context13.prev = 5;
1011
+ _context13.next = 8;
1012
+ return this.store.products.loadProducts(_objectSpread(_objectSpread({
1013
+ with_count: ['bundleGroup', 'optionGroup'],
1014
+ with_schedule: 1
1015
+ }, params), {}, {
1016
+ cacheId: this.cacheId
1017
+ }), options);
1018
+ case 8:
1019
+ _result = _context13.sent;
1020
+ this.productCatalog = Array.isArray(_result) ? _toConsumableArray(_result) : [];
1021
+ this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), _result);
1022
+ return _context13.abrupt("return", _result);
1023
+ case 14:
1024
+ _context13.prev = 14;
1025
+ _context13.t0 = _context13["catch"](5);
1026
+ console.error('Failed to load products:', _context13.t0);
1027
+ throw _context13.t0;
1028
+ case 18:
1029
+ case "end":
1030
+ return _context13.stop();
1031
+ }
1032
+ }, _callee13, this, [[5, 14]]);
1033
+ }));
1034
+ function loadProducts() {
1035
+ return _loadProducts.apply(this, arguments);
1036
+ }
1037
+ return loadProducts;
1038
+ }()
1039
+ /**
1040
+ * 获取加时商品列表。
1041
+ *
1042
+ * @example
1043
+ * const products = await bookingTicket.getAddTimeProducts({ schedule_date: '2026-06-16' });
1044
+ */
1045
+ )
1046
+ }, {
1047
+ key: "getAddTimeProducts",
1048
+ value: (function () {
1049
+ var _getAddTimeProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1050
+ var params,
1051
+ result,
1052
+ _args14 = arguments;
1053
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1054
+ while (1) switch (_context14.prev = _context14.next) {
1055
+ case 0:
1056
+ params = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
1057
+ _context14.next = 3;
1058
+ return this.store.products.getAddTimeProducts(_objectSpread(_objectSpread({}, params), {}, {
1059
+ cacheId: this.cacheId
1060
+ }));
1061
+ case 3:
1062
+ result = _context14.sent;
1063
+ this.addTimeProductsCatalog = Array.isArray(result) ? _toConsumableArray(result) : [];
1064
+ return _context14.abrupt("return", result);
1065
+ case 6:
1066
+ case "end":
1067
+ return _context14.stop();
1068
+ }
1069
+ }, _callee14, this);
1070
+ }));
1071
+ function getAddTimeProducts() {
1072
+ return _getAddTimeProducts.apply(this, arguments);
1073
+ }
1074
+ return getAddTimeProducts;
1075
+ }()
1076
+ /**
1077
+ * 只读查询单商品详情:走 ProductList 报价查询,但不写 productCatalog、
1078
+ * 不 emit onProductsLoaded、不修改 BookingDate。
1079
+ *
1080
+ * 供「列表已 loadProducts、仅需补 product_resource / capacity」等场景使用,
1081
+ * 避免 loadProductDetail 覆盖左侧商品列表。
1082
+ *
1083
+ * @example
1084
+ * const detail = await bookingTicket.queryProductDetail({
1085
+ * product_id: 2,
1086
+ * schedule_date: '2030-01-15',
1087
+ * schedule_datetime: '2030-01-15 10:00:00',
1088
+ * });
1089
+ */
1090
+ )
1091
+ }, {
1092
+ key: "queryProductDetail",
1093
+ value: (function () {
1094
+ var _queryProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params, options) {
1095
+ var product_id, queryParams, _result2, list;
1096
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1097
+ while (1) switch (_context15.prev = _context15.next) {
1098
+ case 0:
1099
+ product_id = params.product_id, queryParams = _objectWithoutProperties(params, _excluded2);
1100
+ _context15.prev = 1;
1101
+ _context15.next = 4;
1102
+ return this.store.products.loadProducts(_objectSpread(_objectSpread({
1103
+ with_count: ['bundleGroup', 'optionGroup'],
1104
+ with_schedule: 1
1105
+ }, queryParams), {}, {
1106
+ product_ids: [product_id],
1107
+ cacheId: this.cacheId
1108
+ }), options);
1109
+ case 4:
1110
+ _result2 = _context15.sent;
1111
+ list = Array.isArray(_result2) ? _result2 : [];
1112
+ return _context15.abrupt("return", list.find(function (product) {
1113
+ return Number(product.id) === Number(product_id);
1114
+ }));
1115
+ case 9:
1116
+ _context15.prev = 9;
1117
+ _context15.t0 = _context15["catch"](1);
1118
+ console.error('Failed to query product detail:', _context15.t0);
1119
+ throw _context15.t0;
1120
+ case 13:
1121
+ case "end":
1122
+ return _context15.stop();
1123
+ }
1124
+ }, _callee15, this, [[1, 9]]);
1125
+ }));
1126
+ function queryProductDetail(_x9, _x10) {
1127
+ return _queryProductDetail.apply(this, arguments);
1128
+ }
1129
+ return queryProductDetail;
1130
+ }()
1131
+ /**
1132
+ * 按预约时间加载单个商品详情。
1133
+ * 价格仍由 server products 的报价单桥接统一计算,避免 solution 实例重复请求报价单。
1134
+ */
1135
+ )
1136
+ }, {
1137
+ key: "loadProductDetail",
1138
+ value: (function () {
1139
+ var _loadProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params, options) {
1140
+ var product_id, queryParams, products;
1141
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1142
+ while (1) switch (_context16.prev = _context16.next) {
1143
+ case 0:
1144
+ product_id = params.product_id, queryParams = _objectWithoutProperties(params, _excluded3);
1145
+ _context16.next = 3;
1146
+ return this.loadProducts(_objectSpread(_objectSpread({}, queryParams), {}, {
1147
+ product_ids: [product_id]
1148
+ }), options);
1149
+ case 3:
1150
+ products = _context16.sent;
1151
+ return _context16.abrupt("return", products.find(function (product) {
1152
+ return Number(product.id) === Number(product_id);
1153
+ }));
1154
+ case 5:
1155
+ case "end":
1156
+ return _context16.stop();
1157
+ }
1158
+ }, _callee16, this);
1159
+ }));
1160
+ function loadProductDetail(_x11, _x12) {
1161
+ return _loadProductDetail.apply(this, arguments);
1162
+ }
1163
+ return loadProductDetail;
1164
+ }()
1165
+ /**
1166
+ * 取消商品查询订阅
1167
+ * @param subscriberId 订阅时传入的 subscriberId
1168
+ */
1169
+ )
1170
+ }, {
1171
+ key: "unsubscribeProductQuery",
1172
+ value: function unsubscribeProductQuery(subscriberId) {
1173
+ var _this$core$server;
1174
+ (_this$core$server = this.core.server) === null || _this$core$server === void 0 || _this$core$server.removeProductQuerySubscriber(subscriberId);
1175
+ }
1176
+
1177
+ /**
1178
+ * 初始化外设扫码结果监听
1179
+ */
1180
+ }, {
1181
+ key: "initPeripheralsListener",
1182
+ value: function initPeripheralsListener() {
1183
+ this.scan.initPeripheralsListener();
1184
+ }
1185
+
1186
+ /**
1187
+ * 获取商品列表(不加载到模块中)
1188
+ * @returns 商品列表
1189
+ */
1190
+ }, {
1191
+ key: "getProducts",
1192
+ value: (function () {
1193
+ var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1194
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1195
+ while (1) switch (_context17.prev = _context17.next) {
1196
+ case 0:
1197
+ return _context17.abrupt("return", this.store.products.getProducts());
1198
+ case 1:
1199
+ case "end":
1200
+ return _context17.stop();
1201
+ }
1202
+ }, _callee17, this);
1203
+ }));
1204
+ function getProducts() {
1205
+ return _getProducts.apply(this, arguments);
1206
+ }
1207
+ return getProducts;
1208
+ }()
1209
+ /**
1210
+ * 获取当前已加载的商品池 UI 视图。
1211
+ *
1212
+ * ProductList.getProducts 是异步 API;BookingTicket 维护最近一次 loadProducts 结果,
1213
+ * 供 UI 同步 getter 使用。未加载时返回空列表。
1214
+ */
1215
+ )
1216
+ }, {
1217
+ key: "getProductCatalog",
1218
+ value: function getProductCatalog() {
1219
+ return {
1220
+ products: _toConsumableArray(this.productCatalog)
1221
+ };
1222
+ }
1223
+
1224
+ /**
1225
+ * 获取购物车 UI 视图。
1226
+ *
1227
+ * tempOrder 仍是 checkout 协议对象;商品行直接透传 products,bookings 附带关联商品。
1228
+ */
1229
+ }, {
1230
+ key: "getCart",
1231
+ value: function getCart() {
1232
+ var _this$store$order$get2, _this$store$order4, _salesDetail$bookings, _operatingDayBoundary, _operatingDayBoundary2, _tempOrder$_extend;
1233
+ var tempOrder = (_this$store$order$get2 = (_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 ? void 0 : _this$store$order4.getTempOrder()) !== null && _this$store$order$get2 !== void 0 ? _this$store$order$get2 : null;
1234
+ var salesDetail = this.getSalesOrder();
1235
+ var bookings = (_salesDetail$bookings = salesDetail === null || salesDetail === void 0 ? void 0 : salesDetail.bookings) !== null && _salesDetail$bookings !== void 0 ? _salesDetail$bookings : (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.bookings) || [];
1236
+ var operatingDayBoundary;
1237
+ try {
1238
+ operatingDayBoundary = this.getAppData('operating_day_boundary');
1239
+ } catch (_unused) {
1240
+ operatingDayBoundary = undefined;
1241
+ }
1242
+ var shopOpeningHours = ((_operatingDayBoundary = operatingDayBoundary) === null || _operatingDayBoundary === void 0 ? void 0 : _operatingDayBoundary.type) === 'start_time' ? '23:59' : (_operatingDayBoundary2 = operatingDayBoundary) === null || _operatingDayBoundary2 === void 0 ? void 0 : _operatingDayBoundary2.time;
1243
+ return buildCartView((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [], bookings, {
1244
+ addTimeProducts: this.addTimeProductsCatalog,
1245
+ bookingConfig: this.getBookingConfig(),
1246
+ productsByUid: tempOrder === null || tempOrder === void 0 || (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.productsByUid,
1247
+ shopOpeningHours: shopOpeningHours
1248
+ });
1249
+ }
1250
+
1251
+ /**
1252
+ * 获取当前下单客户(与 OrderModule.tempOrder snapshot 一致)。
1253
+ */
1254
+ }, {
1255
+ key: "getCustomer",
1256
+ value: function getCustomer() {
1257
+ return this.getOrderCustomerSnapshot();
1258
+ }
1259
+
1260
+ /**
1261
+ * 通过 ids 获取商品列表(不加载到模块中)
1262
+ * @returns 商品列表
1263
+ */
1264
+ }, {
1265
+ key: "getProductByIds",
1266
+ value: (function () {
1267
+ var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(ids) {
1268
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1269
+ while (1) switch (_context18.prev = _context18.next) {
1270
+ case 0:
1271
+ return _context18.abrupt("return", this.store.products.getProductByIds(ids));
1272
+ case 1:
1273
+ case "end":
1274
+ return _context18.stop();
1275
+ }
1276
+ }, _callee18, this);
1277
+ }));
1278
+ function getProductByIds(_x13) {
1279
+ return _getProductByIds.apply(this, arguments);
1280
+ }
1281
+ return getProductByIds;
1282
+ }()
1283
+ /**
1284
+ * 获取日程时间段点
1285
+ * @param params 参数
1286
+ * @returns 日程时间段点
1287
+ */
1288
+ )
1289
+ }, {
1290
+ key: "getScheduleTimePoints",
1291
+ value: (function () {
1292
+ var _getScheduleTimePoints = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
1293
+ var result;
1294
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1295
+ while (1) switch (_context19.prev = _context19.next) {
1296
+ case 0:
1297
+ _context19.next = 2;
1298
+ return this.request.post('/menu/schedule-time-points', {
1299
+ menu_list_ids: params.menu_list_ids
1300
+ }, {
1301
+ osServer: true
1302
+ });
1303
+ case 2:
1304
+ result = _context19.sent;
1305
+ return _context19.abrupt("return", result.data || []);
1306
+ case 4:
1307
+ case "end":
1308
+ return _context19.stop();
1309
+ }
1310
+ }, _callee19, this);
1311
+ }));
1312
+ function getScheduleTimePoints(_x14) {
1313
+ return _getScheduleTimePoints.apply(this, arguments);
1314
+ }
1315
+ return getScheduleTimePoints;
1316
+ }()
1317
+ /**
1318
+ * 获取客户列表
1319
+ * @param params 查询参数
1320
+ * @returns 客户列表响应
1321
+ */
1322
+ )
1323
+ }, {
1324
+ key: "getCustomerList",
1325
+ value: (function () {
1326
+ var _getCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1327
+ var params,
1328
+ _result3,
1329
+ _args20 = arguments;
1330
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1331
+ while (1) switch (_context20.prev = _context20.next) {
1332
+ case 0:
1333
+ params = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : {};
1334
+ _context20.prev = 1;
1335
+ _context20.next = 4;
1336
+ return this.store.customer.getCustomerList(params);
1337
+ case 4:
1338
+ _result3 = _context20.sent;
1339
+ return _context20.abrupt("return", _result3);
1340
+ case 8:
1341
+ _context20.prev = 8;
1342
+ _context20.t0 = _context20["catch"](1);
1343
+ console.error('Failed to get customer list:', _context20.t0);
1344
+ throw _context20.t0;
1345
+ case 12:
1346
+ case "end":
1347
+ return _context20.stop();
1348
+ }
1349
+ }, _callee20, this, [[1, 8]]);
1350
+ }));
1351
+ function getCustomerList() {
1352
+ return _getCustomerList.apply(this, arguments);
1353
+ }
1354
+ return getCustomerList;
1355
+ }()
1356
+ /**
1357
+ * 设置活跃客户
1358
+ * @param customer 客户信息
1359
+ */
1360
+ )
1361
+ }, {
1362
+ key: "setActiveCustomer",
1363
+ value: function setActiveCustomer(customer) {
1364
+ this.store.customer.setSelectedCustomer(customer);
1365
+ this.core.effects.emit("".concat(this.name, ":onCustomerSelected"), {
1366
+ customer: customer
1367
+ });
1368
+ }
1369
+
1370
+ /**
1371
+ * 获取当前活跃客户
1372
+ * @returns 当前活跃客户
1373
+ */
1374
+ }, {
1375
+ key: "getActiveCustomer",
1376
+ value: function getActiveCustomer() {
1377
+ return this.store.customer.getSelectedCustomer();
1378
+ }
1379
+
1380
+ /**
1381
+ * 根据ID设置选中的客户
1382
+ * @param customerId 客户ID
1383
+ */
1384
+ }, {
1385
+ key: "setSelectedCustomerById",
1386
+ value: function setSelectedCustomerById(customerId) {
1387
+ var customer = this.store.customer.getCustomerById(customerId);
1388
+ if (customer) {
1389
+ this.store.customer.setSelectedCustomer(customer);
1390
+ this.core.effects.emit("".concat(this.name, ":onCustomerSelected"), {
1391
+ customer: customer
1392
+ });
1393
+ }
1394
+ }
1395
+
1396
+ /**
1397
+ * 获取所有客户
1398
+ * @returns 客户列表
1399
+ */
1400
+ }, {
1401
+ key: "getCustomers",
1402
+ value: function getCustomers() {
1403
+ return this.store.customer.getCustomers();
1404
+ }
1405
+
1406
+ /**
1407
+ * 根据ID获取客户
1408
+ * @param customerId 客户ID
1409
+ * @returns 客户信息
1410
+ */
1411
+ }, {
1412
+ key: "getCustomerById",
1413
+ value: function getCustomerById(customerId) {
1414
+ return this.store.customer.getCustomerById(customerId);
1415
+ }
1416
+
1417
+ /**
1418
+ * 清空客户列表
1419
+ */
1420
+ }, {
1421
+ key: "clearCustomers",
1422
+ value: function clearCustomers() {
1423
+ this.store.customer.clearCustomers();
1424
+ }
1425
+
1426
+ /**
1427
+ * 添加客户到列表第一位
1428
+ * @param customer 要添加的客户信息
1429
+ */
364
1430
  }, {
365
1431
  key: "addCustomerToFirst",
366
1432
  value: function addCustomerToFirst(customer) {
367
1433
  this.store.customer.addCustomerToFirst(customer);
368
1434
  }
369
1435
 
1436
+ // ─── 下单客户(基于 OrderModule.tempOrder,单一真源)───
1437
+ // 与老的 setActiveCustomer/getActiveCustomer 解耦:
1438
+ // - 老路:写入 CustomerModule.selectedCustomer(保留兼容,存量调用方不动)
1439
+ // - 新路:写入 tempOrder 的 customer 协议字段 + _extend.customerSnapshot
1440
+ // 新业务(如 SalesSdk)应优先使用本组方法。
1441
+
1442
+ /**
1443
+ * 设置当前下单客户。
1444
+ *
1445
+ * @param customer 完整客户对象;null 表示清空
1446
+ *
1447
+ * 内部将 customer 格式化为 tempOrder 协议字段后写入 OrderModule,
1448
+ * 并以 customer 作为 snapshot 保存富字段。
1449
+ *
1450
+ * 同时透传 OrderModule 内部 emit 的 `order:onOrderCustomerChange` 之外,
1451
+ * 在 BookingTicket 命名空间也 emit 一次,方便上层统一从 Solution 订阅。
1452
+ */
1453
+ }, {
1454
+ key: "setOrderCustomer",
1455
+ value: function setOrderCustomer(customer) {
1456
+ var _this$store$order$get3;
1457
+ if (!customer) {
1458
+ this.clearOrderCustomer();
1459
+ return;
1460
+ }
1461
+ var previousCustomerId = (_this$store$order$get3 = this.store.order.getOrderCustomer()) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.customer_id;
1462
+ var snapshotBeforeSet = this.store.order.getOrderCustomerSnapshot();
1463
+ var patch = formatOrderCustomerPatch(customer);
1464
+ var customerUnchanged = Number(previousCustomerId || 0) === Number(patch.customer_id || 0);
1465
+ if (!customerUnchanged) {
1466
+ this.discountConfigCacheKey = null;
1467
+ this.hasManualDiscountSelection = false;
1468
+ }
1469
+ this.store.order.setOrderCustomer(patch, customer);
1470
+ var snapshotAfterOrderSet = this.store.order.getOrderCustomerSnapshot();
1471
+ if (customerUnchanged) {
1472
+ // hydrate 后 customer_id 已存在但 _extend.customerSnapshot 仍为空时,
1473
+ // 须通知 SalesSdk 刷新 selected(否则会一直停在 onSalesOrderLoaded 时的 null)。
1474
+ var snapshotReplenished = !snapshotBeforeSet && Boolean(snapshotAfterOrderSet);
1475
+ if (snapshotReplenished) {
1476
+ var _next2 = this.buildOrderCustomerPayload();
1477
+ this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), _next2);
1478
+ }
1479
+ return;
1480
+ }
1481
+ var next = this.buildOrderCustomerPayload();
1482
+ this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), next);
1483
+ this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
1484
+ // 客户切换可能改变可用促销/赠品;触发一次重算(recursion-safe)。
1485
+ void this.store.order.applyPromotion().catch(function (error) {
1486
+ console.error('[BookingTicket] applyPromotion after customer change failed', error);
1487
+ });
1488
+ }
1489
+
1490
+ /**
1491
+ * 读取 tempOrder 上的下单客户协议字段;customer_id 缺失时返回 null。
1492
+ */
1493
+ }, {
1494
+ key: "getOrderCustomer",
1495
+ value: function getOrderCustomer() {
1496
+ return this.store.order.getOrderCustomer();
1497
+ }
1498
+
1499
+ /**
1500
+ * 读取 tempOrder._extend.customerSnapshot 中的完整客户对象。
1501
+ */
1502
+ }, {
1503
+ key: "getOrderCustomerSnapshot",
1504
+ value: function getOrderCustomerSnapshot() {
1505
+ return this.store.order.getOrderCustomerSnapshot();
1506
+ }
1507
+
1508
+ /**
1509
+ * 清空下单客户(协议字段 + snapshot)。
1510
+ */
1511
+ }, {
1512
+ key: "clearOrderCustomer",
1513
+ value: function clearOrderCustomer() {
1514
+ var _discountModule$setOr,
1515
+ _discountModule$setDi,
1516
+ _this3 = this;
1517
+ this.store.order.clearOrderCustomer();
1518
+ this.discountConfigCacheKey = null;
1519
+ this.hasManualDiscountSelection = false;
1520
+ var orderStore = this.store.order.store || {};
1521
+ var discountModule = orderStore.discount;
1522
+ void (discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, []));
1523
+ void (discountModule === null || discountModule === void 0 || (_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, []));
1524
+ this.store.order.applyDiscount();
1525
+ void this.store.order.recalculateSummary({
1526
+ createIfMissing: true
1527
+ }).then(function () {
1528
+ var _discountModule$getDi;
1529
+ var tempOrder = _this3.store.order.ensureTempOrder();
1530
+ _this3.store.order.persistTempOrder();
1531
+ return _this3.effectsEmit('onDiscountApplied', {
1532
+ productList: tempOrder.products || [],
1533
+ discountList: (discountModule === null || discountModule === void 0 || (_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [],
1534
+ selectedDiscountList: tempOrder.discount_list || [],
1535
+ tempOrder: tempOrder
1536
+ });
1537
+ }).catch(function (error) {
1538
+ console.error('Failed to recalculate summary after clearing customer:', error);
1539
+ });
1540
+ this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), null);
1541
+ }
1542
+
1543
+ /**
1544
+ * 重置 tempOrder,并同步清空下单客户运行态。
1545
+ *
1546
+ * OrderModule.restoreOrder 会重建空单(customer_id 已为 null),但不会:
1547
+ * - emit BookingTicket `onOrderCustomerChange`
1548
+ * - 重置 CustomerModule.selectedCustomer(老路 getActiveCustomer)
1549
+ *
1550
+ * 因此在 super.restoreOrder 之后显式清客户,保证 SalesSdk / ticketBooking 订阅方与 tempOrder 一致。
1551
+ */
1552
+ }, {
1553
+ key: "restoreOrder",
1554
+ value: (function () {
1555
+ var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1556
+ var _this$store$customer;
1557
+ var tempOrder;
1558
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1559
+ while (1) switch (_context21.prev = _context21.next) {
1560
+ case 0:
1561
+ _context21.next = 2;
1562
+ return _get(_getPrototypeOf(BookingTicketImpl.prototype), "restoreOrder", this).call(this);
1563
+ case 2:
1564
+ tempOrder = _context21.sent;
1565
+ this.clearOrderCustomer();
1566
+ (_this$store$customer = this.store.customer) === null || _this$store$customer === void 0 || _this$store$customer.setSelectedCustomer(null);
1567
+ return _context21.abrupt("return", tempOrder);
1568
+ case 6:
1569
+ case "end":
1570
+ return _context21.stop();
1571
+ }
1572
+ }, _callee21, this);
1573
+ }));
1574
+ function restoreOrder() {
1575
+ return _restoreOrder.apply(this, arguments);
1576
+ }
1577
+ return restoreOrder;
1578
+ }() /** 内部:基于 OrderModule 当前状态构造一份 OrderCustomerChangePayload。 */)
1579
+ }, {
1580
+ key: "buildOrderCustomerPayload",
1581
+ value: function buildOrderCustomerPayload() {
1582
+ var patch = this.store.order.getOrderCustomer();
1583
+ if (!patch) return null;
1584
+ return {
1585
+ patch: patch,
1586
+ snapshot: this.store.order.getOrderCustomerSnapshot()
1587
+ };
1588
+ }
1589
+ }, {
1590
+ key: "refreshDiscountConfigAfterOrderCustomerChange",
1591
+ value: function refreshDiscountConfigAfterOrderCustomerChange(customerId) {
1592
+ var _this4 = this;
1593
+ if (!customerId || customerId === 1) return;
1594
+ if (this.orderCustomerDiscountRefreshInFlight && this.orderCustomerDiscountRefreshCustomerId === customerId) {
1595
+ return;
1596
+ }
1597
+ var previousRefresh = this.orderCustomerDiscountRefreshInFlight;
1598
+ var refreshTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1599
+ var currentCustomer;
1600
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1601
+ while (1) switch (_context22.prev = _context22.next) {
1602
+ case 0:
1603
+ if (!previousRefresh) {
1604
+ _context22.next = 3;
1605
+ break;
1606
+ }
1607
+ _context22.next = 3;
1608
+ return previousRefresh.catch(function () {
1609
+ return undefined;
1610
+ });
1611
+ case 3:
1612
+ currentCustomer = _this4.store.order.getOrderCustomer();
1613
+ if (!(!currentCustomer || Number(currentCustomer.customer_id) !== customerId)) {
1614
+ _context22.next = 6;
1615
+ break;
1616
+ }
1617
+ return _context22.abrupt("return");
1618
+ case 6:
1619
+ _context22.next = 8;
1620
+ return _this4.loadDiscountConfig({
1621
+ customerId: customerId
1622
+ });
1623
+ case 8:
1624
+ case "end":
1625
+ return _context22.stop();
1626
+ }
1627
+ }, _callee22);
1628
+ }))();
1629
+ this.orderCustomerDiscountRefreshInFlight = refreshTask;
1630
+ this.orderCustomerDiscountRefreshCustomerId = customerId;
1631
+ refreshTask.catch(function (error) {
1632
+ console.error('Failed to load discount config after customer change:', error);
1633
+ }).finally(function () {
1634
+ if (_this4.orderCustomerDiscountRefreshInFlight !== refreshTask) return;
1635
+ _this4.orderCustomerDiscountRefreshInFlight = null;
1636
+ _this4.orderCustomerDiscountRefreshCustomerId = null;
1637
+ });
1638
+ }
1639
+
370
1640
  /**
371
1641
  * 获取客户分页信息
372
1642
  * @returns 分页信息
@@ -407,29 +1677,29 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
407
1677
  }, {
408
1678
  key: "changeCustomerPage",
409
1679
  value: (function () {
410
- var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(page, pageSize) {
411
- var _result3;
412
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
413
- while (1) switch (_context6.prev = _context6.next) {
1680
+ var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(page, pageSize) {
1681
+ var _result4;
1682
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1683
+ while (1) switch (_context23.prev = _context23.next) {
414
1684
  case 0:
415
- _context6.prev = 0;
416
- _context6.next = 3;
1685
+ _context23.prev = 0;
1686
+ _context23.next = 3;
417
1687
  return this.store.customer.changeCustomerPage(page, pageSize);
418
1688
  case 3:
419
- _result3 = _context6.sent;
420
- return _context6.abrupt("return", _result3);
1689
+ _result4 = _context23.sent;
1690
+ return _context23.abrupt("return", _result4);
421
1691
  case 7:
422
- _context6.prev = 7;
423
- _context6.t0 = _context6["catch"](0);
424
- console.error('Failed to change customer page:', _context6.t0);
425
- throw _context6.t0;
1692
+ _context23.prev = 7;
1693
+ _context23.t0 = _context23["catch"](0);
1694
+ console.error('Failed to change customer page:', _context23.t0);
1695
+ throw _context23.t0;
426
1696
  case 11:
427
1697
  case "end":
428
- return _context6.stop();
1698
+ return _context23.stop();
429
1699
  }
430
- }, _callee6, this, [[0, 7]]);
1700
+ }, _callee23, this, [[0, 7]]);
431
1701
  }));
432
- function changeCustomerPage(_x4, _x5) {
1702
+ function changeCustomerPage(_x15, _x16) {
433
1703
  return _changeCustomerPage.apply(this, arguments);
434
1704
  }
435
1705
  return changeCustomerPage;
@@ -442,28 +1712,28 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
442
1712
  }, {
443
1713
  key: "loadMoreCustomers",
444
1714
  value: (function () {
445
- var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
446
- var _result4;
447
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
448
- while (1) switch (_context7.prev = _context7.next) {
1715
+ var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
1716
+ var _result5;
1717
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1718
+ while (1) switch (_context24.prev = _context24.next) {
449
1719
  case 0:
450
- _context7.prev = 0;
451
- _context7.next = 3;
1720
+ _context24.prev = 0;
1721
+ _context24.next = 3;
452
1722
  return this.store.customer.loadMoreCustomers();
453
1723
  case 3:
454
- _result4 = _context7.sent;
455
- this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), _result4);
456
- return _context7.abrupt("return", _result4);
1724
+ _result5 = _context24.sent;
1725
+ this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), _result5);
1726
+ return _context24.abrupt("return", _result5);
457
1727
  case 8:
458
- _context7.prev = 8;
459
- _context7.t0 = _context7["catch"](0);
460
- console.error('Failed to load more customers:', _context7.t0);
461
- throw _context7.t0;
1728
+ _context24.prev = 8;
1729
+ _context24.t0 = _context24["catch"](0);
1730
+ console.error('Failed to load more customers:', _context24.t0);
1731
+ throw _context24.t0;
462
1732
  case 12:
463
1733
  case "end":
464
- return _context7.stop();
1734
+ return _context24.stop();
465
1735
  }
466
- }, _callee7, this, [[0, 8]]);
1736
+ }, _callee24, this, [[0, 8]]);
467
1737
  }));
468
1738
  function loadMoreCustomers() {
469
1739
  return _loadMoreCustomers.apply(this, arguments);
@@ -479,31 +1749,31 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
479
1749
  }, {
480
1750
  key: "resetAndLoadCustomers",
481
1751
  value: (function () {
482
- var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
1752
+ var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
483
1753
  var params,
484
- _result5,
485
- _args8 = arguments;
486
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
487
- while (1) switch (_context8.prev = _context8.next) {
1754
+ _result6,
1755
+ _args25 = arguments;
1756
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1757
+ while (1) switch (_context25.prev = _context25.next) {
488
1758
  case 0:
489
- params = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
490
- _context8.prev = 1;
491
- _context8.next = 4;
1759
+ params = _args25.length > 0 && _args25[0] !== undefined ? _args25[0] : {};
1760
+ _context25.prev = 1;
1761
+ _context25.next = 4;
492
1762
  return this.store.customer.resetAndLoadCustomers(params);
493
1763
  case 4:
494
- _result5 = _context8.sent;
495
- this.core.effects.emit("".concat(this.name, ":onCustomerListReset"), _result5);
496
- return _context8.abrupt("return", _result5);
1764
+ _result6 = _context25.sent;
1765
+ this.core.effects.emit("".concat(this.name, ":onCustomerListReset"), _result6);
1766
+ return _context25.abrupt("return", _result6);
497
1767
  case 9:
498
- _context8.prev = 9;
499
- _context8.t0 = _context8["catch"](1);
500
- console.error('Failed to reset and load customers:', _context8.t0);
501
- throw _context8.t0;
1768
+ _context25.prev = 9;
1769
+ _context25.t0 = _context25["catch"](1);
1770
+ console.error('Failed to reset and load customers:', _context25.t0);
1771
+ throw _context25.t0;
502
1772
  case 13:
503
1773
  case "end":
504
- return _context8.stop();
1774
+ return _context25.stop();
505
1775
  }
506
- }, _callee8, this, [[1, 9]]);
1776
+ }, _callee25, this, [[1, 9]]);
507
1777
  }));
508
1778
  function resetAndLoadCustomers() {
509
1779
  return _resetAndLoadCustomers.apply(this, arguments);
@@ -511,232 +1781,1025 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
511
1781
  return resetAndLoadCustomers;
512
1782
  }()
513
1783
  /**
514
- * 检查是否还有更多客户数据可以加载
515
- * @returns 是否还有更多数据
1784
+ * 检查是否还有更多客户数据可以加载
1785
+ * @returns 是否还有更多数据
1786
+ */
1787
+ )
1788
+ }, {
1789
+ key: "hasMoreCustomers",
1790
+ value: function hasMoreCustomers() {
1791
+ return this.store.customer.hasMoreCustomers();
1792
+ }
1793
+
1794
+ /**
1795
+ * 获取当前的客户搜索条件
1796
+ * @returns 当前搜索条件
1797
+ */
1798
+ }, {
1799
+ key: "getCurrentCustomerSearchParams",
1800
+ value: function getCurrentCustomerSearchParams() {
1801
+ return this.store.customer.getCurrentSearchParams();
1802
+ }
1803
+
1804
+ /**
1805
+ * 获取客户列表状态(包含滚动加载相关状态)
1806
+ * @returns 客户状态
1807
+ */
1808
+ }, {
1809
+ key: "getCustomerState",
1810
+ value: function getCustomerState() {
1811
+ return this.store.customer.getState();
1812
+ }
1813
+
1814
+ /**
1815
+ * 全局扫描监听
1816
+ * @param callback 回调
1817
+ */
1818
+ }, {
1819
+ key: "scanGlobalListener",
1820
+ value: function scanGlobalListener(callback) {
1821
+ var _this5 = this;
1822
+ var localSearch = function localSearch(v) {
1823
+ return _this5.store.products.findProductsByCodeOrBarcode(v);
1824
+ };
1825
+ var scanCallback = handleGlobalScan(this.request, localSearch, this.getSubmitOrderSalesChannel());
1826
+ var safeCallback = function safeCallback(d) {
1827
+ try {
1828
+ callback(d);
1829
+ } catch (error) {
1830
+ console.error('scanGlobalListener传入的回调函数异常', error);
1831
+ }
1832
+ };
1833
+ var listener = {
1834
+ key: 'global',
1835
+ callback: safeCallback
1836
+ };
1837
+ var removeListener = this.scan.addListener(listener, scanCallback);
1838
+ return removeListener;
1839
+ }
1840
+
1841
+ /**
1842
+ * 客户扫描监听
1843
+ * @param callback 回调
1844
+ */
1845
+ }, {
1846
+ key: "scanCustomerListener",
1847
+ value: function scanCustomerListener(callback) {
1848
+ var scanCallback = handleCustomerScan();
1849
+ var safeCallback = function safeCallback(d) {
1850
+ try {
1851
+ callback(d);
1852
+ } catch (error) {
1853
+ console.error('scanCustomerListener传入的回调函数异常', error);
1854
+ }
1855
+ };
1856
+ var listener = {
1857
+ key: 'customer',
1858
+ callback: safeCallback
1859
+ };
1860
+ var removeListener = this.scan.addListener(listener, scanCallback);
1861
+ return removeListener;
1862
+ }
1863
+
1864
+ /**
1865
+ * @title 通用扫描监听
1866
+ * @description 直接将扫描结果返回给调用方
1867
+ * @param callback 回调
1868
+ */
1869
+ }, {
1870
+ key: "scanUniversalListener",
1871
+ value: function scanUniversalListener(callback, key) {
1872
+ var scanCallback = handleUniversalScan();
1873
+ var safeCallback = function safeCallback(d) {
1874
+ try {
1875
+ callback(d);
1876
+ } catch (error) {
1877
+ console.error("scanUniversalListener\u4F20\u5165\u7684\u56DE\u8C03\u51FD\u6570\u5F02\u5E38, key: ".concat(key), error);
1878
+ }
1879
+ };
1880
+ var listener = {
1881
+ key: key,
1882
+ callback: safeCallback
1883
+ };
1884
+ var removeListener = this.scan.addListener(listener, scanCallback);
1885
+ return removeListener;
1886
+ }
1887
+
1888
+ /**
1889
+ * 调用摄像头
1890
+ * @param data 用户自定义数据
1891
+ */
1892
+ }, {
1893
+ key: "activateCamera",
1894
+ value: function activateCamera(data) {
1895
+ var _this$window, _this$window$postMess;
1896
+ (_this$window = this.window) === null || _this$window === void 0 || (_this$window = _this$window.interaction) === null || _this$window === void 0 || (_this$window = _this$window.utils) === null || _this$window === void 0 || (_this$window$postMess = _this$window.postMessageToApp) === null || _this$window$postMess === void 0 || _this$window$postMess.call(_this$window, {
1897
+ module: 'global',
1898
+ key: 'active_native_scanner',
1899
+ data: data
1900
+ });
1901
+ }
1902
+
1903
+ /**
1904
+ * 禁用所有扫描监听
1905
+ */
1906
+ }, {
1907
+ key: "disableAllScanListeners",
1908
+ value: function disableAllScanListeners() {
1909
+ this.scan.disableAllListeners();
1910
+ }
1911
+
1912
+ /**
1913
+ * 启用所有扫描监听
1914
+ */
1915
+ }, {
1916
+ key: "enableAllScanListeners",
1917
+ value: function enableAllScanListeners() {
1918
+ this.scan.enableAllListeners();
1919
+ }
1920
+
1921
+ /**
1922
+ * 清空所有扫描监听对应的任务执行队列
1923
+ */
1924
+ }, {
1925
+ key: "clearAllScanListenersTaskQueue",
1926
+ value: function clearAllScanListenersTaskQueue() {
1927
+ this.scan.clearTaskQueue();
1928
+ }
1929
+
1930
+ /**
1931
+ * 获取其他参数
1932
+ * @returns 其他参数
1933
+ */
1934
+ }, {
1935
+ key: "getOtherParams",
1936
+ value: (function () {
1937
+ var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
1938
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1939
+ while (1) switch (_context26.prev = _context26.next) {
1940
+ case 0:
1941
+ return _context26.abrupt("return", this.otherParams);
1942
+ case 1:
1943
+ case "end":
1944
+ return _context26.stop();
1945
+ }
1946
+ }, _callee26, this);
1947
+ }));
1948
+ function getOtherParams() {
1949
+ return _getOtherParams.apply(this, arguments);
1950
+ }
1951
+ return getOtherParams;
1952
+ }() // ─── BookingContext API(透传给 BookingContextModule) ──────────────────────
1953
+ // SalesSdkProvider 挂载时默认调 initBookingContext;也可由 UI 显式 set* 灌入已有数据。
1954
+ /** 拉取 board config 并写入 BookingContext。 */
1955
+ )
1956
+ }, {
1957
+ key: "loadBookingConfig",
1958
+ value: function loadBookingConfig(params) {
1959
+ return this.store.bookingContext.loadBookingConfig(params);
1960
+ }
1961
+
1962
+ /** 拉取资源全集并写入 BookingContext。 */
1963
+ }, {
1964
+ key: "loadBookingResources",
1965
+ value: function loadBookingResources(params) {
1966
+ return this.store.bookingContext.loadResources(params);
1967
+ }
1968
+
1969
+ /** 初始化 BookingContext(date + config + resources)。 */
1970
+ }, {
1971
+ key: "initBookingContext",
1972
+ value: function initBookingContext(params) {
1973
+ return this.store.bookingContext.initBookingContext(params);
1974
+ }
1975
+
1976
+ /** 当前 store 是否已具备与入参等价的 config / resources(无需再请求接口)。 */
1977
+ }, {
1978
+ key: "isBookingContextReady",
1979
+ value: function isBookingContextReady(params) {
1980
+ return this.store.bookingContext.isBookingContextReady(params);
1981
+ }
1982
+
1983
+ /** 写入 booking config(来源:`/core/board/management/config`)。 */
1984
+ }, {
1985
+ key: "setBookingConfig",
1986
+ value: function setBookingConfig(config) {
1987
+ this.store.bookingContext.setBookingConfig(config);
1988
+ }
1989
+
1990
+ /** 读取当前 booking config。 */
1991
+ }, {
1992
+ key: "getBookingConfig",
1993
+ value: function getBookingConfig() {
1994
+ return this.store.bookingContext.getBookingConfig();
1995
+ }
1996
+
1997
+ /** 写入资源全集(来源:`/form/schedule`),同步派生 resourcesOriginMap。 */
1998
+ }, {
1999
+ key: "setResources",
2000
+ value: function setResources(resources) {
2001
+ this.store.bookingContext.setResources(resources);
2002
+ }
2003
+
2004
+ /** 读取资源全集(浅克隆)。 */
2005
+ }, {
2006
+ key: "getResourcesOrigin",
2007
+ value: function getResourcesOrigin() {
2008
+ return this.store.bookingContext.getResourcesOrigin();
2009
+ }
2010
+
2011
+ /** 读取资源全集 map(id → resource)。 */
2012
+ }, {
2013
+ key: "getResourcesOriginMap",
2014
+ value: function getResourcesOriginMap() {
2015
+ return this.store.bookingContext.getResourcesOriginMap();
2016
+ }
2017
+
2018
+ /** 写入当前选择的日期;支持 dayjs / Date / string。 */
2019
+ }, {
2020
+ key: "setBookingDate",
2021
+ value: function setBookingDate(date) {
2022
+ this.store.bookingContext.setDate(date);
2023
+ }
2024
+
2025
+ /** 读取当前选择的日期(统一 string)。 */
2026
+ }, {
2027
+ key: "getBookingDate",
2028
+ value: function getBookingDate() {
2029
+ return this.store.bookingContext.getDate();
2030
+ }
2031
+
2032
+ /** 读取 BookingContext 完整 store(调试 / 测试 / 透传给 SDK 使用)。 */
2033
+ }, {
2034
+ key: "getBookingContextState",
2035
+ value: function getBookingContextState() {
2036
+ return this.store.bookingContext.getState();
2037
+ }
2038
+
2039
+ /** 清空 BookingContext(切租户 / destroy 场景)。 */
2040
+ }, {
2041
+ key: "clearBookingContext",
2042
+ value: function clearBookingContext() {
2043
+ this.store.bookingContext.clear();
2044
+ }
2045
+
2046
+ /**
2047
+ * 构造 BookingContext 计算上下文(供 getProductExtend / getResourceByIds 等读 API 复用)。
2048
+ */
2049
+ }, {
2050
+ key: "buildBookingCalcContext",
2051
+ value: function buildBookingCalcContext(extra) {
2052
+ var _extra$date, _extra$presetStartTim;
2053
+ var state = this.store.bookingContext.getState();
2054
+ var date = (_extra$date = extra === null || extra === void 0 ? void 0 : extra.date) !== null && _extra$date !== void 0 ? _extra$date : state.date;
2055
+ return _objectSpread({
2056
+ bookingConfig: state.bookingConfig,
2057
+ resourcesOrigin: state.resourcesOrigin,
2058
+ resourcesOriginMap: state.resourcesOriginMap,
2059
+ date: date,
2060
+ presetStartTime: (_extra$presetStartTim = extra === null || extra === void 0 ? void 0 : extra.presetStartTime) !== null && _extra$presetStartTim !== void 0 ? _extra$presetStartTim : derivePresetStartTimeFromDate(date)
2061
+ }, extra || {});
2062
+ }
2063
+
2064
+ /**
2065
+ * 取商品当前可选资源列表(透传 OS BookingContext utils#getResourceByIds)。
2066
+ * `extraResources` 用于把拖入未绑定的资源也展示出来。
2067
+ */
2068
+ }, {
2069
+ key: "getResourcesForProduct",
2070
+ value: function getResourcesForProduct(product, options) {
2071
+ var _ctx$bookingConfig;
2072
+ var ctx = this.buildBookingCalcContext();
2073
+ return getResourceByIdsUtil(ctx.resourcesOriginMap || {}, product, {
2074
+ resourceTab: (_ctx$bookingConfig = ctx.bookingConfig) === null || _ctx$bookingConfig === void 0 || (_ctx$bookingConfig = _ctx$bookingConfig.config) === null || _ctx$bookingConfig === void 0 ? void 0 : _ctx$bookingConfig.resource_tab,
2075
+ resourcesOrigin: ctx.resourcesOrigin,
2076
+ extraResources: (options === null || options === void 0 ? void 0 : options.extraResources) || []
2077
+ });
2078
+ }
2079
+
2080
+ /**
2081
+ * 拼装 cacheItem 的 _extend / _data(资源 / 容量 / timeObj),与 info2 `getProductExtend` 等价。
516
2082
  */
517
- )
518
2083
  }, {
519
- key: "hasMoreCustomers",
520
- value: function hasMoreCustomers() {
521
- return this.store.customer.hasMoreCustomers();
2084
+ key: "getProductExtend",
2085
+ value: function getProductExtend(cacheItem, extra) {
2086
+ var preparedCacheItem = withProductOptionString(cacheItem);
2087
+ var result = getProductExtendUtil({
2088
+ cacheItem: preparedCacheItem,
2089
+ ctx: this.buildBookingCalcContext(extra)
2090
+ });
2091
+ return result;
522
2092
  }
523
2093
 
524
2094
  /**
525
- * 获取当前的客户搜索条件
526
- * @returns 当前搜索条件
2095
+ * 取资源不可用原因列表(结构化 enum + params,i18n 文案由 UI 渲染)。
527
2096
  */
528
2097
  }, {
529
- key: "getCurrentCustomerSearchParams",
530
- value: function getCurrentCustomerSearchParams() {
531
- return this.store.customer.getCurrentSearchParams();
2098
+ key: "getResourceErrors",
2099
+ value: function getResourceErrors(resource, cacheItem) {
2100
+ return getResourceErrorsUtil(resource, cacheItem);
532
2101
  }
533
2102
 
2103
+ // ─── addProduct 决策 / 转换 API(SDK 加车下沉所需) ─────────────────────────
2104
+ // 这一组方法是 SalesSdkCartContext.addProduct / confirmDetail 的 OS 后端。
2105
+ // 调用方传入 ProductData,OS 自取 bookingContext / customer / date 等上下文,
2106
+ // 输出 (a) autoClose 决策结果或 (b) `{ product, booking }` 协议入参。
2107
+
534
2108
  /**
535
- * 获取客户列表状态(包含滚动加载相关状态)
536
- * @returns 客户状态
2109
+ * session 商品 catalog 日期与 TimeBar 不一致时写业务日志。
2110
+ *
2111
+ * @example
2112
+ * this.logSessionCatalogDateMismatch(product, ctx.date);
537
2113
  */
538
2114
  }, {
539
- key: "getCustomerState",
540
- value: function getCustomerState() {
541
- return this.store.customer.getState();
2115
+ key: "logSessionCatalogDateMismatch",
2116
+ value: function logSessionCatalogDateMismatch(item, bookingDate) {
2117
+ var _this$getTempOrder, _tempOrder$order_id, _tempOrder$external_s, _item$cartDetailValue, _item$cartDetailValue2;
2118
+ var logger = this.logger;
2119
+ if (!(logger !== null && logger !== void 0 && logger.addLog)) return;
2120
+ var tempOrder = (_this$getTempOrder = this.getTempOrder) === null || _this$getTempOrder === void 0 ? void 0 : _this$getTempOrder.call(this);
2121
+ var staleInfo = buildSessionCatalogStaleInfo(item, bookingDate);
2122
+ logger.addLog({
2123
+ type: 'warning',
2124
+ title: "[BookingTicket] session catalog date mismatch, reload products",
2125
+ metadata: _objectSpread(_objectSpread({
2126
+ order_id: (_tempOrder$order_id = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) !== null && _tempOrder$order_id !== void 0 ? _tempOrder$order_id : null,
2127
+ external_sale_number: (_tempOrder$external_s = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.external_sale_number) !== null && _tempOrder$external_s !== void 0 ? _tempOrder$external_s : null
2128
+ }, staleInfo), {}, {
2129
+ cartDetailValueSession: (_item$cartDetailValue = item === null || item === void 0 || (_item$cartDetailValue2 = item.cartDetailValue) === null || _item$cartDetailValue2 === void 0 ? void 0 : _item$cartDetailValue2.session) !== null && _item$cartDetailValue !== void 0 ? _item$cartDetailValue : null
2130
+ })
2131
+ });
542
2132
  }
543
2133
 
544
2134
  /**
545
- * 全局扫描监听
546
- * @param callback 回调
2135
+ * 加车前:session 商品 catalog 日历日与 bookingDate 不一致时中断加购,交由 SDK reload products。
547
2136
  */
548
2137
  }, {
549
- key: "scanGlobalListener",
550
- value: function scanGlobalListener(callback) {
551
- var _this3 = this;
552
- var localSearch = function localSearch(v) {
553
- return _this3.store.products.findProductsByCodeOrBarcode(v);
554
- };
555
- var scanCallback = handleGlobalScan(this.request, localSearch);
556
- var safeCallback = function safeCallback(d) {
557
- try {
558
- callback(d);
559
- } catch (error) {
560
- console.error('scanGlobalListener传入的回调函数异常', error);
561
- }
562
- };
563
- var listener = {
564
- key: 'global',
565
- callback: safeCallback
2138
+ key: "resolveSessionCatalogBeforeAdd",
2139
+ value: function resolveSessionCatalogBeforeAdd(item, ctx) {
2140
+ if (!isSessionCatalogDateStale(item, ctx.date)) {
2141
+ return null;
2142
+ }
2143
+ this.logSessionCatalogDateMismatch(item, ctx.date);
2144
+ return {
2145
+ action: 'reloadCatalog'
566
2146
  };
567
- var removeListener = this.scan.addListener(listener, scanCallback);
568
- return removeListener;
569
2147
  }
570
2148
 
571
2149
  /**
572
- * 客户扫描监听
573
- * @param callback 回调
2150
+ * 拼装 addProductDecision 通用上下文(从 store 自取)。
574
2151
  */
575
2152
  }, {
576
- key: "scanCustomerListener",
577
- value: function scanCustomerListener(callback) {
578
- var scanCallback = handleCustomerScan();
579
- var safeCallback = function safeCallback(d) {
580
- try {
581
- callback(d);
582
- } catch (error) {
583
- console.error('scanCustomerListener传入的回调函数异常', error);
584
- }
585
- };
586
- var listener = {
587
- key: 'customer',
588
- callback: safeCallback
589
- };
590
- var removeListener = this.scan.addListener(listener, scanCallback);
591
- return removeListener;
2153
+ key: "buildAddProductCtx",
2154
+ value: function buildAddProductCtx(extra) {
2155
+ var _extra$date2, _ref12, _this$getOrderCustome, _this$getOrderCustome2, _this$store$order$get4, _extra$presetStartTim2;
2156
+ var bookingContextState = this.store.bookingContext.getState();
2157
+ var date = (_extra$date2 = extra === null || extra === void 0 ? void 0 : extra.date) !== null && _extra$date2 !== void 0 ? _extra$date2 : bookingContextState.date;
2158
+ var orderCustomerId = (_ref12 = (_this$getOrderCustome = (_this$getOrderCustome2 = this.getOrderCustomerSnapshot()) === null || _this$getOrderCustome2 === void 0 ? void 0 : _this$getOrderCustome2.id) !== null && _this$getOrderCustome !== void 0 ? _this$getOrderCustome : (_this$store$order$get4 = this.store.order.getTempOrder()) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.customer_id) !== null && _ref12 !== void 0 ? _ref12 : undefined;
2159
+ return _objectSpread({
2160
+ bookingConfig: bookingContextState.bookingConfig,
2161
+ resourcesOrigin: bookingContextState.resourcesOrigin,
2162
+ resourcesOriginMap: bookingContextState.resourcesOriginMap,
2163
+ date: date,
2164
+ presetStartTime: (_extra$presetStartTim2 = extra === null || extra === void 0 ? void 0 : extra.presetStartTime) !== null && _extra$presetStartTim2 !== void 0 ? _extra$presetStartTim2 : derivePresetStartTimeFromDate(date),
2165
+ customerId: orderCustomerId
2166
+ }, extra || {});
592
2167
  }
593
2168
 
594
2169
  /**
595
- * @title 通用扫描监听
596
- * @description 直接将扫描结果返回给调用方
597
- * @param callback 回调
2170
+ * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
2171
+ * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
598
2172
  */
599
2173
  }, {
600
- key: "scanUniversalListener",
601
- value: function scanUniversalListener(callback, key) {
602
- var scanCallback = handleUniversalScan();
603
- var safeCallback = function safeCallback(d) {
604
- try {
605
- callback(d);
606
- } catch (error) {
607
- console.error("scanUniversalListener\u4F20\u5165\u7684\u56DE\u8C03\u51FD\u6570\u5F02\u5E38, key: ".concat(key), error);
608
- }
609
- };
610
- var listener = {
611
- key: key,
612
- callback: safeCallback
613
- };
614
- var removeListener = this.scan.addListener(listener, scanCallback);
615
- return removeListener;
2174
+ key: "decideAddProduct",
2175
+ value: function decideAddProduct(item, options) {
2176
+ var ctx = this.buildAddProductCtx(options);
2177
+ var staleDecision = this.resolveSessionCatalogBeforeAdd(item, ctx);
2178
+ if (staleDecision) {
2179
+ return staleDecision;
2180
+ }
2181
+ return decideAddProductUtil(item, ctx);
2182
+ }
2183
+
2184
+ /** 规格弹窗 callback 后的第二段决策。 */
2185
+ }, {
2186
+ key: "decideAfterDetail",
2187
+ value: function decideAfterDetail(cacheItem, options) {
2188
+ return decideAfterDetailUtil(cacheItem, this.buildAddProductCtx(options));
616
2189
  }
617
2190
 
618
2191
  /**
619
- * 调用摄像头
620
- * @param data 用户自定义数据
2192
+ * @deprecated 请用 `decideAddProduct`;`autoClose=true` 仅当 action=add。
621
2193
  */
622
2194
  }, {
623
- key: "activateCamera",
624
- value: function activateCamera(data) {
625
- var _this$window, _this$window$postMess;
626
- (_this$window = this.window) === null || _this$window === void 0 || (_this$window = _this$window.interaction) === null || _this$window === void 0 || (_this$window = _this$window.utils) === null || _this$window === void 0 || (_this$window$postMess = _this$window.postMessageToApp) === null || _this$window$postMess === void 0 || _this$window$postMess.call(_this$window, {
627
- module: 'global',
628
- key: 'active_native_scanner',
629
- data: data
630
- });
2195
+ key: "decideAutoClose",
2196
+ value: function decideAutoClose(item, options) {
2197
+ return decideAutoCloseUtil(item, this.buildAddProductCtx(options));
2198
+ }
2199
+
2200
+ /** 替代 info2 `getIsEject`:商品是否需要弹窗(0/1)。 */
2201
+ }, {
2202
+ key: "getIsEject",
2203
+ value: function getIsEject(item) {
2204
+ var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'select';
2205
+ return getIsEjectUtil(item, type);
2206
+ }
2207
+
2208
+ /** 仅 session 商品(无 variant/option/package)→ true。 */
2209
+ }, {
2210
+ key: "getIsOnlySession",
2211
+ value: function getIsOnlySession(item) {
2212
+ return getIsOnlySessionUtil(item);
631
2213
  }
632
2214
 
633
2215
  /**
634
- * 禁用所有扫描监听
2216
+ * 拼装 requiresDetail payload(给 SDK 直接 return 给 UI 用)。
635
2217
  */
636
2218
  }, {
637
- key: "disableAllScanListeners",
638
- value: function disableAllScanListeners() {
639
- this.scan.disableAllListeners();
2219
+ key: "buildRequiresDetailPayload",
2220
+ value: function buildRequiresDetailPayload(item, options) {
2221
+ var ctx = this.buildAddProductCtx(options);
2222
+ return _buildRequiresDetailPayload(item, ctx);
640
2223
  }
641
2224
 
642
2225
  /**
643
- * 启用所有扫描监听
2226
+ * 把 detail 弹窗回调结果(e, extension_type, detail)转换为 `(product, booking)` 入参。
2227
+ * 内部会先拼 cacheItem,再走 cacheItemToBookingInput 严格协议对齐。
644
2228
  */
645
2229
  }, {
646
- key: "enableAllScanListeners",
647
- value: function enableAllScanListeners() {
648
- this.scan.enableAllListeners();
2230
+ key: "transformDetailToProductAndBooking",
2231
+ value: function transformDetailToProductAndBooking(input) {
2232
+ var item = input.item,
2233
+ preparedCacheItem = input.cacheItem,
2234
+ detailResult = input.detailResult,
2235
+ options = input.options;
2236
+ var ctx = this.buildAddProductCtx(options);
2237
+ var cacheItem = preparedCacheItem || (detailResult ? buildCacheItemFromDetail(item, detailResult, ctx) : buildCacheItemFromCartDetail(item, ctx));
2238
+ return transformDetailToProductAndBookingUtil(cacheItem, ctx);
649
2239
  }
650
2240
 
651
2241
  /**
652
- * 清空所有扫描监听对应的任务执行队列
2242
+ * 从已加车的 order line + booking 反查资源编辑抽屉所需的 cacheItem。
2243
+ * 供 SalesSdk「编辑资源」等场景使用;字段语义与 buildCacheItemFromDetail 产出对齐。
653
2244
  */
654
2245
  }, {
655
- key: "clearAllScanListenersTaskQueue",
656
- value: function clearAllScanListenersTaskQueue() {
657
- this.scan.clearTaskQueue();
2246
+ key: "buildCacheItemFromOrderLine",
2247
+ value: function buildCacheItemFromOrderLine(input) {
2248
+ return buildCacheItemFromOrderLineUtil(input);
658
2249
  }
659
2250
 
660
2251
  /**
661
- * 设置其他参数
662
- * @param params 参数
663
- * @param options 选项
2252
+ * 从已加车的普通商品 order line 反查 SkuDetailModal edit 所需的 cacheItem。
664
2253
  */
665
2254
  }, {
666
- key: "setOtherParams",
2255
+ key: "buildNormalProductCacheItemFromOrderLine",
2256
+ value: function buildNormalProductCacheItemFromOrderLine(input) {
2257
+ return buildNormalProductCacheItemFromOrderLineUtil(input);
2258
+ }
2259
+
2260
+ /** 文档别名:与 OrderModule.updateOrderProduct 一致。 */
2261
+ }, {
2262
+ key: "updateProductInOrder",
667
2263
  value: (function () {
668
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
669
- var _ref,
670
- _ref$cover,
671
- cover,
672
- _args9 = arguments;
673
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
674
- while (1) switch (_context9.prev = _context9.next) {
2264
+ var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
2265
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2266
+ while (1) switch (_context27.prev = _context27.next) {
675
2267
  case 0:
676
- _ref = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : {}, _ref$cover = _ref.cover, cover = _ref$cover === void 0 ? false : _ref$cover;
677
- if (cover) {
678
- this.otherParams = params;
679
- } else {
680
- this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
681
- }
682
- case 2:
2268
+ return _context27.abrupt("return", this.updateOrderProduct(params));
2269
+ case 1:
683
2270
  case "end":
684
- return _context9.stop();
2271
+ return _context27.stop();
685
2272
  }
686
- }, _callee9, this);
2273
+ }, _callee27, this);
687
2274
  }));
688
- function setOtherParams(_x6) {
689
- return _setOtherParams.apply(this, arguments);
2275
+ function updateProductInOrder(_x17) {
2276
+ return _updateProductInOrder.apply(this, arguments);
690
2277
  }
691
- return setOtherParams;
2278
+ return updateProductInOrder;
692
2279
  }()
693
2280
  /**
694
- * 获取其他参数
695
- * @returns 其他参数
2281
+ * 全局扫码 pubsub 入口:解析码值 → 搜索 → 业务分发(客户 / 加车 / 开单)。
2282
+ * UI 层在 pubsub 订阅回调里注入 `bridge`(uiHosts / action / cart.confirm*)。
2283
+ *
2284
+ * @example
2285
+ * ```ts
2286
+ * await bookingTicket.handleGlobalScanCode(payload.data, {
2287
+ * openProductDetail: uiHosts.openProductDetail,
2288
+ * confirmDetail: cart.confirmDetail,
2289
+ * openOrder: ({ order_id }) => action({ type: 'pisell1.handleOpenCachedBigSale', data: { order_id } }),
2290
+ * });
2291
+ * ```
696
2292
  */
697
2293
  )
698
2294
  }, {
699
- key: "getOtherParams",
2295
+ key: "handleGlobalScanCode",
700
2296
  value: (function () {
701
- var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
702
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
703
- while (1) switch (_context10.prev = _context10.next) {
2297
+ var _handleGlobalScanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(code, bridge) {
2298
+ var _this6 = this;
2299
+ var trimmed, _bridge$onNotify, _bridge$refresh, localSearch, scanCallback, raw, formatted, _bridge$onNotify2, _result7, _bridge$onNotify3;
2300
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2301
+ while (1) switch (_context28.prev = _context28.next) {
2302
+ case 0:
2303
+ trimmed = typeof code === 'string' ? code.trim() : '';
2304
+ if (trimmed) {
2305
+ _context28.next = 4;
2306
+ break;
2307
+ }
2308
+ bridge === null || bridge === void 0 || (_bridge$onNotify = bridge.onNotify) === null || _bridge$onNotify === void 0 || _bridge$onNotify.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
2309
+ return _context28.abrupt("return", {
2310
+ status: 'failed',
2311
+ reason: 'empty_code'
2312
+ });
2313
+ case 4:
2314
+ _context28.prev = 4;
2315
+ localSearch = function localSearch(v) {
2316
+ return _this6.store.products.findProductsByCodeOrBarcode(v);
2317
+ };
2318
+ scanCallback = handleGlobalScan(this.request, localSearch, this.getSubmitOrderSalesChannel());
2319
+ _context28.next = 9;
2320
+ return scanCallback({
2321
+ type: 'nativeScanner',
2322
+ value: trimmed
2323
+ });
2324
+ case 9:
2325
+ raw = _context28.sent;
2326
+ formatted = formatGlobalScanResult(raw, trimmed);
2327
+ if (formatted) {
2328
+ _context28.next = 14;
2329
+ break;
2330
+ }
2331
+ bridge === null || bridge === void 0 || (_bridge$onNotify2 = bridge.onNotify) === null || _bridge$onNotify2 === void 0 || _bridge$onNotify2.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
2332
+ return _context28.abrupt("return", {
2333
+ status: 'failed',
2334
+ reason: 'not_found'
2335
+ });
2336
+ case 14:
2337
+ _context28.next = 16;
2338
+ return applyGlobalScan({
2339
+ setOrderCustomer: function setOrderCustomer(customer) {
2340
+ return _this6.setOrderCustomer(customer);
2341
+ },
2342
+ getOrderCustomerSnapshot: function getOrderCustomerSnapshot() {
2343
+ return _this6.getOrderCustomerSnapshot();
2344
+ },
2345
+ getBusinessCode: function getBusinessCode() {
2346
+ var _this6$otherParams;
2347
+ return (_this6$otherParams = _this6.otherParams) === null || _this6$otherParams === void 0 ? void 0 : _this6$otherParams.businessCode;
2348
+ },
2349
+ buildAddProductCtx: function buildAddProductCtx(extra) {
2350
+ return _this6.buildAddProductCtx(extra);
2351
+ },
2352
+ decideAddProduct: function decideAddProduct(item, options) {
2353
+ return _this6.decideAddProduct(item, options);
2354
+ },
2355
+ decideAfterDetail: function decideAfterDetail(cacheItem, options) {
2356
+ return _this6.decideAfterDetail(cacheItem, options);
2357
+ },
2358
+ transformDetailToProductAndBooking: function transformDetailToProductAndBooking(input) {
2359
+ return _this6.transformDetailToProductAndBooking(input);
2360
+ },
2361
+ addProductToOrder: function addProductToOrder(product, booking) {
2362
+ return _this6.addProductToOrder(product, booking);
2363
+ }
2364
+ }, formatted, bridge);
2365
+ case 16:
2366
+ _result7 = _context28.sent;
2367
+ bridge === null || bridge === void 0 || (_bridge$refresh = bridge.refresh) === null || _bridge$refresh === void 0 || _bridge$refresh.call(bridge);
2368
+ return _context28.abrupt("return", _result7);
2369
+ case 21:
2370
+ _context28.prev = 21;
2371
+ _context28.t0 = _context28["catch"](4);
2372
+ console.error('[BookingTicket] handleGlobalScanCode failed', _context28.t0);
2373
+ bridge === null || bridge === void 0 || (_bridge$onNotify3 = bridge.onNotify) === null || _bridge$onNotify3 === void 0 || _bridge$onNotify3.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
2374
+ return _context28.abrupt("return", {
2375
+ status: 'failed',
2376
+ reason: 'not_found'
2377
+ });
2378
+ case 26:
2379
+ case "end":
2380
+ return _context28.stop();
2381
+ }
2382
+ }, _callee28, this, [[4, 21]]);
2383
+ }));
2384
+ function handleGlobalScanCode(_x18, _x19) {
2385
+ return _handleGlobalScanCode.apply(this, arguments);
2386
+ }
2387
+ return handleGlobalScanCode;
2388
+ }())
2389
+ }, {
2390
+ key: "resolveBestAddTimePlan",
2391
+ value: function resolveBestAddTimePlan(addTimeProducts, targetMinutes) {
2392
+ return _resolveBestAddTimePlan(addTimeProducts, targetMinutes);
2393
+ }
2394
+
2395
+ /**
2396
+ * 构造一条绑定到已有 booking 的加时商品行。
2397
+ *
2398
+ * @example
2399
+ * const line = this.buildAddTimeOrderLine({ product, product_add_schedule_time: 30 }, 'booking-1');
2400
+ */
2401
+ }, {
2402
+ key: "buildAddTimeOrderLine",
2403
+ value: function buildAddTimeOrderLine(input, bookingUid) {
2404
+ var _input$num, _product$id, _product$product_id, _ref13, _product$product_vari, _ref14, _product$variant_id, _product$original_pri, _ref15, _ref16, _product$option, _product$product_sku, _ref17, _ref18, _product$bundle, _product$id2;
2405
+ var product = input === null || input === void 0 ? void 0 : input.product;
2406
+ if (!product || _typeof(product) !== 'object') {
2407
+ throw new Error('[BookingTicket] addAddTimeProductToBooking: product 不能为空');
2408
+ }
2409
+ var quantity = normalizeAddTimeQuantity((_input$num = input.num) !== null && _input$num !== void 0 ? _input$num : product.num);
2410
+ var price = resolveAddTimeProductPrice(input.price, product);
2411
+ var addScheduleTime = resolveAddTimeScheduleMinutes(input.product_add_schedule_time, product);
2412
+ var payload = {
2413
+ id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : product.product_id,
2414
+ product_id: (_product$product_id = product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : product.id,
2415
+ product_variant_id: (_ref13 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : product.variant_id) !== null && _ref13 !== void 0 ? _ref13 : 0,
2416
+ variant_id: (_ref14 = (_product$variant_id = product.variant_id) !== null && _product$variant_id !== void 0 ? _product$variant_id : product.product_variant_id) !== null && _ref14 !== void 0 ? _ref14 : 0,
2417
+ quantity: quantity,
2418
+ num: quantity,
2419
+ price: price,
2420
+ selling_price: price,
2421
+ original_price: (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : price,
2422
+ line_total: price,
2423
+ total: price,
2424
+ product_sku: product.product_sku,
2425
+ option: (_ref15 = (_ref16 = (_product$option = product.option) !== null && _product$option !== void 0 ? _product$option : product.options) !== null && _ref16 !== void 0 ? _ref16 : (_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.option) !== null && _ref15 !== void 0 ? _ref15 : [],
2426
+ bundle: (_ref17 = (_ref18 = (_product$bundle = product.bundle) !== null && _product$bundle !== void 0 ? _product$bundle : product.bundles) !== null && _ref18 !== void 0 ? _ref18 : product.product_bundle) !== null && _ref17 !== void 0 ? _ref17 : []
2427
+ };
2428
+ var orderLine = this.transformBaseProductToOrderProduct({
2429
+ payload: payload,
2430
+ fallbackProductId: (_product$id2 = product.id) !== null && _product$id2 !== void 0 ? _product$id2 : product.product_id,
2431
+ sourceProduct: product,
2432
+ sourceItem: product
2433
+ });
2434
+ if (!orderLine) {
2435
+ throw new Error('[BookingTicket] addAddTimeProductToBooking: product transform failed');
2436
+ }
2437
+ var metadata = _objectSpread(_objectSpread(_objectSpread({}, orderLine.metadata || {}), addScheduleTime !== undefined ? {
2438
+ product_add_schedule_time: addScheduleTime
2439
+ } : {}), {}, {
2440
+ booking_uid: bookingUid
2441
+ });
2442
+ return _objectSpread(_objectSpread({}, orderLine), {}, {
2443
+ booking_uid: bookingUid,
2444
+ metadata: metadata
2445
+ });
2446
+ }
2447
+
2448
+ /**
2449
+ * 将加时商品作为独立商品行绑定到已有 booking。
2450
+ *
2451
+ * 与预约商品加车不同,本方法不会把当前 booking 作为 `addProductToOrder` 第二参数传入,
2452
+ * 避免 OrderModule 新建 booking 或重写已有 booking.product_uid。
2453
+ *
2454
+ * @example
2455
+ * await bookingTicket.addAddTimeProductToBooking({
2456
+ * booking,
2457
+ * product,
2458
+ * num: 1,
2459
+ * price: '10.00',
2460
+ * product_add_schedule_time: 30,
2461
+ * });
2462
+ */
2463
+ }, {
2464
+ key: "addAddTimeProductToBooking",
2465
+ value: (function () {
2466
+ var _addAddTimeProductToBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(input) {
2467
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2468
+ while (1) switch (_context29.prev = _context29.next) {
704
2469
  case 0:
705
- return _context10.abrupt("return", this.otherParams);
2470
+ return _context29.abrupt("return", this.addAddTimeProductsToBooking({
2471
+ booking: input.booking,
2472
+ products: [input],
2473
+ coveredMinutes: input.coveredMinutes,
2474
+ bookingPatch: input.bookingPatch
2475
+ }));
706
2476
  case 1:
707
2477
  case "end":
708
- return _context10.stop();
2478
+ return _context29.stop();
709
2479
  }
710
- }, _callee10, this);
2480
+ }, _callee29, this);
711
2481
  }));
712
- function getOtherParams() {
713
- return _getOtherParams.apply(this, arguments);
2482
+ function addAddTimeProductToBooking(_x20) {
2483
+ return _addAddTimeProductToBooking.apply(this, arguments);
714
2484
  }
715
- return getOtherParams;
2485
+ return addAddTimeProductToBooking;
716
2486
  }()
717
2487
  /**
718
- * 销毁模块
2488
+ * 批量将加时商品作为独立商品行绑定到已有 booking,并只触发一次购物车重算。
2489
+ *
2490
+ * @example
2491
+ * await bookingTicket.addAddTimeProductsToBooking({
2492
+ * booking,
2493
+ * products: [{ product, product_add_schedule_time: 30 }],
2494
+ * });
719
2495
  */
720
2496
  )
721
2497
  }, {
722
- key: "destroy",
723
- value: function destroy() {
724
- var _this$store$cart, _this$store$products, _this$store$accountLi, _this$store$customer, _this$store$order;
725
- (_this$store$cart = this.store.cart) === null || _this$store$cart === void 0 || _this$store$cart.destroy();
726
- (_this$store$products = this.store.products) === null || _this$store$products === void 0 || _this$store$products.destroy();
727
- (_this$store$accountLi = this.store.accountList) === null || _this$store$accountLi === void 0 || _this$store$accountLi.destroy();
728
- (_this$store$customer = this.store.customer) === null || _this$store$customer === void 0 || _this$store$customer.destroy();
729
- (_this$store$order = this.store.order) === null || _this$store$order === void 0 || _this$store$order.destroy();
730
- this.core.effects.offByModuleDestroy(this.name);
731
- this.core.unregisterModule(this);
732
- // 清除所有的监听
733
- this.scan.removeAllListeners();
734
- // 清除scan数据内存缓存
735
- scanCache.clear();
2498
+ key: "addAddTimeProductsToBooking",
2499
+ value: (function () {
2500
+ var _addAddTimeProductsToBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(input) {
2501
+ var _this7 = this,
2502
+ _input$bookingPatch;
2503
+ var bookingUid, orderLines, coveredMinutes, bookingTimePatch, result, _iterator2, _step2, line;
2504
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2505
+ while (1) switch (_context30.prev = _context30.next) {
2506
+ case 0:
2507
+ bookingUid = resolveBookingUidForAddTime(input === null || input === void 0 ? void 0 : input.booking);
2508
+ if (bookingUid) {
2509
+ _context30.next = 3;
2510
+ break;
2511
+ }
2512
+ throw new Error('[BookingTicket] addAddTimeProductToBooking: booking.metadata.unique_identification_number 缺失');
2513
+ case 3:
2514
+ orderLines = (input.products || []).map(function (line) {
2515
+ return {
2516
+ product: _this7.buildAddTimeOrderLine(line, bookingUid)
2517
+ };
2518
+ });
2519
+ if (this.store.order) {
2520
+ _context30.next = 6;
2521
+ break;
2522
+ }
2523
+ throw new Error('order 模块未初始化');
2524
+ case 6:
2525
+ coveredMinutes = normalizeCoveredMinutes(input.coveredMinutes);
2526
+ bookingTimePatch = (_input$bookingPatch = input.bookingPatch) !== null && _input$bookingPatch !== void 0 ? _input$bookingPatch : buildAddTimeBookingTimePatch(input.booking, coveredMinutes);
2527
+ if (bookingTimePatch) {
2528
+ this.store.order.updateOrderBooking({
2529
+ unique_identification_number: bookingUid,
2530
+ updates: bookingTimePatch
2531
+ });
2532
+ }
2533
+ if (!(typeof this.store.order.addProductsToOrder === 'function')) {
2534
+ _context30.next = 11;
2535
+ break;
2536
+ }
2537
+ return _context30.abrupt("return", this.store.order.addProductsToOrder(orderLines, {
2538
+ skipEditDiscountConfigRefresh: true,
2539
+ skipDiscountRecalculation: true
2540
+ }));
2541
+ case 11:
2542
+ result = [];
2543
+ _iterator2 = _createForOfIteratorHelper(orderLines);
2544
+ _context30.prev = 13;
2545
+ _iterator2.s();
2546
+ case 15:
2547
+ if ((_step2 = _iterator2.n()).done) {
2548
+ _context30.next = 29;
2549
+ break;
2550
+ }
2551
+ line = _step2.value;
2552
+ _context30.t0 = result.splice;
2553
+ _context30.t1 = result;
2554
+ _context30.t2 = [0, result.length];
2555
+ _context30.t3 = _toConsumableArray;
2556
+ _context30.next = 23;
2557
+ return this.addProductToOrder(line.product);
2558
+ case 23:
2559
+ _context30.t4 = _context30.sent;
2560
+ _context30.t5 = (0, _context30.t3)(_context30.t4);
2561
+ _context30.t6 = _context30.t2.concat.call(_context30.t2, _context30.t5);
2562
+ _context30.t0.apply.call(_context30.t0, _context30.t1, _context30.t6);
2563
+ case 27:
2564
+ _context30.next = 15;
2565
+ break;
2566
+ case 29:
2567
+ _context30.next = 34;
2568
+ break;
2569
+ case 31:
2570
+ _context30.prev = 31;
2571
+ _context30.t7 = _context30["catch"](13);
2572
+ _iterator2.e(_context30.t7);
2573
+ case 34:
2574
+ _context30.prev = 34;
2575
+ _iterator2.f();
2576
+ return _context30.finish(34);
2577
+ case 37:
2578
+ return _context30.abrupt("return", result);
2579
+ case 38:
2580
+ case "end":
2581
+ return _context30.stop();
2582
+ }
2583
+ }, _callee30, this, [[13, 31, 34, 37]]);
2584
+ }));
2585
+ function addAddTimeProductsToBooking(_x21) {
2586
+ return _addAddTimeProductsToBooking.apply(this, arguments);
2587
+ }
2588
+ return addAddTimeProductsToBooking;
2589
+ }())
2590
+ }, {
2591
+ key: "setOtherParams",
2592
+ value: function () {
2593
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
2594
+ var _ref19,
2595
+ _ref19$cover,
2596
+ cover,
2597
+ _args31 = arguments;
2598
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2599
+ while (1) switch (_context31.prev = _context31.next) {
2600
+ case 0:
2601
+ _ref19 = _args31.length > 1 && _args31[1] !== undefined ? _args31[1] : {}, _ref19$cover = _ref19.cover, cover = _ref19$cover === void 0 ? false : _ref19$cover;
2602
+ _get(_getPrototypeOf(BookingTicketImpl.prototype), "setOtherParams", this).call(this, params, {
2603
+ cover: cover
2604
+ });
2605
+ if (!(params !== null && params !== void 0 && params.businessCode)) {
2606
+ _context31.next = 5;
2607
+ break;
2608
+ }
2609
+ _context31.next = 5;
2610
+ return this.configureIdGeneratorFromOpenData();
2611
+ case 5:
2612
+ case "end":
2613
+ return _context31.stop();
2614
+ }
2615
+ }, _callee31, this);
2616
+ }));
2617
+ function setOtherParams(_x22) {
2618
+ return _setOtherParams.apply(this, arguments);
2619
+ }
2620
+ return setOtherParams;
2621
+ }()
2622
+ }, {
2623
+ key: "getDeviceTaskPlugin",
2624
+ value: function getDeviceTaskPlugin() {
2625
+ var _app$getApp;
2626
+ var app = this.core.getPlugin('app');
2627
+ return (app === null || app === void 0 || (_app$getApp = app.getApp()) === null || _app$getApp === void 0 ? void 0 : _app$getApp.getPlugin('deviceTask')) || null;
736
2628
  }
2629
+
2630
+ // 打印手环,单个或批量都可以
2631
+ }, {
2632
+ key: "handlePrintWristband",
2633
+ value: function () {
2634
+ var _handlePrintWristband = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
2635
+ var _this$getOrderIdentit;
2636
+ var deviceTask, deviceId, idempotencyKey;
2637
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2638
+ while (1) switch (_context32.prev = _context32.next) {
2639
+ case 0:
2640
+ deviceTask = this.getDeviceTaskPlugin();
2641
+ if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
2642
+ _context32.next = 4;
2643
+ break;
2644
+ }
2645
+ this.logger.addLog({
2646
+ type: 'info',
2647
+ title: '[BookingTicket] handlePrintWristband: deviceTask.dispatch 不可用',
2648
+ metadata: {
2649
+ voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
2650
+ }
2651
+ });
2652
+ return _context32.abrupt("return");
2653
+ case 4:
2654
+ this.logger.addLog({
2655
+ type: 'info',
2656
+ title: '[BookingTicket] handlePrintWristband',
2657
+ metadata: {
2658
+ voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
2659
+ }
2660
+ });
2661
+ _context32.next = 7;
2662
+ return this.getShortNumberOrDeviceId();
2663
+ case 7:
2664
+ deviceId = _context32.sent;
2665
+ idempotencyKey = createUuidV4();
2666
+ deviceTask.dispatch({
2667
+ action: 'print_all',
2668
+ device_id: deviceId,
2669
+ payload: {
2670
+ type: 'WRISTBAND',
2671
+ data: {
2672
+ order_id: (_this$getOrderIdentit = this.getOrderIdentity()) === null || _this$getOrderIdentit === void 0 ? void 0 : _this$getOrderIdentit.orderId,
2673
+ voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
2674
+ }
2675
+ },
2676
+ idempotency_key: idempotencyKey,
2677
+ name: 'PRINT_WRISTBAND',
2678
+ source: 'bookingTicket',
2679
+ source_type: 'handlePrintWristband',
2680
+ source_id: idempotencyKey
2681
+ });
2682
+ case 10:
2683
+ case "end":
2684
+ return _context32.stop();
2685
+ }
2686
+ }, _callee32, this);
2687
+ }));
2688
+ function handlePrintWristband(_x23) {
2689
+ return _handlePrintWristband.apply(this, arguments);
2690
+ }
2691
+ return handlePrintWristband;
2692
+ }() // 触发核销
2693
+ }, {
2694
+ key: "handleRedeem",
2695
+ value: function () {
2696
+ var _handleRedeem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
2697
+ var _this$store$order5, _this$store$order5$ge, _this$store$order6, _ref20, _tempOrder$order_id2;
2698
+ var voucherIds, status, voucherIdSet, tempOrder, vouchers, hasUpdatedVoucher, nextVouchers, identity, externalSaleNumber, orderId, orderLookup;
2699
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2700
+ while (1) switch (_context33.prev = _context33.next) {
2701
+ case 0:
2702
+ voucherIds = Array.isArray(params.voucher_ids) ? params.voucher_ids : [];
2703
+ status = params.is_checkin ? 'used' : 'unused';
2704
+ this.logger.addLog({
2705
+ type: 'info',
2706
+ title: '[BookingTicket] handleRedeem',
2707
+ metadata: {
2708
+ voucher_ids: voucherIds,
2709
+ status: status
2710
+ }
2711
+ });
2712
+ voucherIdSet = new Set(voucherIds);
2713
+ tempOrder = (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 || (_this$store$order5$ge = _this$store$order5.getTempOrder) === null || _this$store$order5$ge === void 0 ? void 0 : _this$store$order5$ge.call(_this$store$order5);
2714
+ vouchers = (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.vouchers) || ((_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getVouchers()) || [];
2715
+ hasUpdatedVoucher = false;
2716
+ nextVouchers = vouchers.map(function (voucher) {
2717
+ if (!voucherIdSet.has(voucher.voucher_id)) return voucher;
2718
+ hasUpdatedVoucher = true;
2719
+ return _objectSpread(_objectSpread({}, voucher), {}, {
2720
+ status: status
2721
+ });
2722
+ });
2723
+ if (!(tempOrder && hasUpdatedVoucher)) {
2724
+ _context33.next = 11;
2725
+ break;
2726
+ }
2727
+ _context33.next = 11;
2728
+ return this.replaceTempOrder(_objectSpread(_objectSpread({}, tempOrder), {}, {
2729
+ vouchers: nextVouchers
2730
+ }));
2731
+ case 11:
2732
+ this.core.effects.emit("".concat(this.name, ":onVouchersChange"), {});
2733
+ if (!(voucherIds.length === 0)) {
2734
+ _context33.next = 14;
2735
+ break;
2736
+ }
2737
+ return _context33.abrupt("return", {
2738
+ code: 200,
2739
+ status: true,
2740
+ message: '',
2741
+ data: []
2742
+ });
2743
+ case 14:
2744
+ identity = this.getOrderIdentity();
2745
+ externalSaleNumber = (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.external_sale_number) || (identity === null || identity === void 0 ? void 0 : identity.externalSaleNumber) || undefined;
2746
+ orderId = (_ref20 = (_tempOrder$order_id2 = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) !== null && _tempOrder$order_id2 !== void 0 ? _tempOrder$order_id2 : identity === null || identity === void 0 ? void 0 : identity.orderId) !== null && _ref20 !== void 0 ? _ref20 : undefined;
2747
+ orderLookup = externalSaleNumber || orderId || (identity === null || identity === void 0 ? void 0 : identity.orderNumber) || (identity === null || identity === void 0 ? void 0 : identity.shopOrderNumber) || (identity === null || identity === void 0 ? void 0 : identity.shopFullOrderNumber) || undefined;
2748
+ return _context33.abrupt("return", this.request.post('/machinecode/batch', {
2749
+ ids: voucherIds,
2750
+ status: status,
2751
+ order_lookup: orderLookup,
2752
+ order_id: orderId,
2753
+ external_sale_number: externalSaleNumber
2754
+ }, {
2755
+ osServer: true
2756
+ }));
2757
+ case 19:
2758
+ case "end":
2759
+ return _context33.stop();
2760
+ }
2761
+ }, _callee33, this);
2762
+ }));
2763
+ function handleRedeem(_x24) {
2764
+ return _handleRedeem.apply(this, arguments);
2765
+ }
2766
+ return handleRedeem;
2767
+ }()
2768
+ /**
2769
+ * 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
2770
+ * 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
2771
+ */
2772
+ }, {
2773
+ key: "destroy",
2774
+ value: (function () {
2775
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
2776
+ var _this$scan;
2777
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2778
+ while (1) switch (_context34.prev = _context34.next) {
2779
+ case 0:
2780
+ _context34.next = 2;
2781
+ return _get(_getPrototypeOf(BookingTicketImpl.prototype), "destroy", this).call(this);
2782
+ case 2:
2783
+ try {
2784
+ (_this$scan = this.scan) === null || _this$scan === void 0 || _this$scan.removeAllListeners();
2785
+ } catch (error) {
2786
+ console.warn('[BookingTicket] scan removeAllListeners 失败', error);
2787
+ }
2788
+ scanCache.clear();
2789
+ case 4:
2790
+ case "end":
2791
+ return _context34.stop();
2792
+ }
2793
+ }, _callee34, this);
2794
+ }));
2795
+ function destroy() {
2796
+ return _destroy.apply(this, arguments);
2797
+ }
2798
+ return destroy;
2799
+ }())
737
2800
  }]);
738
2801
  return BookingTicketImpl;
739
- }(BaseModule);
2802
+ }(BaseSalesImpl);
740
2803
 
741
2804
  // 导出相关类型和实现
742
2805
  export * from "./types";