@pisell/pisellos 2.2.244 → 2.2.246

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 (316) hide show
  1. package/dist/model/strategy/adapter/promotion/evaluator.js +3 -2
  2. package/dist/model/strategy/adapter/walletPass/utils.js +7 -4
  3. package/dist/modules/BookingContext/index.d.ts +48 -0
  4. package/dist/modules/BookingContext/index.js +566 -0
  5. package/dist/modules/BookingContext/types.d.ts +102 -0
  6. package/dist/modules/BookingContext/types.js +51 -0
  7. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  8. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +284 -0
  9. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  10. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +148 -0
  11. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
  12. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +218 -0
  13. package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
  14. package/dist/modules/BookingContext/utils/flexible.js +56 -0
  15. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  16. package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
  17. package/dist/modules/BookingContext/utils/index.d.ts +11 -0
  18. package/dist/modules/BookingContext/utils/index.js +11 -0
  19. package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
  20. package/dist/modules/BookingContext/utils/noResource.js +77 -0
  21. package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
  22. package/dist/modules/BookingContext/utils/orderLineDisplay.js +36 -0
  23. package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
  24. package/dist/modules/BookingContext/utils/productExtend.js +339 -0
  25. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  26. package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
  27. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  28. package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
  29. package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
  30. package/dist/modules/BookingContext/utils/resources.js +486 -0
  31. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  32. package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
  33. package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  34. package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
  35. package/dist/modules/Cart/utils/cartProduct.js +24 -3
  36. package/dist/modules/Cart/utils/changePrice.js +11 -11
  37. package/dist/modules/Customer/index.d.ts +20 -0
  38. package/dist/modules/Customer/index.js +172 -83
  39. package/dist/modules/Customer/types.d.ts +2 -0
  40. package/dist/modules/Discount/index.d.ts +1 -1
  41. package/dist/modules/Discount/index.js +13 -6
  42. package/dist/modules/Discount/types.d.ts +1 -0
  43. package/dist/modules/OpenData/index.d.ts +8 -0
  44. package/dist/modules/OpenData/index.js +37 -17
  45. package/dist/modules/Order/index.d.ts +277 -18
  46. package/dist/modules/Order/index.js +3581 -779
  47. package/dist/modules/Order/types.d.ts +286 -31
  48. package/dist/modules/Order/types.js +38 -0
  49. package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  50. package/dist/modules/Order/utils/manualProductDiscount.js +210 -0
  51. package/dist/modules/Order/utils.d.ts +147 -5
  52. package/dist/modules/Order/utils.js +750 -104
  53. package/dist/modules/Payment/index.d.ts +10 -13
  54. package/dist/modules/Payment/index.js +467 -837
  55. package/dist/modules/Payment/types.d.ts +2 -0
  56. package/dist/modules/Payment/utils.js +2 -1
  57. package/dist/modules/Payment/walletpass.js +41 -25
  58. package/dist/modules/ProductList/index.d.ts +16 -12
  59. package/dist/modules/ProductList/index.js +133 -59
  60. package/dist/modules/ProductList/types.d.ts +14 -0
  61. package/dist/modules/Quotation/index.d.ts +0 -1
  62. package/dist/modules/Quotation/index.js +25 -22
  63. package/dist/modules/Rules/index.d.ts +4 -0
  64. package/dist/modules/Rules/index.js +97 -70
  65. package/dist/modules/Rules/types.d.ts +1 -0
  66. package/dist/modules/SalesSummary/index.d.ts +8 -25
  67. package/dist/modules/SalesSummary/index.js +86 -35
  68. package/dist/modules/SalesSummary/types.d.ts +4 -1
  69. package/dist/modules/SalesSummary/utils.d.ts +2 -25
  70. package/dist/modules/SalesSummary/utils.js +794 -162
  71. package/dist/modules/Schedule/index.d.ts +7 -0
  72. package/dist/modules/Schedule/index.js +24 -2
  73. package/dist/modules/Summary/index.js +4 -3
  74. package/dist/modules/SurchargeList/index.d.ts +16 -0
  75. package/dist/modules/SurchargeList/index.js +162 -0
  76. package/dist/modules/SurchargeList/types.d.ts +11 -0
  77. package/dist/modules/SurchargeList/types.js +1 -0
  78. package/dist/modules/index.d.ts +2 -0
  79. package/dist/modules/index.js +3 -1
  80. package/dist/plugins/request.d.ts +1 -0
  81. package/dist/server/index.d.ts +204 -1
  82. package/dist/server/index.js +3654 -922
  83. package/dist/server/modules/index.d.ts +2 -0
  84. package/dist/server/modules/index.js +2 -0
  85. package/dist/server/modules/order/index.d.ts +120 -3
  86. package/dist/server/modules/order/index.js +1762 -448
  87. package/dist/server/modules/order/types.d.ts +32 -3
  88. package/dist/server/modules/order/types.js +8 -0
  89. package/dist/server/modules/order/utils/filterBookings.js +26 -3
  90. package/dist/server/modules/order/utils/filterOrders.js +23 -8
  91. package/dist/server/modules/payment/index.d.ts +28 -0
  92. package/dist/server/modules/payment/index.js +305 -0
  93. package/dist/server/modules/payment/types.d.ts +9 -0
  94. package/dist/server/modules/payment/types.js +1 -0
  95. package/dist/server/modules/products/index.d.ts +34 -7
  96. package/dist/server/modules/products/index.js +631 -317
  97. package/dist/server/modules/resource/index.d.ts +2 -0
  98. package/dist/server/modules/resource/index.js +29 -3
  99. package/dist/server/modules/schedule/index.d.ts +4 -4
  100. package/dist/server/modules/schedule/index.js +111 -88
  101. package/dist/server/test.json +713 -0
  102. package/dist/server/utils/small-ticket.d.ts +71 -0
  103. package/dist/server/utils/small-ticket.js +840 -0
  104. package/dist/solution/BaseSales/index.d.ts +133 -10
  105. package/dist/solution/BaseSales/index.js +1950 -447
  106. package/dist/solution/BaseSales/types.d.ts +82 -6
  107. package/dist/solution/BaseSales/types.js +5 -4
  108. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
  109. package/dist/solution/BaseSales/utils/cartPromotion.js +1438 -0
  110. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  111. package/dist/solution/BaseSales/utils/quotationPrice.js +237 -0
  112. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  113. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +105 -24
  114. package/dist/solution/BaseSales/utils.d.ts +1 -1
  115. package/dist/solution/BaseSales/utils.js +62 -21
  116. package/dist/solution/BookingByStep/index.d.ts +1 -1
  117. package/dist/solution/BookingTicket/index.d.ts +271 -11
  118. package/dist/solution/BookingTicket/index.js +1777 -242
  119. package/dist/solution/BookingTicket/types.d.ts +118 -1
  120. package/dist/solution/BookingTicket/types.js +41 -2
  121. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
  122. package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
  123. package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
  124. package/dist/solution/BookingTicket/utils/addTimeAvailability.js +95 -0
  125. package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +40 -0
  126. package/dist/solution/BookingTicket/utils/bookingStatus.js +70 -0
  127. package/dist/solution/BookingTicket/utils/cartView.d.ts +9 -1
  128. package/dist/solution/BookingTicket/utils/cartView.js +94 -7
  129. package/dist/solution/BookingTicket/utils/exampleData.d.ts +123 -0
  130. package/dist/solution/BookingTicket/utils/exampleData.js +183 -0
  131. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
  132. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +438 -0
  133. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
  134. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +400 -0
  135. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
  136. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +56 -0
  137. package/dist/solution/BookingTicket/utils/scan/index.d.ts +5 -0
  138. package/dist/solution/BookingTicket/utils/scan/index.js +20 -8
  139. package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
  140. package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +150 -0
  141. package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
  142. package/dist/solution/BookingTicket/utils/sessionCatalogStale.js +78 -0
  143. package/dist/solution/Checkout/index.d.ts +1 -0
  144. package/dist/solution/Checkout/index.js +10 -9
  145. package/dist/solution/RegisterAndLogin/config.js +2 -10
  146. package/dist/solution/ScanOrder/index.d.ts +9 -3
  147. package/dist/solution/ScanOrder/index.js +241 -134
  148. package/dist/solution/ScanOrder/types.d.ts +9 -5
  149. package/dist/solution/ScanOrder/types.js +2 -3
  150. package/dist/solution/ScanOrder/utils.d.ts +1 -1
  151. package/dist/solution/ScanOrder/utils.js +84 -22
  152. package/dist/solution/VenueBooking/index.d.ts +5 -2
  153. package/dist/solution/VenueBooking/index.js +110 -59
  154. package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -2
  155. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  156. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
  157. package/dist/types/index.d.ts +10 -0
  158. package/lib/model/strategy/adapter/promotion/evaluator.js +2 -1
  159. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  160. package/lib/model/strategy/adapter/walletPass/utils.js +3 -2
  161. package/lib/modules/BookingContext/index.d.ts +48 -0
  162. package/lib/modules/BookingContext/index.js +368 -0
  163. package/lib/modules/BookingContext/types.d.ts +102 -0
  164. package/lib/modules/BookingContext/types.js +34 -0
  165. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  166. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +276 -0
  167. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  168. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +154 -0
  169. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
  170. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +201 -0
  171. package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
  172. package/lib/modules/BookingContext/utils/flexible.js +80 -0
  173. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  174. package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
  175. package/lib/modules/BookingContext/utils/index.d.ts +11 -0
  176. package/lib/modules/BookingContext/utils/index.js +43 -0
  177. package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
  178. package/lib/modules/BookingContext/utils/noResource.js +90 -0
  179. package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
  180. package/lib/modules/BookingContext/utils/orderLineDisplay.js +56 -0
  181. package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
  182. package/lib/modules/BookingContext/utils/productExtend.js +283 -0
  183. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  184. package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
  185. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  186. package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
  187. package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
  188. package/lib/modules/BookingContext/utils/resources.js +377 -0
  189. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  190. package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
  191. package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  192. package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
  193. package/lib/modules/Cart/utils/cartProduct.js +20 -3
  194. package/lib/modules/Cart/utils/changePrice.js +12 -20
  195. package/lib/modules/Customer/index.d.ts +20 -0
  196. package/lib/modules/Customer/index.js +64 -11
  197. package/lib/modules/Customer/types.d.ts +2 -0
  198. package/lib/modules/Discount/index.d.ts +1 -1
  199. package/lib/modules/Discount/index.js +9 -1
  200. package/lib/modules/Discount/types.d.ts +1 -0
  201. package/lib/modules/OpenData/index.d.ts +8 -0
  202. package/lib/modules/OpenData/index.js +19 -5
  203. package/lib/modules/Order/index.d.ts +277 -18
  204. package/lib/modules/Order/index.js +2317 -337
  205. package/lib/modules/Order/types.d.ts +286 -31
  206. package/lib/modules/Order/types.js +1 -0
  207. package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  208. package/lib/modules/Order/utils/manualProductDiscount.js +206 -0
  209. package/lib/modules/Order/utils.d.ts +147 -5
  210. package/lib/modules/Order/utils.js +615 -46
  211. package/lib/modules/Payment/index.d.ts +10 -13
  212. package/lib/modules/Payment/index.js +18 -150
  213. package/lib/modules/Payment/types.d.ts +2 -0
  214. package/lib/modules/Payment/utils.js +2 -1
  215. package/lib/modules/Payment/walletpass.js +16 -3
  216. package/lib/modules/ProductList/index.d.ts +16 -12
  217. package/lib/modules/ProductList/index.js +41 -4
  218. package/lib/modules/ProductList/types.d.ts +14 -0
  219. package/lib/modules/Quotation/index.d.ts +0 -1
  220. package/lib/modules/Quotation/index.js +19 -16
  221. package/lib/modules/Rules/index.d.ts +4 -0
  222. package/lib/modules/Rules/index.js +137 -120
  223. package/lib/modules/Rules/types.d.ts +1 -0
  224. package/lib/modules/SalesSummary/index.d.ts +8 -25
  225. package/lib/modules/SalesSummary/index.js +30 -4
  226. package/lib/modules/SalesSummary/types.d.ts +4 -1
  227. package/lib/modules/SalesSummary/utils.d.ts +2 -25
  228. package/lib/modules/SalesSummary/utils.js +645 -91
  229. package/lib/modules/Schedule/index.d.ts +7 -0
  230. package/lib/modules/Schedule/index.js +17 -1
  231. package/lib/modules/Summary/index.js +5 -4
  232. package/lib/modules/SurchargeList/index.d.ts +16 -0
  233. package/lib/modules/SurchargeList/index.js +89 -0
  234. package/lib/modules/SurchargeList/types.d.ts +11 -0
  235. package/lib/modules/SurchargeList/types.js +17 -0
  236. package/lib/modules/index.d.ts +2 -0
  237. package/lib/modules/index.js +5 -1
  238. package/lib/plugins/request.d.ts +1 -0
  239. package/lib/server/index.d.ts +204 -1
  240. package/lib/server/index.js +1891 -59
  241. package/lib/server/modules/index.d.ts +2 -0
  242. package/lib/server/modules/index.js +3 -0
  243. package/lib/server/modules/order/index.d.ts +120 -3
  244. package/lib/server/modules/order/index.js +887 -94
  245. package/lib/server/modules/order/types.d.ts +32 -3
  246. package/lib/server/modules/order/utils/filterBookings.js +24 -5
  247. package/lib/server/modules/order/utils/filterOrders.js +15 -6
  248. package/lib/server/modules/payment/index.d.ts +28 -0
  249. package/lib/server/modules/payment/index.js +192 -0
  250. package/lib/server/modules/payment/types.d.ts +9 -0
  251. package/lib/server/modules/payment/types.js +17 -0
  252. package/lib/server/modules/products/index.d.ts +34 -7
  253. package/lib/server/modules/products/index.js +189 -54
  254. package/lib/server/modules/resource/index.d.ts +2 -0
  255. package/lib/server/modules/resource/index.js +27 -3
  256. package/lib/server/modules/schedule/index.d.ts +4 -4
  257. package/lib/server/modules/schedule/index.js +47 -40
  258. package/lib/server/test.json +713 -0
  259. package/lib/server/utils/small-ticket.d.ts +71 -0
  260. package/lib/server/utils/small-ticket.js +800 -0
  261. package/lib/solution/BaseSales/index.d.ts +133 -10
  262. package/lib/solution/BaseSales/index.js +1111 -63
  263. package/lib/solution/BaseSales/types.d.ts +82 -6
  264. package/lib/solution/BaseSales/types.js +3 -1
  265. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
  266. package/lib/solution/BaseSales/utils/cartPromotion.js +992 -0
  267. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  268. package/lib/solution/BaseSales/utils/quotationPrice.js +277 -0
  269. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  270. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +106 -18
  271. package/lib/solution/BaseSales/utils.d.ts +1 -1
  272. package/lib/solution/BaseSales/utils.js +54 -10
  273. package/lib/solution/BookingByStep/index.d.ts +1 -1
  274. package/lib/solution/BookingTicket/index.d.ts +271 -11
  275. package/lib/solution/BookingTicket/index.js +922 -29
  276. package/lib/solution/BookingTicket/types.d.ts +118 -1
  277. package/lib/solution/BookingTicket/types.js +11 -0
  278. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
  279. package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
  280. package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
  281. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +125 -0
  282. package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +40 -0
  283. package/lib/solution/BookingTicket/utils/bookingStatus.js +44 -2
  284. package/lib/solution/BookingTicket/utils/cartView.d.ts +9 -1
  285. package/lib/solution/BookingTicket/utils/cartView.js +61 -6
  286. package/lib/solution/BookingTicket/utils/exampleData.d.ts +123 -0
  287. package/lib/solution/BookingTicket/utils/exampleData.js +0 -0
  288. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
  289. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +254 -0
  290. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
  291. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +169 -0
  292. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
  293. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +51 -0
  294. package/lib/solution/BookingTicket/utils/scan/index.d.ts +5 -0
  295. package/lib/solution/BookingTicket/utils/scan/index.js +17 -3
  296. package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
  297. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +127 -0
  298. package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
  299. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +85 -0
  300. package/lib/solution/Checkout/index.d.ts +1 -0
  301. package/lib/solution/Checkout/index.js +1 -2
  302. package/lib/solution/RegisterAndLogin/config.js +2 -10
  303. package/lib/solution/ScanOrder/index.d.ts +9 -3
  304. package/lib/solution/ScanOrder/index.js +153 -70
  305. package/lib/solution/ScanOrder/types.d.ts +9 -5
  306. package/lib/solution/ScanOrder/utils.d.ts +1 -1
  307. package/lib/solution/ScanOrder/utils.js +83 -17
  308. package/lib/solution/VenueBooking/index.d.ts +5 -2
  309. package/lib/solution/VenueBooking/index.js +54 -17
  310. package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -2
  311. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  312. package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
  313. package/lib/types/index.d.ts +10 -0
  314. package/package.json +1 -1
  315. package/dist/solution/Checkout/appointmentDemo.json +0 -1
  316. package/lib/solution/Checkout/appointmentDemo.json +0 -1
@@ -34,15 +34,92 @@ __export(BookingTicket_exports, {
34
34
  BookingTicketImpl: () => BookingTicketImpl
35
35
  });
36
36
  module.exports = __toCommonJS(BookingTicket_exports);
37
+ var import_dayjs = __toESM(require("dayjs"));
37
38
  var import_types = require("./types");
39
+ var import_BookingContext = require("../../modules/BookingContext");
38
40
  var import_BaseSales = require("../BaseSales");
39
41
  var import_scan = __toESM(require("./utils/scan"));
40
42
  var import_orderCustomer = require("./utils/orderCustomer");
41
43
  var import_handleScan = require("./utils/scan/handleScan");
42
44
  var import_scanCache = __toESM(require("./utils/scan/scanCache"));
45
+ var import_formatGlobalScan = require("./utils/scan/formatGlobalScan");
46
+ var import_applyGlobalScan = require("./utils/scan/applyGlobalScan");
43
47
  var import_cartView = require("./utils/cartView");
48
+ var import_addProductDecision = require("./utils/addProductDecision");
49
+ var import_buildCacheItemFromOrderLine = require("../../modules/BookingContext/utils/buildCacheItemFromOrderLine");
50
+ var import_sessionCatalogStale = require("./utils/sessionCatalogStale");
51
+ var import_buildNormalProductCacheItemFromOrderLine = require("../../modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine");
52
+ var import_orderLineDisplay = require("../../modules/BookingContext/utils/orderLineDisplay");
44
53
  var import_bookingStatus = require("./utils/bookingStatus");
54
+ var import_resolveBestAddTimePlan = require("./utils/resolveBestAddTimePlan");
45
55
  __reExport(BookingTicket_exports, require("./types"), module.exports);
56
+ var OPEN_DATA_SECTION_CODES = ["sale", "reservation", "fulfillment", "menu", "workflow"];
57
+ var OPEN_DATA_CACHE_TTL = 5 * 60 * 1e3;
58
+ function resolveBookingUidForAddTime(booking) {
59
+ var _a;
60
+ const uid = (_a = booking == null ? void 0 : booking.metadata) == null ? void 0 : _a.unique_identification_number;
61
+ return uid === void 0 || uid === null ? "" : String(uid);
62
+ }
63
+ function normalizeAddTimeQuantity(value) {
64
+ const parsed = Math.floor(Number(value));
65
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : 1;
66
+ }
67
+ function resolveAddTimeScheduleMinutes(explicitValue, product) {
68
+ const raw = explicitValue ?? (product == null ? void 0 : product.product_add_schedule_time);
69
+ if (raw === void 0 || raw === null || raw === "")
70
+ return void 0;
71
+ const parsed = Number(raw);
72
+ return Number.isFinite(parsed) ? parsed : void 0;
73
+ }
74
+ function resolveAddTimeProductPrice(explicitValue, product) {
75
+ return explicitValue ?? (product == null ? void 0 : product.price) ?? (product == null ? void 0 : product.selling_price) ?? (product == null ? void 0 : product.base_price);
76
+ }
77
+ function normalizeCoveredMinutes(value) {
78
+ const parsed = Math.ceil(Number(value));
79
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : 0;
80
+ }
81
+ function buildAddTimeBookingTimePatch(booking, coveredMinutes) {
82
+ if (coveredMinutes <= 0)
83
+ return null;
84
+ const endDate = booking == null ? void 0 : booking.end_date;
85
+ const endTime = booking == null ? void 0 : booking.end_time;
86
+ if (!endDate || !endTime) {
87
+ throw new Error("[BookingTicket] addAddTimeProductsToBooking: booking.end_date/end_time 缺失");
88
+ }
89
+ const currentEnd = (0, import_dayjs.default)(`${endDate} ${endTime}`);
90
+ if (!currentEnd.isValid()) {
91
+ throw new Error("[BookingTicket] addAddTimeProductsToBooking: booking.end_date/end_time 无效");
92
+ }
93
+ const nextEnd = currentEnd.add(coveredMinutes, "minute");
94
+ const currentDuration = Number(booking == null ? void 0 : booking.duration);
95
+ let duration = Number.isFinite(currentDuration) ? currentDuration + coveredMinutes : coveredMinutes;
96
+ if ((booking == null ? void 0 : booking.start_date) && (booking == null ? void 0 : booking.start_time)) {
97
+ const start = (0, import_dayjs.default)(`${booking.start_date} ${booking.start_time}`);
98
+ if (start.isValid()) {
99
+ const diffMinutes = nextEnd.diff(start, "minute");
100
+ duration = diffMinutes > 0 ? diffMinutes : duration;
101
+ }
102
+ }
103
+ return {
104
+ end_date: nextEnd.format("YYYY-MM-DD"),
105
+ end_time: nextEnd.format("HH:mm"),
106
+ duration
107
+ };
108
+ }
109
+ function withProductOptionString(cacheItem) {
110
+ var _a;
111
+ const productOptionString = (0, import_orderLineDisplay.buildProductOptionStringFromOrderLine)(cacheItem);
112
+ if (!productOptionString)
113
+ return cacheItem;
114
+ return {
115
+ ...cacheItem,
116
+ product_option_string: (cacheItem == null ? void 0 : cacheItem.product_option_string) || productOptionString,
117
+ _extend: {
118
+ ...(cacheItem == null ? void 0 : cacheItem._extend) || {},
119
+ product_option_string: ((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.product_option_string) || productOptionString
120
+ }
121
+ };
122
+ }
46
123
  var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
47
124
  constructor() {
48
125
  super(...arguments);
@@ -54,12 +131,22 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
54
131
  */
55
132
  this.store = {};
56
133
  this.productCatalog = [];
134
+ this.addTimeProductsCatalog = [];
135
+ this.orderCustomerDiscountRefreshInFlight = null;
136
+ this.orderCustomerDiscountRefreshCustomerId = null;
137
+ this.loadOpenDataConfigInFlight = null;
57
138
  }
58
139
  /**
59
- * 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer。
140
+ * 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer + bookingContext
141
+ * bookingContext 是 SalesSdk 加车下沉所需的「预约 UI 上下文」(bookingConfig / resourcesOrigin / date)。
60
142
  */
61
143
  getRegisteredModuleNames() {
62
- return [...super.getRegisteredModuleNames(), "customer"];
144
+ return [...super.getRegisteredModuleNames(), "customer", "bookingContext", "openData"];
145
+ }
146
+ getSubmitOrderSalesChannel() {
147
+ var _a, _b, _c;
148
+ const channel = (_c = (_b = (_a = this.core) == null ? void 0 : _a.context) == null ? void 0 : _b.getChannel) == null ? void 0 : _c.call(_b);
149
+ return !channel || channel === "system" ? "pos" : channel;
63
150
  }
64
151
  /**
65
152
  * 业务侧子模块工厂:BookingTicket 自带的 createBookingTicketModule 优先匹配;
@@ -76,14 +163,142 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
76
163
  }
77
164
  async initialize(core, options = {}) {
78
165
  var _a;
79
- this.scan = new import_scan.default(this, "BOOKING_TICKET_SCAN");
166
+ this.scan = new import_scan.default(this, `BOOKING_TICKET_SCAN:${this.name}`);
80
167
  await super.initialize(core, options);
81
168
  if (!this.request) {
82
169
  throw new Error("bookingTicket解决方案需要 request 插件支持");
83
170
  }
84
171
  this.platform = (_a = this.otherParams) == null ? void 0 : _a.platform;
172
+ await this.configureIdGeneratorFromOpenData();
85
173
  console.log("[BookingTicket] 初始化完成");
86
174
  }
175
+ getBookingTicketBusinessCode() {
176
+ var _a, _b;
177
+ const businessCode = ((_a = this.otherParams) == null ? void 0 : _a.businessCode) ?? ((_b = this.otherParams) == null ? void 0 : _b.business_code);
178
+ if (businessCode === void 0 || businessCode === null)
179
+ return null;
180
+ const normalized = String(businessCode).trim();
181
+ return normalized || null;
182
+ }
183
+ getIdGeneratorPlugin() {
184
+ var _a, _b;
185
+ const appPlugin = this.core.getPlugin("app");
186
+ const app = (_a = appPlugin == null ? void 0 : appPlugin.getApp) == null ? void 0 : _a.call(appPlugin);
187
+ return ((_b = app == null ? void 0 : app.getPlugin) == null ? void 0 : _b.call(app, "idGenerator")) || null;
188
+ }
189
+ async loadOpenDataConfig() {
190
+ if (!this.store.openData)
191
+ throw new Error("openData 模块未初始化");
192
+ const businessCode = this.getBookingTicketBusinessCode();
193
+ if (!businessCode) {
194
+ console.warn("[BookingTicket] businessCode 缺失,跳过 OpenData 配置加载,当前 module name: ", this.name);
195
+ return null;
196
+ }
197
+ const lastFetchedAt = this.store.openData.getLastFetchedAt();
198
+ const cachedData = this.store.openData.getOpenData();
199
+ if (cachedData && lastFetchedAt && Date.now() - lastFetchedAt < OPEN_DATA_CACHE_TTL) {
200
+ this.otherParams.openData = cachedData;
201
+ return cachedData;
202
+ }
203
+ if (this.loadOpenDataConfigInFlight)
204
+ return await this.loadOpenDataConfigInFlight;
205
+ const channel = this.getSubmitOrderSalesChannel();
206
+ this.loadOpenDataConfigInFlight = this.store.openData.fetchOpenData({
207
+ scope: "board",
208
+ target: `${businessCode}+${channel}`,
209
+ // target: `dine_in+pos`,
210
+ section_code: [...OPEN_DATA_SECTION_CODES]
211
+ });
212
+ try {
213
+ const openDataConfig = await this.loadOpenDataConfigInFlight;
214
+ this.otherParams.openData = openDataConfig;
215
+ return openDataConfig;
216
+ } finally {
217
+ this.loadOpenDataConfigInFlight = null;
218
+ }
219
+ }
220
+ async getOpenData() {
221
+ var _a;
222
+ return (_a = this.store.openData) == null ? void 0 : _a.getOpenData();
223
+ }
224
+ async getShortNumberOrDeviceId() {
225
+ const getAsyncIotDeviceInfo = this.getAppData("async_iot_device_info");
226
+ if (getAsyncIotDeviceInfo) {
227
+ const res = await (getAsyncIotDeviceInfo == null ? void 0 : getAsyncIotDeviceInfo());
228
+ if (res == null ? void 0 : res.short_number) {
229
+ return res == null ? void 0 : res.short_number;
230
+ }
231
+ }
232
+ return String(this.getAppData("device_id") || 0).slice(-2);
233
+ }
234
+ async configureIdGeneratorFromOpenData() {
235
+ let openDataConfig = null;
236
+ try {
237
+ openDataConfig = await this.loadOpenDataConfig();
238
+ } catch (error) {
239
+ console.warn("[BookingTicket] OpenData 配置加载失败,跳过 idGenerator 配置", error);
240
+ return;
241
+ }
242
+ const idGenerator = this.getIdGeneratorPlugin();
243
+ if (!(idGenerator == null ? void 0 : idGenerator.configure)) {
244
+ console.warn("[BookingTicket] idGenerator 插件不可用,跳过配置");
245
+ return;
246
+ }
247
+ const receiptSequenceLength = this.normalizePositiveInteger(
248
+ openDataConfig == null ? void 0 : openDataConfig["sale.short_number_digits"],
249
+ 5
250
+ );
251
+ const receiptSequenceStart = this.normalizePositiveInteger(
252
+ openDataConfig == null ? void 0 : openDataConfig["sale.short_number_start_number"],
253
+ 1
254
+ );
255
+ const prefix = this.normalizeIdPrefix(
256
+ openDataConfig == null ? void 0 : openDataConfig["sale.short_number_prefix"],
257
+ ""
258
+ );
259
+ const shopOrderPrefix = this.normalizeIdPrefix(
260
+ openDataConfig == null ? void 0 : openDataConfig["sale.sale_number_prefix"],
261
+ ""
262
+ );
263
+ const resetReceiptSequenceDaily = typeof (openDataConfig == null ? void 0 : openDataConfig["sale.short_number_daily_reset"]) === "boolean" ? openDataConfig == null ? void 0 : openDataConfig["sale.short_number_daily_reset"] : false;
264
+ const operatingDayBoundary = this.getAppData("operating_day_boundary");
265
+ const deviceId = await this.getShortNumberOrDeviceId();
266
+ const businessCode = this.getBookingTicketBusinessCode();
267
+ if (!businessCode) {
268
+ console.warn("[BookingTicket] businessCode 缺失,跳过 idGenerator 配置");
269
+ return;
270
+ }
271
+ try {
272
+ await idGenerator.configure({
273
+ biz: businessCode,
274
+ config: {
275
+ prefix,
276
+ deviceCode: deviceId,
277
+ // TODO 现在 picoding 没这个配置的 key
278
+ padReceiptSequence: false,
279
+ receiptSequenceLength,
280
+ resetReceiptSequenceDaily,
281
+ receiptSequenceResetTime: operatingDayBoundary.time,
282
+ receiptSequenceStart,
283
+ shopOrderPrefix
284
+ }
285
+ });
286
+ } catch (error) {
287
+ console.warn("[BookingTicket] idGenerator 配置失败", error);
288
+ }
289
+ }
290
+ normalizePositiveInteger(value, fallback) {
291
+ const numeric = Number(value);
292
+ if (!Number.isInteger(numeric) || numeric <= 0)
293
+ return fallback;
294
+ return numeric;
295
+ }
296
+ normalizeIdPrefix(value, fallback) {
297
+ if (value === void 0 || value === null)
298
+ return fallback;
299
+ const normalized = String(value).trim().toUpperCase();
300
+ return normalized || fallback;
301
+ }
87
302
  /**
88
303
  * 加载销售详情,并在父类基础上把 customer 信息装配到 CustomerModule。
89
304
  *
@@ -92,26 +307,113 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
92
307
  * 让现有 setActiveCustomer / getActiveCustomer 调用方零成本拿到详情态客户。
93
308
  */
94
309
  async loadSalesDetail(orderIdOrParams) {
310
+ debugger;
95
311
  const sales = await super.loadSalesDetail(orderIdOrParams);
96
- console.log(sales, "1234sales");
97
312
  const customerModule = this.store.customer;
98
313
  const detailCustomer = sales == null ? void 0 : sales.customer;
99
- if (customerModule && detailCustomer) {
100
- const { id: detailCustomerId, ...detailCustomerRest } = detailCustomer ?? {};
314
+ const orderCustomerSnapshot = this.store.order.getOrderCustomerSnapshot();
315
+ const protocolCustomerId = sales == null ? void 0 : sales.customer_id;
316
+ const protocolCustomer = protocolCustomerId !== void 0 && protocolCustomerId !== null ? {
317
+ id: protocolCustomerId,
318
+ name: String((sales == null ? void 0 : sales.customer_name) || ""),
319
+ phone: sales == null ? void 0 : sales.phone,
320
+ email: sales == null ? void 0 : sales.email,
321
+ country_calling_code: sales == null ? void 0 : sales.country_calling_code
322
+ } : null;
323
+ const selectedCustomer = detailCustomer ?? orderCustomerSnapshot ?? protocolCustomer;
324
+ if (customerModule && selectedCustomer) {
325
+ const { id: detailCustomerId, ...detailCustomerRest } = selectedCustomer ?? {};
101
326
  const rawId = detailCustomerId ?? "";
102
327
  const customer = {
103
328
  ...detailCustomerRest,
104
329
  id: rawId == null ? "" : rawId,
105
- name: (detailCustomer == null ? void 0 : detailCustomer.name) ?? "",
106
- phone: detailCustomer == null ? void 0 : detailCustomer.phone,
107
- email: detailCustomer == null ? void 0 : detailCustomer.email,
108
- country_calling_code: detailCustomer == null ? void 0 : detailCustomer.country_calling_code
330
+ name: (selectedCustomer == null ? void 0 : selectedCustomer.name) ?? "",
331
+ phone: selectedCustomer == null ? void 0 : selectedCustomer.phone,
332
+ email: selectedCustomer == null ? void 0 : selectedCustomer.email,
333
+ country_calling_code: selectedCustomer == null ? void 0 : selectedCustomer.country_calling_code
109
334
  };
110
335
  customerModule.setSelectedCustomer(customer);
111
336
  this.setOrderCustomer(customer);
112
337
  }
113
338
  return sales;
114
339
  }
340
+ async scanPromotionCode(code, customerId) {
341
+ if (!this.store.order)
342
+ throw new Error("order 模块未初始化");
343
+ const raw = await this.store.order.scanCode(code, customerId);
344
+ if (raw.isAvailable) {
345
+ await this.hydrateOrderCustomerFromScanDiscounts(raw.scannedDiscountList || []);
346
+ await this.store.order.recalculateSummary({ createIfMissing: true });
347
+ this.store.order.persistTempOrder();
348
+ }
349
+ return {
350
+ isAvailable: raw.isAvailable,
351
+ type: raw.type,
352
+ unavailableReason: raw.unavailableReason
353
+ };
354
+ }
355
+ async hydrateOrderCustomerFromScanDiscounts(discounts) {
356
+ const currentOrderCustomer = this.store.order.getOrderCustomer();
357
+ if (currentOrderCustomer)
358
+ return;
359
+ const customerId = this.getDiscountCustomerId(discounts);
360
+ if (!customerId)
361
+ return;
362
+ const customer = await this.resolveCustomerByDiscountCustomerId(customerId);
363
+ if (!customer)
364
+ return;
365
+ this.store.customer.setSelectedCustomer(customer);
366
+ this.setOrderCustomer(customer);
367
+ }
368
+ getDiscountCustomerId(discounts) {
369
+ const discount = discounts.find((item) => item.customer_id != null);
370
+ const customerId = Number(discount == null ? void 0 : discount.customer_id);
371
+ if (!Number.isFinite(customerId) || customerId <= 0)
372
+ return null;
373
+ return customerId;
374
+ }
375
+ async resolveCustomerByDiscountCustomerId(customerId) {
376
+ var _a;
377
+ const localCustomers = this.store.customer.getCustomers();
378
+ const localCustomer = this.findCustomerById(localCustomers, customerId);
379
+ const normalizedLocalCustomer = localCustomer ? this.normalizeCustomer(localCustomer) : null;
380
+ if (normalizedLocalCustomer && this.hasUsableCustomerDetails(normalizedLocalCustomer)) {
381
+ return normalizedLocalCustomer;
382
+ }
383
+ const result = await this.store.customer.queryCustomerList({
384
+ ids: [customerId],
385
+ skip: 1,
386
+ num: 1
387
+ });
388
+ const remoteCustomer = this.findCustomerById((result == null ? void 0 : result.list) || [], customerId) || ((_a = result == null ? void 0 : result.list) == null ? void 0 : _a[0]) || null;
389
+ return remoteCustomer ? this.normalizeCustomer(remoteCustomer) : null;
390
+ }
391
+ findCustomerById(customers = [], customerId) {
392
+ return customers.find((customer) => {
393
+ const rawId = this.getRawCustomerId(customer);
394
+ return rawId !== null && String(rawId) === String(customerId);
395
+ }) || null;
396
+ }
397
+ normalizeCustomer(customer) {
398
+ const raw = customer;
399
+ const rawId = this.getRawCustomerId(customer);
400
+ const name = customer.name || raw.display_name || raw.nickname || raw.customer_name || [raw.first_name, raw.last_name].filter(Boolean).join(" ") || "";
401
+ return {
402
+ ...customer,
403
+ id: rawId ?? customer.id,
404
+ name,
405
+ phone: customer.phone ?? raw.phone ?? raw.mobile ?? "",
406
+ email: customer.email ?? raw.email ?? "",
407
+ country_calling_code: customer.country_calling_code ?? raw.country_calling_code ?? ""
408
+ };
409
+ }
410
+ getRawCustomerId(customer) {
411
+ const raw = customer;
412
+ return customer.id ?? raw.customer_id ?? raw.customerId ?? null;
413
+ }
414
+ hasUsableCustomerDetails(customer) {
415
+ return !!(customer.name || customer.phone || customer.email || customer.display_name || customer.customer_name);
416
+ }
115
417
  /**
116
418
  * 更新当前预约的 appointment_status。
117
419
  *
@@ -160,6 +462,66 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
160
462
  throw error;
161
463
  }
162
464
  }
465
+ /**
466
+ * 子预约状态机转移(POST /schedule/booking-transition/{schedule_event_id})。
467
+ *
468
+ * 与 `setBookingStatus`(父预约 PUT appointment-status)不同,本方法按子预约
469
+ * `schedule_event_id` 调用状态转移接口,body 为 `{ action }`。
470
+ *
471
+ * 流程:能解析出目标状态时先乐观更新对应子预约的 `appointment_status`,
472
+ * 再调 POST;成功后强制刷新销售详情;失败则回滚该子预约本地状态并抛错。
473
+ * `reschedule` 暂未启用状态矩阵,跳过乐观更新仅调接口。
474
+ *
475
+ * @param params.schedule_event_id 子预约 schedule_event_id
476
+ * @param params.action 转移动作:confirm | reject | arrive | start | complete | cancel | no_show | reschedule
477
+ * @returns 接口返回的 data
478
+ *
479
+ * @example
480
+ * await bookingTicket.transitionChildBooking({
481
+ * schedule_event_id: 301,
482
+ * action: 'confirm',
483
+ * });
484
+ */
485
+ async transitionChildBooking(params) {
486
+ var _a, _b;
487
+ const { schedule_event_id, action } = params;
488
+ if (schedule_event_id === void 0 || schedule_event_id === null || schedule_event_id === "") {
489
+ throw new Error("transitionChildBooking: schedule_event_id 不能为空");
490
+ }
491
+ if (!action) {
492
+ throw new Error("transitionChildBooking: action 不能为空");
493
+ }
494
+ const tempOrder = (_b = (_a = this.store.order) == null ? void 0 : _a.getTempOrder) == null ? void 0 : _b.call(_a);
495
+ if (!tempOrder) {
496
+ throw new Error("transitionChildBooking: tempOrder 未加载");
497
+ }
498
+ const orderId = tempOrder.order_id;
499
+ if (orderId === void 0 || orderId === null) {
500
+ throw new Error("transitionChildBooking: tempOrder.order_id 缺失");
501
+ }
502
+ const bookings = Array.isArray(tempOrder.bookings) ? tempOrder.bookings : [];
503
+ const targetStatus = (0, import_bookingStatus.resolveStatusAfterTransition)(action);
504
+ const previous = targetStatus !== null ? (0, import_bookingStatus.applyChildBookingStatus)(bookings, schedule_event_id, targetStatus) : void 0;
505
+ try {
506
+ const res = await this.request.post(
507
+ `/schedule/booking-transition/${schedule_event_id}`,
508
+ { action }
509
+ );
510
+ await this.refreshSalesDetail();
511
+ this.core.effects.emit(`${this.name}:onChildBookingStatusChange`, {
512
+ orderId,
513
+ schedule_event_id,
514
+ action,
515
+ status: targetStatus
516
+ });
517
+ return (res == null ? void 0 : res.data) ?? res;
518
+ } catch (error) {
519
+ if (previous !== void 0) {
520
+ (0, import_bookingStatus.restoreChildBookingStatus)(bookings, schedule_event_id, previous);
521
+ }
522
+ throw error;
523
+ }
524
+ }
163
525
  /**
164
526
  * 基于当前 tempOrder.order_id 强制从远端重新拉取销售详情。
165
527
  *
@@ -170,19 +532,21 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
170
532
  *
171
533
  * @returns loadSalesDetail 的返回值
172
534
  */
173
- async refreshSalesDetail() {
535
+ async refreshSalesDetail(params = {}) {
174
536
  var _a, _b;
175
537
  const tempOrder = (_b = (_a = this.store.order) == null ? void 0 : _a.getTempOrder) == null ? void 0 : _b.call(_a);
176
538
  if (!tempOrder) {
177
539
  throw new Error("refreshSalesDetail: tempOrder 未加载");
178
540
  }
179
- const orderId = tempOrder.order_id;
541
+ debugger;
542
+ const orderId = tempOrder.order_id || tempOrder.external_sale_number;
180
543
  if (orderId === void 0 || orderId === null) {
181
- throw new Error("refreshSalesDetail: tempOrder.order_id 缺失");
544
+ return {};
182
545
  }
183
546
  return this.loadSalesDetail({
184
- orderId: Number(orderId),
185
- forceRemote: true
547
+ orderId,
548
+ // merge: true
549
+ forceRemote: params.forceRemote
186
550
  });
187
551
  }
188
552
  /**
@@ -192,6 +556,10 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
192
556
  */
193
557
  async loadProducts(params = {}, options) {
194
558
  const { schedule_date, customer_id, menu_list_ids, schedule_datetime } = params;
559
+ const bookingDate = schedule_datetime || schedule_date || "";
560
+ if (bookingDate) {
561
+ this.setBookingDate(bookingDate);
562
+ }
195
563
  try {
196
564
  const result = await this.store.products.loadProducts({
197
565
  with_count: ["bundleGroup", "optionGroup"],
@@ -207,6 +575,53 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
207
575
  throw error;
208
576
  }
209
577
  }
578
+ /**
579
+ * 获取加时商品列表。
580
+ *
581
+ * @example
582
+ * const products = await bookingTicket.getAddTimeProducts({ schedule_date: '2026-06-16' });
583
+ */
584
+ async getAddTimeProducts(params = {}) {
585
+ const result = await this.store.products.getAddTimeProducts({
586
+ ...params,
587
+ cacheId: this.cacheId
588
+ });
589
+ this.addTimeProductsCatalog = Array.isArray(result) ? [...result] : [];
590
+ return result;
591
+ }
592
+ /**
593
+ * 只读查询单商品详情:走 ProductList 报价查询,但不写 productCatalog、
594
+ * 不 emit onProductsLoaded、不修改 BookingDate。
595
+ *
596
+ * 供「列表已 loadProducts、仅需补 product_resource / capacity」等场景使用,
597
+ * 避免 loadProductDetail 覆盖左侧商品列表。
598
+ *
599
+ * @example
600
+ * const detail = await bookingTicket.queryProductDetail({
601
+ * product_id: 2,
602
+ * schedule_date: '2030-01-15',
603
+ * schedule_datetime: '2030-01-15 10:00:00',
604
+ * });
605
+ */
606
+ async queryProductDetail(params, options) {
607
+ const { product_id, ...queryParams } = params;
608
+ try {
609
+ const result = await this.store.products.loadProducts({
610
+ with_count: ["bundleGroup", "optionGroup"],
611
+ with_schedule: 1,
612
+ ...queryParams,
613
+ product_ids: [product_id],
614
+ cacheId: this.cacheId
615
+ }, options);
616
+ const list = Array.isArray(result) ? result : [];
617
+ return list.find(
618
+ (product) => Number(product.id) === Number(product_id)
619
+ );
620
+ } catch (error) {
621
+ console.error("Failed to query product detail:", error);
622
+ throw error;
623
+ }
624
+ }
210
625
  /**
211
626
  * 按预约时间加载单个商品详情。
212
627
  * 价格仍由 server products 的报价单桥接统一计算,避免 solution 实例重复请求报价单。
@@ -259,11 +674,23 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
259
674
  * tempOrder 仍是 checkout 协议对象;商品行直接透传 products,bookings 附带关联商品。
260
675
  */
261
676
  getCart() {
262
- var _a;
677
+ var _a, _b;
263
678
  const tempOrder = ((_a = this.store.order) == null ? void 0 : _a.getTempOrder()) ?? null;
264
679
  const salesDetail = this.getSalesOrder();
265
680
  const bookings = (salesDetail == null ? void 0 : salesDetail.bookings) ?? ((tempOrder == null ? void 0 : tempOrder.bookings) || []);
266
- return (0, import_cartView.buildCartView)((tempOrder == null ? void 0 : tempOrder.products) || [], bookings);
681
+ let operatingDayBoundary;
682
+ try {
683
+ operatingDayBoundary = this.getAppData("operating_day_boundary");
684
+ } catch {
685
+ operatingDayBoundary = void 0;
686
+ }
687
+ const shopOpeningHours = (operatingDayBoundary == null ? void 0 : operatingDayBoundary.type) === "start_time" ? "23:59" : operatingDayBoundary == null ? void 0 : operatingDayBoundary.time;
688
+ return (0, import_cartView.buildCartView)((tempOrder == null ? void 0 : tempOrder.products) || [], bookings, {
689
+ addTimeProducts: this.addTimeProductsCatalog,
690
+ bookingConfig: this.getBookingConfig(),
691
+ productsByUid: (_b = tempOrder == null ? void 0 : tempOrder._extend) == null ? void 0 : _b.productsByUid,
692
+ shopOpeningHours
693
+ });
267
694
  }
268
695
  /**
269
696
  * 获取当前下单客户(与 OrderModule.tempOrder snapshot 一致)。
@@ -380,14 +807,35 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
380
807
  * 在 BookingTicket 命名空间也 emit 一次,方便上层统一从 Solution 订阅。
381
808
  */
382
809
  setOrderCustomer(customer) {
810
+ var _a;
383
811
  if (!customer) {
384
812
  this.clearOrderCustomer();
385
813
  return;
386
814
  }
815
+ const previousCustomerId = (_a = this.store.order.getOrderCustomer()) == null ? void 0 : _a.customer_id;
816
+ const snapshotBeforeSet = this.store.order.getOrderCustomerSnapshot();
387
817
  const patch = (0, import_orderCustomer.formatOrderCustomerPatch)(customer);
818
+ const customerUnchanged = Number(previousCustomerId || 0) === Number(patch.customer_id || 0);
819
+ if (!customerUnchanged) {
820
+ this.discountConfigCacheKey = null;
821
+ this.hasManualDiscountSelection = false;
822
+ }
388
823
  this.store.order.setOrderCustomer(patch, customer);
824
+ const snapshotAfterOrderSet = this.store.order.getOrderCustomerSnapshot();
825
+ if (customerUnchanged) {
826
+ const snapshotReplenished = !snapshotBeforeSet && Boolean(snapshotAfterOrderSet);
827
+ if (snapshotReplenished) {
828
+ const next2 = this.buildOrderCustomerPayload();
829
+ this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next2);
830
+ }
831
+ return;
832
+ }
389
833
  const next = this.buildOrderCustomerPayload();
390
834
  this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next);
835
+ this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
836
+ void this.store.order.applyPromotion().catch((error) => {
837
+ console.error("[BookingTicket] applyPromotion after customer change failed", error);
838
+ });
391
839
  }
392
840
  /**
393
841
  * 读取 tempOrder 上的下单客户协议字段;customer_id 缺失时返回 null。
@@ -405,9 +853,36 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
405
853
  * 清空下单客户(协议字段 + snapshot)。
406
854
  */
407
855
  clearOrderCustomer() {
856
+ var _a, _b;
408
857
  this.store.order.clearOrderCustomer();
858
+ this.discountConfigCacheKey = null;
859
+ this.hasManualDiscountSelection = false;
860
+ const orderStore = this.store.order.store || {};
861
+ const discountModule = orderStore.discount;
862
+ void ((_a = discountModule == null ? void 0 : discountModule.setOriginalDiscountList) == null ? void 0 : _a.call(discountModule, []));
863
+ void ((_b = discountModule == null ? void 0 : discountModule.setDiscountList) == null ? void 0 : _b.call(discountModule, []));
864
+ this.store.order.applyDiscount();
865
+ void this.store.order.recalculateSummary({ createIfMissing: true }).then(() => this.store.order.persistTempOrder()).catch((error) => {
866
+ console.error("Failed to recalculate summary after clearing customer:", error);
867
+ });
409
868
  this.core.effects.emit(`${this.name}:onOrderCustomerChange`, null);
410
869
  }
870
+ /**
871
+ * 重置 tempOrder,并同步清空下单客户运行态。
872
+ *
873
+ * OrderModule.restoreOrder 会重建空单(customer_id 已为 null),但不会:
874
+ * - emit BookingTicket `onOrderCustomerChange`
875
+ * - 重置 CustomerModule.selectedCustomer(老路 getActiveCustomer)
876
+ *
877
+ * 因此在 super.restoreOrder 之后显式清客户,保证 SalesSdk / ticketBooking 订阅方与 tempOrder 一致。
878
+ */
879
+ async restoreOrder() {
880
+ var _a;
881
+ const tempOrder = await super.restoreOrder();
882
+ this.clearOrderCustomer();
883
+ (_a = this.store.customer) == null ? void 0 : _a.setSelectedCustomer(null);
884
+ return tempOrder;
885
+ }
411
886
  /** 内部:基于 OrderModule 当前状态构造一份 OrderCustomerChangePayload。 */
412
887
  buildOrderCustomerPayload() {
413
888
  const patch = this.store.order.getOrderCustomer();
@@ -418,6 +893,34 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
418
893
  snapshot: this.store.order.getOrderCustomerSnapshot()
419
894
  };
420
895
  }
896
+ refreshDiscountConfigAfterOrderCustomerChange(customerId) {
897
+ if (!customerId || customerId === 1)
898
+ return;
899
+ if (this.orderCustomerDiscountRefreshInFlight && this.orderCustomerDiscountRefreshCustomerId === customerId) {
900
+ return;
901
+ }
902
+ const previousRefresh = this.orderCustomerDiscountRefreshInFlight;
903
+ const refreshTask = (async () => {
904
+ if (previousRefresh) {
905
+ await previousRefresh.catch(() => void 0);
906
+ }
907
+ const currentCustomer = this.store.order.getOrderCustomer();
908
+ if (!currentCustomer || Number(currentCustomer.customer_id) !== customerId) {
909
+ return;
910
+ }
911
+ await this.loadDiscountConfig({ customerId });
912
+ })();
913
+ this.orderCustomerDiscountRefreshInFlight = refreshTask;
914
+ this.orderCustomerDiscountRefreshCustomerId = customerId;
915
+ refreshTask.catch((error) => {
916
+ console.error("Failed to load discount config after customer change:", error);
917
+ }).finally(() => {
918
+ if (this.orderCustomerDiscountRefreshInFlight !== refreshTask)
919
+ return;
920
+ this.orderCustomerDiscountRefreshInFlight = null;
921
+ this.orderCustomerDiscountRefreshCustomerId = null;
922
+ });
923
+ }
421
924
  /**
422
925
  * 获取客户分页信息
423
926
  * @returns 分页信息
@@ -594,18 +1097,6 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
594
1097
  clearAllScanListenersTaskQueue() {
595
1098
  this.scan.clearTaskQueue();
596
1099
  }
597
- /**
598
- * 设置其他参数
599
- * @param params 参数
600
- * @param options 选项
601
- */
602
- async setOtherParams(params, { cover = false } = {}) {
603
- if (cover) {
604
- this.otherParams = params;
605
- } else {
606
- this.otherParams = { ...this.otherParams, ...params };
607
- }
608
- }
609
1100
  /**
610
1101
  * 获取其他参数
611
1102
  * @returns 其他参数
@@ -613,6 +1104,408 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
613
1104
  async getOtherParams() {
614
1105
  return this.otherParams;
615
1106
  }
1107
+ // ─── BookingContext API(透传给 BookingContextModule) ──────────────────────
1108
+ // SalesSdkProvider 挂载时默认调 initBookingContext;也可由 UI 显式 set* 灌入已有数据。
1109
+ /** 拉取 board config 并写入 BookingContext。 */
1110
+ loadBookingConfig(params) {
1111
+ return this.store.bookingContext.loadBookingConfig(params);
1112
+ }
1113
+ /** 拉取资源全集并写入 BookingContext。 */
1114
+ loadBookingResources(params) {
1115
+ return this.store.bookingContext.loadResources(params);
1116
+ }
1117
+ /** 初始化 BookingContext(date + config + resources)。 */
1118
+ initBookingContext(params) {
1119
+ return this.store.bookingContext.initBookingContext(params);
1120
+ }
1121
+ /** 当前 store 是否已具备与入参等价的 config / resources(无需再请求接口)。 */
1122
+ isBookingContextReady(params) {
1123
+ return this.store.bookingContext.isBookingContextReady(params);
1124
+ }
1125
+ /** 写入 booking config(来源:`/core/board/management/config`)。 */
1126
+ setBookingConfig(config) {
1127
+ this.store.bookingContext.setBookingConfig(config);
1128
+ }
1129
+ /** 读取当前 booking config。 */
1130
+ getBookingConfig() {
1131
+ return this.store.bookingContext.getBookingConfig();
1132
+ }
1133
+ /** 写入资源全集(来源:`/form/schedule`),同步派生 resourcesOriginMap。 */
1134
+ setResources(resources) {
1135
+ this.store.bookingContext.setResources(resources);
1136
+ }
1137
+ /** 读取资源全集(浅克隆)。 */
1138
+ getResourcesOrigin() {
1139
+ return this.store.bookingContext.getResourcesOrigin();
1140
+ }
1141
+ /** 读取资源全集 map(id → resource)。 */
1142
+ getResourcesOriginMap() {
1143
+ return this.store.bookingContext.getResourcesOriginMap();
1144
+ }
1145
+ /** 写入当前选择的日期;支持 dayjs / Date / string。 */
1146
+ setBookingDate(date) {
1147
+ this.store.bookingContext.setDate(date);
1148
+ }
1149
+ /** 读取当前选择的日期(统一 string)。 */
1150
+ getBookingDate() {
1151
+ return this.store.bookingContext.getDate();
1152
+ }
1153
+ /** 读取 BookingContext 完整 store(调试 / 测试 / 透传给 SDK 使用)。 */
1154
+ getBookingContextState() {
1155
+ return this.store.bookingContext.getState();
1156
+ }
1157
+ /** 清空 BookingContext(切租户 / destroy 场景)。 */
1158
+ clearBookingContext() {
1159
+ this.store.bookingContext.clear();
1160
+ }
1161
+ /**
1162
+ * 构造 BookingContext 计算上下文(供 getProductExtend / getResourceByIds 等读 API 复用)。
1163
+ */
1164
+ buildBookingCalcContext(extra) {
1165
+ const state = this.store.bookingContext.getState();
1166
+ const date = (extra == null ? void 0 : extra.date) ?? state.date;
1167
+ return {
1168
+ bookingConfig: state.bookingConfig,
1169
+ resourcesOrigin: state.resourcesOrigin,
1170
+ resourcesOriginMap: state.resourcesOriginMap,
1171
+ date,
1172
+ presetStartTime: (extra == null ? void 0 : extra.presetStartTime) ?? (0, import_BookingContext.derivePresetStartTimeFromDate)(date),
1173
+ ...extra || {}
1174
+ };
1175
+ }
1176
+ /**
1177
+ * 取商品当前可选资源列表(透传 OS BookingContext utils#getResourceByIds)。
1178
+ * `extraResources` 用于把拖入未绑定的资源也展示出来。
1179
+ */
1180
+ getResourcesForProduct(product, options) {
1181
+ var _a, _b;
1182
+ const ctx = this.buildBookingCalcContext();
1183
+ return (0, import_BookingContext.getResourceByIds)(ctx.resourcesOriginMap || {}, product, {
1184
+ resourceTab: (_b = (_a = ctx.bookingConfig) == null ? void 0 : _a.config) == null ? void 0 : _b.resource_tab,
1185
+ resourcesOrigin: ctx.resourcesOrigin,
1186
+ extraResources: (options == null ? void 0 : options.extraResources) || []
1187
+ });
1188
+ }
1189
+ /**
1190
+ * 拼装 cacheItem 的 _extend / _data(资源 / 容量 / timeObj),与 info2 `getProductExtend` 等价。
1191
+ */
1192
+ getProductExtend(cacheItem, extra) {
1193
+ const preparedCacheItem = withProductOptionString(cacheItem);
1194
+ const result = (0, import_BookingContext.getProductExtend)({
1195
+ cacheItem: preparedCacheItem,
1196
+ ctx: this.buildBookingCalcContext(extra)
1197
+ });
1198
+ return result;
1199
+ }
1200
+ /**
1201
+ * 取资源不可用原因列表(结构化 enum + params,i18n 文案由 UI 渲染)。
1202
+ */
1203
+ getResourceErrors(resource, cacheItem) {
1204
+ return (0, import_BookingContext.getResourceErrors)(resource, cacheItem);
1205
+ }
1206
+ // ─── addProduct 决策 / 转换 API(SDK 加车下沉所需) ─────────────────────────
1207
+ // 这一组方法是 SalesSdkCartContext.addProduct / confirmDetail 的 OS 后端。
1208
+ // 调用方传入 ProductData,OS 自取 bookingContext / customer / date 等上下文,
1209
+ // 输出 (a) autoClose 决策结果或 (b) `{ product, booking }` 协议入参。
1210
+ /**
1211
+ * session 商品 catalog 日期与 TimeBar 不一致时写业务日志。
1212
+ *
1213
+ * @example
1214
+ * this.logSessionCatalogDateMismatch(product, ctx.date);
1215
+ */
1216
+ logSessionCatalogDateMismatch(item, bookingDate) {
1217
+ var _a, _b;
1218
+ const logger = this.logger;
1219
+ if (!(logger == null ? void 0 : logger.addLog))
1220
+ return;
1221
+ const tempOrder = (_a = this.getTempOrder) == null ? void 0 : _a.call(this);
1222
+ const staleInfo = (0, import_sessionCatalogStale.buildSessionCatalogStaleInfo)(item, bookingDate);
1223
+ logger.addLog({
1224
+ type: "warning",
1225
+ title: `[BookingTicket] session catalog date mismatch, reload products`,
1226
+ metadata: {
1227
+ order_id: (tempOrder == null ? void 0 : tempOrder.order_id) ?? null,
1228
+ external_sale_number: (tempOrder == null ? void 0 : tempOrder.external_sale_number) ?? null,
1229
+ ...staleInfo,
1230
+ cartDetailValueSession: ((_b = item == null ? void 0 : item.cartDetailValue) == null ? void 0 : _b.session) ?? null
1231
+ }
1232
+ });
1233
+ }
1234
+ /**
1235
+ * 加车前:session 商品 catalog 日历日与 bookingDate 不一致时中断加购,交由 SDK reload products。
1236
+ */
1237
+ resolveSessionCatalogBeforeAdd(item, ctx) {
1238
+ if (!(0, import_sessionCatalogStale.isSessionCatalogDateStale)(item, ctx.date)) {
1239
+ return null;
1240
+ }
1241
+ this.logSessionCatalogDateMismatch(item, ctx.date);
1242
+ return { action: "reloadCatalog" };
1243
+ }
1244
+ /**
1245
+ * 拼装 addProductDecision 通用上下文(从 store 自取)。
1246
+ */
1247
+ buildAddProductCtx(extra) {
1248
+ var _a, _b;
1249
+ const bookingContextState = this.store.bookingContext.getState();
1250
+ const date = (extra == null ? void 0 : extra.date) ?? bookingContextState.date;
1251
+ const orderCustomerId = ((_a = this.getOrderCustomerSnapshot()) == null ? void 0 : _a.id) ?? ((_b = this.store.order.getTempOrder()) == null ? void 0 : _b.customer_id) ?? void 0;
1252
+ return {
1253
+ bookingConfig: bookingContextState.bookingConfig,
1254
+ resourcesOrigin: bookingContextState.resourcesOrigin,
1255
+ resourcesOriginMap: bookingContextState.resourcesOriginMap,
1256
+ date,
1257
+ presetStartTime: (extra == null ? void 0 : extra.presetStartTime) ?? (0, import_BookingContext.derivePresetStartTimeFromDate)(date),
1258
+ customerId: orderCustomerId,
1259
+ ...extra || {}
1260
+ };
1261
+ }
1262
+ /**
1263
+ * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
1264
+ * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
1265
+ */
1266
+ decideAddProduct(item, options) {
1267
+ const ctx = this.buildAddProductCtx(options);
1268
+ const staleDecision = this.resolveSessionCatalogBeforeAdd(item, ctx);
1269
+ if (staleDecision) {
1270
+ return staleDecision;
1271
+ }
1272
+ return (0, import_addProductDecision.decideAddProduct)(item, ctx);
1273
+ }
1274
+ /** 规格弹窗 callback 后的第二段决策。 */
1275
+ decideAfterDetail(cacheItem, options) {
1276
+ return (0, import_addProductDecision.decideAfterDetail)(cacheItem, this.buildAddProductCtx(options));
1277
+ }
1278
+ /**
1279
+ * @deprecated 请用 `decideAddProduct`;`autoClose=true` 仅当 action=add。
1280
+ */
1281
+ decideAutoClose(item, options) {
1282
+ return (0, import_addProductDecision.decideAutoClose)(item, this.buildAddProductCtx(options));
1283
+ }
1284
+ /** 替代 info2 `getIsEject`:商品是否需要弹窗(0/1)。 */
1285
+ getIsEject(item, type = "select") {
1286
+ return (0, import_addProductDecision.getIsEject)(item, type);
1287
+ }
1288
+ /** 仅 session 商品(无 variant/option/package)→ true。 */
1289
+ getIsOnlySession(item) {
1290
+ return (0, import_addProductDecision.getIsOnlySession)(item);
1291
+ }
1292
+ /**
1293
+ * 拼装 requiresDetail payload(给 SDK 直接 return 给 UI 用)。
1294
+ */
1295
+ buildRequiresDetailPayload(item, options) {
1296
+ const ctx = this.buildAddProductCtx(options);
1297
+ return (0, import_addProductDecision.buildRequiresDetailPayload)(item, ctx);
1298
+ }
1299
+ /**
1300
+ * 把 detail 弹窗回调结果(e, extension_type, detail)转换为 `(product, booking)` 入参。
1301
+ * 内部会先拼 cacheItem,再走 cacheItemToBookingInput 严格协议对齐。
1302
+ */
1303
+ transformDetailToProductAndBooking(input) {
1304
+ const { item, cacheItem: preparedCacheItem, detailResult, options } = input;
1305
+ const ctx = this.buildAddProductCtx(options);
1306
+ const cacheItem = preparedCacheItem || (detailResult ? (0, import_addProductDecision.buildCacheItemFromDetail)(item, detailResult, ctx) : (0, import_addProductDecision.buildCacheItemFromCartDetail)(item, ctx));
1307
+ return (0, import_addProductDecision.transformDetailToProductAndBooking)(cacheItem, ctx);
1308
+ }
1309
+ /**
1310
+ * 从已加车的 order line + booking 反查资源编辑抽屉所需的 cacheItem。
1311
+ * 供 SalesSdk「编辑资源」等场景使用;字段语义与 buildCacheItemFromDetail 产出对齐。
1312
+ */
1313
+ buildCacheItemFromOrderLine(input) {
1314
+ return (0, import_buildCacheItemFromOrderLine.buildCacheItemFromOrderLine)(input);
1315
+ }
1316
+ /**
1317
+ * 从已加车的普通商品 order line 反查 SkuDetailModal edit 所需的 cacheItem。
1318
+ */
1319
+ buildNormalProductCacheItemFromOrderLine(input) {
1320
+ return (0, import_buildNormalProductCacheItemFromOrderLine.buildNormalProductCacheItemFromOrderLine)(input);
1321
+ }
1322
+ /** 文档别名:与 OrderModule.updateOrderProduct 一致。 */
1323
+ async updateProductInOrder(params) {
1324
+ return this.updateOrderProduct(params);
1325
+ }
1326
+ /**
1327
+ * 全局扫码 pubsub 入口:解析码值 → 搜索 → 业务分发(客户 / 加车 / 开单)。
1328
+ * UI 层在 pubsub 订阅回调里注入 `bridge`(uiHosts / action / cart.confirm*)。
1329
+ *
1330
+ * @example
1331
+ * ```ts
1332
+ * await bookingTicket.handleGlobalScanCode(payload.data, {
1333
+ * openProductDetail: uiHosts.openProductDetail,
1334
+ * confirmDetail: cart.confirmDetail,
1335
+ * openOrder: ({ order_id }) => action({ type: 'pisell1.handleOpenCachedBigSale', data: { order_id } }),
1336
+ * });
1337
+ * ```
1338
+ */
1339
+ async handleGlobalScanCode(code, bridge) {
1340
+ var _a, _b, _c, _d;
1341
+ const trimmed = typeof code === "string" ? code.trim() : "";
1342
+ if (!trimmed) {
1343
+ (_a = bridge == null ? void 0 : bridge.onNotify) == null ? void 0 : _a.call(bridge, "fail", "pisell2.text.scan-global-failed");
1344
+ return { status: "failed", reason: "empty_code" };
1345
+ }
1346
+ try {
1347
+ const localSearch = (v) => this.store.products.findProductsByCodeOrBarcode(v);
1348
+ const scanCallback = (0, import_handleScan.handleGlobalScan)(this.request, localSearch);
1349
+ const raw = await scanCallback({ type: "nativeScanner", value: trimmed });
1350
+ const formatted = (0, import_formatGlobalScan.formatGlobalScanResult)(raw, trimmed);
1351
+ if (!formatted) {
1352
+ (_b = bridge == null ? void 0 : bridge.onNotify) == null ? void 0 : _b.call(bridge, "fail", "pisell2.text.scan-global-failed");
1353
+ return { status: "failed", reason: "not_found" };
1354
+ }
1355
+ const result = await (0, import_applyGlobalScan.applyGlobalScan)(
1356
+ {
1357
+ setOrderCustomer: (customer) => this.setOrderCustomer(customer),
1358
+ getOrderCustomerSnapshot: () => this.getOrderCustomerSnapshot(),
1359
+ getBusinessCode: () => {
1360
+ var _a2;
1361
+ return (_a2 = this.otherParams) == null ? void 0 : _a2.businessCode;
1362
+ },
1363
+ buildAddProductCtx: (extra) => this.buildAddProductCtx(extra),
1364
+ decideAddProduct: (item, options) => this.decideAddProduct(item, options),
1365
+ decideAfterDetail: (cacheItem, options) => this.decideAfterDetail(cacheItem, options),
1366
+ transformDetailToProductAndBooking: (input) => this.transformDetailToProductAndBooking(input),
1367
+ addProductToOrder: (product, booking) => this.addProductToOrder(product, booking)
1368
+ },
1369
+ formatted,
1370
+ bridge
1371
+ );
1372
+ (_c = bridge == null ? void 0 : bridge.refresh) == null ? void 0 : _c.call(bridge);
1373
+ return result;
1374
+ } catch (error) {
1375
+ console.error("[BookingTicket] handleGlobalScanCode failed", error);
1376
+ (_d = bridge == null ? void 0 : bridge.onNotify) == null ? void 0 : _d.call(bridge, "fail", "pisell2.text.scan-global-failed");
1377
+ return { status: "failed", reason: "not_found" };
1378
+ }
1379
+ }
1380
+ resolveBestAddTimePlan(addTimeProducts, targetMinutes) {
1381
+ return (0, import_resolveBestAddTimePlan.resolveBestAddTimePlan)(addTimeProducts, targetMinutes);
1382
+ }
1383
+ /**
1384
+ * 构造一条绑定到已有 booking 的加时商品行。
1385
+ *
1386
+ * @example
1387
+ * const line = this.buildAddTimeOrderLine({ product, product_add_schedule_time: 30 }, 'booking-1');
1388
+ */
1389
+ buildAddTimeOrderLine(input, bookingUid) {
1390
+ var _a;
1391
+ const product = input == null ? void 0 : input.product;
1392
+ if (!product || typeof product !== "object") {
1393
+ throw new Error("[BookingTicket] addAddTimeProductToBooking: product 不能为空");
1394
+ }
1395
+ const quantity = normalizeAddTimeQuantity(input.num ?? product.num);
1396
+ const price = resolveAddTimeProductPrice(input.price, product);
1397
+ const addScheduleTime = resolveAddTimeScheduleMinutes(
1398
+ input.product_add_schedule_time,
1399
+ product
1400
+ );
1401
+ const payload = {
1402
+ id: product.id ?? product.product_id,
1403
+ product_id: product.product_id ?? product.id,
1404
+ product_variant_id: product.product_variant_id ?? product.variant_id ?? 0,
1405
+ variant_id: product.variant_id ?? product.product_variant_id ?? 0,
1406
+ quantity,
1407
+ num: quantity,
1408
+ price,
1409
+ selling_price: price,
1410
+ original_price: product.original_price ?? price,
1411
+ line_total: price,
1412
+ total: price,
1413
+ product_sku: product.product_sku,
1414
+ option: product.option ?? product.options ?? ((_a = product.product_sku) == null ? void 0 : _a.option) ?? [],
1415
+ bundle: product.bundle ?? product.bundles ?? product.product_bundle ?? []
1416
+ };
1417
+ const orderLine = this.transformBaseProductToOrderProduct({
1418
+ payload,
1419
+ fallbackProductId: product.id ?? product.product_id,
1420
+ sourceProduct: product,
1421
+ sourceItem: product
1422
+ });
1423
+ if (!orderLine) {
1424
+ throw new Error(
1425
+ "[BookingTicket] addAddTimeProductToBooking: product transform failed"
1426
+ );
1427
+ }
1428
+ const metadata = {
1429
+ ...orderLine.metadata || {},
1430
+ ...addScheduleTime !== void 0 ? { product_add_schedule_time: addScheduleTime } : {},
1431
+ booking_uid: bookingUid
1432
+ };
1433
+ return {
1434
+ ...orderLine,
1435
+ booking_uid: bookingUid,
1436
+ metadata
1437
+ };
1438
+ }
1439
+ /**
1440
+ * 将加时商品作为独立商品行绑定到已有 booking。
1441
+ *
1442
+ * 与预约商品加车不同,本方法不会把当前 booking 作为 `addProductToOrder` 第二参数传入,
1443
+ * 避免 OrderModule 新建 booking 或重写已有 booking.product_uid。
1444
+ *
1445
+ * @example
1446
+ * await bookingTicket.addAddTimeProductToBooking({
1447
+ * booking,
1448
+ * product,
1449
+ * num: 1,
1450
+ * price: '10.00',
1451
+ * product_add_schedule_time: 30,
1452
+ * });
1453
+ */
1454
+ async addAddTimeProductToBooking(input) {
1455
+ return this.addAddTimeProductsToBooking({
1456
+ booking: input.booking,
1457
+ products: [input],
1458
+ coveredMinutes: input.coveredMinutes,
1459
+ bookingPatch: input.bookingPatch
1460
+ });
1461
+ }
1462
+ /**
1463
+ * 批量将加时商品作为独立商品行绑定到已有 booking,并只触发一次购物车重算。
1464
+ *
1465
+ * @example
1466
+ * await bookingTicket.addAddTimeProductsToBooking({
1467
+ * booking,
1468
+ * products: [{ product, product_add_schedule_time: 30 }],
1469
+ * });
1470
+ */
1471
+ async addAddTimeProductsToBooking(input) {
1472
+ const bookingUid = resolveBookingUidForAddTime(input == null ? void 0 : input.booking);
1473
+ if (!bookingUid) {
1474
+ throw new Error(
1475
+ "[BookingTicket] addAddTimeProductToBooking: booking.metadata.unique_identification_number 缺失"
1476
+ );
1477
+ }
1478
+ const orderLines = (input.products || []).map((line) => ({
1479
+ product: this.buildAddTimeOrderLine(line, bookingUid)
1480
+ }));
1481
+ if (!this.store.order)
1482
+ throw new Error("order 模块未初始化");
1483
+ const coveredMinutes = normalizeCoveredMinutes(input.coveredMinutes);
1484
+ const bookingTimePatch = input.bookingPatch ?? buildAddTimeBookingTimePatch(input.booking, coveredMinutes);
1485
+ if (bookingTimePatch) {
1486
+ this.store.order.updateOrderBooking({
1487
+ unique_identification_number: bookingUid,
1488
+ updates: bookingTimePatch
1489
+ });
1490
+ }
1491
+ if (typeof this.store.order.addProductsToOrder === "function") {
1492
+ return this.store.order.addProductsToOrder(orderLines, {
1493
+ skipEditDiscountConfigRefresh: true,
1494
+ skipDiscountRecalculation: true
1495
+ });
1496
+ }
1497
+ const result = [];
1498
+ for (const line of orderLines) {
1499
+ result.splice(0, result.length, ...await this.addProductToOrder(line.product));
1500
+ }
1501
+ return result;
1502
+ }
1503
+ async setOtherParams(params, { cover = false } = {}) {
1504
+ super.setOtherParams(params, { cover });
1505
+ if (params == null ? void 0 : params.businessCode) {
1506
+ await this.configureIdGeneratorFromOpenData();
1507
+ }
1508
+ }
616
1509
  /**
617
1510
  * 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
618
1511
  * 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。