@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
@@ -89,13 +89,45 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
89
89
  moduleName: "scanOrder"
90
90
  };
91
91
  }
92
+ safeStringify(value) {
93
+ try {
94
+ return JSON.stringify(value);
95
+ } catch {
96
+ return void 0;
97
+ }
98
+ }
99
+ pickErrorMessage(error) {
100
+ var _a, _b, _c, _d;
101
+ const candidates = [
102
+ error.message,
103
+ (_a = error.data) == null ? void 0 : _a.message,
104
+ (_c = (_b = error.response) == null ? void 0 : _b.data) == null ? void 0 : _c.message,
105
+ (_d = error.error) == null ? void 0 : _d.message
106
+ ];
107
+ for (const candidate of candidates) {
108
+ if (typeof candidate === "string" && candidate.trim())
109
+ return candidate;
110
+ }
111
+ return void 0;
112
+ }
92
113
  serializeError(error) {
93
114
  if (error instanceof Error) {
94
- return JSON.stringify({
115
+ return {
95
116
  name: error.name,
96
117
  message: error.message,
97
118
  stack: error.stack
98
- });
119
+ };
120
+ }
121
+ if (error && typeof error === "object") {
122
+ const raw = error;
123
+ const message = this.pickErrorMessage(raw) || this.safeStringify(raw) || String(error);
124
+ return {
125
+ ...typeof raw.name === "string" ? { name: raw.name } : {},
126
+ message,
127
+ ..."code" in raw ? { code: raw.code } : {},
128
+ ..."status" in raw ? { status: raw.status } : {},
129
+ ...this.safeStringify(raw) ? { raw: this.safeStringify(raw) } : {}
130
+ };
99
131
  }
100
132
  return {
101
133
  message: String(error)
@@ -155,6 +187,14 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
155
187
  }
156
188
  });
157
189
  }
190
+ assertProductListLoaded(method, result, payload = {}) {
191
+ if (Array.isArray(result))
192
+ return result;
193
+ const error = result instanceof Error ? result : new Error("商品列表接口返回异常");
194
+ this.logMethodError(method, error, payload);
195
+ error.__scanOrderLogged = true;
196
+ throw error;
197
+ }
158
198
  async addLog(params) {
159
199
  await this.addScanOrderLog({
160
200
  ...params,
@@ -319,13 +359,13 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
319
359
  if (targetModule) {
320
360
  this.store[step] = targetModule;
321
361
  const initialState = step === "salesSummary" ? {
322
- // TODO(Order types): ScanOrder runtime should read OrderState.summary instead of tempOrder.summary.
323
362
  summary: ((_b2 = (_a2 = this.store.order) == null ? void 0 : _a2.getTempOrder()) == null ? void 0 : _b2.summary) || (0, import_utils.createEmptySummary)()
324
363
  } : {};
325
364
  const loggerProvider = ((_c2 = this.otherParams) == null ? void 0 : _c2.scanOrderLoggerProvider) || "feishu";
326
365
  const loggerConfig = ((_d2 = this.otherParams) == null ? void 0 : _d2.scanOrderLoggerConfig) || {
327
366
  feishu: {
328
- webhook: "https://open.feishu.cn/open-apis/bot/v2/hook/216b3fe6-af98-424e-8706-f0471241a7ed"
367
+ webhook: "https://open.feishu.cn/open-apis/bot/v2/hook/216b3fe6-af98-424e-8706-f0471241a7ed",
368
+ errorHook: "https://open.feishu.cn/open-apis/bot/v2/hook/015b7c2a-dd3c-4c30-9898-ef0f5253111f"
329
369
  }
330
370
  };
331
371
  this.core.registerModule(targetModule, {
@@ -711,7 +751,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
711
751
  (sum, pd) => sum + (pd.amount || 0),
712
752
  0
713
753
  );
714
- const optionSum = (0, import_utils2.sumOptionUnitPrice)(product.product_option_item);
754
+ const optionSum = (0, import_utils2.sumOptionUnitPrice)((0, import_utils2.getProductSkuOptions)(product));
715
755
  const sourcePrice = ((_d = product.metadata) == null ? void 0 : _d.source_product_price) ?? (((_e = product.metadata) == null ? void 0 : _e.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
716
756
  const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
717
757
  const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
@@ -747,6 +787,34 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
747
787
  throw error;
748
788
  }
749
789
  }
790
+ findReservationRuleResource(formId) {
791
+ var _a;
792
+ if (formId == null)
793
+ return void 0;
794
+ const numericFormId = Number(formId);
795
+ if (!Number.isFinite(numericFormId) || numericFormId <= 0)
796
+ return void 0;
797
+ for (const product of this.enabledReservationRuleProducts) {
798
+ const resources = (_a = product == null ? void 0 : product.product_resource) == null ? void 0 : _a.resources;
799
+ if (!Array.isArray(resources))
800
+ continue;
801
+ const matched = resources.find((resource) => Number(resource == null ? void 0 : resource.id) === numericFormId);
802
+ if (matched)
803
+ return matched;
804
+ }
805
+ return void 0;
806
+ }
807
+ buildScanOrderResourceMetadata(params) {
808
+ const { resourceState, resourceName } = params;
809
+ const ruleResource = this.findReservationRuleResource(resourceState.tableFormId);
810
+ const combined = ruleResource == null ? void 0 : ruleResource.combined_resource;
811
+ const isCombined = !!(combined && combined.status === 1 && Array.isArray(combined.resource_ids));
812
+ return {
813
+ form_name: (ruleResource == null ? void 0 : ruleResource.title) ?? "",
814
+ resource_name: resourceName,
815
+ combined_resource: isCombined ? combined : null
816
+ };
817
+ }
750
818
  // ScanOrder 提交 payload enhancer:
751
819
  // - 给所有 booking 注入 appointment_status: 'started'(扫码点餐语义)
752
820
  // - 给所有 booking 的 metadata 注入 resource_select_type(来自预约规则商品的 resource.type)
@@ -770,6 +838,9 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
770
838
  return (payload, { bookingUuid, tempOrder }) => {
771
839
  var _a, _b;
772
840
  const resourceId = tempOrder.resource_id ?? (resourceState == null ? void 0 : resourceState.relationId);
841
+ const rawCollectPax = (_a = tempOrder.metadata) == null ? void 0 : _a.collect_pax;
842
+ const hasCollectPaxForCapacity = rawCollectPax !== null && rawCollectPax !== void 0 && rawCollectPax !== "";
843
+ const resourceCapacityValue = hasCollectPaxForCapacity ? (0, import_utils2.normalizeSubmitCollectPaxValue)(rawCollectPax) : resolveResourceCapacity();
773
844
  const pickOriginal = (value) => {
774
845
  if (value && typeof value === "object" && !Array.isArray(value)) {
775
846
  const original = value.original;
@@ -777,7 +848,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
777
848
  }
778
849
  return void 0;
779
850
  };
780
- const mainField = pickOriginal(tempOrder.table_number) ?? pickOriginal((_a = resourceState == null ? void 0 : resourceState.table_form_record) == null ? void 0 : _a.name) ?? "";
851
+ const mainField = pickOriginal(tempOrder.table_number) ?? pickOriginal((_b = resourceState == null ? void 0 : resourceState.table_form_record) == null ? void 0 : _b.name) ?? "";
781
852
  const resourceEntry = resourceState && resourceId ? {
782
853
  relation_type: "form",
783
854
  like_status: "common",
@@ -785,37 +856,35 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
785
856
  main_field: mainField,
786
857
  form_id: resourceState.tableFormId,
787
858
  relation_id: resourceState.relationId ?? resourceId,
788
- capacity: resolveResourceCapacity(),
789
- metadata: {}
859
+ capacity: resourceCapacityValue,
860
+ metadata: this.buildScanOrderResourceMetadata({
861
+ resourceState,
862
+ resourceName: mainField
863
+ })
790
864
  } : void 0;
791
865
  const ruleProductUid = ruleProduct ? (0, import_utils2.createUuidV4)() : void 0;
792
- const rawCollectPax = (_b = tempOrder.metadata) == null ? void 0 : _b.collect_pax;
793
- const hasCollectPaxForCapacity = rawCollectPax !== null && rawCollectPax !== void 0 && rawCollectPax !== "";
794
- const bookingCapacityValue = hasCollectPaxForCapacity ? (0, import_utils2.normalizeSubmitCollectPaxValue)(rawCollectPax) : resolveResourceCapacity();
866
+ const bookingCapacityValue = resourceCapacityValue;
795
867
  const bookingCapacityDimensionId = (0, import_utils.pickFirstCustomCapacityDimensionId)(this.enabledReservationRuleProducts) ?? 0;
796
- const nextBookings = (payload.bookings || []).map((booking, idx) => {
797
- var _a2;
798
- return {
799
- ...booking,
800
- appointment_status: "started",
801
- metadata: {
802
- ...booking.metadata || {},
803
- holder_id: ((_a2 = booking.metadata) == null ? void 0 : _a2.holder_id) ?? null,
804
- ...resourceSelectType ? { resource_select_type: resourceSelectType } : {},
805
- ...resourceSelectType ? {
806
- capacity: [
807
- {
808
- id: bookingCapacityDimensionId,
809
- value: bookingCapacityValue,
810
- name: ""
811
- }
812
- ]
813
- } : {}
814
- },
815
- ...idx === 0 && resourceEntry ? { resources: [resourceEntry] } : {},
816
- ...idx === 0 && ruleProductUid ? { product_uid: ruleProductUid } : {}
817
- };
818
- });
868
+ const nextBookings = (payload.bookings || []).map((booking, idx) => ({
869
+ ...booking,
870
+ number: bookingCapacityValue,
871
+ appointment_status: "started",
872
+ metadata: {
873
+ ...booking.metadata || {},
874
+ ...resourceSelectType ? { resource_select_type: resourceSelectType } : {},
875
+ ...resourceSelectType ? {
876
+ capacity: [
877
+ {
878
+ id: bookingCapacityDimensionId,
879
+ value: bookingCapacityValue,
880
+ name: ""
881
+ }
882
+ ]
883
+ } : {}
884
+ },
885
+ ...idx === 0 && resourceEntry ? { resources: [resourceEntry] } : {},
886
+ ...idx === 0 && ruleProductUid ? { product_uid: ruleProductUid } : {}
887
+ }));
819
888
  const nextProducts = [...payload.products || []];
820
889
  if (ruleProduct && ruleProductUid && !tempOrder.order_id) {
821
890
  const sellingPrice = String(ruleProduct.price ?? "0.00");
@@ -830,7 +899,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
830
899
  original_price: originalPrice,
831
900
  payment_price: sellingPrice,
832
901
  is_charge_tax: ruleProduct.is_gst ?? 0,
833
- product_option_item: [],
902
+ product_sku: { option: [] },
834
903
  discount_list: [],
835
904
  product_bundle: [],
836
905
  booking_uid: bookingUuid,
@@ -903,23 +972,23 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
903
972
  throw error;
904
973
  }
905
974
  }
906
- async updateProductInOrder(params) {
907
- this.logMethodStart("updateProductInOrder", {
975
+ async updateOrderProduct(params) {
976
+ this.logMethodStart("updateOrderProduct", {
908
977
  product_id: params.product_id,
909
978
  product_variant_id: params.product_variant_id
910
979
  });
911
980
  try {
912
981
  if (!this.store.order)
913
982
  throw new Error("order 模块未初始化");
914
- const products = await this.store.order.updateProductInOrder(params);
983
+ const products = await this.store.order.updateOrderProduct(params);
915
984
  await this.refreshItemRuleQuantityLimits();
916
985
  await this.refreshCartValidationPassed();
917
- this.logMethodSuccess("updateProductInOrder", {
986
+ this.logMethodSuccess("updateOrderProduct", {
918
987
  productCount: products.length
919
988
  });
920
989
  return products;
921
990
  } catch (error) {
922
- this.logMethodError("updateProductInOrder", error);
991
+ this.logMethodError("updateOrderProduct", error);
923
992
  throw error;
924
993
  }
925
994
  }
@@ -938,15 +1007,14 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
938
1007
  product_variant_id: identity.product_variant_id,
939
1008
  updates: { note: String(note || "") }
940
1009
  };
941
- if (identity.identity_key !== void 0) {
1010
+ if (identity.identity_key !== void 0)
942
1011
  params.identity_key = identity.identity_key;
943
- }
944
- if (identity.product_option_item !== void 0) {
945
- params.product_option_item = identity.product_option_item;
1012
+ if (identity.product_sku !== void 0) {
1013
+ params.product_sku = identity.product_sku;
946
1014
  }
947
1015
  if (identity.product_bundle !== void 0)
948
1016
  params.product_bundle = identity.product_bundle;
949
- const products = await this.updateProductInOrder(params);
1017
+ const products = await this.updateOrderProduct(params);
950
1018
  this.logMethodSuccess("setOrderProductLineNote", { productCount: products.length });
951
1019
  return products;
952
1020
  } catch (error) {
@@ -1208,7 +1276,6 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1208
1276
  item_rule_prefill: true,
1209
1277
  item_rule_id: prefillItem.ruleId
1210
1278
  },
1211
- // TODO(Order types): migrate ScanOrder prefill origin runtime into tempOrder._extend.
1212
1279
  _origin: sourceItem ? {
1213
1280
  ...targetProduct._origin || {},
1214
1281
  ...sourceItem
@@ -1433,14 +1500,17 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1433
1500
  // 通过 resource_id + 店铺配置
1434
1501
  // hasOrderId 表示 url 上是否有 orderid,如果是的话,后续的流程会走加单
1435
1502
  async checkResourceAvailable(resourceId, hasOrderId) {
1436
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
1503
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
1437
1504
  this.logMethodStart("checkResourceAvailable", {
1438
1505
  resourceId
1439
1506
  });
1440
1507
  try {
1441
- const openData = await ((_b = (_a = this.otherParams) == null ? void 0 : _a.getOpenData) == null ? void 0 : _b.call(_a, {
1508
+ const businessCode = String(((_a = this.otherParams) == null ? void 0 : _a.businessCode) ?? "").trim();
1509
+ const channel = String(((_b = this.otherParams) == null ? void 0 : _b.channel) ?? "").trim();
1510
+ const openDataTarget = businessCode && channel ? `${businessCode}+${channel}` : "dine_in+scan_to_order";
1511
+ const openData = await ((_d = (_c = this.otherParams) == null ? void 0 : _c.getOpenData) == null ? void 0 : _d.call(_c, {
1442
1512
  scope: "board",
1443
- target: "dine_in+scan_to_order",
1513
+ target: openDataTarget,
1444
1514
  section_code: ["basic", "fulfillment", "reservation", "sale", "menu", "availability", "workflow"]
1445
1515
  }));
1446
1516
  if ((openData == null ? void 0 : openData.status) === false) {
@@ -1531,13 +1601,13 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1531
1601
  }
1532
1602
  } else {
1533
1603
  this.enabledReservationRuleProducts = [];
1534
- void this.addScanOrderLog({
1535
- level: "error",
1536
- title: "[ScanOrder] enabled_reservation_rules product query failed",
1537
- payload: {
1538
- linkIds: reservationLinkIds,
1539
- error: this.serializeError(loaded)
1540
- }
1604
+ const error = loaded instanceof Error ? loaded : new Error("预约规则商品列表接口返回异常");
1605
+ this.logMethodError("loadReservationRuleProducts", error, {
1606
+ resourceId,
1607
+ reservationLinkIds,
1608
+ scheduleDate,
1609
+ scheduleDatetime,
1610
+ cacheId: this.cacheId
1541
1611
  });
1542
1612
  }
1543
1613
  }
@@ -1567,16 +1637,16 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1567
1637
  table_form_id: resourceState.tableFormId,
1568
1638
  deskmate_valid: resourceState.deskmate_valid,
1569
1639
  table_form_record: resourceState.table_form_record,
1570
- policy: (_c = occupyDetail == null ? void 0 : occupyDetail.form_record) == null ? void 0 : _c.policy,
1571
- partyroom_booking: (_d = occupyDetail == null ? void 0 : occupyDetail.form_record) == null ? void 0 : _d.partyroom_booking,
1640
+ policy: (_e = occupyDetail == null ? void 0 : occupyDetail.form_record) == null ? void 0 : _e.policy,
1641
+ partyroom_booking: (_f = occupyDetail == null ? void 0 : occupyDetail.form_record) == null ? void 0 : _f.partyroom_booking,
1572
1642
  ...this.store.resource.requestEntryPax !== void 0 ? { requestEntryPax: this.store.resource.requestEntryPax } : {},
1573
1643
  ...this.store.resource.requestPaxMin !== void 0 ? { requestPaxMin: this.store.resource.requestPaxMin } : {},
1574
1644
  ...this.store.resource.requestPaxMax !== void 0 ? { requestPaxMax: this.store.resource.requestPaxMax } : {}
1575
1645
  };
1576
- tempOrder.relation_id = resourceId || ((_e = this.otherParams) == null ? void 0 : _e.relation_id);
1646
+ tempOrder.relation_id = resourceId || ((_g = this.otherParams) == null ? void 0 : _g.relation_id);
1577
1647
  tempOrder.table_form_id = resourceState.tableFormId;
1578
1648
  tempOrder.resource_id = resourceId;
1579
- (_f = this.store.order) == null ? void 0 : _f.persistTempOrder();
1649
+ (_h = this.store.order) == null ? void 0 : _h.persistTempOrder();
1580
1650
  if (availabilityInfo.mode === "idle") {
1581
1651
  await this.addNewOrder();
1582
1652
  }
@@ -1584,16 +1654,18 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1584
1654
  tempOrder.order_id = resourceState.lastOrderId;
1585
1655
  }
1586
1656
  if (tempOrder.order_id) {
1587
- const res = await ((_g = this.store.order) == null ? void 0 : _g.getOrderInfoByRemote(tempOrder.order_id));
1588
- const entryPaxNumber = (_k = (_j = (_i = (_h = res == null ? void 0 : res.data) == null ? void 0 : _h.bookings) == null ? void 0 : _i.find((p) => {
1657
+ const res = await ((_i = this.store.order) == null ? void 0 : _i.getSalesOrderByLookup({
1658
+ lookup: tempOrder.order_id
1659
+ }));
1660
+ const entryPaxNumber = (_m = (_l = (_k = (_j = res == null ? void 0 : res.data) == null ? void 0 : _j.bookings) == null ? void 0 : _k.find((p) => {
1589
1661
  var _a2;
1590
1662
  return (_a2 = p.metadata) == null ? void 0 : _a2.collect_pax;
1591
- })) == null ? void 0 : _j.metadata) == null ? void 0 : _k.collect_pax;
1663
+ })) == null ? void 0 : _l.metadata) == null ? void 0 : _m.collect_pax;
1592
1664
  if (entryPaxNumber) {
1593
1665
  await this.setEntryPaxNumber(entryPaxNumber);
1594
1666
  }
1595
1667
  }
1596
- const lastOrderInfo = (_m = (_l = this.store.order) == null ? void 0 : _l.getLastOrderInfo) == null ? void 0 : _m.call(_l);
1668
+ const lastOrderInfo = (_o = (_n = this.store.order) == null ? void 0 : _n.getLastOrderInfo) == null ? void 0 : _o.call(_n);
1597
1669
  const historicalItems = hasOrderId && Array.isArray(lastOrderInfo == null ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce((acc, p) => {
1598
1670
  if (typeof (p == null ? void 0 : p.product_id) !== "number")
1599
1671
  return acc;
@@ -1605,7 +1677,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1605
1677
  return acc;
1606
1678
  }, []) : [];
1607
1679
  await this.setItemRuleRuntimeConfig({
1608
- serviceType: (_n = this.otherParams) == null ? void 0 : _n.businessCode,
1680
+ serviceType: (_p = this.otherParams) == null ? void 0 : _p.businessCode,
1609
1681
  submissionIndex: hasOrderId ? 1 : 0,
1610
1682
  historicalItems
1611
1683
  });
@@ -1653,18 +1725,24 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1653
1725
  }
1654
1726
  // 获取商品列表
1655
1727
  async getProductList() {
1656
- var _a, _b, _c;
1728
+ var _a, _b;
1657
1729
  this.logMethodStart("getProductList");
1658
1730
  const menu_list_ids = ((_b = (_a = this.otherParams) == null ? void 0 : _a.dineInConfig) == null ? void 0 : _b["menu.associated_menus"].map((n) => Number(n.value))) || [];
1659
1731
  try {
1660
- const res = await ((_c = this.store.products) == null ? void 0 : _c.loadProducts({
1732
+ if (!this.store.products)
1733
+ throw new Error("products 模块未初始化");
1734
+ const res = await this.store.products.loadProducts({
1661
1735
  menu_list_ids,
1662
1736
  cacheId: this.cacheId,
1663
1737
  schedule_date: (0, import_dayjs.default)().format("YYYY-MM-DD"),
1664
1738
  schedule_datetime: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss")
1665
- }));
1739
+ });
1740
+ const productList = this.assertProductListLoaded("getProductList", res, {
1741
+ menu_list_ids,
1742
+ cacheId: this.cacheId
1743
+ });
1666
1744
  const formattedRes = (0, import_utils.attachItemRuleLimitsToTopLevelProducts)(
1667
- res,
1745
+ productList,
1668
1746
  this.store.itemRuleQuantityLimits || []
1669
1747
  );
1670
1748
  this.logMethodSuccess("getProductList", {
@@ -1672,7 +1750,12 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1672
1750
  });
1673
1751
  return formattedRes;
1674
1752
  } catch (error) {
1675
- this.logMethodError("getProductList", error.message);
1753
+ if (!(error == null ? void 0 : error.__scanOrderLogged)) {
1754
+ this.logMethodError("getProductList", error, {
1755
+ menu_list_ids,
1756
+ cacheId: this.cacheId
1757
+ });
1758
+ }
1676
1759
  throw error;
1677
1760
  }
1678
1761
  }
@@ -33,13 +33,17 @@ export interface ScanOrderOrderProductIdentity {
33
33
  identity_key?: string;
34
34
  unique_identification_number?: string;
35
35
  /** 参与合并/匹配;与 remove 通配语义见 isSkuOnlyDeleteIdentity */
36
- product_option_item?: any[];
36
+ product_sku?: ScanOrderProductSku;
37
37
  product_bundle?: any[];
38
38
  }
39
+ export interface ScanOrderProductSku {
40
+ option: any[];
41
+ [key: string]: any;
42
+ }
39
43
  export interface ScanOrderOrderProduct extends ScanOrderOrderProductIdentity {
40
44
  order_detail_id: number | null;
41
45
  num: number;
42
- product_option_item: any[];
46
+ product_sku: ScanOrderProductSku;
43
47
  /**
44
48
  * 券后 **行 composite 单价** = `metadata.main_product_selling_price`
45
49
  * + Σ((bundle.bundle_selling_price ?? bundle.price) × (bundle.num ?? 1))
@@ -85,9 +89,8 @@ export interface ScanOrderOrderProduct extends ScanOrderOrderProductIdentity {
85
89
  * 出站 payload 版本的商品行。
86
90
  *
87
91
  * 与 tempOrder 内部 `ScanOrderOrderProduct` 的字段差异:
88
- * - `product_option_item[*]`:内部为 `{ option_group_item_id, option_group_id, num, price, ... }`,
89
- * 出站保留 `{ option_group_item_id, option_group_id, num }`
90
- * (后端 checkout 协议;丢弃 `price` 等运行时辅助字段)。
92
+ * - `product_sku.option[*]`:内部直接维护统一 Sales 协议字段;
93
+ * 提交时仅规范 `add_price`,保留传入/恢复得到的展示字段。
91
94
  * - `product_bundle[*].option[*]`:同上重命名规则。
92
95
  *
93
96
  * 运行时(UI 显示、加购合并、指纹、持久化)与提交边界统一消费字段名
@@ -112,6 +115,7 @@ export interface ScanOrderSummary {
112
115
  shipping_tax_fee: string;
113
116
  tax_fee: string;
114
117
  surcharge_fee: string;
118
+ surcharges: any[];
115
119
  discount_amount: string;
116
120
  deposit_amount: string;
117
121
  deposit?: {
@@ -88,7 +88,7 @@ export declare function attachItemRuleLimitsToTopLevelProducts<T>(productList: T
88
88
  export declare function buildProductLineFingerprint(productOptionItem?: unknown, productBundle?: unknown): string;
89
89
  /**
90
90
  * removeProductFromOrder 仅传 SKU 时的通配 identity(对象上未声明选项键)。
91
- * 与显式 `product_option_item: []` 区分:后者只匹配「无选项」行。
91
+ * 与显式 `product_sku: { option: [] }` 区分:后者只匹配「无选项」行。
92
92
  */
93
93
  export declare function isSkuOnlyDeleteIdentity(x: ScanOrderOrderProductIdentity): boolean;
94
94
  /**
@@ -63,6 +63,7 @@ module.exports = __toCommonJS(utils_exports);
63
63
  var import_dayjs = __toESM(require("dayjs"));
64
64
  var import_decimal = __toESM(require("decimal.js"));
65
65
  var import_utils = require("../../modules/Order/utils");
66
+ var import_manualProductDiscount = require("../../modules/Order/utils/manualProductDiscount");
66
67
  function createEmptySummary() {
67
68
  return {
68
69
  product_quantity: 0,
@@ -74,6 +75,7 @@ function createEmptySummary() {
74
75
  shipping_tax_fee: "0.00",
75
76
  tax_fee: "0.00",
76
77
  surcharge_fee: "0.00",
78
+ surcharges: [],
77
79
  discount_amount: "0.00",
78
80
  deposit_amount: "0.00",
79
81
  expect_amount: "0.00",
@@ -352,7 +354,7 @@ function buildProductLineFingerprint(productOptionItem, productBundle) {
352
354
  option_group_item_id: Number(item == null ? void 0 : item.option_group_item_id) || 0,
353
355
  option_group_id: Number(item == null ? void 0 : item.option_group_id) || 0,
354
356
  num: typeof (item == null ? void 0 : item.num) === "number" && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
355
- price: String((item == null ? void 0 : item.price) ?? "")
357
+ price: String((item == null ? void 0 : item.add_price) ?? (item == null ? void 0 : item.price) ?? "")
356
358
  })).sort((p, q) => {
357
359
  if (p.option_group_item_id !== q.option_group_item_id) {
358
360
  return p.option_group_item_id - q.option_group_item_id;
@@ -380,11 +382,11 @@ function buildProductLineFingerprint(productOptionItem, productBundle) {
380
382
  function isSkuOnlyDeleteIdentity(x) {
381
383
  if (x.unique_identification_number || x.identity_key)
382
384
  return false;
383
- return !("product_option_item" in x) && !("product_bundle" in x);
385
+ return !("product_sku" in x) && !("product_bundle" in x);
384
386
  }
385
387
  function fingerprintForIdentityWithOptionKeys(x) {
386
388
  const row = x;
387
- const opts = "product_option_item" in row ? Array.isArray(row.product_option_item) ? row.product_option_item : [] : [];
389
+ const opts = "product_sku" in row ? (0, import_utils.getProductSkuOptions)(row) : [];
388
390
  const buds = "product_bundle" in row ? Array.isArray(row.product_bundle) ? row.product_bundle : [] : [];
389
391
  return buildProductLineFingerprint(opts, buds);
390
392
  }
@@ -406,23 +408,72 @@ function getProductIdentityIndex(products, identity) {
406
408
  return products.findIndex((item) => isIdentityMatch(item, identity));
407
409
  }
408
410
  function normalizeOrderProduct(product) {
409
- var _a, _b, _c;
411
+ var _a, _b, _c, _d, _e, _f, _g;
410
412
  const metadata = { ...product.metadata || {} };
411
413
  const resolvedIdentityKey = ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) ? String(product.metadata.unique_identification_number) : product.unique_identification_number && String(product.unique_identification_number).length > 0 ? String(product.unique_identification_number) : product.identity_key && String(product.identity_key).length > 0 ? String(product.identity_key) : (0, import_utils.createUuidV4)();
412
414
  metadata.unique_identification_number = resolvedIdentityKey;
413
- const normalizedBundle = (product.product_bundle || []).map((item) => ({
414
- ...item,
415
- bundle_selling_price: item.bundle_selling_price ?? item.price ?? "0.00",
416
- price: item.price ?? item.custom_price ?? item.bundle_selling_price ?? "0.00",
417
- price_type: item.price_type ?? item.custom_price_type ?? "",
418
- price_type_ext: item.price_type_ext ?? item.custom_price_type_ext ?? ""
419
- }));
420
- const normalizedOptions = product.product_option_item || [];
415
+ const priceOverride = metadata.price_override;
416
+ const originOtherBundle = (_d = (_c = (_b = metadata.origin) == null ? void 0 : _b._extend) == null ? void 0 : _c.other) == null ? void 0 : _d.bundle;
417
+ let bundleInput = product.product_bundle || [];
418
+ if (priceOverride !== void 0 && priceOverride !== null && priceOverride !== "" && Array.isArray(originOtherBundle) && originOtherBundle.length > 0) {
419
+ const priceById = /* @__PURE__ */ new Map();
420
+ originOtherBundle.forEach((item) => {
421
+ if ((item == null ? void 0 : item.id) == null)
422
+ return;
423
+ const unit = item.price ?? item.bundle_selling_price;
424
+ if (unit === void 0 || unit === null)
425
+ return;
426
+ priceById.set(String(item.id), String(unit));
427
+ });
428
+ const base = Array.isArray(bundleInput) && bundleInput.length > 0 ? bundleInput : originOtherBundle;
429
+ bundleInput = base.map((item) => {
430
+ const unit = priceById.get(String(item == null ? void 0 : item.id));
431
+ if (unit === void 0)
432
+ return item;
433
+ return {
434
+ ...item,
435
+ price: unit,
436
+ bundle_selling_price: unit
437
+ };
438
+ });
439
+ }
440
+ const normalizedBundle = bundleInput.map((item) => {
441
+ const magnitudeSource = {
442
+ ...item,
443
+ // 计算 markdown 净额时,只把真实毛价交给 helper;若只有 bundle_selling_price,
444
+ // helper 会按历史净额兜底,避免 option 二次扣减。
445
+ price: item.price ?? item.custom_price
446
+ };
447
+ const normalizedItem = {
448
+ ...item,
449
+ bundle_id: item.bundle_id ?? item.id,
450
+ bundle_product_id: item.bundle_product_id ?? item._bundle_product_id,
451
+ bundle_group_id: item.bundle_group_id ?? item.group_id,
452
+ // price 保留毛价(markdown 仍为 5),由 price_type 决定符号。
453
+ price: item.price ?? item.custom_price ?? item.bundle_selling_price ?? "0.00",
454
+ price_type: item.price_type ?? item.custom_price_type ?? "",
455
+ price_type_ext: item.price_type_ext ?? item.custom_price_type_ext ?? ""
456
+ };
457
+ normalizedItem.bundle_selling_price = (0, import_utils.getBundleSellingMagnitude)(magnitudeSource).toFixed(2);
458
+ if (normalizedItem.price_type === "markdown" && (normalizedItem.price_type_ext === "" || normalizedItem.price_type_ext === void 0 || normalizedItem.price_type_ext === null)) {
459
+ normalizedItem.custom_price = normalizedItem.custom_price ?? normalizedItem.price;
460
+ normalizedItem.price = normalizedItem.bundle_selling_price;
461
+ }
462
+ if ((normalizedItem.price_type === "markdown" || normalizedItem.price_type === "markup") && (normalizedItem.price_type_ext === "" || normalizedItem.price_type_ext === void 0 || normalizedItem.price_type_ext === null)) {
463
+ delete normalizedItem.original_total;
464
+ }
465
+ return normalizedItem;
466
+ });
467
+ const normalizedOptions = (0, import_utils.normalizeProductSkuOptions)((_e = product.product_sku) == null ? void 0 : _e.option);
421
468
  const optionSum = (0, import_utils.sumOptionUnitPrice)(normalizedOptions);
469
+ const productSku = {
470
+ ...(0, import_utils.ensureProductSku)(product),
471
+ option: normalizedOptions
472
+ };
422
473
  const isV2 = metadata.price_schema_version === 2 || metadata.price_schema_version === "2";
423
474
  const variantId = Number(product.product_variant_id || 0);
424
- const variantList = variantId ? (_b = metadata == null ? void 0 : metadata.origin) == null ? void 0 : _b.variant : null;
425
- const variantPrice = Array.isArray(variantList) ? (_c = variantList.find((v) => Number(v == null ? void 0 : v.id) === variantId)) == null ? void 0 : _c.price : void 0;
475
+ const variantList = variantId ? (_f = metadata == null ? void 0 : metadata.origin) == null ? void 0 : _f.variant : null;
476
+ const variantPrice = Array.isArray(variantList) ? (_g = variantList.find((v) => Number(v == null ? void 0 : v.id) === variantId)) == null ? void 0 : _g.price : void 0;
426
477
  const resolvedSource = (() => {
427
478
  var _a2, _b2;
428
479
  if (metadata.source_product_price !== void 0) {
@@ -478,17 +529,32 @@ function normalizeOrderProduct(product) {
478
529
  bundle: normalizedBundle,
479
530
  useOriginalBundle: true
480
531
  });
532
+ const finalOriginalPrice = (0, import_utils.resolveManualOverrideLineOriginalPrice)(
533
+ { num: product.num, metadata, lineOriginalPrice: product.original_price },
534
+ composedOriginalPrice
535
+ );
536
+ const hasManualProductDiscount = (product.discount_list || []).some(
537
+ (item) => (item == null ? void 0 : item.type) === "product"
538
+ );
539
+ const manualOriginalPrice = hasManualProductDiscount && product.original_price != null ? String(product.original_price) : finalOriginalPrice;
540
+ const discountList = (0, import_manualProductDiscount.ensureManualProductDiscountList)({
541
+ discountList: product.discount_list,
542
+ metadata,
543
+ originalPrice: manualOriginalPrice,
544
+ sellingPrice: composedSellingPrice,
545
+ quantity: getSafeProductNum(product.num)
546
+ });
481
547
  return {
482
548
  order_detail_id: product.order_detail_id || null,
483
549
  product_id: product.product_id,
484
550
  num: getSafeProductNum(product.num),
485
551
  product_variant_id: product.product_variant_id,
486
- product_option_item: normalizedOptions,
552
+ product_sku: productSku,
487
553
  selling_price: composedSellingPrice,
488
- original_price: composedOriginalPrice,
554
+ original_price: manualOriginalPrice,
489
555
  tax_fee: product.tax_fee || "0.00",
490
556
  is_charge_tax: product.is_charge_tax ?? 0,
491
- discount_list: product.discount_list || [],
557
+ discount_list: discountList,
492
558
  product_bundle: normalizedBundle,
493
559
  metadata,
494
560
  note: product.note != null ? String(product.note) : ""
@@ -2,7 +2,7 @@ import { Module, ModuleOptions, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../../modules/BaseModule';
3
3
  import { VenueBookingAddLogParams, VenueBookingSlotConfig, VenueDateSummaryItem, VenueSlotSelection, VenueTimeSlotGrid } from './types';
4
4
  import type { ScanOrderOrderProduct, ScanOrderOrderProductIdentity } from '../ScanOrder/types';
5
- import type { UpdateProductInOrderParams } from '../../modules/Order/types';
5
+ import type { UpdateOrderProductParams } from '../../modules/Order/types';
6
6
  import type { OpenDataAvailabilityResult } from '../../modules/OpenData';
7
7
  import type { ProductData } from '../../modules/Product/types';
8
8
  import { type CartItemSummary, type PaxInfo, type QuantityCheckResult, type QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
@@ -41,6 +41,8 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
41
41
  private loadOpenDataConfigInFlight;
42
42
  private static readonly OPEN_DATA_CACHE_TTL;
43
43
  private getLoggerContext;
44
+ private safeStringify;
45
+ private pickErrorMessage;
44
46
  private serializeError;
45
47
  private addVenueBookingLog;
46
48
  private logMethodStart;
@@ -154,6 +156,7 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
154
156
  type: "server" | "clientCalc";
155
157
  unavailableReason?: import("../../modules/Rules/types").UnavailableReason | undefined;
156
158
  unavailableReasonKey?: string | null | undefined;
159
+ scannedDiscountList?: import("../../modules/Discount").Discount[] | undefined;
157
160
  }>;
158
161
  /** 获取当前折扣列表(包装 order.getDiscountList) */
159
162
  getDiscountList(): import("../../modules/Discount").Discount[];
@@ -167,7 +170,7 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
167
170
  getSummary(): Promise<import("../../modules/Order/types").OrderSummary>;
168
171
  submitOrder<T = any>(): Promise<T>;
169
172
  addProductToOrder(product: Partial<ScanOrderOrderProduct> & ScanOrderOrderProductIdentity): Promise<import("../../modules/Order/types").OrderProduct[]>;
170
- updateProductInOrder(params: UpdateProductInOrderParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
173
+ updateOrderProduct(params: UpdateOrderProductParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
171
174
  removeProductFromOrder(identity: ScanOrderOrderProductIdentity): Promise<import("../../modules/Order/types").OrderProduct[]>;
172
175
  getProductList(): Promise<ProductData[]>;
173
176
  private loadOpenDataConfig;