@pisell/pisellos 2.2.244 → 2.2.245

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (317) hide show
  1. package/dist/model/strategy/adapter/promotion/evaluator.js +3 -2
  2. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  3. package/dist/model/strategy/adapter/walletPass/utils.js +7 -4
  4. package/dist/modules/BookingContext/index.d.ts +48 -0
  5. package/dist/modules/BookingContext/index.js +566 -0
  6. package/dist/modules/BookingContext/types.d.ts +102 -0
  7. package/dist/modules/BookingContext/types.js +51 -0
  8. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  9. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +284 -0
  10. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  11. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +145 -0
  12. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
  13. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +218 -0
  14. package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
  15. package/dist/modules/BookingContext/utils/flexible.js +56 -0
  16. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  17. package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
  18. package/dist/modules/BookingContext/utils/index.d.ts +11 -0
  19. package/dist/modules/BookingContext/utils/index.js +11 -0
  20. package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
  21. package/dist/modules/BookingContext/utils/noResource.js +77 -0
  22. package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
  23. package/dist/modules/BookingContext/utils/orderLineDisplay.js +36 -0
  24. package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
  25. package/dist/modules/BookingContext/utils/productExtend.js +339 -0
  26. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  27. package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
  28. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  29. package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
  30. package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
  31. package/dist/modules/BookingContext/utils/resources.js +486 -0
  32. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  33. package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
  34. package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  35. package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
  36. package/dist/modules/Cart/utils/cartProduct.js +24 -3
  37. package/dist/modules/Cart/utils/changePrice.js +11 -11
  38. package/dist/modules/Customer/index.d.ts +20 -0
  39. package/dist/modules/Customer/index.js +172 -83
  40. package/dist/modules/Customer/types.d.ts +2 -0
  41. package/dist/modules/Discount/index.d.ts +1 -1
  42. package/dist/modules/Discount/index.js +13 -6
  43. package/dist/modules/Discount/types.d.ts +1 -0
  44. package/dist/modules/OpenData/index.d.ts +8 -0
  45. package/dist/modules/OpenData/index.js +37 -17
  46. package/dist/modules/Order/index.d.ts +275 -19
  47. package/dist/modules/Order/index.js +3493 -809
  48. package/dist/modules/Order/types.d.ts +286 -31
  49. package/dist/modules/Order/types.js +38 -0
  50. package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  51. package/dist/modules/Order/utils/manualProductDiscount.js +210 -0
  52. package/dist/modules/Order/utils.d.ts +147 -5
  53. package/dist/modules/Order/utils.js +750 -104
  54. package/dist/modules/Payment/index.d.ts +10 -13
  55. package/dist/modules/Payment/index.js +467 -837
  56. package/dist/modules/Payment/types.d.ts +2 -0
  57. package/dist/modules/Payment/utils.js +2 -1
  58. package/dist/modules/Payment/walletpass.js +41 -25
  59. package/dist/modules/ProductList/index.d.ts +16 -12
  60. package/dist/modules/ProductList/index.js +133 -59
  61. package/dist/modules/ProductList/types.d.ts +14 -0
  62. package/dist/modules/Quotation/index.d.ts +0 -1
  63. package/dist/modules/Quotation/index.js +25 -22
  64. package/dist/modules/Rules/index.d.ts +4 -0
  65. package/dist/modules/Rules/index.js +97 -70
  66. package/dist/modules/Rules/types.d.ts +1 -0
  67. package/dist/modules/SalesSummary/index.d.ts +8 -25
  68. package/dist/modules/SalesSummary/index.js +86 -35
  69. package/dist/modules/SalesSummary/types.d.ts +4 -1
  70. package/dist/modules/SalesSummary/utils.d.ts +2 -25
  71. package/dist/modules/SalesSummary/utils.js +794 -162
  72. package/dist/modules/Schedule/index.d.ts +7 -0
  73. package/dist/modules/Schedule/index.js +24 -2
  74. package/dist/modules/Summary/index.js +4 -3
  75. package/dist/modules/SurchargeList/index.d.ts +16 -0
  76. package/dist/modules/SurchargeList/index.js +162 -0
  77. package/dist/modules/SurchargeList/types.d.ts +11 -0
  78. package/dist/modules/SurchargeList/types.js +1 -0
  79. package/dist/modules/index.d.ts +2 -0
  80. package/dist/modules/index.js +3 -1
  81. package/dist/plugins/request.d.ts +1 -0
  82. package/dist/server/index.d.ts +204 -1
  83. package/dist/server/index.js +3654 -922
  84. package/dist/server/modules/index.d.ts +2 -0
  85. package/dist/server/modules/index.js +2 -0
  86. package/dist/server/modules/order/index.d.ts +120 -3
  87. package/dist/server/modules/order/index.js +1758 -448
  88. package/dist/server/modules/order/types.d.ts +32 -3
  89. package/dist/server/modules/order/types.js +8 -0
  90. package/dist/server/modules/order/utils/filterBookings.js +26 -3
  91. package/dist/server/modules/order/utils/filterOrders.js +23 -8
  92. package/dist/server/modules/payment/index.d.ts +28 -0
  93. package/dist/server/modules/payment/index.js +305 -0
  94. package/dist/server/modules/payment/types.d.ts +9 -0
  95. package/dist/server/modules/payment/types.js +1 -0
  96. package/dist/server/modules/products/index.d.ts +34 -7
  97. package/dist/server/modules/products/index.js +631 -317
  98. package/dist/server/modules/resource/index.d.ts +2 -0
  99. package/dist/server/modules/resource/index.js +29 -3
  100. package/dist/server/modules/schedule/index.d.ts +4 -4
  101. package/dist/server/modules/schedule/index.js +111 -88
  102. package/dist/server/test.json +713 -0
  103. package/dist/server/utils/small-ticket.d.ts +71 -0
  104. package/dist/server/utils/small-ticket.js +840 -0
  105. package/dist/solution/BaseSales/index.d.ts +133 -10
  106. package/dist/solution/BaseSales/index.js +1950 -447
  107. package/dist/solution/BaseSales/types.d.ts +82 -6
  108. package/dist/solution/BaseSales/types.js +5 -4
  109. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
  110. package/dist/solution/BaseSales/utils/cartPromotion.js +1438 -0
  111. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  112. package/dist/solution/BaseSales/utils/quotationPrice.js +237 -0
  113. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  114. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +105 -24
  115. package/dist/solution/BaseSales/utils.d.ts +1 -1
  116. package/dist/solution/BaseSales/utils.js +62 -21
  117. package/dist/solution/BookingByStep/index.d.ts +1 -1
  118. package/dist/solution/BookingTicket/index.d.ts +271 -11
  119. package/dist/solution/BookingTicket/index.js +1777 -242
  120. package/dist/solution/BookingTicket/types.d.ts +118 -1
  121. package/dist/solution/BookingTicket/types.js +41 -2
  122. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
  123. package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
  124. package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
  125. package/dist/solution/BookingTicket/utils/addTimeAvailability.js +95 -0
  126. package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +40 -0
  127. package/dist/solution/BookingTicket/utils/bookingStatus.js +70 -0
  128. package/dist/solution/BookingTicket/utils/cartView.d.ts +9 -1
  129. package/dist/solution/BookingTicket/utils/cartView.js +94 -7
  130. package/dist/solution/BookingTicket/utils/exampleData.d.ts +123 -0
  131. package/dist/solution/BookingTicket/utils/exampleData.js +183 -0
  132. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
  133. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +438 -0
  134. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
  135. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +400 -0
  136. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
  137. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +56 -0
  138. package/dist/solution/BookingTicket/utils/scan/index.d.ts +5 -0
  139. package/dist/solution/BookingTicket/utils/scan/index.js +20 -8
  140. package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
  141. package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +150 -0
  142. package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
  143. package/dist/solution/BookingTicket/utils/sessionCatalogStale.js +78 -0
  144. package/dist/solution/Checkout/index.d.ts +1 -0
  145. package/dist/solution/Checkout/index.js +10 -9
  146. package/dist/solution/RegisterAndLogin/config.js +2 -10
  147. package/dist/solution/ScanOrder/index.d.ts +9 -3
  148. package/dist/solution/ScanOrder/index.js +241 -134
  149. package/dist/solution/ScanOrder/types.d.ts +9 -5
  150. package/dist/solution/ScanOrder/types.js +2 -3
  151. package/dist/solution/ScanOrder/utils.d.ts +1 -1
  152. package/dist/solution/ScanOrder/utils.js +84 -22
  153. package/dist/solution/VenueBooking/index.d.ts +5 -2
  154. package/dist/solution/VenueBooking/index.js +110 -59
  155. package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -2
  156. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  157. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
  158. package/dist/types/index.d.ts +10 -0
  159. package/lib/model/strategy/adapter/promotion/evaluator.js +2 -1
  160. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  161. package/lib/model/strategy/adapter/walletPass/utils.js +3 -2
  162. package/lib/modules/BookingContext/index.d.ts +48 -0
  163. package/lib/modules/BookingContext/index.js +368 -0
  164. package/lib/modules/BookingContext/types.d.ts +102 -0
  165. package/lib/modules/BookingContext/types.js +34 -0
  166. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  167. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +276 -0
  168. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  169. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +151 -0
  170. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
  171. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +201 -0
  172. package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
  173. package/lib/modules/BookingContext/utils/flexible.js +80 -0
  174. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  175. package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
  176. package/lib/modules/BookingContext/utils/index.d.ts +11 -0
  177. package/lib/modules/BookingContext/utils/index.js +43 -0
  178. package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
  179. package/lib/modules/BookingContext/utils/noResource.js +90 -0
  180. package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
  181. package/lib/modules/BookingContext/utils/orderLineDisplay.js +56 -0
  182. package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
  183. package/lib/modules/BookingContext/utils/productExtend.js +283 -0
  184. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  185. package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
  186. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  187. package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
  188. package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
  189. package/lib/modules/BookingContext/utils/resources.js +377 -0
  190. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  191. package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
  192. package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  193. package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
  194. package/lib/modules/Cart/utils/cartProduct.js +20 -3
  195. package/lib/modules/Cart/utils/changePrice.js +12 -20
  196. package/lib/modules/Customer/index.d.ts +20 -0
  197. package/lib/modules/Customer/index.js +64 -11
  198. package/lib/modules/Customer/types.d.ts +2 -0
  199. package/lib/modules/Discount/index.d.ts +1 -1
  200. package/lib/modules/Discount/index.js +9 -1
  201. package/lib/modules/Discount/types.d.ts +1 -0
  202. package/lib/modules/OpenData/index.d.ts +8 -0
  203. package/lib/modules/OpenData/index.js +19 -5
  204. package/lib/modules/Order/index.d.ts +275 -19
  205. package/lib/modules/Order/index.js +2245 -336
  206. package/lib/modules/Order/types.d.ts +286 -31
  207. package/lib/modules/Order/types.js +1 -0
  208. package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  209. package/lib/modules/Order/utils/manualProductDiscount.js +206 -0
  210. package/lib/modules/Order/utils.d.ts +147 -5
  211. package/lib/modules/Order/utils.js +615 -46
  212. package/lib/modules/Payment/index.d.ts +10 -13
  213. package/lib/modules/Payment/index.js +18 -150
  214. package/lib/modules/Payment/types.d.ts +2 -0
  215. package/lib/modules/Payment/utils.js +2 -1
  216. package/lib/modules/Payment/walletpass.js +16 -3
  217. package/lib/modules/ProductList/index.d.ts +16 -12
  218. package/lib/modules/ProductList/index.js +41 -4
  219. package/lib/modules/ProductList/types.d.ts +14 -0
  220. package/lib/modules/Quotation/index.d.ts +0 -1
  221. package/lib/modules/Quotation/index.js +19 -16
  222. package/lib/modules/Rules/index.d.ts +4 -0
  223. package/lib/modules/Rules/index.js +137 -120
  224. package/lib/modules/Rules/types.d.ts +1 -0
  225. package/lib/modules/SalesSummary/index.d.ts +8 -25
  226. package/lib/modules/SalesSummary/index.js +30 -4
  227. package/lib/modules/SalesSummary/types.d.ts +4 -1
  228. package/lib/modules/SalesSummary/utils.d.ts +2 -25
  229. package/lib/modules/SalesSummary/utils.js +645 -91
  230. package/lib/modules/Schedule/index.d.ts +7 -0
  231. package/lib/modules/Schedule/index.js +17 -1
  232. package/lib/modules/Summary/index.js +5 -4
  233. package/lib/modules/SurchargeList/index.d.ts +16 -0
  234. package/lib/modules/SurchargeList/index.js +89 -0
  235. package/lib/modules/SurchargeList/types.d.ts +11 -0
  236. package/lib/modules/SurchargeList/types.js +17 -0
  237. package/lib/modules/index.d.ts +2 -0
  238. package/lib/modules/index.js +5 -1
  239. package/lib/plugins/request.d.ts +1 -0
  240. package/lib/server/index.d.ts +204 -1
  241. package/lib/server/index.js +1891 -59
  242. package/lib/server/modules/index.d.ts +2 -0
  243. package/lib/server/modules/index.js +3 -0
  244. package/lib/server/modules/order/index.d.ts +120 -3
  245. package/lib/server/modules/order/index.js +883 -94
  246. package/lib/server/modules/order/types.d.ts +32 -3
  247. package/lib/server/modules/order/utils/filterBookings.js +24 -5
  248. package/lib/server/modules/order/utils/filterOrders.js +15 -6
  249. package/lib/server/modules/payment/index.d.ts +28 -0
  250. package/lib/server/modules/payment/index.js +192 -0
  251. package/lib/server/modules/payment/types.d.ts +9 -0
  252. package/lib/server/modules/payment/types.js +17 -0
  253. package/lib/server/modules/products/index.d.ts +34 -7
  254. package/lib/server/modules/products/index.js +189 -54
  255. package/lib/server/modules/resource/index.d.ts +2 -0
  256. package/lib/server/modules/resource/index.js +27 -3
  257. package/lib/server/modules/schedule/index.d.ts +4 -4
  258. package/lib/server/modules/schedule/index.js +47 -40
  259. package/lib/server/test.json +713 -0
  260. package/lib/server/utils/small-ticket.d.ts +71 -0
  261. package/lib/server/utils/small-ticket.js +800 -0
  262. package/lib/solution/BaseSales/index.d.ts +133 -10
  263. package/lib/solution/BaseSales/index.js +1111 -63
  264. package/lib/solution/BaseSales/types.d.ts +82 -6
  265. package/lib/solution/BaseSales/types.js +3 -1
  266. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
  267. package/lib/solution/BaseSales/utils/cartPromotion.js +992 -0
  268. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  269. package/lib/solution/BaseSales/utils/quotationPrice.js +277 -0
  270. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  271. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +106 -18
  272. package/lib/solution/BaseSales/utils.d.ts +1 -1
  273. package/lib/solution/BaseSales/utils.js +54 -10
  274. package/lib/solution/BookingByStep/index.d.ts +1 -1
  275. package/lib/solution/BookingTicket/index.d.ts +271 -11
  276. package/lib/solution/BookingTicket/index.js +922 -29
  277. package/lib/solution/BookingTicket/types.d.ts +118 -1
  278. package/lib/solution/BookingTicket/types.js +11 -0
  279. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
  280. package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
  281. package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
  282. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +125 -0
  283. package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +40 -0
  284. package/lib/solution/BookingTicket/utils/bookingStatus.js +44 -2
  285. package/lib/solution/BookingTicket/utils/cartView.d.ts +9 -1
  286. package/lib/solution/BookingTicket/utils/cartView.js +61 -6
  287. package/lib/solution/BookingTicket/utils/exampleData.d.ts +123 -0
  288. package/lib/solution/BookingTicket/utils/exampleData.js +0 -0
  289. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
  290. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +254 -0
  291. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
  292. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +169 -0
  293. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
  294. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +51 -0
  295. package/lib/solution/BookingTicket/utils/scan/index.d.ts +5 -0
  296. package/lib/solution/BookingTicket/utils/scan/index.js +17 -3
  297. package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
  298. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +127 -0
  299. package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
  300. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +85 -0
  301. package/lib/solution/Checkout/index.d.ts +1 -0
  302. package/lib/solution/Checkout/index.js +1 -2
  303. package/lib/solution/RegisterAndLogin/config.js +2 -10
  304. package/lib/solution/ScanOrder/index.d.ts +9 -3
  305. package/lib/solution/ScanOrder/index.js +153 -70
  306. package/lib/solution/ScanOrder/types.d.ts +9 -5
  307. package/lib/solution/ScanOrder/utils.d.ts +1 -1
  308. package/lib/solution/ScanOrder/utils.js +83 -17
  309. package/lib/solution/VenueBooking/index.d.ts +5 -2
  310. package/lib/solution/VenueBooking/index.js +54 -17
  311. package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -2
  312. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  313. package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
  314. package/lib/types/index.d.ts +10 -0
  315. package/package.json +1 -1
  316. package/dist/solution/Checkout/appointmentDemo.json +0 -1
  317. package/lib/solution/Checkout/appointmentDemo.json +0 -1
@@ -1,8 +1,8 @@
1
1
  var _excluded = ["id"],
2
- _excluded2 = ["product_id"];
2
+ _excluded2 = ["product_id"],
3
+ _excluded3 = ["product_id"];
4
+ 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; } } }; }
3
5
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- 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; }
5
- 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; }
6
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
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; }
8
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; }
@@ -26,17 +26,134 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
26
26
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
27
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; } }
28
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; }
29
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; }
30
32
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
31
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); }
34
+ import dayjs from 'dayjs';
32
35
  import { createBookingTicketModule } from "./types";
36
+ import { getProductExtend as getProductExtendUtil, getResourceByIds as getResourceByIdsUtil, getResourceErrors as getResourceErrorsUtil, derivePresetStartTimeFromDate } from "../../modules/BookingContext";
33
37
  import { BaseSalesImpl } from "../BaseSales";
34
38
  import Scan from "./utils/scan";
35
39
  import { formatOrderCustomerPatch } from "./utils/orderCustomer";
36
40
  import { handleGlobalScan, handleCustomerScan, handleUniversalScan } from "./utils/scan/handleScan";
37
41
  import scanCache from "./utils/scan/scanCache";
42
+ import { formatGlobalScanResult } from "./utils/scan/formatGlobalScan";
43
+ import { applyGlobalScan } from "./utils/scan/applyGlobalScan";
38
44
  import { buildCartView } from "./utils/cartView";
39
- import { applyBookingsStatus, resolveScheduleId, restoreBookingsStatus } from "./utils/bookingStatus";
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
+ var OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow'];
53
+ var OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
54
+
55
+ /**
56
+ * 读取已有 booking 的协议唯一值,用于加时商品行绑定原预约。
57
+ *
58
+ * @example
59
+ * const bookingUid = resolveBookingUidForAddTime(booking);
60
+ */
61
+ function resolveBookingUidForAddTime(booking) {
62
+ var _booking$metadata;
63
+ var uid = booking === null || booking === void 0 || (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.unique_identification_number;
64
+ return uid === undefined || uid === null ? '' : String(uid);
65
+ }
66
+
67
+ /**
68
+ * 规范化加车数量,避免非法值进入 OrderModule。
69
+ *
70
+ * @example
71
+ * const quantity = normalizeAddTimeQuantity(product.num);
72
+ */
73
+ function normalizeAddTimeQuantity(value) {
74
+ var parsed = Math.floor(Number(value));
75
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : 1;
76
+ }
77
+
78
+ /**
79
+ * 解析加时时长,优先使用显式入参,其次回退商品字段。
80
+ *
81
+ * @example
82
+ * const minutes = resolveAddTimeScheduleMinutes(input.product_add_schedule_time, product);
83
+ */
84
+ function resolveAddTimeScheduleMinutes(explicitValue, product) {
85
+ var raw = explicitValue !== null && explicitValue !== void 0 ? explicitValue : product === null || product === void 0 ? void 0 : product.product_add_schedule_time;
86
+ if (raw === undefined || raw === null || raw === '') return undefined;
87
+ var parsed = Number(raw);
88
+ return Number.isFinite(parsed) ? parsed : undefined;
89
+ }
90
+
91
+ /**
92
+ * 计算加时商品行价格字段,保持 `price` 与 `selling_price` 输入口径一致。
93
+ *
94
+ * @example
95
+ * const price = resolveAddTimeProductPrice(input.price, product);
96
+ */
97
+ function resolveAddTimeProductPrice(explicitValue, product) {
98
+ var _ref, _ref2;
99
+ 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;
100
+ }
101
+
102
+ /**
103
+ * 规范化加时覆盖分钟数。
104
+ *
105
+ * @example
106
+ * const minutes = normalizeCoveredMinutes(input.coveredMinutes);
107
+ */
108
+ function normalizeCoveredMinutes(value) {
109
+ var parsed = Math.ceil(Number(value));
110
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : 0;
111
+ }
112
+
113
+ /**
114
+ * 计算 booking 加时后的结束时间与时长。
115
+ *
116
+ * @example
117
+ * const updates = buildAddTimeBookingTimePatch(booking, 30);
118
+ */
119
+ function buildAddTimeBookingTimePatch(booking, coveredMinutes) {
120
+ if (coveredMinutes <= 0) return null;
121
+ var endDate = booking === null || booking === void 0 ? void 0 : booking.end_date;
122
+ var endTime = booking === null || booking === void 0 ? void 0 : booking.end_time;
123
+ if (!endDate || !endTime) {
124
+ throw new Error('[BookingTicket] addAddTimeProductsToBooking: booking.end_date/end_time 缺失');
125
+ }
126
+ var currentEnd = dayjs("".concat(endDate, " ").concat(endTime));
127
+ if (!currentEnd.isValid()) {
128
+ throw new Error('[BookingTicket] addAddTimeProductsToBooking: booking.end_date/end_time 无效');
129
+ }
130
+ var nextEnd = currentEnd.add(coveredMinutes, 'minute');
131
+ var currentDuration = Number(booking === null || booking === void 0 ? void 0 : booking.duration);
132
+ var duration = Number.isFinite(currentDuration) ? currentDuration + coveredMinutes : coveredMinutes;
133
+ if (booking !== null && booking !== void 0 && booking.start_date && booking !== null && booking !== void 0 && booking.start_time) {
134
+ var start = dayjs("".concat(booking.start_date, " ").concat(booking.start_time));
135
+ if (start.isValid()) {
136
+ var diffMinutes = nextEnd.diff(start, 'minute');
137
+ duration = diffMinutes > 0 ? diffMinutes : duration;
138
+ }
139
+ }
140
+ return {
141
+ end_date: nextEnd.format('YYYY-MM-DD'),
142
+ end_time: nextEnd.format('HH:mm'),
143
+ duration: duration
144
+ };
145
+ }
146
+ function withProductOptionString(cacheItem) {
147
+ var _cacheItem$_extend;
148
+ var productOptionString = buildProductOptionStringFromOrderLine(cacheItem);
149
+ if (!productOptionString) return cacheItem;
150
+ return _objectSpread(_objectSpread({}, cacheItem), {}, {
151
+ product_option_string: (cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.product_option_string) || productOptionString,
152
+ _extend: _objectSpread(_objectSpread({}, (cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem._extend) || {}), {}, {
153
+ 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
154
+ })
155
+ });
156
+ }
40
157
  export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
41
158
  _inherits(BookingTicketImpl, _BaseSalesImpl);
42
159
  var _super = _createSuper(BookingTicketImpl);
@@ -57,16 +174,28 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
57
174
  _defineProperty(_assertThisInitialized(_this), "platform", void 0);
58
175
  _defineProperty(_assertThisInitialized(_this), "scan", void 0);
59
176
  _defineProperty(_assertThisInitialized(_this), "productCatalog", []);
177
+ _defineProperty(_assertThisInitialized(_this), "addTimeProductsCatalog", []);
178
+ _defineProperty(_assertThisInitialized(_this), "orderCustomerDiscountRefreshInFlight", null);
179
+ _defineProperty(_assertThisInitialized(_this), "orderCustomerDiscountRefreshCustomerId", null);
180
+ _defineProperty(_assertThisInitialized(_this), "loadOpenDataConfigInFlight", null);
60
181
  return _this;
61
182
  }
62
183
  _createClass(BookingTicketImpl, [{
63
184
  key: "getRegisteredModuleNames",
64
185
  value:
65
186
  /**
66
- * 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer。
187
+ * 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer + bookingContext
188
+ * bookingContext 是 SalesSdk 加车下沉所需的「预约 UI 上下文」(bookingConfig / resourcesOrigin / date)。
67
189
  */
68
190
  function getRegisteredModuleNames() {
69
- return [].concat(_toConsumableArray(_get(_getPrototypeOf(BookingTicketImpl.prototype), "getRegisteredModuleNames", this).call(this)), ['customer']);
191
+ return [].concat(_toConsumableArray(_get(_getPrototypeOf(BookingTicketImpl.prototype), "getRegisteredModuleNames", this).call(this)), ['customer', 'bookingContext', 'openData']);
192
+ }
193
+ }, {
194
+ key: "getSubmitOrderSalesChannel",
195
+ value: function getSubmitOrderSalesChannel() {
196
+ var _this$core, _this$core$getChannel;
197
+ 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);
198
+ return !channel || channel === 'system' ? 'pos' : channel;
70
199
  }
71
200
 
72
201
  /**
@@ -91,7 +220,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
91
220
  while (1) switch (_context.prev = _context.next) {
92
221
  case 0:
93
222
  options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
94
- this.scan = new Scan(this, 'BOOKING_TICKET_SCAN');
223
+ this.scan = new Scan(this, "BOOKING_TICKET_SCAN:".concat(this.name));
95
224
  _context.next = 4;
96
225
  return _get(_getPrototypeOf(BookingTicketImpl.prototype), "initialize", this).call(this, core, options);
97
226
  case 4:
@@ -102,8 +231,11 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
102
231
  throw new Error('bookingTicket解决方案需要 request 插件支持');
103
232
  case 6:
104
233
  this.platform = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.platform;
234
+ _context.next = 9;
235
+ return this.configureIdGeneratorFromOpenData();
236
+ case 9:
105
237
  console.log('[BookingTicket] 初始化完成');
106
- case 8:
238
+ case 10:
107
239
  case "end":
108
240
  return _context.stop();
109
241
  }
@@ -114,6 +246,246 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
114
246
  }
115
247
  return initialize;
116
248
  }()
249
+ }, {
250
+ key: "getBookingTicketBusinessCode",
251
+ value: function getBookingTicketBusinessCode() {
252
+ var _this$otherParams$bus, _this$otherParams2, _this$otherParams3;
253
+ 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;
254
+ if (businessCode === undefined || businessCode === null) return null;
255
+ var normalized = String(businessCode).trim();
256
+ return normalized || null;
257
+ }
258
+ }, {
259
+ key: "getIdGeneratorPlugin",
260
+ value: function getIdGeneratorPlugin() {
261
+ var _appPlugin$getApp, _app$getPlugin;
262
+ var appPlugin = this.core.getPlugin('app');
263
+ var app = appPlugin === null || appPlugin === void 0 || (_appPlugin$getApp = appPlugin.getApp) === null || _appPlugin$getApp === void 0 ? void 0 : _appPlugin$getApp.call(appPlugin);
264
+ return (app === null || app === void 0 || (_app$getPlugin = app.getPlugin) === null || _app$getPlugin === void 0 ? void 0 : _app$getPlugin.call(app, 'idGenerator')) || null;
265
+ }
266
+ }, {
267
+ key: "loadOpenDataConfig",
268
+ value: function () {
269
+ var _loadOpenDataConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
270
+ var businessCode, lastFetchedAt, cachedData, channel, openDataConfig;
271
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
272
+ while (1) switch (_context2.prev = _context2.next) {
273
+ case 0:
274
+ if (this.store.openData) {
275
+ _context2.next = 2;
276
+ break;
277
+ }
278
+ throw new Error('openData 模块未初始化');
279
+ case 2:
280
+ businessCode = this.getBookingTicketBusinessCode();
281
+ if (businessCode) {
282
+ _context2.next = 6;
283
+ break;
284
+ }
285
+ console.warn('[BookingTicket] businessCode 缺失,跳过 OpenData 配置加载,当前 module name: ', this.name);
286
+ return _context2.abrupt("return", null);
287
+ case 6:
288
+ lastFetchedAt = this.store.openData.getLastFetchedAt();
289
+ cachedData = this.store.openData.getOpenData();
290
+ if (!(cachedData && lastFetchedAt && Date.now() - lastFetchedAt < OPEN_DATA_CACHE_TTL)) {
291
+ _context2.next = 11;
292
+ break;
293
+ }
294
+ this.otherParams.openData = cachedData;
295
+ return _context2.abrupt("return", cachedData);
296
+ case 11:
297
+ if (!this.loadOpenDataConfigInFlight) {
298
+ _context2.next = 15;
299
+ break;
300
+ }
301
+ _context2.next = 14;
302
+ return this.loadOpenDataConfigInFlight;
303
+ case 14:
304
+ return _context2.abrupt("return", _context2.sent);
305
+ case 15:
306
+ channel = this.getSubmitOrderSalesChannel();
307
+ this.loadOpenDataConfigInFlight = this.store.openData.fetchOpenData({
308
+ scope: 'board',
309
+ target: "".concat(businessCode, "+").concat(channel),
310
+ // target: `dine_in+pos`,
311
+ section_code: [].concat(OPEN_DATA_SECTION_CODES)
312
+ });
313
+ _context2.prev = 17;
314
+ _context2.next = 20;
315
+ return this.loadOpenDataConfigInFlight;
316
+ case 20:
317
+ openDataConfig = _context2.sent;
318
+ this.otherParams.openData = openDataConfig;
319
+ return _context2.abrupt("return", openDataConfig);
320
+ case 23:
321
+ _context2.prev = 23;
322
+ this.loadOpenDataConfigInFlight = null;
323
+ return _context2.finish(23);
324
+ case 26:
325
+ case "end":
326
+ return _context2.stop();
327
+ }
328
+ }, _callee2, this, [[17,, 23, 26]]);
329
+ }));
330
+ function loadOpenDataConfig() {
331
+ return _loadOpenDataConfig.apply(this, arguments);
332
+ }
333
+ return loadOpenDataConfig;
334
+ }()
335
+ }, {
336
+ key: "getOpenData",
337
+ value: function () {
338
+ var _getOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
339
+ var _this$store$openData;
340
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
341
+ while (1) switch (_context3.prev = _context3.next) {
342
+ case 0:
343
+ return _context3.abrupt("return", (_this$store$openData = this.store.openData) === null || _this$store$openData === void 0 ? void 0 : _this$store$openData.getOpenData());
344
+ case 1:
345
+ case "end":
346
+ return _context3.stop();
347
+ }
348
+ }, _callee3, this);
349
+ }));
350
+ function getOpenData() {
351
+ return _getOpenData.apply(this, arguments);
352
+ }
353
+ return getOpenData;
354
+ }()
355
+ }, {
356
+ key: "getShortNumberOrDeviceId",
357
+ value: function () {
358
+ var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
359
+ var getAsyncIotDeviceInfo, res;
360
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
361
+ while (1) switch (_context4.prev = _context4.next) {
362
+ case 0:
363
+ getAsyncIotDeviceInfo = this.getAppData('async_iot_device_info');
364
+ if (!getAsyncIotDeviceInfo) {
365
+ _context4.next = 7;
366
+ break;
367
+ }
368
+ _context4.next = 4;
369
+ return getAsyncIotDeviceInfo === null || getAsyncIotDeviceInfo === void 0 ? void 0 : getAsyncIotDeviceInfo();
370
+ case 4:
371
+ res = _context4.sent;
372
+ if (!(res !== null && res !== void 0 && res.short_number)) {
373
+ _context4.next = 7;
374
+ break;
375
+ }
376
+ return _context4.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
377
+ case 7:
378
+ return _context4.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
379
+ case 8:
380
+ case "end":
381
+ return _context4.stop();
382
+ }
383
+ }, _callee4, this);
384
+ }));
385
+ function getShortNumberOrDeviceId() {
386
+ return _getShortNumberOrDeviceId.apply(this, arguments);
387
+ }
388
+ return getShortNumberOrDeviceId;
389
+ }()
390
+ }, {
391
+ key: "configureIdGeneratorFromOpenData",
392
+ value: function () {
393
+ var _configureIdGeneratorFromOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
394
+ var _openDataConfig, _openDataConfig2, _openDataConfig3, _openDataConfig4, _openDataConfig5, _openDataConfig6;
395
+ var openDataConfig, idGenerator, receiptSequenceLength, receiptSequenceStart, prefix, shopOrderPrefix, resetReceiptSequenceDaily, operatingDayBoundary, deviceId, businessCode;
396
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
397
+ while (1) switch (_context5.prev = _context5.next) {
398
+ case 0:
399
+ openDataConfig = null;
400
+ _context5.prev = 1;
401
+ _context5.next = 4;
402
+ return this.loadOpenDataConfig();
403
+ case 4:
404
+ openDataConfig = _context5.sent;
405
+ _context5.next = 11;
406
+ break;
407
+ case 7:
408
+ _context5.prev = 7;
409
+ _context5.t0 = _context5["catch"](1);
410
+ console.warn('[BookingTicket] OpenData 配置加载失败,跳过 idGenerator 配置', _context5.t0);
411
+ return _context5.abrupt("return");
412
+ case 11:
413
+ // if (!openDataConfig) return;
414
+ idGenerator = this.getIdGeneratorPlugin();
415
+ if (idGenerator !== null && idGenerator !== void 0 && idGenerator.configure) {
416
+ _context5.next = 15;
417
+ break;
418
+ }
419
+ console.warn('[BookingTicket] idGenerator 插件不可用,跳过配置');
420
+ return _context5.abrupt("return");
421
+ case 15:
422
+ receiptSequenceLength = this.normalizePositiveInteger((_openDataConfig = openDataConfig) === null || _openDataConfig === void 0 ? void 0 : _openDataConfig['sale.short_number_digits'], 5);
423
+ receiptSequenceStart = this.normalizePositiveInteger((_openDataConfig2 = openDataConfig) === null || _openDataConfig2 === void 0 ? void 0 : _openDataConfig2['sale.short_number_start_number'], 1);
424
+ prefix = this.normalizeIdPrefix((_openDataConfig3 = openDataConfig) === null || _openDataConfig3 === void 0 ? void 0 : _openDataConfig3['sale.short_number_prefix'], '');
425
+ shopOrderPrefix = this.normalizeIdPrefix((_openDataConfig4 = openDataConfig) === null || _openDataConfig4 === void 0 ? void 0 : _openDataConfig4['sale.sale_number_prefix'], '');
426
+ 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;
427
+ operatingDayBoundary = this.getAppData('operating_day_boundary');
428
+ _context5.next = 23;
429
+ return this.getShortNumberOrDeviceId();
430
+ case 23:
431
+ deviceId = _context5.sent;
432
+ businessCode = this.getBookingTicketBusinessCode();
433
+ if (businessCode) {
434
+ _context5.next = 28;
435
+ break;
436
+ }
437
+ console.warn('[BookingTicket] businessCode 缺失,跳过 idGenerator 配置');
438
+ return _context5.abrupt("return");
439
+ case 28:
440
+ _context5.prev = 28;
441
+ _context5.next = 31;
442
+ return idGenerator.configure({
443
+ biz: businessCode,
444
+ config: {
445
+ prefix: prefix,
446
+ deviceCode: deviceId,
447
+ // TODO 现在 picoding 没这个配置的 key
448
+ padReceiptSequence: false,
449
+ receiptSequenceLength: receiptSequenceLength,
450
+ resetReceiptSequenceDaily: resetReceiptSequenceDaily,
451
+ receiptSequenceResetTime: operatingDayBoundary.time,
452
+ receiptSequenceStart: receiptSequenceStart,
453
+ shopOrderPrefix: shopOrderPrefix
454
+ }
455
+ });
456
+ case 31:
457
+ _context5.next = 36;
458
+ break;
459
+ case 33:
460
+ _context5.prev = 33;
461
+ _context5.t1 = _context5["catch"](28);
462
+ console.warn('[BookingTicket] idGenerator 配置失败', _context5.t1);
463
+ case 36:
464
+ case "end":
465
+ return _context5.stop();
466
+ }
467
+ }, _callee5, this, [[1, 7], [28, 33]]);
468
+ }));
469
+ function configureIdGeneratorFromOpenData() {
470
+ return _configureIdGeneratorFromOpenData.apply(this, arguments);
471
+ }
472
+ return configureIdGeneratorFromOpenData;
473
+ }()
474
+ }, {
475
+ key: "normalizePositiveInteger",
476
+ value: function normalizePositiveInteger(value, fallback) {
477
+ var numeric = Number(value);
478
+ if (!Number.isInteger(numeric) || numeric <= 0) return fallback;
479
+ return numeric;
480
+ }
481
+ }, {
482
+ key: "normalizeIdPrefix",
483
+ value: function normalizeIdPrefix(value, fallback) {
484
+ if (value === undefined || value === null) return fallback;
485
+ var normalized = String(value).trim().toUpperCase();
486
+ return normalized || fallback;
487
+ }
488
+
117
489
  /**
118
490
  * 加载销售详情,并在父类基础上把 customer 信息装配到 CustomerModule。
119
491
  *
@@ -124,43 +496,236 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
124
496
  }, {
125
497
  key: "loadSalesDetail",
126
498
  value: (function () {
127
- var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(orderIdOrParams) {
128
- var sales, customerModule, detailCustomer, _detailCustomer$name, _ref, detailCustomerId, detailCustomerRest, rawId, customer;
129
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
130
- while (1) switch (_context2.prev = _context2.next) {
499
+ var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(orderIdOrParams) {
500
+ var _ref3;
501
+ var sales, customerModule, detailCustomer, orderCustomerSnapshot, protocolCustomerId, protocolCustomer, selectedCustomer, _selectedCustomer$nam, _ref4, detailCustomerId, detailCustomerRest, rawId, customer;
502
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
503
+ while (1) switch (_context6.prev = _context6.next) {
131
504
  case 0:
132
- _context2.next = 2;
505
+ debugger;
506
+ _context6.next = 3;
133
507
  return _get(_getPrototypeOf(BookingTicketImpl.prototype), "loadSalesDetail", this).call(this, orderIdOrParams);
134
- case 2:
135
- sales = _context2.sent;
136
- console.log(sales, '1234sales');
508
+ case 3:
509
+ sales = _context6.sent;
137
510
  customerModule = this.store.customer;
138
511
  detailCustomer = sales === null || sales === void 0 ? void 0 : sales.customer;
139
- if (customerModule && detailCustomer) {
140
- _ref = detailCustomer !== null && detailCustomer !== void 0 ? detailCustomer : {}, detailCustomerId = _ref.id, detailCustomerRest = _objectWithoutProperties(_ref, _excluded);
512
+ orderCustomerSnapshot = this.store.order.getOrderCustomerSnapshot();
513
+ protocolCustomerId = sales === null || sales === void 0 ? void 0 : sales.customer_id;
514
+ protocolCustomer = protocolCustomerId !== undefined && protocolCustomerId !== null ? {
515
+ id: protocolCustomerId,
516
+ name: String((sales === null || sales === void 0 ? void 0 : sales.customer_name) || ''),
517
+ phone: sales === null || sales === void 0 ? void 0 : sales.phone,
518
+ email: sales === null || sales === void 0 ? void 0 : sales.email,
519
+ country_calling_code: sales === null || sales === void 0 ? void 0 : sales.country_calling_code
520
+ } : null;
521
+ selectedCustomer = (_ref3 = detailCustomer !== null && detailCustomer !== void 0 ? detailCustomer : orderCustomerSnapshot) !== null && _ref3 !== void 0 ? _ref3 : protocolCustomer;
522
+ if (customerModule && selectedCustomer) {
523
+ _ref4 = selectedCustomer !== null && selectedCustomer !== void 0 ? selectedCustomer : {}, detailCustomerId = _ref4.id, detailCustomerRest = _objectWithoutProperties(_ref4, _excluded);
141
524
  rawId = detailCustomerId !== null && detailCustomerId !== void 0 ? detailCustomerId : '';
142
525
  customer = _objectSpread(_objectSpread({}, detailCustomerRest), {}, {
143
526
  id: rawId == null ? '' : rawId,
144
- name: (_detailCustomer$name = detailCustomer === null || detailCustomer === void 0 ? void 0 : detailCustomer.name) !== null && _detailCustomer$name !== void 0 ? _detailCustomer$name : '',
145
- phone: detailCustomer === null || detailCustomer === void 0 ? void 0 : detailCustomer.phone,
146
- email: detailCustomer === null || detailCustomer === void 0 ? void 0 : detailCustomer.email,
147
- country_calling_code: detailCustomer === null || detailCustomer === void 0 ? void 0 : detailCustomer.country_calling_code
527
+ name: (_selectedCustomer$nam = selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.name) !== null && _selectedCustomer$nam !== void 0 ? _selectedCustomer$nam : '',
528
+ phone: selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.phone,
529
+ email: selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.email,
530
+ country_calling_code: selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.country_calling_code
148
531
  });
149
532
  customerModule.setSelectedCustomer(customer);
150
533
  this.setOrderCustomer(customer);
534
+ // await this.store.order.saveDraft();
151
535
  }
152
- return _context2.abrupt("return", sales);
153
- case 8:
536
+ return _context6.abrupt("return", sales);
537
+ case 12:
154
538
  case "end":
155
- return _context2.stop();
539
+ return _context6.stop();
156
540
  }
157
- }, _callee2, this);
541
+ }, _callee6, this);
158
542
  }));
159
543
  function loadSalesDetail(_x2) {
160
544
  return _loadSalesDetail.apply(this, arguments);
161
545
  }
162
546
  return loadSalesDetail;
547
+ }())
548
+ }, {
549
+ key: "scanPromotionCode",
550
+ value: function () {
551
+ var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(code, customerId) {
552
+ var raw;
553
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
554
+ while (1) switch (_context7.prev = _context7.next) {
555
+ case 0:
556
+ if (this.store.order) {
557
+ _context7.next = 2;
558
+ break;
559
+ }
560
+ throw new Error('order 模块未初始化');
561
+ case 2:
562
+ _context7.next = 4;
563
+ return this.store.order.scanCode(code, customerId);
564
+ case 4:
565
+ raw = _context7.sent;
566
+ if (!raw.isAvailable) {
567
+ _context7.next = 11;
568
+ break;
569
+ }
570
+ _context7.next = 8;
571
+ return this.hydrateOrderCustomerFromScanDiscounts(raw.scannedDiscountList || []);
572
+ case 8:
573
+ _context7.next = 10;
574
+ return this.store.order.recalculateSummary({
575
+ createIfMissing: true
576
+ });
577
+ case 10:
578
+ this.store.order.persistTempOrder();
579
+ case 11:
580
+ return _context7.abrupt("return", {
581
+ isAvailable: raw.isAvailable,
582
+ type: raw.type,
583
+ unavailableReason: raw.unavailableReason
584
+ });
585
+ case 12:
586
+ case "end":
587
+ return _context7.stop();
588
+ }
589
+ }, _callee7, this);
590
+ }));
591
+ function scanPromotionCode(_x3, _x4) {
592
+ return _scanPromotionCode.apply(this, arguments);
593
+ }
594
+ return scanPromotionCode;
595
+ }()
596
+ }, {
597
+ key: "hydrateOrderCustomerFromScanDiscounts",
598
+ value: function () {
599
+ var _hydrateOrderCustomerFromScanDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(discounts) {
600
+ var currentOrderCustomer, customerId, customer;
601
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
602
+ while (1) switch (_context8.prev = _context8.next) {
603
+ case 0:
604
+ currentOrderCustomer = this.store.order.getOrderCustomer();
605
+ if (!currentOrderCustomer) {
606
+ _context8.next = 3;
607
+ break;
608
+ }
609
+ return _context8.abrupt("return");
610
+ case 3:
611
+ customerId = this.getDiscountCustomerId(discounts);
612
+ if (customerId) {
613
+ _context8.next = 6;
614
+ break;
615
+ }
616
+ return _context8.abrupt("return");
617
+ case 6:
618
+ _context8.next = 8;
619
+ return this.resolveCustomerByDiscountCustomerId(customerId);
620
+ case 8:
621
+ customer = _context8.sent;
622
+ if (customer) {
623
+ _context8.next = 11;
624
+ break;
625
+ }
626
+ return _context8.abrupt("return");
627
+ case 11:
628
+ this.store.customer.setSelectedCustomer(customer);
629
+ this.setOrderCustomer(customer);
630
+ case 13:
631
+ case "end":
632
+ return _context8.stop();
633
+ }
634
+ }, _callee8, this);
635
+ }));
636
+ function hydrateOrderCustomerFromScanDiscounts(_x5) {
637
+ return _hydrateOrderCustomerFromScanDiscounts.apply(this, arguments);
638
+ }
639
+ return hydrateOrderCustomerFromScanDiscounts;
640
+ }()
641
+ }, {
642
+ key: "getDiscountCustomerId",
643
+ value: function getDiscountCustomerId(discounts) {
644
+ var discount = discounts.find(function (item) {
645
+ return item.customer_id != null;
646
+ });
647
+ var customerId = Number(discount === null || discount === void 0 ? void 0 : discount.customer_id);
648
+ if (!Number.isFinite(customerId) || customerId <= 0) return null;
649
+ return customerId;
650
+ }
651
+ }, {
652
+ key: "resolveCustomerByDiscountCustomerId",
653
+ value: function () {
654
+ var _resolveCustomerByDiscountCustomerId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(customerId) {
655
+ var _result$list;
656
+ var localCustomers, localCustomer, normalizedLocalCustomer, result, remoteCustomer;
657
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
658
+ while (1) switch (_context9.prev = _context9.next) {
659
+ case 0:
660
+ localCustomers = this.store.customer.getCustomers();
661
+ localCustomer = this.findCustomerById(localCustomers, customerId);
662
+ normalizedLocalCustomer = localCustomer ? this.normalizeCustomer(localCustomer) : null;
663
+ if (!(normalizedLocalCustomer && this.hasUsableCustomerDetails(normalizedLocalCustomer))) {
664
+ _context9.next = 5;
665
+ break;
666
+ }
667
+ return _context9.abrupt("return", normalizedLocalCustomer);
668
+ case 5:
669
+ _context9.next = 7;
670
+ return this.store.customer.queryCustomerList({
671
+ ids: [customerId],
672
+ skip: 1,
673
+ num: 1
674
+ });
675
+ case 7:
676
+ result = _context9.sent;
677
+ 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;
678
+ return _context9.abrupt("return", remoteCustomer ? this.normalizeCustomer(remoteCustomer) : null);
679
+ case 10:
680
+ case "end":
681
+ return _context9.stop();
682
+ }
683
+ }, _callee9, this);
684
+ }));
685
+ function resolveCustomerByDiscountCustomerId(_x6) {
686
+ return _resolveCustomerByDiscountCustomerId.apply(this, arguments);
687
+ }
688
+ return resolveCustomerByDiscountCustomerId;
163
689
  }()
690
+ }, {
691
+ key: "findCustomerById",
692
+ value: function findCustomerById() {
693
+ var _this2 = this;
694
+ var customers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
695
+ var customerId = arguments.length > 1 ? arguments[1] : undefined;
696
+ return customers.find(function (customer) {
697
+ var rawId = _this2.getRawCustomerId(customer);
698
+ return rawId !== null && String(rawId) === String(customerId);
699
+ }) || null;
700
+ }
701
+ }, {
702
+ key: "normalizeCustomer",
703
+ value: function normalizeCustomer(customer) {
704
+ var _ref5, _ref6, _customer$phone, _ref7, _customer$email, _ref8, _customer$country_cal;
705
+ var raw = customer;
706
+ var rawId = this.getRawCustomerId(customer);
707
+ var name = customer.name || raw.display_name || raw.nickname || raw.customer_name || [raw.first_name, raw.last_name].filter(Boolean).join(' ') || '';
708
+ return _objectSpread(_objectSpread({}, customer), {}, {
709
+ id: rawId !== null && rawId !== void 0 ? rawId : customer.id,
710
+ name: name,
711
+ 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 : '',
712
+ email: (_ref7 = (_customer$email = customer.email) !== null && _customer$email !== void 0 ? _customer$email : raw.email) !== null && _ref7 !== void 0 ? _ref7 : '',
713
+ 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 : ''
714
+ });
715
+ }
716
+ }, {
717
+ key: "getRawCustomerId",
718
+ value: function getRawCustomerId(customer) {
719
+ var _ref9, _ref10, _customer$id;
720
+ var raw = customer;
721
+ 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;
722
+ }
723
+ }, {
724
+ key: "hasUsableCustomerDetails",
725
+ value: function hasUsableCustomerDetails(customer) {
726
+ return !!(customer.name || customer.phone || customer.email || customer.display_name || customer.customer_name);
727
+ }
728
+
164
729
  /**
165
730
  * 更新当前预约的 appointment_status。
166
731
  *
@@ -175,172 +740,370 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
175
740
  * @param status 目标状态(如 'confirmed')
176
741
  * @returns 接口返回的 data
177
742
  */
178
- )
179
743
  }, {
180
744
  key: "setBookingStatus",
181
745
  value: (function () {
182
- var _setBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(status) {
746
+ var _setBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(status) {
183
747
  var _this$store$order, _this$store$order$get;
184
748
  var tempOrder, orderId, scheduleId, bookings, previous, _data, res;
185
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
186
- while (1) switch (_context3.prev = _context3.next) {
749
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
750
+ while (1) switch (_context10.prev = _context10.next) {
187
751
  case 0:
188
752
  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);
189
753
  if (tempOrder) {
190
- _context3.next = 3;
754
+ _context10.next = 3;
191
755
  break;
192
756
  }
193
757
  throw new Error('setBookingStatus: tempOrder 未加载');
194
758
  case 3:
195
759
  orderId = tempOrder.order_id;
196
760
  if (!(orderId === undefined || orderId === null)) {
197
- _context3.next = 6;
761
+ _context10.next = 6;
198
762
  break;
199
763
  }
200
764
  throw new Error('setBookingStatus: tempOrder.order_id 缺失');
201
765
  case 6:
202
766
  scheduleId = resolveScheduleId(tempOrder);
203
767
  if (!(scheduleId === null)) {
204
- _context3.next = 9;
768
+ _context10.next = 9;
205
769
  break;
206
770
  }
207
771
  throw new Error('setBookingStatus: 无法解析 schedule id(metadata 与 root booking 均缺失)');
208
772
  case 9:
209
773
  bookings = Array.isArray(tempOrder.bookings) ? tempOrder.bookings : [];
210
774
  previous = applyBookingsStatus(bookings, status);
211
- _context3.prev = 11;
212
- _context3.next = 14;
775
+ _context10.prev = 11;
776
+ _context10.next = 14;
213
777
  return this.request.put("/schedule/booking/appointment-status/".concat(scheduleId), {
214
778
  appointment_status: status
215
779
  });
216
780
  case 14:
217
- res = _context3.sent;
218
- _context3.next = 17;
781
+ res = _context10.sent;
782
+ _context10.next = 17;
219
783
  return this.refreshSalesDetail();
220
784
  case 17:
221
785
  this.core.effects.emit("".concat(this.name, ":onBookingStatusChange"), {
222
786
  orderId: orderId,
223
787
  status: status
224
788
  });
225
- return _context3.abrupt("return", (_data = res === null || res === void 0 ? void 0 : res.data) !== null && _data !== void 0 ? _data : res);
789
+ return _context10.abrupt("return", (_data = res === null || res === void 0 ? void 0 : res.data) !== null && _data !== void 0 ? _data : res);
226
790
  case 21:
227
- _context3.prev = 21;
228
- _context3.t0 = _context3["catch"](11);
791
+ _context10.prev = 21;
792
+ _context10.t0 = _context10["catch"](11);
229
793
  restoreBookingsStatus(bookings, previous);
230
- throw _context3.t0;
794
+ throw _context10.t0;
231
795
  case 25:
232
796
  case "end":
233
- return _context3.stop();
797
+ return _context10.stop();
234
798
  }
235
- }, _callee3, this, [[11, 21]]);
799
+ }, _callee10, this, [[11, 21]]);
236
800
  }));
237
- function setBookingStatus(_x3) {
801
+ function setBookingStatus(_x7) {
238
802
  return _setBookingStatus.apply(this, arguments);
239
803
  }
240
804
  return setBookingStatus;
241
805
  }()
242
806
  /**
243
- * 基于当前 tempOrder.order_id 强制从远端重新拉取销售详情。
807
+ * 子预约状态机转移(POST /schedule/booking-transition/{schedule_event_id})。
244
808
  *
245
- * 适用场景:在 BookingTicket 内执行了「修改服务端订单状态」的动作(如改预约状态、
246
- * 改下单客户、改商品行等)后,统一刷新本地销售详情,保证 UI 与服务端一致。
809
+ * `setBookingStatus`(父预约 PUT appointment-status)不同,本方法按子预约
810
+ * `schedule_event_id` 调用状态转移接口,body 为 `{ action }`。
247
811
  *
248
- * 约束:调用前必须已有 tempOrder 且 order_id 存在,否则视为非法调用并抛错。
812
+ * 流程:能解析出目标状态时先乐观更新对应子预约的 `appointment_status`,
813
+ * 再调 POST;成功后强制刷新销售详情;失败则回滚该子预约本地状态并抛错。
814
+ * `reschedule` 暂未启用状态矩阵,跳过乐观更新仅调接口。
249
815
  *
250
- * @returns loadSalesDetail 的返回值
816
+ * @param params.schedule_event_id 子预约 schedule_event_id
817
+ * @param params.action 转移动作:confirm | reject | arrive | start | complete | cancel | no_show | reschedule
818
+ * @returns 接口返回的 data
819
+ *
820
+ * @example
821
+ * await bookingTicket.transitionChildBooking({
822
+ * schedule_event_id: 301,
823
+ * action: 'confirm',
824
+ * });
251
825
  */
252
826
  )
253
827
  }, {
254
- key: "refreshSalesDetail",
828
+ key: "transitionChildBooking",
255
829
  value: (function () {
256
- var _refreshSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
830
+ var _transitionChildBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
257
831
  var _this$store$order2, _this$store$order2$ge;
258
- var tempOrder, orderId;
259
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
260
- while (1) switch (_context4.prev = _context4.next) {
832
+ var schedule_event_id, action, tempOrder, orderId, bookings, targetStatus, previous, _data2, res;
833
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
834
+ while (1) switch (_context11.prev = _context11.next) {
261
835
  case 0:
836
+ schedule_event_id = params.schedule_event_id, action = params.action;
837
+ if (!(schedule_event_id === undefined || schedule_event_id === null || schedule_event_id === '')) {
838
+ _context11.next = 3;
839
+ break;
840
+ }
841
+ throw new Error('transitionChildBooking: schedule_event_id 不能为空');
842
+ case 3:
843
+ if (action) {
844
+ _context11.next = 5;
845
+ break;
846
+ }
847
+ throw new Error('transitionChildBooking: action 不能为空');
848
+ case 5:
262
849
  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);
263
850
  if (tempOrder) {
264
- _context4.next = 3;
851
+ _context11.next = 8;
265
852
  break;
266
853
  }
267
- throw new Error('refreshSalesDetail: tempOrder 未加载');
268
- case 3:
854
+ throw new Error('transitionChildBooking: tempOrder 未加载');
855
+ case 8:
269
856
  orderId = tempOrder.order_id;
270
857
  if (!(orderId === undefined || orderId === null)) {
271
- _context4.next = 6;
858
+ _context11.next = 11;
272
859
  break;
273
860
  }
274
- throw new Error('refreshSalesDetail: tempOrder.order_id 缺失');
275
- case 6:
276
- return _context4.abrupt("return", this.loadSalesDetail({
277
- orderId: Number(orderId),
278
- forceRemote: true
279
- }));
280
- case 7:
861
+ throw new Error('transitionChildBooking: tempOrder.order_id 缺失');
862
+ case 11:
863
+ bookings = Array.isArray(tempOrder.bookings) ? tempOrder.bookings : [];
864
+ targetStatus = resolveStatusAfterTransition(action);
865
+ previous = targetStatus !== null ? applyChildBookingStatus(bookings, schedule_event_id, targetStatus) : undefined;
866
+ _context11.prev = 14;
867
+ _context11.next = 17;
868
+ return this.request.post("/schedule/booking-transition/".concat(schedule_event_id), {
869
+ action: action
870
+ });
871
+ case 17:
872
+ res = _context11.sent;
873
+ _context11.next = 20;
874
+ return this.refreshSalesDetail();
875
+ case 20:
876
+ this.core.effects.emit("".concat(this.name, ":onChildBookingStatusChange"), {
877
+ orderId: orderId,
878
+ schedule_event_id: schedule_event_id,
879
+ action: action,
880
+ status: targetStatus
881
+ });
882
+ return _context11.abrupt("return", (_data2 = res === null || res === void 0 ? void 0 : res.data) !== null && _data2 !== void 0 ? _data2 : res);
883
+ case 24:
884
+ _context11.prev = 24;
885
+ _context11.t0 = _context11["catch"](14);
886
+ if (previous !== undefined) {
887
+ restoreChildBookingStatus(bookings, schedule_event_id, previous);
888
+ }
889
+ throw _context11.t0;
890
+ case 28:
281
891
  case "end":
282
- return _context4.stop();
892
+ return _context11.stop();
283
893
  }
284
- }, _callee4, this);
894
+ }, _callee11, this, [[14, 24]]);
285
895
  }));
286
- function refreshSalesDetail() {
287
- return _refreshSalesDetail.apply(this, arguments);
896
+ function transitionChildBooking(_x8) {
897
+ return _transitionChildBooking.apply(this, arguments);
288
898
  }
289
- return refreshSalesDetail;
899
+ return transitionChildBooking;
290
900
  }()
291
901
  /**
292
- * 获取商品列表
293
- * @param params 包含 schedule_date 的参数
294
- * @returns 商品列表
902
+ * 基于当前 tempOrder.order_id 强制从远端重新拉取销售详情。
903
+ *
904
+ * 适用场景:在 BookingTicket 内执行了「修改服务端订单状态」的动作(如改预约状态、
905
+ * 改下单客户、改商品行等)后,统一刷新本地销售详情,保证 UI 与服务端一致。
906
+ *
907
+ * 约束:调用前必须已有 tempOrder 且 order_id 存在,否则视为非法调用并抛错。
908
+ *
909
+ * @returns loadSalesDetail 的返回值
295
910
  */
296
911
  )
297
912
  }, {
298
- key: "loadProducts",
913
+ key: "refreshSalesDetail",
299
914
  value: (function () {
300
- var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
915
+ var _refreshSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
916
+ var _this$store$order3, _this$store$order3$ge;
301
917
  var params,
302
- options,
303
- schedule_date,
304
- customer_id,
305
- menu_list_ids,
306
- schedule_datetime,
918
+ tempOrder,
919
+ orderId,
920
+ _args12 = arguments;
921
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
922
+ while (1) switch (_context12.prev = _context12.next) {
923
+ case 0:
924
+ params = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
925
+ 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);
926
+ if (tempOrder) {
927
+ _context12.next = 4;
928
+ break;
929
+ }
930
+ throw new Error('refreshSalesDetail: tempOrder 未加载');
931
+ case 4:
932
+ debugger;
933
+ orderId = tempOrder.order_id || tempOrder.external_sale_number;
934
+ if (!(orderId === undefined || orderId === null)) {
935
+ _context12.next = 8;
936
+ break;
937
+ }
938
+ return _context12.abrupt("return", {});
939
+ case 8:
940
+ return _context12.abrupt("return", this.loadSalesDetail({
941
+ orderId: orderId,
942
+ // merge: true
943
+ forceRemote: params.forceRemote
944
+ }));
945
+ case 9:
946
+ case "end":
947
+ return _context12.stop();
948
+ }
949
+ }, _callee12, this);
950
+ }));
951
+ function refreshSalesDetail() {
952
+ return _refreshSalesDetail.apply(this, arguments);
953
+ }
954
+ return refreshSalesDetail;
955
+ }()
956
+ /**
957
+ * 获取商品列表
958
+ * @param params 包含 schedule_date 的参数
959
+ * @returns 商品列表
960
+ */
961
+ )
962
+ }, {
963
+ key: "loadProducts",
964
+ value: (function () {
965
+ var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
966
+ var params,
967
+ options,
968
+ schedule_date,
969
+ customer_id,
970
+ menu_list_ids,
971
+ schedule_datetime,
972
+ bookingDate,
307
973
  _result,
308
- _args5 = arguments;
309
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
310
- while (1) switch (_context5.prev = _context5.next) {
974
+ _args13 = arguments;
975
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
976
+ while (1) switch (_context13.prev = _context13.next) {
311
977
  case 0:
312
- params = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
313
- options = _args5.length > 1 ? _args5[1] : undefined;
314
- schedule_date = params.schedule_date, customer_id = params.customer_id, menu_list_ids = params.menu_list_ids, schedule_datetime = params.schedule_datetime;
315
- _context5.prev = 3;
316
- _context5.next = 6;
978
+ params = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
979
+ options = _args13.length > 1 ? _args13[1] : undefined;
980
+ 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 对齐;
981
+ // requiresDetail 弹窗仍通过 formatBookingDateForUI 只取日历日 YYYY-MM-DD。
982
+ bookingDate = schedule_datetime || schedule_date || '';
983
+ if (bookingDate) {
984
+ this.setBookingDate(bookingDate);
985
+ }
986
+ _context13.prev = 5;
987
+ _context13.next = 8;
317
988
  return this.store.products.loadProducts(_objectSpread(_objectSpread({
318
989
  with_count: ['bundleGroup', 'optionGroup'],
319
990
  with_schedule: 1
320
991
  }, params), {}, {
321
992
  cacheId: this.cacheId
322
993
  }), options);
323
- case 6:
324
- _result = _context5.sent;
994
+ case 8:
995
+ _result = _context13.sent;
325
996
  this.productCatalog = Array.isArray(_result) ? _toConsumableArray(_result) : [];
326
997
  this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), _result);
327
- return _context5.abrupt("return", _result);
328
- case 12:
329
- _context5.prev = 12;
330
- _context5.t0 = _context5["catch"](3);
331
- console.error('Failed to load products:', _context5.t0);
332
- throw _context5.t0;
333
- case 16:
998
+ return _context13.abrupt("return", _result);
999
+ case 14:
1000
+ _context13.prev = 14;
1001
+ _context13.t0 = _context13["catch"](5);
1002
+ console.error('Failed to load products:', _context13.t0);
1003
+ throw _context13.t0;
1004
+ case 18:
334
1005
  case "end":
335
- return _context5.stop();
1006
+ return _context13.stop();
336
1007
  }
337
- }, _callee5, this, [[3, 12]]);
1008
+ }, _callee13, this, [[5, 14]]);
338
1009
  }));
339
1010
  function loadProducts() {
340
1011
  return _loadProducts.apply(this, arguments);
341
1012
  }
342
1013
  return loadProducts;
343
1014
  }()
1015
+ /**
1016
+ * 获取加时商品列表。
1017
+ *
1018
+ * @example
1019
+ * const products = await bookingTicket.getAddTimeProducts({ schedule_date: '2026-06-16' });
1020
+ */
1021
+ )
1022
+ }, {
1023
+ key: "getAddTimeProducts",
1024
+ value: (function () {
1025
+ var _getAddTimeProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1026
+ var params,
1027
+ result,
1028
+ _args14 = arguments;
1029
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1030
+ while (1) switch (_context14.prev = _context14.next) {
1031
+ case 0:
1032
+ params = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
1033
+ _context14.next = 3;
1034
+ return this.store.products.getAddTimeProducts(_objectSpread(_objectSpread({}, params), {}, {
1035
+ cacheId: this.cacheId
1036
+ }));
1037
+ case 3:
1038
+ result = _context14.sent;
1039
+ this.addTimeProductsCatalog = Array.isArray(result) ? _toConsumableArray(result) : [];
1040
+ return _context14.abrupt("return", result);
1041
+ case 6:
1042
+ case "end":
1043
+ return _context14.stop();
1044
+ }
1045
+ }, _callee14, this);
1046
+ }));
1047
+ function getAddTimeProducts() {
1048
+ return _getAddTimeProducts.apply(this, arguments);
1049
+ }
1050
+ return getAddTimeProducts;
1051
+ }()
1052
+ /**
1053
+ * 只读查询单商品详情:走 ProductList 报价查询,但不写 productCatalog、
1054
+ * 不 emit onProductsLoaded、不修改 BookingDate。
1055
+ *
1056
+ * 供「列表已 loadProducts、仅需补 product_resource / capacity」等场景使用,
1057
+ * 避免 loadProductDetail 覆盖左侧商品列表。
1058
+ *
1059
+ * @example
1060
+ * const detail = await bookingTicket.queryProductDetail({
1061
+ * product_id: 2,
1062
+ * schedule_date: '2030-01-15',
1063
+ * schedule_datetime: '2030-01-15 10:00:00',
1064
+ * });
1065
+ */
1066
+ )
1067
+ }, {
1068
+ key: "queryProductDetail",
1069
+ value: (function () {
1070
+ var _queryProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params, options) {
1071
+ var product_id, queryParams, _result2, list;
1072
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1073
+ while (1) switch (_context15.prev = _context15.next) {
1074
+ case 0:
1075
+ product_id = params.product_id, queryParams = _objectWithoutProperties(params, _excluded2);
1076
+ _context15.prev = 1;
1077
+ _context15.next = 4;
1078
+ return this.store.products.loadProducts(_objectSpread(_objectSpread({
1079
+ with_count: ['bundleGroup', 'optionGroup'],
1080
+ with_schedule: 1
1081
+ }, queryParams), {}, {
1082
+ product_ids: [product_id],
1083
+ cacheId: this.cacheId
1084
+ }), options);
1085
+ case 4:
1086
+ _result2 = _context15.sent;
1087
+ list = Array.isArray(_result2) ? _result2 : [];
1088
+ return _context15.abrupt("return", list.find(function (product) {
1089
+ return Number(product.id) === Number(product_id);
1090
+ }));
1091
+ case 9:
1092
+ _context15.prev = 9;
1093
+ _context15.t0 = _context15["catch"](1);
1094
+ console.error('Failed to query product detail:', _context15.t0);
1095
+ throw _context15.t0;
1096
+ case 13:
1097
+ case "end":
1098
+ return _context15.stop();
1099
+ }
1100
+ }, _callee15, this, [[1, 9]]);
1101
+ }));
1102
+ function queryProductDetail(_x9, _x10) {
1103
+ return _queryProductDetail.apply(this, arguments);
1104
+ }
1105
+ return queryProductDetail;
1106
+ }()
344
1107
  /**
345
1108
  * 按预约时间加载单个商品详情。
346
1109
  * 价格仍由 server products 的报价单桥接统一计算,避免 solution 实例重复请求报价单。
@@ -349,28 +1112,28 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
349
1112
  }, {
350
1113
  key: "loadProductDetail",
351
1114
  value: (function () {
352
- var _loadProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params, options) {
1115
+ var _loadProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params, options) {
353
1116
  var product_id, queryParams, products;
354
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
355
- while (1) switch (_context6.prev = _context6.next) {
1117
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1118
+ while (1) switch (_context16.prev = _context16.next) {
356
1119
  case 0:
357
- product_id = params.product_id, queryParams = _objectWithoutProperties(params, _excluded2);
358
- _context6.next = 3;
1120
+ product_id = params.product_id, queryParams = _objectWithoutProperties(params, _excluded3);
1121
+ _context16.next = 3;
359
1122
  return this.loadProducts(_objectSpread(_objectSpread({}, queryParams), {}, {
360
1123
  product_ids: [product_id]
361
1124
  }), options);
362
1125
  case 3:
363
- products = _context6.sent;
364
- return _context6.abrupt("return", products.find(function (product) {
1126
+ products = _context16.sent;
1127
+ return _context16.abrupt("return", products.find(function (product) {
365
1128
  return Number(product.id) === Number(product_id);
366
1129
  }));
367
1130
  case 5:
368
1131
  case "end":
369
- return _context6.stop();
1132
+ return _context16.stop();
370
1133
  }
371
- }, _callee6, this);
1134
+ }, _callee16, this);
372
1135
  }));
373
- function loadProductDetail(_x4, _x5) {
1136
+ function loadProductDetail(_x11, _x12) {
374
1137
  return _loadProductDetail.apply(this, arguments);
375
1138
  }
376
1139
  return loadProductDetail;
@@ -403,16 +1166,16 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
403
1166
  }, {
404
1167
  key: "getProducts",
405
1168
  value: (function () {
406
- var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
407
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
408
- while (1) switch (_context7.prev = _context7.next) {
1169
+ var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1170
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1171
+ while (1) switch (_context17.prev = _context17.next) {
409
1172
  case 0:
410
- return _context7.abrupt("return", this.store.products.getProducts());
1173
+ return _context17.abrupt("return", this.store.products.getProducts());
411
1174
  case 1:
412
1175
  case "end":
413
- return _context7.stop();
1176
+ return _context17.stop();
414
1177
  }
415
- }, _callee7, this);
1178
+ }, _callee17, this);
416
1179
  }));
417
1180
  function getProducts() {
418
1181
  return _getProducts.apply(this, arguments);
@@ -442,11 +1205,23 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
442
1205
  }, {
443
1206
  key: "getCart",
444
1207
  value: function getCart() {
445
- var _this$store$order$get2, _this$store$order3, _salesDetail$bookings;
446
- var tempOrder = (_this$store$order$get2 = (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 ? void 0 : _this$store$order3.getTempOrder()) !== null && _this$store$order$get2 !== void 0 ? _this$store$order$get2 : null;
1208
+ var _this$store$order$get2, _this$store$order4, _salesDetail$bookings, _operatingDayBoundary, _operatingDayBoundary2, _tempOrder$_extend;
1209
+ 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;
447
1210
  var salesDetail = this.getSalesOrder();
448
1211
  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) || [];
449
- return buildCartView((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [], bookings);
1212
+ var operatingDayBoundary;
1213
+ try {
1214
+ operatingDayBoundary = this.getAppData('operating_day_boundary');
1215
+ } catch (_unused) {
1216
+ operatingDayBoundary = undefined;
1217
+ }
1218
+ 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;
1219
+ return buildCartView((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [], bookings, {
1220
+ addTimeProducts: this.addTimeProductsCatalog,
1221
+ bookingConfig: this.getBookingConfig(),
1222
+ productsByUid: tempOrder === null || tempOrder === void 0 || (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.productsByUid,
1223
+ shopOpeningHours: shopOpeningHours
1224
+ });
450
1225
  }
451
1226
 
452
1227
  /**
@@ -465,18 +1240,18 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
465
1240
  }, {
466
1241
  key: "getProductByIds",
467
1242
  value: (function () {
468
- var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(ids) {
469
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
470
- while (1) switch (_context8.prev = _context8.next) {
1243
+ var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(ids) {
1244
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1245
+ while (1) switch (_context18.prev = _context18.next) {
471
1246
  case 0:
472
- return _context8.abrupt("return", this.store.products.getProductByIds(ids));
1247
+ return _context18.abrupt("return", this.store.products.getProductByIds(ids));
473
1248
  case 1:
474
1249
  case "end":
475
- return _context8.stop();
1250
+ return _context18.stop();
476
1251
  }
477
- }, _callee8, this);
1252
+ }, _callee18, this);
478
1253
  }));
479
- function getProductByIds(_x6) {
1254
+ function getProductByIds(_x13) {
480
1255
  return _getProductByIds.apply(this, arguments);
481
1256
  }
482
1257
  return getProductByIds;
@@ -490,27 +1265,27 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
490
1265
  }, {
491
1266
  key: "getScheduleTimePoints",
492
1267
  value: (function () {
493
- var _getScheduleTimePoints = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
1268
+ var _getScheduleTimePoints = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
494
1269
  var result;
495
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
496
- while (1) switch (_context9.prev = _context9.next) {
1270
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1271
+ while (1) switch (_context19.prev = _context19.next) {
497
1272
  case 0:
498
- _context9.next = 2;
1273
+ _context19.next = 2;
499
1274
  return this.request.post('/menu/schedule-time-points', {
500
1275
  menu_list_ids: params.menu_list_ids
501
1276
  }, {
502
1277
  osServer: true
503
1278
  });
504
1279
  case 2:
505
- result = _context9.sent;
506
- return _context9.abrupt("return", result.data || []);
1280
+ result = _context19.sent;
1281
+ return _context19.abrupt("return", result.data || []);
507
1282
  case 4:
508
1283
  case "end":
509
- return _context9.stop();
1284
+ return _context19.stop();
510
1285
  }
511
- }, _callee9, this);
1286
+ }, _callee19, this);
512
1287
  }));
513
- function getScheduleTimePoints(_x7) {
1288
+ function getScheduleTimePoints(_x14) {
514
1289
  return _getScheduleTimePoints.apply(this, arguments);
515
1290
  }
516
1291
  return getScheduleTimePoints;
@@ -524,30 +1299,30 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
524
1299
  }, {
525
1300
  key: "getCustomerList",
526
1301
  value: (function () {
527
- var _getCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
1302
+ var _getCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
528
1303
  var params,
529
- _result2,
530
- _args10 = arguments;
531
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
532
- while (1) switch (_context10.prev = _context10.next) {
1304
+ _result3,
1305
+ _args20 = arguments;
1306
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1307
+ while (1) switch (_context20.prev = _context20.next) {
533
1308
  case 0:
534
- params = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {};
535
- _context10.prev = 1;
536
- _context10.next = 4;
1309
+ params = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : {};
1310
+ _context20.prev = 1;
1311
+ _context20.next = 4;
537
1312
  return this.store.customer.getCustomerList(params);
538
1313
  case 4:
539
- _result2 = _context10.sent;
540
- return _context10.abrupt("return", _result2);
1314
+ _result3 = _context20.sent;
1315
+ return _context20.abrupt("return", _result3);
541
1316
  case 8:
542
- _context10.prev = 8;
543
- _context10.t0 = _context10["catch"](1);
544
- console.error('Failed to get customer list:', _context10.t0);
545
- throw _context10.t0;
1317
+ _context20.prev = 8;
1318
+ _context20.t0 = _context20["catch"](1);
1319
+ console.error('Failed to get customer list:', _context20.t0);
1320
+ throw _context20.t0;
546
1321
  case 12:
547
1322
  case "end":
548
- return _context10.stop();
1323
+ return _context20.stop();
549
1324
  }
550
- }, _callee10, this, [[1, 8]]);
1325
+ }, _callee20, this, [[1, 8]]);
551
1326
  }));
552
1327
  function getCustomerList() {
553
1328
  return _getCustomerList.apply(this, arguments);
@@ -654,14 +1429,38 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
654
1429
  }, {
655
1430
  key: "setOrderCustomer",
656
1431
  value: function setOrderCustomer(customer) {
1432
+ var _this$store$order$get3;
657
1433
  if (!customer) {
658
1434
  this.clearOrderCustomer();
659
1435
  return;
660
1436
  }
1437
+ 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;
1438
+ var snapshotBeforeSet = this.store.order.getOrderCustomerSnapshot();
661
1439
  var patch = formatOrderCustomerPatch(customer);
1440
+ var customerUnchanged = Number(previousCustomerId || 0) === Number(patch.customer_id || 0);
1441
+ if (!customerUnchanged) {
1442
+ this.discountConfigCacheKey = null;
1443
+ this.hasManualDiscountSelection = false;
1444
+ }
662
1445
  this.store.order.setOrderCustomer(patch, customer);
1446
+ var snapshotAfterOrderSet = this.store.order.getOrderCustomerSnapshot();
1447
+ if (customerUnchanged) {
1448
+ // hydrate 后 customer_id 已存在但 _extend.customerSnapshot 仍为空时,
1449
+ // 须通知 SalesSdk 刷新 selected(否则会一直停在 onSalesOrderLoaded 时的 null)。
1450
+ var snapshotReplenished = !snapshotBeforeSet && Boolean(snapshotAfterOrderSet);
1451
+ if (snapshotReplenished) {
1452
+ var _next2 = this.buildOrderCustomerPayload();
1453
+ this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), _next2);
1454
+ }
1455
+ return;
1456
+ }
663
1457
  var next = this.buildOrderCustomerPayload();
664
1458
  this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), next);
1459
+ this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
1460
+ // 客户切换可能改变可用促销/赠品;触发一次重算(recursion-safe)。
1461
+ void this.store.order.applyPromotion().catch(function (error) {
1462
+ console.error('[BookingTicket] applyPromotion after customer change failed', error);
1463
+ });
665
1464
  }
666
1465
 
667
1466
  /**
@@ -688,11 +1487,63 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
688
1487
  }, {
689
1488
  key: "clearOrderCustomer",
690
1489
  value: function clearOrderCustomer() {
1490
+ var _discountModule$setOr,
1491
+ _discountModule$setDi,
1492
+ _this3 = this;
691
1493
  this.store.order.clearOrderCustomer();
1494
+ this.discountConfigCacheKey = null;
1495
+ this.hasManualDiscountSelection = false;
1496
+ var orderStore = this.store.order.store || {};
1497
+ var discountModule = orderStore.discount;
1498
+ void (discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, []));
1499
+ void (discountModule === null || discountModule === void 0 || (_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, []));
1500
+ this.store.order.applyDiscount();
1501
+ void this.store.order.recalculateSummary({
1502
+ createIfMissing: true
1503
+ }).then(function () {
1504
+ return _this3.store.order.persistTempOrder();
1505
+ }).catch(function (error) {
1506
+ console.error('Failed to recalculate summary after clearing customer:', error);
1507
+ });
692
1508
  this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), null);
693
1509
  }
694
1510
 
695
- /** 内部:基于 OrderModule 当前状态构造一份 OrderCustomerChangePayload。 */
1511
+ /**
1512
+ * 重置 tempOrder,并同步清空下单客户运行态。
1513
+ *
1514
+ * OrderModule.restoreOrder 会重建空单(customer_id 已为 null),但不会:
1515
+ * - emit BookingTicket `onOrderCustomerChange`
1516
+ * - 重置 CustomerModule.selectedCustomer(老路 getActiveCustomer)
1517
+ *
1518
+ * 因此在 super.restoreOrder 之后显式清客户,保证 SalesSdk / ticketBooking 订阅方与 tempOrder 一致。
1519
+ */
1520
+ }, {
1521
+ key: "restoreOrder",
1522
+ value: (function () {
1523
+ var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1524
+ var _this$store$customer;
1525
+ var tempOrder;
1526
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1527
+ while (1) switch (_context21.prev = _context21.next) {
1528
+ case 0:
1529
+ _context21.next = 2;
1530
+ return _get(_getPrototypeOf(BookingTicketImpl.prototype), "restoreOrder", this).call(this);
1531
+ case 2:
1532
+ tempOrder = _context21.sent;
1533
+ this.clearOrderCustomer();
1534
+ (_this$store$customer = this.store.customer) === null || _this$store$customer === void 0 || _this$store$customer.setSelectedCustomer(null);
1535
+ return _context21.abrupt("return", tempOrder);
1536
+ case 6:
1537
+ case "end":
1538
+ return _context21.stop();
1539
+ }
1540
+ }, _callee21, this);
1541
+ }));
1542
+ function restoreOrder() {
1543
+ return _restoreOrder.apply(this, arguments);
1544
+ }
1545
+ return restoreOrder;
1546
+ }() /** 内部:基于 OrderModule 当前状态构造一份 OrderCustomerChangePayload。 */)
696
1547
  }, {
697
1548
  key: "buildOrderCustomerPayload",
698
1549
  value: function buildOrderCustomerPayload() {
@@ -703,6 +1554,56 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
703
1554
  snapshot: this.store.order.getOrderCustomerSnapshot()
704
1555
  };
705
1556
  }
1557
+ }, {
1558
+ key: "refreshDiscountConfigAfterOrderCustomerChange",
1559
+ value: function refreshDiscountConfigAfterOrderCustomerChange(customerId) {
1560
+ var _this4 = this;
1561
+ if (!customerId || customerId === 1) return;
1562
+ if (this.orderCustomerDiscountRefreshInFlight && this.orderCustomerDiscountRefreshCustomerId === customerId) {
1563
+ return;
1564
+ }
1565
+ var previousRefresh = this.orderCustomerDiscountRefreshInFlight;
1566
+ var refreshTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1567
+ var currentCustomer;
1568
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1569
+ while (1) switch (_context22.prev = _context22.next) {
1570
+ case 0:
1571
+ if (!previousRefresh) {
1572
+ _context22.next = 3;
1573
+ break;
1574
+ }
1575
+ _context22.next = 3;
1576
+ return previousRefresh.catch(function () {
1577
+ return undefined;
1578
+ });
1579
+ case 3:
1580
+ currentCustomer = _this4.store.order.getOrderCustomer();
1581
+ if (!(!currentCustomer || Number(currentCustomer.customer_id) !== customerId)) {
1582
+ _context22.next = 6;
1583
+ break;
1584
+ }
1585
+ return _context22.abrupt("return");
1586
+ case 6:
1587
+ _context22.next = 8;
1588
+ return _this4.loadDiscountConfig({
1589
+ customerId: customerId
1590
+ });
1591
+ case 8:
1592
+ case "end":
1593
+ return _context22.stop();
1594
+ }
1595
+ }, _callee22);
1596
+ }))();
1597
+ this.orderCustomerDiscountRefreshInFlight = refreshTask;
1598
+ this.orderCustomerDiscountRefreshCustomerId = customerId;
1599
+ refreshTask.catch(function (error) {
1600
+ console.error('Failed to load discount config after customer change:', error);
1601
+ }).finally(function () {
1602
+ if (_this4.orderCustomerDiscountRefreshInFlight !== refreshTask) return;
1603
+ _this4.orderCustomerDiscountRefreshInFlight = null;
1604
+ _this4.orderCustomerDiscountRefreshCustomerId = null;
1605
+ });
1606
+ }
706
1607
 
707
1608
  /**
708
1609
  * 获取客户分页信息
@@ -744,29 +1645,29 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
744
1645
  }, {
745
1646
  key: "changeCustomerPage",
746
1647
  value: (function () {
747
- var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(page, pageSize) {
748
- var _result3;
749
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
750
- while (1) switch (_context11.prev = _context11.next) {
1648
+ var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(page, pageSize) {
1649
+ var _result4;
1650
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1651
+ while (1) switch (_context23.prev = _context23.next) {
751
1652
  case 0:
752
- _context11.prev = 0;
753
- _context11.next = 3;
1653
+ _context23.prev = 0;
1654
+ _context23.next = 3;
754
1655
  return this.store.customer.changeCustomerPage(page, pageSize);
755
1656
  case 3:
756
- _result3 = _context11.sent;
757
- return _context11.abrupt("return", _result3);
1657
+ _result4 = _context23.sent;
1658
+ return _context23.abrupt("return", _result4);
758
1659
  case 7:
759
- _context11.prev = 7;
760
- _context11.t0 = _context11["catch"](0);
761
- console.error('Failed to change customer page:', _context11.t0);
762
- throw _context11.t0;
1660
+ _context23.prev = 7;
1661
+ _context23.t0 = _context23["catch"](0);
1662
+ console.error('Failed to change customer page:', _context23.t0);
1663
+ throw _context23.t0;
763
1664
  case 11:
764
1665
  case "end":
765
- return _context11.stop();
1666
+ return _context23.stop();
766
1667
  }
767
- }, _callee11, this, [[0, 7]]);
1668
+ }, _callee23, this, [[0, 7]]);
768
1669
  }));
769
- function changeCustomerPage(_x8, _x9) {
1670
+ function changeCustomerPage(_x15, _x16) {
770
1671
  return _changeCustomerPage.apply(this, arguments);
771
1672
  }
772
1673
  return changeCustomerPage;
@@ -779,28 +1680,28 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
779
1680
  }, {
780
1681
  key: "loadMoreCustomers",
781
1682
  value: (function () {
782
- var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
783
- var _result4;
784
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
785
- while (1) switch (_context12.prev = _context12.next) {
1683
+ var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
1684
+ var _result5;
1685
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1686
+ while (1) switch (_context24.prev = _context24.next) {
786
1687
  case 0:
787
- _context12.prev = 0;
788
- _context12.next = 3;
1688
+ _context24.prev = 0;
1689
+ _context24.next = 3;
789
1690
  return this.store.customer.loadMoreCustomers();
790
1691
  case 3:
791
- _result4 = _context12.sent;
792
- this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), _result4);
793
- return _context12.abrupt("return", _result4);
1692
+ _result5 = _context24.sent;
1693
+ this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), _result5);
1694
+ return _context24.abrupt("return", _result5);
794
1695
  case 8:
795
- _context12.prev = 8;
796
- _context12.t0 = _context12["catch"](0);
797
- console.error('Failed to load more customers:', _context12.t0);
798
- throw _context12.t0;
1696
+ _context24.prev = 8;
1697
+ _context24.t0 = _context24["catch"](0);
1698
+ console.error('Failed to load more customers:', _context24.t0);
1699
+ throw _context24.t0;
799
1700
  case 12:
800
1701
  case "end":
801
- return _context12.stop();
1702
+ return _context24.stop();
802
1703
  }
803
- }, _callee12, this, [[0, 8]]);
1704
+ }, _callee24, this, [[0, 8]]);
804
1705
  }));
805
1706
  function loadMoreCustomers() {
806
1707
  return _loadMoreCustomers.apply(this, arguments);
@@ -816,31 +1717,31 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
816
1717
  }, {
817
1718
  key: "resetAndLoadCustomers",
818
1719
  value: (function () {
819
- var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
1720
+ var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
820
1721
  var params,
821
- _result5,
822
- _args13 = arguments;
823
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
824
- while (1) switch (_context13.prev = _context13.next) {
1722
+ _result6,
1723
+ _args25 = arguments;
1724
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1725
+ while (1) switch (_context25.prev = _context25.next) {
825
1726
  case 0:
826
- params = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
827
- _context13.prev = 1;
828
- _context13.next = 4;
1727
+ params = _args25.length > 0 && _args25[0] !== undefined ? _args25[0] : {};
1728
+ _context25.prev = 1;
1729
+ _context25.next = 4;
829
1730
  return this.store.customer.resetAndLoadCustomers(params);
830
1731
  case 4:
831
- _result5 = _context13.sent;
832
- this.core.effects.emit("".concat(this.name, ":onCustomerListReset"), _result5);
833
- return _context13.abrupt("return", _result5);
1732
+ _result6 = _context25.sent;
1733
+ this.core.effects.emit("".concat(this.name, ":onCustomerListReset"), _result6);
1734
+ return _context25.abrupt("return", _result6);
834
1735
  case 9:
835
- _context13.prev = 9;
836
- _context13.t0 = _context13["catch"](1);
837
- console.error('Failed to reset and load customers:', _context13.t0);
838
- throw _context13.t0;
1736
+ _context25.prev = 9;
1737
+ _context25.t0 = _context25["catch"](1);
1738
+ console.error('Failed to reset and load customers:', _context25.t0);
1739
+ throw _context25.t0;
839
1740
  case 13:
840
1741
  case "end":
841
- return _context13.stop();
1742
+ return _context25.stop();
842
1743
  }
843
- }, _callee13, this, [[1, 9]]);
1744
+ }, _callee25, this, [[1, 9]]);
844
1745
  }));
845
1746
  function resetAndLoadCustomers() {
846
1747
  return _resetAndLoadCustomers.apply(this, arguments);
@@ -885,9 +1786,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
885
1786
  }, {
886
1787
  key: "scanGlobalListener",
887
1788
  value: function scanGlobalListener(callback) {
888
- var _this2 = this;
1789
+ var _this5 = this;
889
1790
  var localSearch = function localSearch(v) {
890
- return _this2.store.products.findProductsByCodeOrBarcode(v);
1791
+ return _this5.store.products.findProductsByCodeOrBarcode(v);
891
1792
  };
892
1793
  var scanCallback = handleGlobalScan(this.request, localSearch);
893
1794
  var safeCallback = function safeCallback(d) {
@@ -995,76 +1896,710 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
995
1896
  }
996
1897
 
997
1898
  /**
998
- * 设置其他参数
999
- * @param params 参数
1000
- * @param options 选项
1899
+ * 获取其他参数
1900
+ * @returns 其他参数
1001
1901
  */
1002
1902
  }, {
1003
- key: "setOtherParams",
1903
+ key: "getOtherParams",
1004
1904
  value: (function () {
1005
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
1006
- var _ref2,
1007
- _ref2$cover,
1008
- cover,
1009
- _args14 = arguments;
1010
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1011
- while (1) switch (_context14.prev = _context14.next) {
1905
+ var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
1906
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1907
+ while (1) switch (_context26.prev = _context26.next) {
1012
1908
  case 0:
1013
- _ref2 = _args14.length > 1 && _args14[1] !== undefined ? _args14[1] : {}, _ref2$cover = _ref2.cover, cover = _ref2$cover === void 0 ? false : _ref2$cover;
1014
- if (cover) {
1015
- this.otherParams = params;
1016
- } else {
1017
- this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
1018
- }
1019
- case 2:
1909
+ return _context26.abrupt("return", this.otherParams);
1910
+ case 1:
1020
1911
  case "end":
1021
- return _context14.stop();
1912
+ return _context26.stop();
1022
1913
  }
1023
- }, _callee14, this);
1914
+ }, _callee26, this);
1024
1915
  }));
1025
- function setOtherParams(_x10) {
1026
- return _setOtherParams.apply(this, arguments);
1916
+ function getOtherParams() {
1917
+ return _getOtherParams.apply(this, arguments);
1027
1918
  }
1028
- return setOtherParams;
1919
+ return getOtherParams;
1920
+ }() // ─── BookingContext API(透传给 BookingContextModule) ──────────────────────
1921
+ // SalesSdkProvider 挂载时默认调 initBookingContext;也可由 UI 显式 set* 灌入已有数据。
1922
+ /** 拉取 board config 并写入 BookingContext。 */
1923
+ )
1924
+ }, {
1925
+ key: "loadBookingConfig",
1926
+ value: function loadBookingConfig(params) {
1927
+ return this.store.bookingContext.loadBookingConfig(params);
1928
+ }
1929
+
1930
+ /** 拉取资源全集并写入 BookingContext。 */
1931
+ }, {
1932
+ key: "loadBookingResources",
1933
+ value: function loadBookingResources(params) {
1934
+ return this.store.bookingContext.loadResources(params);
1935
+ }
1936
+
1937
+ /** 初始化 BookingContext(date + config + resources)。 */
1938
+ }, {
1939
+ key: "initBookingContext",
1940
+ value: function initBookingContext(params) {
1941
+ return this.store.bookingContext.initBookingContext(params);
1942
+ }
1943
+
1944
+ /** 当前 store 是否已具备与入参等价的 config / resources(无需再请求接口)。 */
1945
+ }, {
1946
+ key: "isBookingContextReady",
1947
+ value: function isBookingContextReady(params) {
1948
+ return this.store.bookingContext.isBookingContextReady(params);
1949
+ }
1950
+
1951
+ /** 写入 booking config(来源:`/core/board/management/config`)。 */
1952
+ }, {
1953
+ key: "setBookingConfig",
1954
+ value: function setBookingConfig(config) {
1955
+ this.store.bookingContext.setBookingConfig(config);
1956
+ }
1957
+
1958
+ /** 读取当前 booking config。 */
1959
+ }, {
1960
+ key: "getBookingConfig",
1961
+ value: function getBookingConfig() {
1962
+ return this.store.bookingContext.getBookingConfig();
1963
+ }
1964
+
1965
+ /** 写入资源全集(来源:`/form/schedule`),同步派生 resourcesOriginMap。 */
1966
+ }, {
1967
+ key: "setResources",
1968
+ value: function setResources(resources) {
1969
+ this.store.bookingContext.setResources(resources);
1970
+ }
1971
+
1972
+ /** 读取资源全集(浅克隆)。 */
1973
+ }, {
1974
+ key: "getResourcesOrigin",
1975
+ value: function getResourcesOrigin() {
1976
+ return this.store.bookingContext.getResourcesOrigin();
1977
+ }
1978
+
1979
+ /** 读取资源全集 map(id → resource)。 */
1980
+ }, {
1981
+ key: "getResourcesOriginMap",
1982
+ value: function getResourcesOriginMap() {
1983
+ return this.store.bookingContext.getResourcesOriginMap();
1984
+ }
1985
+
1986
+ /** 写入当前选择的日期;支持 dayjs / Date / string。 */
1987
+ }, {
1988
+ key: "setBookingDate",
1989
+ value: function setBookingDate(date) {
1990
+ this.store.bookingContext.setDate(date);
1991
+ }
1992
+
1993
+ /** 读取当前选择的日期(统一 string)。 */
1994
+ }, {
1995
+ key: "getBookingDate",
1996
+ value: function getBookingDate() {
1997
+ return this.store.bookingContext.getDate();
1998
+ }
1999
+
2000
+ /** 读取 BookingContext 完整 store(调试 / 测试 / 透传给 SDK 使用)。 */
2001
+ }, {
2002
+ key: "getBookingContextState",
2003
+ value: function getBookingContextState() {
2004
+ return this.store.bookingContext.getState();
2005
+ }
2006
+
2007
+ /** 清空 BookingContext(切租户 / destroy 场景)。 */
2008
+ }, {
2009
+ key: "clearBookingContext",
2010
+ value: function clearBookingContext() {
2011
+ this.store.bookingContext.clear();
2012
+ }
2013
+
2014
+ /**
2015
+ * 构造 BookingContext 计算上下文(供 getProductExtend / getResourceByIds 等读 API 复用)。
2016
+ */
2017
+ }, {
2018
+ key: "buildBookingCalcContext",
2019
+ value: function buildBookingCalcContext(extra) {
2020
+ var _extra$date, _extra$presetStartTim;
2021
+ var state = this.store.bookingContext.getState();
2022
+ var date = (_extra$date = extra === null || extra === void 0 ? void 0 : extra.date) !== null && _extra$date !== void 0 ? _extra$date : state.date;
2023
+ return _objectSpread({
2024
+ bookingConfig: state.bookingConfig,
2025
+ resourcesOrigin: state.resourcesOrigin,
2026
+ resourcesOriginMap: state.resourcesOriginMap,
2027
+ date: date,
2028
+ presetStartTime: (_extra$presetStartTim = extra === null || extra === void 0 ? void 0 : extra.presetStartTime) !== null && _extra$presetStartTim !== void 0 ? _extra$presetStartTim : derivePresetStartTimeFromDate(date)
2029
+ }, extra || {});
2030
+ }
2031
+
2032
+ /**
2033
+ * 取商品当前可选资源列表(透传 OS BookingContext utils#getResourceByIds)。
2034
+ * `extraResources` 用于把拖入未绑定的资源也展示出来。
2035
+ */
2036
+ }, {
2037
+ key: "getResourcesForProduct",
2038
+ value: function getResourcesForProduct(product, options) {
2039
+ var _ctx$bookingConfig;
2040
+ var ctx = this.buildBookingCalcContext();
2041
+ return getResourceByIdsUtil(ctx.resourcesOriginMap || {}, product, {
2042
+ 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,
2043
+ resourcesOrigin: ctx.resourcesOrigin,
2044
+ extraResources: (options === null || options === void 0 ? void 0 : options.extraResources) || []
2045
+ });
2046
+ }
2047
+
2048
+ /**
2049
+ * 拼装 cacheItem 的 _extend / _data(资源 / 容量 / timeObj),与 info2 `getProductExtend` 等价。
2050
+ */
2051
+ }, {
2052
+ key: "getProductExtend",
2053
+ value: function getProductExtend(cacheItem, extra) {
2054
+ var preparedCacheItem = withProductOptionString(cacheItem);
2055
+ var result = getProductExtendUtil({
2056
+ cacheItem: preparedCacheItem,
2057
+ ctx: this.buildBookingCalcContext(extra)
2058
+ });
2059
+ return result;
2060
+ }
2061
+
2062
+ /**
2063
+ * 取资源不可用原因列表(结构化 enum + params,i18n 文案由 UI 渲染)。
2064
+ */
2065
+ }, {
2066
+ key: "getResourceErrors",
2067
+ value: function getResourceErrors(resource, cacheItem) {
2068
+ return getResourceErrorsUtil(resource, cacheItem);
2069
+ }
2070
+
2071
+ // ─── addProduct 决策 / 转换 API(SDK 加车下沉所需) ─────────────────────────
2072
+ // 这一组方法是 SalesSdkCartContext.addProduct / confirmDetail 的 OS 后端。
2073
+ // 调用方传入 ProductData,OS 自取 bookingContext / customer / date 等上下文,
2074
+ // 输出 (a) autoClose 决策结果或 (b) `{ product, booking }` 协议入参。
2075
+
2076
+ /**
2077
+ * session 商品 catalog 日期与 TimeBar 不一致时写业务日志。
2078
+ *
2079
+ * @example
2080
+ * this.logSessionCatalogDateMismatch(product, ctx.date);
2081
+ */
2082
+ }, {
2083
+ key: "logSessionCatalogDateMismatch",
2084
+ value: function logSessionCatalogDateMismatch(item, bookingDate) {
2085
+ var _this$getTempOrder, _tempOrder$order_id, _tempOrder$external_s, _item$cartDetailValue, _item$cartDetailValue2;
2086
+ var logger = this.logger;
2087
+ if (!(logger !== null && logger !== void 0 && logger.addLog)) return;
2088
+ var tempOrder = (_this$getTempOrder = this.getTempOrder) === null || _this$getTempOrder === void 0 ? void 0 : _this$getTempOrder.call(this);
2089
+ var staleInfo = buildSessionCatalogStaleInfo(item, bookingDate);
2090
+ logger.addLog({
2091
+ type: 'warning',
2092
+ title: "[BookingTicket] session catalog date mismatch, reload products",
2093
+ metadata: _objectSpread(_objectSpread({
2094
+ 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,
2095
+ 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
2096
+ }, staleInfo), {}, {
2097
+ 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
2098
+ })
2099
+ });
2100
+ }
2101
+
2102
+ /**
2103
+ * 加车前:session 商品 catalog 日历日与 bookingDate 不一致时中断加购,交由 SDK reload products。
2104
+ */
2105
+ }, {
2106
+ key: "resolveSessionCatalogBeforeAdd",
2107
+ value: function resolveSessionCatalogBeforeAdd(item, ctx) {
2108
+ if (!isSessionCatalogDateStale(item, ctx.date)) {
2109
+ return null;
2110
+ }
2111
+ this.logSessionCatalogDateMismatch(item, ctx.date);
2112
+ return {
2113
+ action: 'reloadCatalog'
2114
+ };
2115
+ }
2116
+
2117
+ /**
2118
+ * 拼装 addProductDecision 通用上下文(从 store 自取)。
2119
+ */
2120
+ }, {
2121
+ key: "buildAddProductCtx",
2122
+ value: function buildAddProductCtx(extra) {
2123
+ var _extra$date2, _ref12, _this$getOrderCustome, _this$getOrderCustome2, _this$store$order$get4, _extra$presetStartTim2;
2124
+ var bookingContextState = this.store.bookingContext.getState();
2125
+ var date = (_extra$date2 = extra === null || extra === void 0 ? void 0 : extra.date) !== null && _extra$date2 !== void 0 ? _extra$date2 : bookingContextState.date;
2126
+ 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;
2127
+ return _objectSpread({
2128
+ bookingConfig: bookingContextState.bookingConfig,
2129
+ resourcesOrigin: bookingContextState.resourcesOrigin,
2130
+ resourcesOriginMap: bookingContextState.resourcesOriginMap,
2131
+ date: date,
2132
+ presetStartTime: (_extra$presetStartTim2 = extra === null || extra === void 0 ? void 0 : extra.presetStartTime) !== null && _extra$presetStartTim2 !== void 0 ? _extra$presetStartTim2 : derivePresetStartTimeFromDate(date),
2133
+ customerId: orderCustomerId
2134
+ }, extra || {});
2135
+ }
2136
+
2137
+ /**
2138
+ * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
2139
+ * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
2140
+ */
2141
+ }, {
2142
+ key: "decideAddProduct",
2143
+ value: function decideAddProduct(item, options) {
2144
+ var ctx = this.buildAddProductCtx(options);
2145
+ var staleDecision = this.resolveSessionCatalogBeforeAdd(item, ctx);
2146
+ if (staleDecision) {
2147
+ return staleDecision;
2148
+ }
2149
+ return decideAddProductUtil(item, ctx);
2150
+ }
2151
+
2152
+ /** 规格弹窗 callback 后的第二段决策。 */
2153
+ }, {
2154
+ key: "decideAfterDetail",
2155
+ value: function decideAfterDetail(cacheItem, options) {
2156
+ return decideAfterDetailUtil(cacheItem, this.buildAddProductCtx(options));
2157
+ }
2158
+
2159
+ /**
2160
+ * @deprecated 请用 `decideAddProduct`;`autoClose=true` 仅当 action=add。
2161
+ */
2162
+ }, {
2163
+ key: "decideAutoClose",
2164
+ value: function decideAutoClose(item, options) {
2165
+ return decideAutoCloseUtil(item, this.buildAddProductCtx(options));
2166
+ }
2167
+
2168
+ /** 替代 info2 `getIsEject`:商品是否需要弹窗(0/1)。 */
2169
+ }, {
2170
+ key: "getIsEject",
2171
+ value: function getIsEject(item) {
2172
+ var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'select';
2173
+ return getIsEjectUtil(item, type);
2174
+ }
2175
+
2176
+ /** 仅 session 商品(无 variant/option/package)→ true。 */
2177
+ }, {
2178
+ key: "getIsOnlySession",
2179
+ value: function getIsOnlySession(item) {
2180
+ return getIsOnlySessionUtil(item);
2181
+ }
2182
+
2183
+ /**
2184
+ * 拼装 requiresDetail payload(给 SDK 直接 return 给 UI 用)。
2185
+ */
2186
+ }, {
2187
+ key: "buildRequiresDetailPayload",
2188
+ value: function buildRequiresDetailPayload(item, options) {
2189
+ var ctx = this.buildAddProductCtx(options);
2190
+ return _buildRequiresDetailPayload(item, ctx);
2191
+ }
2192
+
2193
+ /**
2194
+ * 把 detail 弹窗回调结果(e, extension_type, detail)转换为 `(product, booking)` 入参。
2195
+ * 内部会先拼 cacheItem,再走 cacheItemToBookingInput 严格协议对齐。
2196
+ */
2197
+ }, {
2198
+ key: "transformDetailToProductAndBooking",
2199
+ value: function transformDetailToProductAndBooking(input) {
2200
+ var item = input.item,
2201
+ preparedCacheItem = input.cacheItem,
2202
+ detailResult = input.detailResult,
2203
+ options = input.options;
2204
+ var ctx = this.buildAddProductCtx(options);
2205
+ var cacheItem = preparedCacheItem || (detailResult ? buildCacheItemFromDetail(item, detailResult, ctx) : buildCacheItemFromCartDetail(item, ctx));
2206
+ return transformDetailToProductAndBookingUtil(cacheItem, ctx);
2207
+ }
2208
+
2209
+ /**
2210
+ * 从已加车的 order line + booking 反查资源编辑抽屉所需的 cacheItem。
2211
+ * 供 SalesSdk「编辑资源」等场景使用;字段语义与 buildCacheItemFromDetail 产出对齐。
2212
+ */
2213
+ }, {
2214
+ key: "buildCacheItemFromOrderLine",
2215
+ value: function buildCacheItemFromOrderLine(input) {
2216
+ return buildCacheItemFromOrderLineUtil(input);
2217
+ }
2218
+
2219
+ /**
2220
+ * 从已加车的普通商品 order line 反查 SkuDetailModal edit 所需的 cacheItem。
2221
+ */
2222
+ }, {
2223
+ key: "buildNormalProductCacheItemFromOrderLine",
2224
+ value: function buildNormalProductCacheItemFromOrderLine(input) {
2225
+ return buildNormalProductCacheItemFromOrderLineUtil(input);
2226
+ }
2227
+
2228
+ /** 文档别名:与 OrderModule.updateOrderProduct 一致。 */
2229
+ }, {
2230
+ key: "updateProductInOrder",
2231
+ value: (function () {
2232
+ var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
2233
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2234
+ while (1) switch (_context27.prev = _context27.next) {
2235
+ case 0:
2236
+ return _context27.abrupt("return", this.updateOrderProduct(params));
2237
+ case 1:
2238
+ case "end":
2239
+ return _context27.stop();
2240
+ }
2241
+ }, _callee27, this);
2242
+ }));
2243
+ function updateProductInOrder(_x17) {
2244
+ return _updateProductInOrder.apply(this, arguments);
2245
+ }
2246
+ return updateProductInOrder;
1029
2247
  }()
1030
2248
  /**
1031
- * 获取其他参数
1032
- * @returns 其他参数
2249
+ * 全局扫码 pubsub 入口:解析码值 → 搜索 → 业务分发(客户 / 加车 / 开单)。
2250
+ * UI 层在 pubsub 订阅回调里注入 `bridge`(uiHosts / action / cart.confirm*)。
2251
+ *
2252
+ * @example
2253
+ * ```ts
2254
+ * await bookingTicket.handleGlobalScanCode(payload.data, {
2255
+ * openProductDetail: uiHosts.openProductDetail,
2256
+ * confirmDetail: cart.confirmDetail,
2257
+ * openOrder: ({ order_id }) => action({ type: 'pisell1.handleOpenCachedBigSale', data: { order_id } }),
2258
+ * });
2259
+ * ```
1033
2260
  */
1034
2261
  )
1035
2262
  }, {
1036
- key: "getOtherParams",
2263
+ key: "handleGlobalScanCode",
1037
2264
  value: (function () {
1038
- var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1039
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1040
- while (1) switch (_context15.prev = _context15.next) {
2265
+ var _handleGlobalScanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(code, bridge) {
2266
+ var _this6 = this;
2267
+ var trimmed, _bridge$onNotify, _bridge$refresh, localSearch, scanCallback, raw, formatted, _bridge$onNotify2, _result7, _bridge$onNotify3;
2268
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2269
+ while (1) switch (_context28.prev = _context28.next) {
2270
+ case 0:
2271
+ trimmed = typeof code === 'string' ? code.trim() : '';
2272
+ if (trimmed) {
2273
+ _context28.next = 4;
2274
+ break;
2275
+ }
2276
+ bridge === null || bridge === void 0 || (_bridge$onNotify = bridge.onNotify) === null || _bridge$onNotify === void 0 || _bridge$onNotify.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
2277
+ return _context28.abrupt("return", {
2278
+ status: 'failed',
2279
+ reason: 'empty_code'
2280
+ });
2281
+ case 4:
2282
+ _context28.prev = 4;
2283
+ localSearch = function localSearch(v) {
2284
+ return _this6.store.products.findProductsByCodeOrBarcode(v);
2285
+ };
2286
+ scanCallback = handleGlobalScan(this.request, localSearch);
2287
+ _context28.next = 9;
2288
+ return scanCallback({
2289
+ type: 'nativeScanner',
2290
+ value: trimmed
2291
+ });
2292
+ case 9:
2293
+ raw = _context28.sent;
2294
+ formatted = formatGlobalScanResult(raw, trimmed);
2295
+ if (formatted) {
2296
+ _context28.next = 14;
2297
+ break;
2298
+ }
2299
+ bridge === null || bridge === void 0 || (_bridge$onNotify2 = bridge.onNotify) === null || _bridge$onNotify2 === void 0 || _bridge$onNotify2.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
2300
+ return _context28.abrupt("return", {
2301
+ status: 'failed',
2302
+ reason: 'not_found'
2303
+ });
2304
+ case 14:
2305
+ _context28.next = 16;
2306
+ return applyGlobalScan({
2307
+ setOrderCustomer: function setOrderCustomer(customer) {
2308
+ return _this6.setOrderCustomer(customer);
2309
+ },
2310
+ getOrderCustomerSnapshot: function getOrderCustomerSnapshot() {
2311
+ return _this6.getOrderCustomerSnapshot();
2312
+ },
2313
+ getBusinessCode: function getBusinessCode() {
2314
+ var _this6$otherParams;
2315
+ return (_this6$otherParams = _this6.otherParams) === null || _this6$otherParams === void 0 ? void 0 : _this6$otherParams.businessCode;
2316
+ },
2317
+ buildAddProductCtx: function buildAddProductCtx(extra) {
2318
+ return _this6.buildAddProductCtx(extra);
2319
+ },
2320
+ decideAddProduct: function decideAddProduct(item, options) {
2321
+ return _this6.decideAddProduct(item, options);
2322
+ },
2323
+ decideAfterDetail: function decideAfterDetail(cacheItem, options) {
2324
+ return _this6.decideAfterDetail(cacheItem, options);
2325
+ },
2326
+ transformDetailToProductAndBooking: function transformDetailToProductAndBooking(input) {
2327
+ return _this6.transformDetailToProductAndBooking(input);
2328
+ },
2329
+ addProductToOrder: function addProductToOrder(product, booking) {
2330
+ return _this6.addProductToOrder(product, booking);
2331
+ }
2332
+ }, formatted, bridge);
2333
+ case 16:
2334
+ _result7 = _context28.sent;
2335
+ bridge === null || bridge === void 0 || (_bridge$refresh = bridge.refresh) === null || _bridge$refresh === void 0 || _bridge$refresh.call(bridge);
2336
+ return _context28.abrupt("return", _result7);
2337
+ case 21:
2338
+ _context28.prev = 21;
2339
+ _context28.t0 = _context28["catch"](4);
2340
+ console.error('[BookingTicket] handleGlobalScanCode failed', _context28.t0);
2341
+ bridge === null || bridge === void 0 || (_bridge$onNotify3 = bridge.onNotify) === null || _bridge$onNotify3 === void 0 || _bridge$onNotify3.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
2342
+ return _context28.abrupt("return", {
2343
+ status: 'failed',
2344
+ reason: 'not_found'
2345
+ });
2346
+ case 26:
2347
+ case "end":
2348
+ return _context28.stop();
2349
+ }
2350
+ }, _callee28, this, [[4, 21]]);
2351
+ }));
2352
+ function handleGlobalScanCode(_x18, _x19) {
2353
+ return _handleGlobalScanCode.apply(this, arguments);
2354
+ }
2355
+ return handleGlobalScanCode;
2356
+ }())
2357
+ }, {
2358
+ key: "resolveBestAddTimePlan",
2359
+ value: function resolveBestAddTimePlan(addTimeProducts, targetMinutes) {
2360
+ return _resolveBestAddTimePlan(addTimeProducts, targetMinutes);
2361
+ }
2362
+
2363
+ /**
2364
+ * 构造一条绑定到已有 booking 的加时商品行。
2365
+ *
2366
+ * @example
2367
+ * const line = this.buildAddTimeOrderLine({ product, product_add_schedule_time: 30 }, 'booking-1');
2368
+ */
2369
+ }, {
2370
+ key: "buildAddTimeOrderLine",
2371
+ value: function buildAddTimeOrderLine(input, bookingUid) {
2372
+ 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;
2373
+ var product = input === null || input === void 0 ? void 0 : input.product;
2374
+ if (!product || _typeof(product) !== 'object') {
2375
+ throw new Error('[BookingTicket] addAddTimeProductToBooking: product 不能为空');
2376
+ }
2377
+ var quantity = normalizeAddTimeQuantity((_input$num = input.num) !== null && _input$num !== void 0 ? _input$num : product.num);
2378
+ var price = resolveAddTimeProductPrice(input.price, product);
2379
+ var addScheduleTime = resolveAddTimeScheduleMinutes(input.product_add_schedule_time, product);
2380
+ var payload = {
2381
+ id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : product.product_id,
2382
+ product_id: (_product$product_id = product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : product.id,
2383
+ 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,
2384
+ 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,
2385
+ quantity: quantity,
2386
+ num: quantity,
2387
+ price: price,
2388
+ selling_price: price,
2389
+ original_price: (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : price,
2390
+ line_total: price,
2391
+ total: price,
2392
+ product_sku: product.product_sku,
2393
+ 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 : [],
2394
+ 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 : []
2395
+ };
2396
+ var orderLine = this.transformBaseProductToOrderProduct({
2397
+ payload: payload,
2398
+ fallbackProductId: (_product$id2 = product.id) !== null && _product$id2 !== void 0 ? _product$id2 : product.product_id,
2399
+ sourceProduct: product,
2400
+ sourceItem: product
2401
+ });
2402
+ if (!orderLine) {
2403
+ throw new Error('[BookingTicket] addAddTimeProductToBooking: product transform failed');
2404
+ }
2405
+ var metadata = _objectSpread(_objectSpread(_objectSpread({}, orderLine.metadata || {}), addScheduleTime !== undefined ? {
2406
+ product_add_schedule_time: addScheduleTime
2407
+ } : {}), {}, {
2408
+ booking_uid: bookingUid
2409
+ });
2410
+ return _objectSpread(_objectSpread({}, orderLine), {}, {
2411
+ booking_uid: bookingUid,
2412
+ metadata: metadata
2413
+ });
2414
+ }
2415
+
2416
+ /**
2417
+ * 将加时商品作为独立商品行绑定到已有 booking。
2418
+ *
2419
+ * 与预约商品加车不同,本方法不会把当前 booking 作为 `addProductToOrder` 第二参数传入,
2420
+ * 避免 OrderModule 新建 booking 或重写已有 booking.product_uid。
2421
+ *
2422
+ * @example
2423
+ * await bookingTicket.addAddTimeProductToBooking({
2424
+ * booking,
2425
+ * product,
2426
+ * num: 1,
2427
+ * price: '10.00',
2428
+ * product_add_schedule_time: 30,
2429
+ * });
2430
+ */
2431
+ }, {
2432
+ key: "addAddTimeProductToBooking",
2433
+ value: (function () {
2434
+ var _addAddTimeProductToBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(input) {
2435
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2436
+ while (1) switch (_context29.prev = _context29.next) {
1041
2437
  case 0:
1042
- return _context15.abrupt("return", this.otherParams);
2438
+ return _context29.abrupt("return", this.addAddTimeProductsToBooking({
2439
+ booking: input.booking,
2440
+ products: [input],
2441
+ coveredMinutes: input.coveredMinutes,
2442
+ bookingPatch: input.bookingPatch
2443
+ }));
1043
2444
  case 1:
1044
2445
  case "end":
1045
- return _context15.stop();
2446
+ return _context29.stop();
1046
2447
  }
1047
- }, _callee15, this);
2448
+ }, _callee29, this);
1048
2449
  }));
1049
- function getOtherParams() {
1050
- return _getOtherParams.apply(this, arguments);
2450
+ function addAddTimeProductToBooking(_x20) {
2451
+ return _addAddTimeProductToBooking.apply(this, arguments);
1051
2452
  }
1052
- return getOtherParams;
2453
+ return addAddTimeProductToBooking;
2454
+ }()
2455
+ /**
2456
+ * 批量将加时商品作为独立商品行绑定到已有 booking,并只触发一次购物车重算。
2457
+ *
2458
+ * @example
2459
+ * await bookingTicket.addAddTimeProductsToBooking({
2460
+ * booking,
2461
+ * products: [{ product, product_add_schedule_time: 30 }],
2462
+ * });
2463
+ */
2464
+ )
2465
+ }, {
2466
+ key: "addAddTimeProductsToBooking",
2467
+ value: (function () {
2468
+ var _addAddTimeProductsToBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(input) {
2469
+ var _this7 = this,
2470
+ _input$bookingPatch;
2471
+ var bookingUid, orderLines, coveredMinutes, bookingTimePatch, result, _iterator, _step, line;
2472
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2473
+ while (1) switch (_context30.prev = _context30.next) {
2474
+ case 0:
2475
+ bookingUid = resolveBookingUidForAddTime(input === null || input === void 0 ? void 0 : input.booking);
2476
+ if (bookingUid) {
2477
+ _context30.next = 3;
2478
+ break;
2479
+ }
2480
+ throw new Error('[BookingTicket] addAddTimeProductToBooking: booking.metadata.unique_identification_number 缺失');
2481
+ case 3:
2482
+ orderLines = (input.products || []).map(function (line) {
2483
+ return {
2484
+ product: _this7.buildAddTimeOrderLine(line, bookingUid)
2485
+ };
2486
+ });
2487
+ if (this.store.order) {
2488
+ _context30.next = 6;
2489
+ break;
2490
+ }
2491
+ throw new Error('order 模块未初始化');
2492
+ case 6:
2493
+ coveredMinutes = normalizeCoveredMinutes(input.coveredMinutes);
2494
+ bookingTimePatch = (_input$bookingPatch = input.bookingPatch) !== null && _input$bookingPatch !== void 0 ? _input$bookingPatch : buildAddTimeBookingTimePatch(input.booking, coveredMinutes);
2495
+ if (bookingTimePatch) {
2496
+ this.store.order.updateOrderBooking({
2497
+ unique_identification_number: bookingUid,
2498
+ updates: bookingTimePatch
2499
+ });
2500
+ }
2501
+ if (!(typeof this.store.order.addProductsToOrder === 'function')) {
2502
+ _context30.next = 11;
2503
+ break;
2504
+ }
2505
+ return _context30.abrupt("return", this.store.order.addProductsToOrder(orderLines, {
2506
+ skipEditDiscountConfigRefresh: true,
2507
+ skipDiscountRecalculation: true
2508
+ }));
2509
+ case 11:
2510
+ result = [];
2511
+ _iterator = _createForOfIteratorHelper(orderLines);
2512
+ _context30.prev = 13;
2513
+ _iterator.s();
2514
+ case 15:
2515
+ if ((_step = _iterator.n()).done) {
2516
+ _context30.next = 29;
2517
+ break;
2518
+ }
2519
+ line = _step.value;
2520
+ _context30.t0 = result.splice;
2521
+ _context30.t1 = result;
2522
+ _context30.t2 = [0, result.length];
2523
+ _context30.t3 = _toConsumableArray;
2524
+ _context30.next = 23;
2525
+ return this.addProductToOrder(line.product);
2526
+ case 23:
2527
+ _context30.t4 = _context30.sent;
2528
+ _context30.t5 = (0, _context30.t3)(_context30.t4);
2529
+ _context30.t6 = _context30.t2.concat.call(_context30.t2, _context30.t5);
2530
+ _context30.t0.apply.call(_context30.t0, _context30.t1, _context30.t6);
2531
+ case 27:
2532
+ _context30.next = 15;
2533
+ break;
2534
+ case 29:
2535
+ _context30.next = 34;
2536
+ break;
2537
+ case 31:
2538
+ _context30.prev = 31;
2539
+ _context30.t7 = _context30["catch"](13);
2540
+ _iterator.e(_context30.t7);
2541
+ case 34:
2542
+ _context30.prev = 34;
2543
+ _iterator.f();
2544
+ return _context30.finish(34);
2545
+ case 37:
2546
+ return _context30.abrupt("return", result);
2547
+ case 38:
2548
+ case "end":
2549
+ return _context30.stop();
2550
+ }
2551
+ }, _callee30, this, [[13, 31, 34, 37]]);
2552
+ }));
2553
+ function addAddTimeProductsToBooking(_x21) {
2554
+ return _addAddTimeProductsToBooking.apply(this, arguments);
2555
+ }
2556
+ return addAddTimeProductsToBooking;
2557
+ }())
2558
+ }, {
2559
+ key: "setOtherParams",
2560
+ value: function () {
2561
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
2562
+ var _ref19,
2563
+ _ref19$cover,
2564
+ cover,
2565
+ _args31 = arguments;
2566
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2567
+ while (1) switch (_context31.prev = _context31.next) {
2568
+ case 0:
2569
+ _ref19 = _args31.length > 1 && _args31[1] !== undefined ? _args31[1] : {}, _ref19$cover = _ref19.cover, cover = _ref19$cover === void 0 ? false : _ref19$cover;
2570
+ _get(_getPrototypeOf(BookingTicketImpl.prototype), "setOtherParams", this).call(this, params, {
2571
+ cover: cover
2572
+ });
2573
+ if (!(params !== null && params !== void 0 && params.businessCode)) {
2574
+ _context31.next = 5;
2575
+ break;
2576
+ }
2577
+ _context31.next = 5;
2578
+ return this.configureIdGeneratorFromOpenData();
2579
+ case 5:
2580
+ case "end":
2581
+ return _context31.stop();
2582
+ }
2583
+ }, _callee31, this);
2584
+ }));
2585
+ function setOtherParams(_x22) {
2586
+ return _setOtherParams.apply(this, arguments);
2587
+ }
2588
+ return setOtherParams;
1053
2589
  }()
1054
2590
  /**
1055
2591
  * 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
1056
2592
  * 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
1057
2593
  */
1058
- )
1059
2594
  }, {
1060
2595
  key: "destroy",
1061
2596
  value: (function () {
1062
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
2597
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
1063
2598
  var _this$scan;
1064
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1065
- while (1) switch (_context16.prev = _context16.next) {
2599
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2600
+ while (1) switch (_context32.prev = _context32.next) {
1066
2601
  case 0:
1067
- _context16.next = 2;
2602
+ _context32.next = 2;
1068
2603
  return _get(_getPrototypeOf(BookingTicketImpl.prototype), "destroy", this).call(this);
1069
2604
  case 2:
1070
2605
  try {
@@ -1075,9 +2610,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1075
2610
  scanCache.clear();
1076
2611
  case 4:
1077
2612
  case "end":
1078
- return _context16.stop();
2613
+ return _context32.stop();
1079
2614
  }
1080
- }, _callee16, this);
2615
+ }, _callee32, this);
1081
2616
  }));
1082
2617
  function destroy() {
1083
2618
  return _destroy.apply(this, arguments);