@pisell/pisellos 2.2.244 → 2.2.245

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (317) hide show
  1. package/dist/model/strategy/adapter/promotion/evaluator.js +3 -2
  2. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  3. package/dist/model/strategy/adapter/walletPass/utils.js +7 -4
  4. package/dist/modules/BookingContext/index.d.ts +48 -0
  5. package/dist/modules/BookingContext/index.js +566 -0
  6. package/dist/modules/BookingContext/types.d.ts +102 -0
  7. package/dist/modules/BookingContext/types.js +51 -0
  8. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  9. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +284 -0
  10. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  11. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +145 -0
  12. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
  13. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +218 -0
  14. package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
  15. package/dist/modules/BookingContext/utils/flexible.js +56 -0
  16. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  17. package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
  18. package/dist/modules/BookingContext/utils/index.d.ts +11 -0
  19. package/dist/modules/BookingContext/utils/index.js +11 -0
  20. package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
  21. package/dist/modules/BookingContext/utils/noResource.js +77 -0
  22. package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
  23. package/dist/modules/BookingContext/utils/orderLineDisplay.js +36 -0
  24. package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
  25. package/dist/modules/BookingContext/utils/productExtend.js +339 -0
  26. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  27. package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
  28. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  29. package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
  30. package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
  31. package/dist/modules/BookingContext/utils/resources.js +486 -0
  32. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  33. package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
  34. package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  35. package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
  36. package/dist/modules/Cart/utils/cartProduct.js +24 -3
  37. package/dist/modules/Cart/utils/changePrice.js +11 -11
  38. package/dist/modules/Customer/index.d.ts +20 -0
  39. package/dist/modules/Customer/index.js +172 -83
  40. package/dist/modules/Customer/types.d.ts +2 -0
  41. package/dist/modules/Discount/index.d.ts +1 -1
  42. package/dist/modules/Discount/index.js +13 -6
  43. package/dist/modules/Discount/types.d.ts +1 -0
  44. package/dist/modules/OpenData/index.d.ts +8 -0
  45. package/dist/modules/OpenData/index.js +37 -17
  46. package/dist/modules/Order/index.d.ts +275 -19
  47. package/dist/modules/Order/index.js +3493 -809
  48. package/dist/modules/Order/types.d.ts +286 -31
  49. package/dist/modules/Order/types.js +38 -0
  50. package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  51. package/dist/modules/Order/utils/manualProductDiscount.js +210 -0
  52. package/dist/modules/Order/utils.d.ts +147 -5
  53. package/dist/modules/Order/utils.js +750 -104
  54. package/dist/modules/Payment/index.d.ts +10 -13
  55. package/dist/modules/Payment/index.js +467 -837
  56. package/dist/modules/Payment/types.d.ts +2 -0
  57. package/dist/modules/Payment/utils.js +2 -1
  58. package/dist/modules/Payment/walletpass.js +41 -25
  59. package/dist/modules/ProductList/index.d.ts +16 -12
  60. package/dist/modules/ProductList/index.js +133 -59
  61. package/dist/modules/ProductList/types.d.ts +14 -0
  62. package/dist/modules/Quotation/index.d.ts +0 -1
  63. package/dist/modules/Quotation/index.js +25 -22
  64. package/dist/modules/Rules/index.d.ts +4 -0
  65. package/dist/modules/Rules/index.js +97 -70
  66. package/dist/modules/Rules/types.d.ts +1 -0
  67. package/dist/modules/SalesSummary/index.d.ts +8 -25
  68. package/dist/modules/SalesSummary/index.js +86 -35
  69. package/dist/modules/SalesSummary/types.d.ts +4 -1
  70. package/dist/modules/SalesSummary/utils.d.ts +2 -25
  71. package/dist/modules/SalesSummary/utils.js +794 -162
  72. package/dist/modules/Schedule/index.d.ts +7 -0
  73. package/dist/modules/Schedule/index.js +24 -2
  74. package/dist/modules/Summary/index.js +4 -3
  75. package/dist/modules/SurchargeList/index.d.ts +16 -0
  76. package/dist/modules/SurchargeList/index.js +162 -0
  77. package/dist/modules/SurchargeList/types.d.ts +11 -0
  78. package/dist/modules/SurchargeList/types.js +1 -0
  79. package/dist/modules/index.d.ts +2 -0
  80. package/dist/modules/index.js +3 -1
  81. package/dist/plugins/request.d.ts +1 -0
  82. package/dist/server/index.d.ts +204 -1
  83. package/dist/server/index.js +3654 -922
  84. package/dist/server/modules/index.d.ts +2 -0
  85. package/dist/server/modules/index.js +2 -0
  86. package/dist/server/modules/order/index.d.ts +120 -3
  87. package/dist/server/modules/order/index.js +1758 -448
  88. package/dist/server/modules/order/types.d.ts +32 -3
  89. package/dist/server/modules/order/types.js +8 -0
  90. package/dist/server/modules/order/utils/filterBookings.js +26 -3
  91. package/dist/server/modules/order/utils/filterOrders.js +23 -8
  92. package/dist/server/modules/payment/index.d.ts +28 -0
  93. package/dist/server/modules/payment/index.js +305 -0
  94. package/dist/server/modules/payment/types.d.ts +9 -0
  95. package/dist/server/modules/payment/types.js +1 -0
  96. package/dist/server/modules/products/index.d.ts +34 -7
  97. package/dist/server/modules/products/index.js +631 -317
  98. package/dist/server/modules/resource/index.d.ts +2 -0
  99. package/dist/server/modules/resource/index.js +29 -3
  100. package/dist/server/modules/schedule/index.d.ts +4 -4
  101. package/dist/server/modules/schedule/index.js +111 -88
  102. package/dist/server/test.json +713 -0
  103. package/dist/server/utils/small-ticket.d.ts +71 -0
  104. package/dist/server/utils/small-ticket.js +840 -0
  105. package/dist/solution/BaseSales/index.d.ts +133 -10
  106. package/dist/solution/BaseSales/index.js +1950 -447
  107. package/dist/solution/BaseSales/types.d.ts +82 -6
  108. package/dist/solution/BaseSales/types.js +5 -4
  109. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
  110. package/dist/solution/BaseSales/utils/cartPromotion.js +1438 -0
  111. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  112. package/dist/solution/BaseSales/utils/quotationPrice.js +237 -0
  113. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  114. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +105 -24
  115. package/dist/solution/BaseSales/utils.d.ts +1 -1
  116. package/dist/solution/BaseSales/utils.js +62 -21
  117. package/dist/solution/BookingByStep/index.d.ts +1 -1
  118. package/dist/solution/BookingTicket/index.d.ts +271 -11
  119. package/dist/solution/BookingTicket/index.js +1777 -242
  120. package/dist/solution/BookingTicket/types.d.ts +118 -1
  121. package/dist/solution/BookingTicket/types.js +41 -2
  122. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
  123. package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
  124. package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
  125. package/dist/solution/BookingTicket/utils/addTimeAvailability.js +95 -0
  126. package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +40 -0
  127. package/dist/solution/BookingTicket/utils/bookingStatus.js +70 -0
  128. package/dist/solution/BookingTicket/utils/cartView.d.ts +9 -1
  129. package/dist/solution/BookingTicket/utils/cartView.js +94 -7
  130. package/dist/solution/BookingTicket/utils/exampleData.d.ts +123 -0
  131. package/dist/solution/BookingTicket/utils/exampleData.js +183 -0
  132. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
  133. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +438 -0
  134. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
  135. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +400 -0
  136. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
  137. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +56 -0
  138. package/dist/solution/BookingTicket/utils/scan/index.d.ts +5 -0
  139. package/dist/solution/BookingTicket/utils/scan/index.js +20 -8
  140. package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
  141. package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +150 -0
  142. package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
  143. package/dist/solution/BookingTicket/utils/sessionCatalogStale.js +78 -0
  144. package/dist/solution/Checkout/index.d.ts +1 -0
  145. package/dist/solution/Checkout/index.js +10 -9
  146. package/dist/solution/RegisterAndLogin/config.js +2 -10
  147. package/dist/solution/ScanOrder/index.d.ts +9 -3
  148. package/dist/solution/ScanOrder/index.js +241 -134
  149. package/dist/solution/ScanOrder/types.d.ts +9 -5
  150. package/dist/solution/ScanOrder/types.js +2 -3
  151. package/dist/solution/ScanOrder/utils.d.ts +1 -1
  152. package/dist/solution/ScanOrder/utils.js +84 -22
  153. package/dist/solution/VenueBooking/index.d.ts +5 -2
  154. package/dist/solution/VenueBooking/index.js +110 -59
  155. package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -2
  156. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  157. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
  158. package/dist/types/index.d.ts +10 -0
  159. package/lib/model/strategy/adapter/promotion/evaluator.js +2 -1
  160. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  161. package/lib/model/strategy/adapter/walletPass/utils.js +3 -2
  162. package/lib/modules/BookingContext/index.d.ts +48 -0
  163. package/lib/modules/BookingContext/index.js +368 -0
  164. package/lib/modules/BookingContext/types.d.ts +102 -0
  165. package/lib/modules/BookingContext/types.js +34 -0
  166. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  167. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +276 -0
  168. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  169. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +151 -0
  170. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
  171. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +201 -0
  172. package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
  173. package/lib/modules/BookingContext/utils/flexible.js +80 -0
  174. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  175. package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
  176. package/lib/modules/BookingContext/utils/index.d.ts +11 -0
  177. package/lib/modules/BookingContext/utils/index.js +43 -0
  178. package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
  179. package/lib/modules/BookingContext/utils/noResource.js +90 -0
  180. package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
  181. package/lib/modules/BookingContext/utils/orderLineDisplay.js +56 -0
  182. package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
  183. package/lib/modules/BookingContext/utils/productExtend.js +283 -0
  184. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  185. package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
  186. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  187. package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
  188. package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
  189. package/lib/modules/BookingContext/utils/resources.js +377 -0
  190. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  191. package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
  192. package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  193. package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
  194. package/lib/modules/Cart/utils/cartProduct.js +20 -3
  195. package/lib/modules/Cart/utils/changePrice.js +12 -20
  196. package/lib/modules/Customer/index.d.ts +20 -0
  197. package/lib/modules/Customer/index.js +64 -11
  198. package/lib/modules/Customer/types.d.ts +2 -0
  199. package/lib/modules/Discount/index.d.ts +1 -1
  200. package/lib/modules/Discount/index.js +9 -1
  201. package/lib/modules/Discount/types.d.ts +1 -0
  202. package/lib/modules/OpenData/index.d.ts +8 -0
  203. package/lib/modules/OpenData/index.js +19 -5
  204. package/lib/modules/Order/index.d.ts +275 -19
  205. package/lib/modules/Order/index.js +2245 -336
  206. package/lib/modules/Order/types.d.ts +286 -31
  207. package/lib/modules/Order/types.js +1 -0
  208. package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  209. package/lib/modules/Order/utils/manualProductDiscount.js +206 -0
  210. package/lib/modules/Order/utils.d.ts +147 -5
  211. package/lib/modules/Order/utils.js +615 -46
  212. package/lib/modules/Payment/index.d.ts +10 -13
  213. package/lib/modules/Payment/index.js +18 -150
  214. package/lib/modules/Payment/types.d.ts +2 -0
  215. package/lib/modules/Payment/utils.js +2 -1
  216. package/lib/modules/Payment/walletpass.js +16 -3
  217. package/lib/modules/ProductList/index.d.ts +16 -12
  218. package/lib/modules/ProductList/index.js +41 -4
  219. package/lib/modules/ProductList/types.d.ts +14 -0
  220. package/lib/modules/Quotation/index.d.ts +0 -1
  221. package/lib/modules/Quotation/index.js +19 -16
  222. package/lib/modules/Rules/index.d.ts +4 -0
  223. package/lib/modules/Rules/index.js +137 -120
  224. package/lib/modules/Rules/types.d.ts +1 -0
  225. package/lib/modules/SalesSummary/index.d.ts +8 -25
  226. package/lib/modules/SalesSummary/index.js +30 -4
  227. package/lib/modules/SalesSummary/types.d.ts +4 -1
  228. package/lib/modules/SalesSummary/utils.d.ts +2 -25
  229. package/lib/modules/SalesSummary/utils.js +645 -91
  230. package/lib/modules/Schedule/index.d.ts +7 -0
  231. package/lib/modules/Schedule/index.js +17 -1
  232. package/lib/modules/Summary/index.js +5 -4
  233. package/lib/modules/SurchargeList/index.d.ts +16 -0
  234. package/lib/modules/SurchargeList/index.js +89 -0
  235. package/lib/modules/SurchargeList/types.d.ts +11 -0
  236. package/lib/modules/SurchargeList/types.js +17 -0
  237. package/lib/modules/index.d.ts +2 -0
  238. package/lib/modules/index.js +5 -1
  239. package/lib/plugins/request.d.ts +1 -0
  240. package/lib/server/index.d.ts +204 -1
  241. package/lib/server/index.js +1891 -59
  242. package/lib/server/modules/index.d.ts +2 -0
  243. package/lib/server/modules/index.js +3 -0
  244. package/lib/server/modules/order/index.d.ts +120 -3
  245. package/lib/server/modules/order/index.js +883 -94
  246. package/lib/server/modules/order/types.d.ts +32 -3
  247. package/lib/server/modules/order/utils/filterBookings.js +24 -5
  248. package/lib/server/modules/order/utils/filterOrders.js +15 -6
  249. package/lib/server/modules/payment/index.d.ts +28 -0
  250. package/lib/server/modules/payment/index.js +192 -0
  251. package/lib/server/modules/payment/types.d.ts +9 -0
  252. package/lib/server/modules/payment/types.js +17 -0
  253. package/lib/server/modules/products/index.d.ts +34 -7
  254. package/lib/server/modules/products/index.js +189 -54
  255. package/lib/server/modules/resource/index.d.ts +2 -0
  256. package/lib/server/modules/resource/index.js +27 -3
  257. package/lib/server/modules/schedule/index.d.ts +4 -4
  258. package/lib/server/modules/schedule/index.js +47 -40
  259. package/lib/server/test.json +713 -0
  260. package/lib/server/utils/small-ticket.d.ts +71 -0
  261. package/lib/server/utils/small-ticket.js +800 -0
  262. package/lib/solution/BaseSales/index.d.ts +133 -10
  263. package/lib/solution/BaseSales/index.js +1111 -63
  264. package/lib/solution/BaseSales/types.d.ts +82 -6
  265. package/lib/solution/BaseSales/types.js +3 -1
  266. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
  267. package/lib/solution/BaseSales/utils/cartPromotion.js +992 -0
  268. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  269. package/lib/solution/BaseSales/utils/quotationPrice.js +277 -0
  270. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  271. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +106 -18
  272. package/lib/solution/BaseSales/utils.d.ts +1 -1
  273. package/lib/solution/BaseSales/utils.js +54 -10
  274. package/lib/solution/BookingByStep/index.d.ts +1 -1
  275. package/lib/solution/BookingTicket/index.d.ts +271 -11
  276. package/lib/solution/BookingTicket/index.js +922 -29
  277. package/lib/solution/BookingTicket/types.d.ts +118 -1
  278. package/lib/solution/BookingTicket/types.js +11 -0
  279. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
  280. package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
  281. package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
  282. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +125 -0
  283. package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +40 -0
  284. package/lib/solution/BookingTicket/utils/bookingStatus.js +44 -2
  285. package/lib/solution/BookingTicket/utils/cartView.d.ts +9 -1
  286. package/lib/solution/BookingTicket/utils/cartView.js +61 -6
  287. package/lib/solution/BookingTicket/utils/exampleData.d.ts +123 -0
  288. package/lib/solution/BookingTicket/utils/exampleData.js +0 -0
  289. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
  290. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +254 -0
  291. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
  292. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +169 -0
  293. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
  294. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +51 -0
  295. package/lib/solution/BookingTicket/utils/scan/index.d.ts +5 -0
  296. package/lib/solution/BookingTicket/utils/scan/index.js +17 -3
  297. package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
  298. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +127 -0
  299. package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
  300. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +85 -0
  301. package/lib/solution/Checkout/index.d.ts +1 -0
  302. package/lib/solution/Checkout/index.js +1 -2
  303. package/lib/solution/RegisterAndLogin/config.js +2 -10
  304. package/lib/solution/ScanOrder/index.d.ts +9 -3
  305. package/lib/solution/ScanOrder/index.js +153 -70
  306. package/lib/solution/ScanOrder/types.d.ts +9 -5
  307. package/lib/solution/ScanOrder/utils.d.ts +1 -1
  308. package/lib/solution/ScanOrder/utils.js +83 -17
  309. package/lib/solution/VenueBooking/index.d.ts +5 -2
  310. package/lib/solution/VenueBooking/index.js +54 -17
  311. package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -2
  312. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  313. package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
  314. package/lib/types/index.d.ts +10 -0
  315. package/package.json +1 -1
  316. package/dist/solution/Checkout/appointmentDemo.json +0 -1
  317. package/lib/solution/Checkout/appointmentDemo.json +0 -1
@@ -2,15 +2,129 @@ import { CartItem } from '../Cart/types';
2
2
  import type { DiscountModule } from '../Discount';
3
3
  import type { RulesModule } from '../Rules';
4
4
  import type { Discount } from '../Discount/types';
5
+ import type { UnavailableReason } from '../Rules/types';
5
6
  import type { SubmitPayloadEnhancer } from './utils';
6
7
  import type { PaymentItem } from '../Payment/types';
7
8
  import type { ICustomer } from '../AccountList/types';
9
+ import type { OrderProductDiscountItem } from '../../server/modules/order/types';
10
+ export type { OrderProductDiscountItem } from '../../server/modules/order/types';
8
11
  export declare enum OrderHooks {
9
12
  OnOrderCreate = "order:onOrderCreate",
10
13
  OnOrderUpdate = "order:onOrderUpdate",
11
14
  OnOrderCancel = "order:onOrderCancel",
12
15
  OnOrderStatusChange = "order:onOrderStatusChange",
13
- OnOrderCustomerChange = "order:onOrderCustomerChange"
16
+ OnOrderCustomerChange = "order:onOrderCustomerChange",
17
+ OnPromotionApplied = "order:onPromotionApplied"
18
+ }
19
+ /**
20
+ * 促销评估器协议(OS 与 PromotionEvaluator 之间的桥接接口)。
21
+ *
22
+ * 与 `pisell_os/src/model/strategy/adapter/promotion/evaluator.ts` 中的
23
+ * `PromotionEvaluator` 实例结构保持兼容。SalesSdkProvider 会从 `appHelper.utils.promotionEvaluator`
24
+ * 读取实例并通过 `setPromotionEvaluator` 注入到 OrderModule。
25
+ *
26
+ * 这里只声明 OrderModule 需要调用的子集,避免反向依赖具体 evaluator 实现。
27
+ */
28
+ export interface OrderPromotionEvaluator {
29
+ evaluateCartWithPricing(input: {
30
+ products: any[];
31
+ channel?: string;
32
+ }): any;
33
+ getProductsApplicableStrategies(input: {
34
+ products: any[];
35
+ channel?: string;
36
+ }, matchVariant?: boolean): any[];
37
+ }
38
+ /** 赠品解析回调 context(OS → SDK 的请求体) */
39
+ export interface OrderGiftSelectContext {
40
+ strategyId: string;
41
+ strategyName: string | Record<string, string>;
42
+ giftCount: number;
43
+ giftOptions: Array<{
44
+ product_id: number;
45
+ product_variant_id: number;
46
+ }>;
47
+ /** 触发此赠品的主商品 metadata.unique_identification_number 列表 */
48
+ sourceProductIds: string[];
49
+ }
50
+ /**
51
+ * 赠品 resolver 返回值。
52
+ *
53
+ * @example
54
+ * return { products: [giftProduct], bookings: [giftBooking] };
55
+ */
56
+ export interface OrderGiftSelectResult {
57
+ /** 完整赠品购物车行,必须带 metadata._giftInfo。 */
58
+ products: Partial<OrderProduct>[];
59
+ /** 预约赠品对应的 booking,按 products 下标一一关联。 */
60
+ bookings?: AddProductBookingInput[];
61
+ }
62
+ /**
63
+ * 赠品解析回调签名(SDK → OS 的返回值)。
64
+ *
65
+ * - 单选项:SDK 内部自动构造商品,不弹窗
66
+ * - 多选项:SDK 弹窗等用户确认后构造
67
+ * - 用户取消:抛错或返回空数组(OS 视为放弃本次添加)
68
+ *
69
+ * 返回数组时沿用旧协议,只写 tempOrder.products;返回对象时可同时写入预约 bookings。
70
+ */
71
+ export type OrderGiftSelectResolver = (ctx: OrderGiftSelectContext) => Promise<Partial<OrderProduct>[] | OrderGiftSelectResult | null>;
72
+ /** 未满足的促销策略(购物车底部 alert 渲染源) */
73
+ export interface OrderUnfulfilledPromotion {
74
+ strategyId: string;
75
+ strategyName: string | Record<string, string>;
76
+ actionType: string;
77
+ needQuantity: number;
78
+ currentQuantity: number;
79
+ requiredQuantity: number;
80
+ eligibleProducts: Array<{
81
+ product_id: number;
82
+ product_variant_id: number;
83
+ }>;
84
+ strategyMetadata?: any;
85
+ display?: {
86
+ text: string | Record<string, string>;
87
+ type: string;
88
+ };
89
+ }
90
+ /** 上一次 applyPromotion 计算出的赠品操作(仅供调试/读取使用) */
91
+ export interface OrderLastGiftActions {
92
+ toAdd: Array<{
93
+ strategyId: string;
94
+ strategyName: string | Record<string, string>;
95
+ giftCount: number;
96
+ giftOptions: Array<{
97
+ product_id: number;
98
+ product_variant_id: number;
99
+ }>;
100
+ sourceProductIds: string[];
101
+ }>;
102
+ toReduce: Array<{
103
+ strategyId: string;
104
+ items: Array<{
105
+ uid: string;
106
+ currentQuantity: number;
107
+ newQuantity: number;
108
+ }>;
109
+ }>;
110
+ toRemove: string[];
111
+ }
112
+ /** onPromotionApplied 事件 payload */
113
+ export interface OrderPromotionAppliedPayload {
114
+ unfulfilledPromotions: OrderUnfulfilledPromotion[];
115
+ giftActions: OrderLastGiftActions;
116
+ /** evaluator 返回的赠品摘要 */
117
+ gifts: Array<{
118
+ strategyId: string;
119
+ strategyName: string | Record<string, string>;
120
+ giftCount: number;
121
+ giftOptions: Array<{
122
+ product_id: number;
123
+ product_variant_id: number;
124
+ }>;
125
+ }>;
126
+ /** 处理后的商品列表 */
127
+ products: OrderProduct[];
14
128
  }
15
129
  /**
16
130
  * tempOrder 上的下单客户协议字段视图。
@@ -48,27 +162,41 @@ export interface OrderCustomerChangePayload {
48
162
  patch: OrderCustomerView;
49
163
  snapshot: ICustomer | null;
50
164
  }
165
+ export interface OrderScanCodeResult {
166
+ isAvailable: boolean;
167
+ discountList: Discount[];
168
+ scannedDiscountList: Discount[];
169
+ type: 'server' | 'clientCalc';
170
+ unavailableReason?: UnavailableReason;
171
+ }
51
172
  export interface OrderProductIdentity {
52
173
  product_id: number | null;
53
174
  product_variant_id: number;
54
175
  unique_identification_number?: string;
55
- product_option_item?: any[];
176
+ product_sku?: OrderProductSku;
56
177
  product_bundle?: any[];
57
178
  }
179
+ export interface OrderProductSku {
180
+ option: any[];
181
+ [key: string]: any;
182
+ }
183
+ export interface OrderLocalizedText {
184
+ [locale: string]: string | null;
185
+ }
58
186
  export interface OrderProduct extends OrderProductIdentity {
59
187
  order_detail_id: number | null;
60
188
  num: number;
61
189
  bundle_edit?: number;
62
- product_option_item: any[];
63
- product_sku?: Record<string, any>;
190
+ product_sku: OrderProductSku;
64
191
  gift_card?: number;
65
192
  selling_price: string;
66
193
  original_price: string;
67
194
  tax_fee: string;
68
195
  is_charge_tax: number;
69
- discount_list: any[];
196
+ discount_list: OrderProductDiscountItem[];
70
197
  product_bundle: any[];
71
198
  booking_uid?: string;
199
+ product_title?: OrderLocalizedText;
72
200
  metadata: Record<string, any>;
73
201
  note?: string;
74
202
  }
@@ -82,11 +210,13 @@ export interface OrderSummary {
82
210
  shipping_tax_fee: string;
83
211
  tax_fee: string;
84
212
  surcharge_fee: string;
213
+ surcharges: any[];
85
214
  discount_amount: string;
86
215
  deposit_amount: string;
87
216
  deposit?: {
88
217
  total: string;
89
218
  deposit_policy_ids: number[];
219
+ deposit_policy_data?: any[];
90
220
  hasDeposit: boolean;
91
221
  };
92
222
  expect_amount: string;
@@ -103,11 +233,11 @@ export interface OrderSummary {
103
233
  export interface OrderTempOrder {
104
234
  order_id: number | null;
105
235
  external_sale_number: string;
106
- order_number: string;
107
- shop_order_number: string;
108
- shop_full_order_number: string;
236
+ order_number: string | null;
237
+ shop_order_number: string | null;
238
+ shop_full_order_number: string | null;
109
239
  type: string;
110
- business_code: string;
240
+ business_code?: string;
111
241
  platform: string;
112
242
  sales_channel: string;
113
243
  order_sales_channel: string;
@@ -136,36 +266,39 @@ export interface OrderTempOrder {
136
266
  delivery_type?: string;
137
267
  table_number?: Record<string, any>;
138
268
  schedule_date: string;
139
- created_at: string;
269
+ created_at: string | undefined;
140
270
  request_unique_idempotency_token?: string;
141
271
  products: OrderProduct[];
142
272
  bookings: any[];
143
273
  payments: any[];
144
274
  surcharges: any[];
145
- discount_list: any[];
275
+ discount_list?: any[];
146
276
  relation_forms: any[];
147
277
  contacts: any[];
148
278
  contacts_info: Record<string, any> | null;
149
279
  holder: Record<string, any> | null;
150
280
  metadata: Record<string, any>;
281
+ summary?: OrderSummary;
151
282
  _extend?: {
152
283
  productsByUid?: Record<string, Record<string, any>>;
153
284
  [key: string]: any;
154
285
  };
155
286
  }
156
- export interface OrderSubmitProduct extends Omit<OrderProduct, 'unique_identification_number' | 'num' | 'product_option_item'> {
287
+ export interface OrderSubmitProduct extends Omit<OrderProduct, 'unique_identification_number' | 'num'> {
157
288
  product_quantity: number;
158
289
  payment_price: string;
159
- product_sku: Record<string, any>;
290
+ product_sku: OrderProductSku;
160
291
  }
161
- export interface OrderSubmitPayload extends Omit<OrderTempOrder, 'platform' | 'products' | '_extend' | 'customer' | 'shop_full_order_number'> {
292
+ export interface OrderSubmitPayload extends Omit<OrderTempOrder, 'platform' | 'products' | '_extend' | 'customer' | 'discount_list' | 'created_at'> {
162
293
  platform: string;
294
+ created_at?: string | undefined;
163
295
  request_unique_idempotency_token?: string;
164
296
  form_record_ids?: Array<{
165
297
  form_id: number | string;
166
298
  form_record_id: number | string;
167
299
  }>;
168
300
  products: OrderSubmitProduct[];
301
+ summary?: OrderSummary;
169
302
  small_ticket_data_flag?: number;
170
303
  }
171
304
  export interface OrderState {
@@ -177,16 +310,45 @@ export interface OrderState {
177
310
  discount: DiscountModule | null;
178
311
  rules: RulesModule | null;
179
312
  }
313
+ export interface ReplaceTempOrderOptions {
314
+ recalculateSummary?: boolean;
315
+ persist?: boolean;
316
+ saveDraft?: boolean;
317
+ }
318
+ export type AddProductBookingInput = Record<string, any>;
180
319
  /** 更新购物车行:仅传 SKU 时命中同 SKU 第一行;多行同 SKU 须传 unique_identification_number / 选项指纹等 */
181
- export interface UpdateProductInOrderParams {
320
+ export interface UpdateOrderProductParams {
182
321
  product_id: number | null;
183
322
  product_variant_id: number;
184
323
  updates: Partial<OrderProduct>;
185
324
  unique_identification_number?: string;
186
- product_option_item?: any[];
325
+ identity_key?: string;
326
+ product_sku?: OrderProductSku;
187
327
  product_bundle?: any[];
328
+ booking?: AddProductBookingInput;
329
+ /**
330
+ * 预约时间 / 时长变更后允许使用本次报价覆盖已落库订单行历史价。
331
+ *
332
+ * @example
333
+ * await order.updateOrderProduct({
334
+ * product_id: 1,
335
+ * product_variant_id: 0,
336
+ * updates: { selling_price: '6.00', metadata: { source_product_price: '6.00' } },
337
+ * booking: { duration: 2 },
338
+ * allow_booking_reprice: true,
339
+ * });
340
+ */
341
+ allow_booking_reprice?: boolean;
342
+ }
343
+ /** 仅更新购物车行数量;行定位语义与 updateOrderProduct / removeProductFromOrder 保持一致 */
344
+ export interface UpdateOrderProductQuantityParams extends OrderProductIdentity {
345
+ num: number;
346
+ identity_key?: string;
347
+ }
348
+ export interface UpdateOrderBookingParams {
349
+ unique_identification_number: string;
350
+ updates: AddProductBookingInput;
188
351
  }
189
- export type AddProductBookingInput = Record<string, any>;
190
352
  export interface OrderProductMergeDecisionContext {
191
353
  incomingProduct: Partial<OrderProduct> & OrderProductIdentity;
192
354
  normalizedIncoming: OrderProduct;
@@ -237,10 +399,11 @@ export interface SubmitSalesOrderParams {
237
399
  query: {
238
400
  order_id: number | null;
239
401
  external_sale_number: string;
240
- order_number: string;
241
- shop_order_number: string;
402
+ order_number: string | null;
403
+ shop_order_number: string | null;
404
+ shop_full_order_number: string | null;
242
405
  type: string;
243
- business_code: string;
406
+ business_code?: string;
244
407
  platform: string;
245
408
  request_unique_idempotency_token?: string;
246
409
  sales_channel: string;
@@ -267,18 +430,19 @@ export interface SubmitSalesOrderParams {
267
430
  delivery_type?: string;
268
431
  table_number?: Record<string, any>;
269
432
  schedule_date: string;
270
- created_at: string;
433
+ created_at?: string | undefined;
271
434
  products: OrderSubmitProduct[];
272
435
  bookings: OrderSubmitBooking[];
273
436
  payments: any[];
437
+ vouchers: any[];
274
438
  surcharges?: any[];
275
- discount_list: any[];
276
439
  relation_forms: any[];
277
440
  form_record_ids?: OrderSubmitFormRecord[];
278
441
  contacts: any[];
279
442
  contacts_info: Record<string, any> | null;
280
443
  holder: Record<string, any> | null;
281
444
  metadata: Record<string, any>;
445
+ summary?: OrderSummary;
282
446
  small_ticket_data_flag?: number;
283
447
  };
284
448
  }
@@ -300,6 +464,10 @@ export interface PaymentItemData {
300
464
  name: string;
301
465
  /** 支付类型 */
302
466
  type: string;
467
+ /** 支付时间 (格式: YYYY-MM-DD HH:mm:ss) */
468
+ payment_time?: string;
469
+ /** 支付项创建时间 (格式: YYYY-MM-DD HH:mm:ss) */
470
+ created_at?: string;
303
471
  /** @deprecated BaseSales/Sales 协议不提交该字段;旧 Checkout/Payment 内部仍可能使用 */
304
472
  isSynced?: boolean;
305
473
  }
@@ -312,18 +480,22 @@ export interface OrderPaymentMetadata {
312
480
  [key: string]: any;
313
481
  }
314
482
  export interface OrderPaymentData {
483
+ order_payment_id?: number | string;
315
484
  amount: string;
316
485
  code: string;
317
486
  custom_payment_id: number;
487
+ custom_payment_type?: string;
318
488
  name: string;
319
489
  type: string;
320
490
  voucher_id?: string | number;
321
491
  origin_amount?: string;
322
492
  service_fee?: string;
323
493
  status?: 'active' | 'voided' | string;
494
+ /** 支付时间 (格式: YYYY-MM-DD HH:mm:ss) */
324
495
  payment_time?: string;
325
496
  wallet_pass_usage_unit?: unknown;
326
497
  wallet_pass_use_value?: string | number | null;
498
+ fund_record?: Record<string, any>;
327
499
  metadata: OrderPaymentMetadata;
328
500
  rounding_amount?: string;
329
501
  service_charge?: {
@@ -331,6 +503,7 @@ export interface OrderPaymentData {
331
503
  amount?: string;
332
504
  };
333
505
  order_payment_type?: 'normal' | 'deposit';
506
+ /** 支付项创建时间 (格式: YYYY-MM-DD HH:mm:ss) */
334
507
  created_at?: string;
335
508
  updated_at?: string;
336
509
  }
@@ -345,12 +518,19 @@ export interface LoadSalesDetailParams {
345
518
  externalSaleNumber?: string;
346
519
  external_sale_number?: string;
347
520
  forceRemote?: boolean;
521
+ merge?: boolean;
522
+ }
523
+ export interface SalesOrderLookupParams {
524
+ lookup: number | string;
525
+ forceRemote?: boolean;
348
526
  }
349
527
  export interface SyncPaymentsToOrderParams {
350
528
  payments: OrderPaymentSource[];
351
529
  paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
352
530
  submitWhenPaid?: boolean;
353
531
  smallTicketDataFlag?: number;
532
+ businessCode?: string;
533
+ channel?: string;
354
534
  }
355
535
  export interface SyncPaymentsToOrderResult<T = any> {
356
536
  isFullyPaid: boolean;
@@ -447,6 +627,7 @@ export interface OrderModuleAPI {
447
627
  }) => void;
448
628
  getTempOrder: () => OrderTempOrder | null;
449
629
  ensureTempOrder: () => OrderTempOrder;
630
+ replaceTempOrder: (tempOrder: OrderTempOrder, options?: ReplaceTempOrderOptions) => Promise<OrderTempOrder>;
450
631
  addNewOrder: () => Promise<OrderTempOrder>;
451
632
  restoreOrder: () => OrderTempOrder;
452
633
  getOrderProducts: () => OrderProduct[];
@@ -458,16 +639,41 @@ export interface OrderModuleAPI {
458
639
  getOrderSnapshot: () => OrderSnapshot | null;
459
640
  getOrderSyncState: () => OrderSyncState;
460
641
  getOrderAmountSnapshot: () => OrderAmountSnapshot | null;
642
+ buildCurrentSubmitPayloadForLocalPrint: (params?: {
643
+ cacheId?: string;
644
+ platform?: string;
645
+ businessCode?: string;
646
+ channel?: string;
647
+ type?: string;
648
+ }) => OrderSubmitPayload;
649
+ applyLocalPrintOrderNumbers: (order?: Record<string, any> | null) => Promise<OrderTempOrder>;
461
650
  getTempOrderNote: () => string;
462
- updateTempOrderNote: (note: string) => string;
651
+ updateTempOrderNote: {
652
+ (note: string): string;
653
+ (note: string, sync: true): Promise<string>;
654
+ (note: string, sync: boolean): string | Promise<string>;
655
+ };
463
656
  updateTempOrderShopDiscount: (amount: string | number) => string;
657
+ updateTempOrderDepositAmount: (amount: string | number) => OrderSummary;
464
658
  updateTempOrderCustomer: (customer: UpdateTempOrderCustomerInput) => OrderSnapshot['customer'];
465
659
  updateTempOrderBuzzer: (buzzer: string) => string;
466
660
  updateTempOrderContactsInfo: (contactsInfo: Record<string, any> | null) => Record<string, any> | null;
467
661
  addProductToOrder: (product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput) => Promise<OrderProduct[]>;
468
- updateProductInOrder: (params: UpdateProductInOrderParams) => Promise<OrderProduct[]>;
662
+ updateOrderProduct: (params: UpdateOrderProductParams) => Promise<OrderProduct[]>;
663
+ updateOrderProductQuantity: (params: UpdateOrderProductQuantityParams) => Promise<OrderProduct[]>;
664
+ updateOrderBooking: (params: UpdateOrderBookingParams) => any[];
469
665
  removeProductFromOrder: (identity: OrderProductIdentity) => Promise<OrderProduct[]>;
666
+ /** 批量删除购物车行,末尾仅触发一次促销重算与 summary 刷新 */
667
+ removeProductsFromOrder: (identities: OrderProductIdentity[]) => Promise<OrderProduct[]>;
668
+ /** @deprecated no-op;OrderModule 不再负责 tempOrder localStorage 持久化。 */
470
669
  persistTempOrder: () => void;
670
+ /**
671
+ * 控制 IndexedDB 草稿(saveDraft)开关;localStorage tempOrder 持久化已废弃。
672
+ * BigSale 弹窗等场景传 false 可跳过 saveDraft。
673
+ */
674
+ setEnableTempOrderPersist: (enabled: boolean) => void;
675
+ /** 是否允许 saveDraft 写入 IndexedDB 草稿。 */
676
+ isTempOrderPersistEnabled: () => boolean;
471
677
  submitTempOrder: <T = any>(params?: {
472
678
  cacheId?: string;
473
679
  platform?: string;
@@ -479,6 +685,17 @@ export interface OrderModuleAPI {
479
685
  smallTicketDataFlag?: number;
480
686
  enhancePayload?: SubmitPayloadEnhancer;
481
687
  }) => Promise<T>;
688
+ submitTempOrderAsync: <T = any>(params?: {
689
+ cacheId?: string;
690
+ platform?: string;
691
+ businessCode?: string;
692
+ channel?: string;
693
+ type?: string;
694
+ payments?: OrderPaymentSource[];
695
+ paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
696
+ smallTicketDataFlag?: number;
697
+ enhancePayload?: SubmitPayloadEnhancer;
698
+ }) => Promise<T>;
482
699
  getOrderPayments: () => OrderPaymentData[];
483
700
  setOrderPayments: (payments: OrderPaymentSource[]) => OrderPaymentData[];
484
701
  addOrderPayment: (payment: OrderPaymentSource) => OrderPaymentData[];
@@ -487,15 +704,11 @@ export interface OrderModuleAPI {
487
704
  updateVoucherOrderPayments: (payments: OrderPaymentSource[]) => OrderPaymentData[];
488
705
  sendCustomerPayLink: <T = any>(params: SendCustomerPayLinkParams) => Promise<T>;
489
706
  saveDraft: () => Promise<void>;
490
- hasLocalDatabase: () => boolean;
491
- getLocalOrderByOrderId: (orderId: number | string) => Promise<Record<string, any> | null>;
492
- getLocalOrderByExternalSaleNumber: (externalSaleNumber: string) => Promise<Record<string, any> | null>;
493
- getLocalOrderByOrderNumber: (orderNumber: string) => Promise<Record<string, any> | null>;
494
707
  hydrateTempOrderFromRecord: (record: Record<string, any>, options?: {
495
708
  recalcOnHydrate?: boolean;
496
709
  }) => Promise<OrderTempOrder>;
497
710
  syncPaymentsToOrder: <T = any>(params: SyncPaymentsToOrderParams) => Promise<SyncPaymentsToOrderResult<T>>;
498
- getOrderInfoByRemote: (order_id: number) => Promise<any>;
711
+ getSalesOrderByLookup: (params: SalesOrderLookupParams) => Promise<any>;
499
712
  getLastOrderInfo: () => Record<string, any> | undefined;
500
713
  getOrderInfo: (order_id: number) => Promise<any>;
501
714
  /**
@@ -517,10 +730,52 @@ export interface OrderModuleAPI {
517
730
  clearOrderCustomer: () => void;
518
731
  loadDiscountConfig: (params: {
519
732
  customerId: number;
520
- action?: 'create';
521
- }) => Promise<void>;
733
+ action?: 'create' | 'edit';
734
+ orderId?: number;
735
+ apply?: boolean;
736
+ }) => Promise<Discount[]>;
522
737
  getDiscountList: () => Discount[];
523
738
  applyDiscount: () => void;
739
+ /**
740
+ * 注入促销评估器。
741
+ *
742
+ * SalesSdkProvider 在初始化 bookingTicket 后会自动从 `appHelper.utils.promotionEvaluator`
743
+ * 读取实例并调用本方法注入。host 透明,业务 UI 不感知。
744
+ *
745
+ * @example
746
+ * order.setPromotionEvaluator(appHelper.utils.promotionEvaluator);
747
+ */
748
+ setPromotionEvaluator: (evaluator: OrderPromotionEvaluator | null) => void;
749
+ /**
750
+ * 注入赠品选择 resolver。OS 在 applyPromotion 内部当需要新增赠品时会 await 调用 resolver。
751
+ *
752
+ * 缺省时 OS 会 `console.warn` 并跳过新增(既有赠品的 reduce/remove 仍会执行)。
753
+ *
754
+ * @example
755
+ * order.setGiftSelectResolver((ctx) => giftSelectBridge.request(ctx));
756
+ */
757
+ setGiftSelectResolver: (resolver: OrderGiftSelectResolver | null) => void;
758
+ /**
759
+ * 为商品目录追加促销标签。
760
+ *
761
+ * @example
762
+ * const taggedProducts = order.appendPromotionTags(products);
763
+ */
764
+ appendPromotionTags: <T extends Record<string, any>>(products: T[]) => T[];
765
+ /**
766
+ * 应用购物车促销(评估 → 差异化赠品 → 写回 tempOrder.products → emit onPromotionApplied)。
767
+ *
768
+ * 自动在 addProductToOrder / updateOrderProductQuantity / removeProductFromOrder /
769
+ * clearOrderCartLines / setOrderCustomer 等写路径末尾触发,业务一般无需手动调用。
770
+ *
771
+ * 多选项赠品依赖 giftSelectResolver;如未注入则跳过且 console.warn。
772
+ * 内部以 `_isApplyingPromotion` flag 防递归。
773
+ */
774
+ applyPromotion: () => Promise<void>;
775
+ /** 读取上次 applyPromotion 产出的未满足促销提示 */
776
+ getUnfulfilledPromotions: () => OrderUnfulfilledPromotion[];
777
+ /** 读取上次 applyPromotion 产出的赠品操作 diff(toAdd / toReduce / toRemove) */
778
+ getLastGiftActions: () => OrderLastGiftActions | null;
524
779
  /**
525
780
  * 取消订单
526
781
  * @param params 取消订单参数
@@ -28,6 +28,7 @@ var OrderHooks = /* @__PURE__ */ ((OrderHooks2) => {
28
28
  OrderHooks2["OnOrderCancel"] = "order:onOrderCancel";
29
29
  OrderHooks2["OnOrderStatusChange"] = "order:onOrderStatusChange";
30
30
  OrderHooks2["OnOrderCustomerChange"] = "order:onOrderCustomerChange";
31
+ OrderHooks2["OnPromotionApplied"] = "order:onPromotionApplied";
31
32
  return OrderHooks2;
32
33
  })(OrderHooks || {});
33
34
  // Annotate the CommonJS export names for ESM import in node:
@@ -0,0 +1,106 @@
1
+ /** 解析商品行数量(checkout 协议 product_num 语义 = 当前行 num) */
2
+ export declare function resolveSafeProductNum(num?: number | null): number;
3
+ /**
4
+ * 将 discount_list 中 type=product 项的 product_num 同步为当前商品数量。
5
+ *
6
+ * @example
7
+ * syncManualProductDiscountProductNum(line.discount_list, line.num);
8
+ */
9
+ export declare function syncManualProductDiscountProductNum(discountList: any[] | undefined | null, productNum?: number | null): any[];
10
+ /** 从多源解析改价前行总价(与 cacheItem._extend.origin_total 语义一致) */
11
+ export declare function resolveManualDiscountOriginTotal(sources: {
12
+ originTotal?: unknown;
13
+ extendOriginTotal?: unknown;
14
+ originExtendOriginTotal?: unknown;
15
+ sourceExtendOriginTotal?: unknown;
16
+ catalogUnitPrice?: unknown;
17
+ quantity?: number;
18
+ }): number;
19
+ /** 从 payload / extend / origin 解析手动折扣原因 */
20
+ export declare function resolveManualDiscountReasonFromSources(sources: {
21
+ discountReason?: unknown;
22
+ extendDiscountReason?: unknown;
23
+ originExtendDiscountReason?: unknown;
24
+ }): string;
25
+ /** 是否带手动改价标记(price_override / is_manual_discount) */
26
+ export declare function hasManualProductDiscountFlag(metadata?: Record<string, any> | null): boolean;
27
+ /**
28
+ * normalize 兜底:手动改价但 discount_list 缺 type=product 时,按行级原价/折后价补写。
29
+ *
30
+ * @example
31
+ * ensureManualProductDiscountList({
32
+ * discountList: [],
33
+ * metadata: { price_override: '5', is_manual_discount: 1 },
34
+ * originalPrice: '11.00',
35
+ * sellingPrice: '5.00',
36
+ * quantity: 1,
37
+ * });
38
+ */
39
+ export declare function ensureManualProductDiscountList(params: {
40
+ discountList?: any[] | null;
41
+ metadata?: Record<string, any> | null;
42
+ originalPrice: string | number;
43
+ sellingPrice: string | number;
44
+ quantity?: number;
45
+ }): any[];
46
+ /** 商品手动折扣 discount_list 项(checkout 协议,type = product) */
47
+ export interface ManualProductDiscountItem {
48
+ amount: number;
49
+ type: 'product';
50
+ discount: {
51
+ message: string;
52
+ discountway: string;
53
+ product_num: number;
54
+ discount_per: string;
55
+ discount_type: 'discount' | 'change_price';
56
+ };
57
+ }
58
+ /**
59
+ * 从 discount_list 中取手动改价项(type = product)。
60
+ *
61
+ * @example
62
+ * const manual = findManualProductDiscountItem(product.discount_list);
63
+ * manual?.discount.message; // 折扣原因
64
+ */
65
+ export declare function findManualProductDiscountItem(discountList?: any[] | null): ManualProductDiscountItem | undefined;
66
+ /**
67
+ * 解析折扣原因:优先 discount_list[type=product].discount.message。
68
+ *
69
+ * @example
70
+ * resolveManualDiscountMessage(line.discount_list, line.metadata?.legacy_reason);
71
+ */
72
+ export declare function resolveManualDiscountMessage(discountList?: any[] | null, fallback?: string): string;
73
+ /** 去掉 discount_list 中已有的手动改价项,避免重复叠加 */
74
+ export declare function stripManualProductDiscountItems(discountList?: any[] | null): any[];
75
+ /**
76
+ * 由改价前后行总价构建手动折扣项;amount = |originTotal - sellingTotal|(行级差额)。
77
+ *
78
+ * @example
79
+ * buildManualProductDiscountItem({
80
+ * originTotal: 11,
81
+ * sellingTotal: 4,
82
+ * quantity: 1,
83
+ * message: 'VIP',
84
+ * });
85
+ */
86
+ export declare function buildManualProductDiscountItem(params: {
87
+ originTotal: number;
88
+ sellingTotal: number;
89
+ quantity?: number;
90
+ message?: string;
91
+ discountway?: string;
92
+ discount_per?: string;
93
+ }): ManualProductDiscountItem;
94
+ /**
95
+ * 将手动改价项合并进 discount_list(替换已有 type=product 项)。
96
+ *
97
+ * @example
98
+ * mergeManualProductDiscountIntoList(coupons, manualItem);
99
+ */
100
+ export declare function mergeManualProductDiscountIntoList(discountList: any[] | undefined | null, manualItem: ManualProductDiscountItem | null | undefined): any[];
101
+ /** 是否应写入手动改价 discount_list 项 */
102
+ export declare function shouldBuildManualProductDiscount(params: {
103
+ hasPriceOverride?: boolean;
104
+ originTotal?: number;
105
+ sellingTotal?: number;
106
+ }): boolean;