@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
@@ -0,0 +1,7 @@
1
+ import type { QuotationModule } from '../../../modules/Quotation';
2
+ import type { BaseSalesCalculateProductBookingPriceParams, BaseSalesProductBookingPriceResult } from '../types';
3
+ interface BuildBaseSalesQuotationPriceParams extends BaseSalesCalculateProductBookingPriceParams {
4
+ quotation?: Pick<QuotationModule, 'getPriceForProduct' | 'getQuotationShelfId'> | null;
5
+ }
6
+ export declare function calculateBaseSalesProductBookingPrice(params: BuildBaseSalesQuotationPriceParams): BaseSalesProductBookingPriceResult;
7
+ export {};
@@ -0,0 +1,237 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ import dayjs from 'dayjs';
8
+ import Decimal from 'decimal.js';
9
+ function toFiniteNumber(value) {
10
+ var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
11
+ var parsedValue = Number(value);
12
+ if (!Number.isFinite(parsedValue)) return fallback;
13
+ return parsedValue;
14
+ }
15
+ function toPositiveInt(value) {
16
+ var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
17
+ var parsedValue = Math.floor(Number(value));
18
+ if (!Number.isFinite(parsedValue) || parsedValue < 1) return fallback;
19
+ return parsedValue;
20
+ }
21
+ function toPriceString(value) {
22
+ return new Decimal(Number(value) || 0).toDecimalPlaces(2).toFixed(2);
23
+ }
24
+ function normalizeDateTime(value) {
25
+ if (typeof value !== 'string' || !value.trim()) return null;
26
+ var normalized = value.includes(':') ? value : "".concat(value, " 00:00:00");
27
+ var datetime = dayjs(normalized);
28
+ if (!datetime.isValid()) return null;
29
+ return datetime;
30
+ }
31
+ function buildBookingDateTime(date, time) {
32
+ if (typeof date !== 'string' || !date.trim()) return null;
33
+ var timeText = typeof time === 'string' && time.trim() ? time.trim() : '00:00';
34
+ var datetime = dayjs("".concat(date.trim(), " ").concat(timeText));
35
+ if (!datetime.isValid()) return null;
36
+ return datetime;
37
+ }
38
+ function getDurationUnit(type) {
39
+ var normalizedType = String(type || '').toLowerCase();
40
+ if (normalizedType === 'day' || normalizedType === 'days') return 'day';
41
+ if (normalizedType === 'minute' || normalizedType === 'minutes') return 'minute';
42
+ return null;
43
+ }
44
+ function getProductId(product) {
45
+ var _product$product_id;
46
+ var productId = toFiniteNumber((_product$product_id = product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : product.id, NaN);
47
+ if (!Number.isFinite(productId)) return null;
48
+ return productId;
49
+ }
50
+ function getProductVariantId(product) {
51
+ var _product$product_vari;
52
+ var variantId = toFiniteNumber((_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : product.variant_id, 0);
53
+ if (!Number.isFinite(variantId) || variantId <= 0) return undefined;
54
+ return variantId;
55
+ }
56
+ function getFallbackPrice(params) {
57
+ var _ref, _ref2, _ref3, _params$fallback_pric;
58
+ var product = params.product || {};
59
+ return toPriceString((_ref = (_ref2 = (_ref3 = (_params$fallback_pric = params.fallback_price) !== null && _params$fallback_pric !== void 0 ? _params$fallback_pric : product.price) !== null && _ref3 !== void 0 ? _ref3 : product.selling_price) !== null && _ref2 !== void 0 ? _ref2 : product.original_price) !== null && _ref !== void 0 ? _ref : 0);
60
+ }
61
+ function getProductQuantity(product) {
62
+ var _product$num;
63
+ return toPositiveInt((_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity, 1);
64
+ }
65
+ function getBundleProductId(bundle) {
66
+ var _bundle$bundle_produc;
67
+ var productId = toFiniteNumber((_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id, NaN);
68
+ if (!Number.isFinite(productId)) return null;
69
+ return productId;
70
+ }
71
+ function getBundleVariantId(bundle) {
72
+ var _bundle$bundle_varian;
73
+ var variantId = toFiniteNumber((_bundle$bundle_varian = bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle.variant_id, 0);
74
+ if (!Number.isFinite(variantId) || variantId <= 0) return undefined;
75
+ return variantId;
76
+ }
77
+ function getBundleFallbackPrice(bundle) {
78
+ var _ref4, _ref5, _ref6, _bundle$bundle_sellin;
79
+ return toPriceString((_ref4 = (_ref5 = (_ref6 = (_bundle$bundle_sellin = bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : bundle.price) !== null && _ref6 !== void 0 ? _ref6 : bundle.original_price) !== null && _ref5 !== void 0 ? _ref5 : bundle.base_price) !== null && _ref4 !== void 0 ? _ref4 : 0);
80
+ }
81
+ function shouldSplitByDuration(duration, start, end) {
82
+ if (!duration) return false;
83
+ if (!start || !end || !end.isAfter(start)) return false;
84
+ var unit = getDurationUnit(duration.type);
85
+ var value = toFiniteNumber(duration.value);
86
+ return !!unit && value > 0;
87
+ }
88
+ function buildTimeSegments(params) {
89
+ var booking = params.booking || {};
90
+ var explicitDatetime = normalizeDateTime(params.datetime);
91
+ var bookingStart = buildBookingDateTime(booking.start_date, booking.start_time);
92
+ var start = bookingStart || explicitDatetime || dayjs();
93
+ var bookingEnd = buildBookingDateTime(booking.end_date, booking.end_time);
94
+ if (!shouldSplitByDuration(params.duration, start, bookingEnd)) {
95
+ return [{
96
+ start: start
97
+ }];
98
+ }
99
+ var unit = getDurationUnit(params.duration.type);
100
+ var value = toFiniteNumber(params.duration.value);
101
+ var segments = [];
102
+ var cursor = start;
103
+ var guard = 0;
104
+ while (cursor.isBefore(bookingEnd) && guard < 10000) {
105
+ var next = cursor.add(value, unit);
106
+ segments.push({
107
+ start: cursor,
108
+ end: next.isBefore(bookingEnd) ? next : bookingEnd !== null && bookingEnd !== void 0 ? bookingEnd : undefined
109
+ });
110
+ cursor = next;
111
+ guard += 1;
112
+ }
113
+ return segments.length ? segments : [{
114
+ start: start
115
+ }];
116
+ }
117
+ function formatTimePoint(datetime) {
118
+ return datetime.format('YYYY-MM-DD HH:mm:ss');
119
+ }
120
+ function buildPriceSegment(params) {
121
+ var timePoint = formatTimePoint(params.segment.start);
122
+ var quotedPrice = params.quotation && params.productId !== null ? params.quotation.getPriceForProduct({
123
+ productId: params.productId,
124
+ variantId: params.variantId,
125
+ datetime: timePoint,
126
+ customer_id: params.customerId
127
+ }) : null;
128
+ var unitPrice = toPriceString(quotedPrice !== null && quotedPrice !== void 0 ? quotedPrice : params.fallbackPrice);
129
+ var quotationShelfId = quotedPrice !== null && params.quotation && params.productId !== null ? params.quotation.getQuotationShelfId({
130
+ productId: params.productId,
131
+ variantId: params.variantId,
132
+ datetime: timePoint,
133
+ customer_id: params.customerId
134
+ }) : 0;
135
+ return {
136
+ start_datetime: timePoint,
137
+ end_datetime: params.segment.end ? formatTimePoint(params.segment.end) : undefined,
138
+ time_point: timePoint,
139
+ unit_price: unitPrice,
140
+ quantity: 1,
141
+ total_price: unitPrice,
142
+ quotation_shelf_id: quotationShelfId,
143
+ source: quotedPrice !== null ? 'quotation' : 'fallback'
144
+ };
145
+ }
146
+ function calculatePriceForProduct(params) {
147
+ var _segments$find;
148
+ var segments = params.segments.map(function (segment) {
149
+ return buildPriceSegment({
150
+ quotation: params.quotation,
151
+ productId: params.productId,
152
+ variantId: params.variantId,
153
+ customerId: params.customerId,
154
+ fallbackPrice: params.fallbackPrice,
155
+ segment: segment
156
+ });
157
+ });
158
+ var unitPrice = segments.reduce(function (total, segment) {
159
+ return total.plus(segment.total_price);
160
+ }, new Decimal(0));
161
+ var totalPrice = unitPrice.times(params.quantity);
162
+ var quotationShelfId = ((_segments$find = segments.find(function (segment) {
163
+ return segment.quotation_shelf_id;
164
+ })) === null || _segments$find === void 0 ? void 0 : _segments$find.quotation_shelf_id) || 0;
165
+ return {
166
+ unitPrice: unitPrice,
167
+ totalPrice: totalPrice,
168
+ quotationShelfId: quotationShelfId,
169
+ segments: segments
170
+ };
171
+ }
172
+ function calculateBundlePrices(params, segments) {
173
+ var _params$product;
174
+ var bundleList = ((_params$product = params.product) === null || _params$product === void 0 ? void 0 : _params$product.product_bundle) || [];
175
+ if (!bundleList.length) return undefined;
176
+ return bundleList.map(function (bundle) {
177
+ var _bundle$bundle_id;
178
+ var productId = getBundleProductId(bundle);
179
+ var variantId = getBundleVariantId(bundle);
180
+ var quantity = getProductQuantity(bundle);
181
+ var price = calculatePriceForProduct({
182
+ quotation: params.quotation,
183
+ productId: productId,
184
+ variantId: variantId,
185
+ customerId: params.customer_id,
186
+ quantity: quantity,
187
+ fallbackPrice: getBundleFallbackPrice(bundle),
188
+ segments: segments
189
+ });
190
+ return {
191
+ bundle_id: (_bundle$bundle_id = bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle.id,
192
+ group_id: bundle.group_id,
193
+ bundle_group_id: bundle.bundle_group_id,
194
+ bundle_product_id: productId,
195
+ bundle_variant_id: variantId !== null && variantId !== void 0 ? variantId : 0,
196
+ unit_price: price.unitPrice.toDecimalPlaces(2).toFixed(2),
197
+ total_price: price.totalPrice.toDecimalPlaces(2).toFixed(2),
198
+ quantity: quantity,
199
+ quotation_shelf_id: price.quotationShelfId,
200
+ source: price.segments.some(function (segment) {
201
+ return segment.source === 'quotation';
202
+ }) ? 'quotation' : 'fallback',
203
+ segments: price.segments
204
+ };
205
+ });
206
+ }
207
+ export function calculateBaseSalesProductBookingPrice(params) {
208
+ var product = params.product || {};
209
+ var productId = getProductId(product);
210
+ var variantId = getProductVariantId(product);
211
+ var productQuantity = getProductQuantity(product);
212
+ var fallbackPrice = getFallbackPrice(params);
213
+ var timeSegments = buildTimeSegments(params);
214
+ var price = calculatePriceForProduct({
215
+ quotation: params.quotation,
216
+ productId: productId,
217
+ variantId: variantId,
218
+ customerId: params.customer_id,
219
+ quantity: productQuantity,
220
+ fallbackPrice: fallbackPrice,
221
+ segments: timeSegments
222
+ });
223
+ var bundlePrices = calculateBundlePrices(params, timeSegments);
224
+ return _objectSpread({
225
+ product_id: productId,
226
+ product_variant_id: variantId !== null && variantId !== void 0 ? variantId : 0,
227
+ customer_id: params.customer_id,
228
+ unit_price: price.unitPrice.toDecimalPlaces(2).toFixed(2),
229
+ total_price: price.totalPrice.toDecimalPlaces(2).toFixed(2),
230
+ quantity: productQuantity,
231
+ duration: params.duration,
232
+ quotation_shelf_id: price.quotationShelfId,
233
+ segments: price.segments
234
+ }, bundlePrices ? {
235
+ product_bundle: bundlePrices
236
+ } : {});
237
+ }
@@ -23,6 +23,7 @@ export interface BaseProductDetailPayload {
23
23
  option?: BaseProductDetailOptionItem[];
24
24
  options?: BaseProductDetailOptionItem[];
25
25
  product_option_item?: BaseProductDetailOptionItem[];
26
+ product_sku?: Record<string, any>;
26
27
  bundle?: BaseProductDetailBundleItem[];
27
28
  product_bundle?: BaseProductDetailBundleItem[];
28
29
  unique?: string;
@@ -4,6 +4,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ import { composeLinePrice, getBundleSellingMagnitude, normalizeProductSkuOptions, sumOptionUnitPrice } from "../../../modules/Order/utils";
8
+ import { buildManualProductDiscountItem, mergeManualProductDiscountIntoList, resolveManualDiscountOriginTotal, resolveManualDiscountReasonFromSources, shouldBuildManualProductDiscount } from "../../../modules/Order/utils/manualProductDiscount";
7
9
  function toNumber(value) {
8
10
  var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
9
11
  var parsedValue = Number(value);
@@ -31,23 +33,49 @@ function toPriceString(value) {
31
33
  function normalizeOptionItems(optionItems) {
32
34
  if (!Array.isArray(optionItems)) return [];
33
35
  return optionItems.map(function (optionItem) {
34
- var _ref, _optionItem$price, _optionItem$num;
35
- var optionGroupItemId = toNumber(optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id);
36
+ var _optionItem$option_gr, _ref, _optionItem$price, _optionItem$num;
37
+ var optionGroupItemId = toNumber((_optionItem$option_gr = optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id) !== null && _optionItem$option_gr !== void 0 ? _optionItem$option_gr : optionItem === null || optionItem === void 0 ? void 0 : optionItem.id);
36
38
  var price = (_ref = (_optionItem$price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _optionItem$price !== void 0 ? _optionItem$price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _ref !== void 0 ? _ref : 0;
37
- return {
39
+ return _objectSpread(_objectSpread({}, optionItem), {}, {
38
40
  option_group_item_id: optionGroupItemId,
39
41
  option_group_id: toNumber(optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_id),
40
42
  num: toSafePositiveInt((_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity, 1),
41
- price: toNumber(price, 0)
42
- };
43
+ add_price: toNumber(price, 0),
44
+ price: undefined
45
+ });
43
46
  });
44
47
  }
45
48
  function normalizeBundleItems(bundleItems) {
49
+ var preferPriceField = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
46
50
  if (!Array.isArray(bundleItems)) return [];
47
51
  return bundleItems.map(function (bundleItem) {
48
- return _objectSpread(_objectSpread({}, bundleItem), {}, {
52
+ var _ref2, _ref3, _ref4, _bundleItem$price, _ref5, _ref6, _ref7, _bundleItem$bundle_se, _bundleItem$num, _bundleItem$price2, _bundleItem$quantity, _bundleItem$price3, _ref8, _ref9, _bundleItem$original_, _normalizedItem$price;
53
+ var unitSelling = preferPriceField ? (_ref2 = (_ref3 = (_ref4 = (_bundleItem$price = bundleItem.price) !== null && _bundleItem$price !== void 0 ? _bundleItem$price : bundleItem.bundle_selling_price) !== null && _ref4 !== void 0 ? _ref4 : bundleItem.custom_price) !== null && _ref3 !== void 0 ? _ref3 : bundleItem.product_price) !== null && _ref2 !== void 0 ? _ref2 : '0' : (_ref5 = (_ref6 = (_ref7 = (_bundleItem$bundle_se = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se !== void 0 ? _bundleItem$bundle_se : bundleItem.price) !== null && _ref7 !== void 0 ? _ref7 : bundleItem.custom_price) !== null && _ref6 !== void 0 ? _ref6 : bundleItem.product_price) !== null && _ref5 !== void 0 ? _ref5 : '0';
54
+ var unitStr = toPriceString(unitSelling, '0.00');
55
+ var num = toSafePositiveInt((_bundleItem$num = bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.num) !== null && _bundleItem$num !== void 0 ? _bundleItem$num : bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.quantity, 1);
56
+ var magnitudeSource = _objectSpread(_objectSpread({}, bundleItem), {}, {
57
+ option: normalizeOptionItems(bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.option),
58
+ bundle_selling_price: unitStr,
59
+ // 计算 markdown 净额时,只传真实毛价;仅有 bundle_selling_price 时按历史净额兜底。
60
+ price: (_bundleItem$price2 = bundleItem.price) !== null && _bundleItem$price2 !== void 0 ? _bundleItem$price2 : bundleItem.custom_price
61
+ });
62
+ var normalizedItem = _objectSpread(_objectSpread({}, bundleItem), {}, {
63
+ num: num,
64
+ quantity: (_bundleItem$quantity = bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.quantity) !== null && _bundleItem$quantity !== void 0 ? _bundleItem$quantity : num,
65
+ // price 保留毛价(markdown 仍为正),由 price_type 决定符号。
66
+ price: (_bundleItem$price3 = bundleItem.price) !== null && _bundleItem$price3 !== void 0 ? _bundleItem$price3 : unitStr,
67
+ bundle_selling_price: unitStr,
68
+ original_price: (_ref8 = (_ref9 = (_bundleItem$original_ = bundleItem.original_price) !== null && _bundleItem$original_ !== void 0 ? _bundleItem$original_ : bundleItem.product_price) !== null && _ref9 !== void 0 ? _ref9 : bundleItem.price) !== null && _ref8 !== void 0 ? _ref8 : unitStr,
49
69
  option: normalizeOptionItems(bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.option)
50
70
  });
71
+ // bundle_selling_price 落「正净额」:markdown = |price| − Σoptions;markup/原价维持原值。
72
+ normalizedItem.bundle_selling_price = getBundleSellingMagnitude(magnitudeSource).toFixed(2);
73
+ if (((_normalizedItem$price = normalizedItem.price_type) !== null && _normalizedItem$price !== void 0 ? _normalizedItem$price : normalizedItem.custom_price_type) === 'markdown' && (normalizedItem.price_type_ext === '' || normalizedItem.price_type_ext === undefined || normalizedItem.price_type_ext === null)) {
74
+ var _normalizedItem$custo;
75
+ normalizedItem.custom_price = (_normalizedItem$custo = normalizedItem.custom_price) !== null && _normalizedItem$custo !== void 0 ? _normalizedItem$custo : normalizedItem.price;
76
+ normalizedItem.price = normalizedItem.bundle_selling_price;
77
+ }
78
+ return normalizedItem;
51
79
  });
52
80
  }
53
81
  function findVariantById(origin, variantId) {
@@ -64,23 +92,65 @@ function findVariantById(origin, variantId) {
64
92
  * 注意:这里不生成 identity,缺省时由 OrderModule 自动补齐。
65
93
  */
66
94
  export function transformBaseProductToOrderProduct(params) {
67
- var _ref2, _ref3, _ref4, _payload$product_id, _ref5, _ref6, _payload$product_vari, _payload$_origin, _payload$_origin2, _ref7, _findVariantById, _ref8, _ref9, _ref10, _ref11, _ref12, _ref13, _ref14, _payload$price, _ref15, _payload$option, _payload$bundle, _payload$unique_ident, _payload$quantity, _ref16, _ref17, _payload$tax_fee, _ref18, _ref19, _payload$is_charge_ta;
95
+ var _ref10, _ref11, _ref12, _payload$product_id, _ref13, _ref14, _payload$product_vari, _payload$_origin, _payload$_origin2, _ref15, _findVariantById, _ref16, _ref17, _ref18, _ref19, _ref20, _ref21, _ref22, _payload$price, _ref23, _payload$line_total, _payload$_extend, _ref24, _ref25, _payload$product_sku$, _payload$product_sku, _payload$bundle, _payload$quantity, _payload$_extend2, _extend, _extend2, _ref26, _ref27, _origin$base_price, _ref28, _ref29, _payload$line_total2, _payload$_extend3, _payload$_extend4, _extend3, _payload$_extend5, _payload$_extend6, _ref30, _ref31, _payload$tax_fee, _ref32, _ref33, _payload$is_charge_ta;
68
96
  var payload = params.payload,
69
97
  _params$fallbackProdu = params.fallbackProductId,
70
98
  fallbackProductId = _params$fallbackProdu === void 0 ? null : _params$fallbackProdu;
71
99
  if (!payload || _typeof(payload) !== 'object') return null;
72
100
  var sourceProduct = params.sourceProduct || params.sourceItem || {};
73
- var productId = toProductId((_ref2 = (_ref3 = (_ref4 = (_payload$product_id = payload.product_id) !== null && _payload$product_id !== void 0 ? _payload$product_id : payload.id) !== null && _ref4 !== void 0 ? _ref4 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.product_id) !== null && _ref3 !== void 0 ? _ref3 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.id) !== null && _ref2 !== void 0 ? _ref2 : fallbackProductId);
101
+ var productId = toProductId((_ref10 = (_ref11 = (_ref12 = (_payload$product_id = payload.product_id) !== null && _payload$product_id !== void 0 ? _payload$product_id : payload.id) !== null && _ref12 !== void 0 ? _ref12 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.product_id) !== null && _ref11 !== void 0 ? _ref11 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.id) !== null && _ref10 !== void 0 ? _ref10 : fallbackProductId);
74
102
  if (productId === null) return null;
75
- var productVariantId = toNumber((_ref5 = (_ref6 = (_payload$product_vari = payload.product_variant_id) !== null && _payload$product_vari !== void 0 ? _payload$product_vari : payload.variant_id) !== null && _ref6 !== void 0 ? _ref6 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.product_variant_id) !== null && _ref5 !== void 0 ? _ref5 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.variant_id, 0);
103
+ var productVariantId = toNumber((_ref13 = (_ref14 = (_payload$product_vari = payload.product_variant_id) !== null && _payload$product_vari !== void 0 ? _payload$product_vari : payload.variant_id) !== null && _ref14 !== void 0 ? _ref14 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.product_variant_id) !== null && _ref13 !== void 0 ? _ref13 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.variant_id, 0);
76
104
  var callbackOrigin = payload.origin || ((_payload$_origin = payload._origin) === null || _payload$_origin === void 0 ? void 0 : _payload$_origin.sourceProduct) || ((_payload$_origin2 = payload._origin) === null || _payload$_origin2 === void 0 ? void 0 : _payload$_origin2.sourceItem) || payload._origin || {};
77
105
  var origin = _objectSpread(_objectSpread({}, sourceProduct || {}), callbackOrigin || {});
78
- var matchedVariant = (_ref7 = (_findVariantById = findVariantById(callbackOrigin, productVariantId)) !== null && _findVariantById !== void 0 ? _findVariantById : findVariantById(sourceProduct, productVariantId)) !== null && _ref7 !== void 0 ? _ref7 : findVariantById(origin, productVariantId);
79
- var sourceProductPrice = toPriceString((_ref8 = (_ref9 = (_ref10 = (_ref11 = (_ref12 = (_ref13 = (_ref14 = (_payload$price = payload.price) !== null && _payload$price !== void 0 ? _payload$price : payload.selling_price) !== null && _ref14 !== void 0 ? _ref14 : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.price) !== null && _ref13 !== void 0 ? _ref13 : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.base_price) !== null && _ref12 !== void 0 ? _ref12 : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref11 !== void 0 ? _ref11 : origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _ref10 !== void 0 ? _ref10 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _ref9 !== void 0 ? _ref9 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.selling_price) !== null && _ref8 !== void 0 ? _ref8 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price, '0.00');
80
- var productOptionItem = normalizeOptionItems((_ref15 = (_payload$option = payload.option) !== null && _payload$option !== void 0 ? _payload$option : payload.options) !== null && _ref15 !== void 0 ? _ref15 : payload.product_option_item);
81
- var productBundle = normalizeBundleItems((_payload$bundle = payload.bundle) !== null && _payload$bundle !== void 0 ? _payload$bundle : payload.product_bundle);
82
- var uniqueIdentificationNumber = (_payload$unique_ident = payload.unique_identification_number) !== null && _payload$unique_ident !== void 0 ? _payload$unique_ident : payload.unique;
83
- var metadata = {
106
+ var matchedVariant = (_ref15 = (_findVariantById = findVariantById(callbackOrigin, productVariantId)) !== null && _findVariantById !== void 0 ? _findVariantById : findVariantById(sourceProduct, productVariantId)) !== null && _ref15 !== void 0 ? _ref15 : findVariantById(origin, productVariantId);
107
+ var sourceProductPrice = toPriceString((_ref16 = (_ref17 = (_ref18 = (_ref19 = (_ref20 = (_ref21 = (_ref22 = (_payload$price = payload.price) !== null && _payload$price !== void 0 ? _payload$price : payload.selling_price) !== null && _ref22 !== void 0 ? _ref22 : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.price) !== null && _ref21 !== void 0 ? _ref21 : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.base_price) !== null && _ref20 !== void 0 ? _ref20 : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref19 !== void 0 ? _ref19 : origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _ref18 !== void 0 ? _ref18 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _ref17 !== void 0 ? _ref17 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.selling_price) !== null && _ref16 !== void 0 ? _ref16 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price, '0.00');
108
+ var lineCompositeTotal = toPriceString((_ref23 = (_payload$line_total = payload.line_total) !== null && _payload$line_total !== void 0 ? _payload$line_total : payload.total) !== null && _ref23 !== void 0 ? _ref23 : (_payload$_extend = payload._extend) === null || _payload$_extend === void 0 ? void 0 : _payload$_extend.total, sourceProductPrice);
109
+ var hasPriceOverride = payload.price_override !== undefined && payload.price_override !== null && payload.price_override !== '';
110
+ var productOptionItem = normalizeProductSkuOptions(normalizeOptionItems((_ref24 = (_ref25 = (_payload$product_sku$ = (_payload$product_sku = payload.product_sku) === null || _payload$product_sku === void 0 ? void 0 : _payload$product_sku.option) !== null && _payload$product_sku$ !== void 0 ? _payload$product_sku$ : payload.option) !== null && _ref25 !== void 0 ? _ref25 : payload.options) !== null && _ref24 !== void 0 ? _ref24 : payload.product_option_item));
111
+ var productBundle = normalizeBundleItems((_payload$bundle = payload.bundle) !== null && _payload$bundle !== void 0 ? _payload$bundle : payload.product_bundle, hasPriceOverride);
112
+ // `payload.unique` 是业务侧商品/票务标识,可能在连续加同一商品时重复;
113
+ // 行级唯一值只接受显式协议字段,缺省交给 OrderModule 生成。
114
+ var uniqueIdentificationNumber = payload.unique_identification_number;
115
+ var resolvedQuantity = toSafePositiveInt((_payload$quantity = payload.quantity) !== null && _payload$quantity !== void 0 ? _payload$quantity : payload.num, 1);
116
+ var originTotal = resolveManualDiscountOriginTotal({
117
+ originTotal: payload.origin_total,
118
+ extendOriginTotal: (_payload$_extend2 = payload._extend) === null || _payload$_extend2 === void 0 ? void 0 : _payload$_extend2.origin_total,
119
+ originExtendOriginTotal: origin === null || origin === void 0 || (_extend = origin._extend) === null || _extend === void 0 ? void 0 : _extend.origin_total,
120
+ sourceExtendOriginTotal: sourceProduct === null || sourceProduct === void 0 || (_extend2 = sourceProduct._extend) === null || _extend2 === void 0 ? void 0 : _extend2.origin_total,
121
+ catalogUnitPrice: (_ref26 = (_ref27 = (_origin$base_price = origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _origin$base_price !== void 0 ? _origin$base_price : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref27 !== void 0 ? _ref27 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price) !== null && _ref26 !== void 0 ? _ref26 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price,
122
+ quantity: resolvedQuantity
123
+ });
124
+ var sellingTotal = Number((_ref28 = (_ref29 = (_payload$line_total2 = payload.line_total) !== null && _payload$line_total2 !== void 0 ? _payload$line_total2 : payload.total) !== null && _ref29 !== void 0 ? _ref29 : (_payload$_extend3 = payload._extend) === null || _payload$_extend3 === void 0 ? void 0 : _payload$_extend3.total) !== null && _ref28 !== void 0 ? _ref28 : lineCompositeTotal);
125
+ var discountReason = resolveManualDiscountReasonFromSources({
126
+ discountReason: payload.discount_reason,
127
+ extendDiscountReason: (_payload$_extend4 = payload._extend) === null || _payload$_extend4 === void 0 ? void 0 : _payload$_extend4.discount_reason,
128
+ originExtendDiscountReason: origin === null || origin === void 0 || (_extend3 = origin._extend) === null || _extend3 === void 0 ? void 0 : _extend3.discount_reason
129
+ });
130
+ var lineOriginalPrice = hasPriceOverride && Number.isFinite(originTotal) ? toPriceString(originTotal) : lineCompositeTotal;
131
+ var manualDiscountList = shouldBuildManualProductDiscount({
132
+ hasPriceOverride: hasPriceOverride,
133
+ originTotal: originTotal,
134
+ sellingTotal: sellingTotal
135
+ }) ? mergeManualProductDiscountIntoList(payload.discount_list, buildManualProductDiscountItem({
136
+ originTotal: Number.isFinite(originTotal) ? originTotal : Number(lineOriginalPrice),
137
+ sellingTotal: Number.isFinite(sellingTotal) ? sellingTotal : Number(lineCompositeTotal),
138
+ quantity: resolvedQuantity,
139
+ message: discountReason,
140
+ discountway: (_payload$_extend5 = payload._extend) === null || _payload$_extend5 === void 0 ? void 0 : _payload$_extend5.discountway,
141
+ discount_per: (_payload$_extend6 = payload._extend) === null || _payload$_extend6 === void 0 ? void 0 : _payload$_extend6.discount_per
142
+ })) : payload.discount_list || [];
143
+
144
+ // v2:source 不含 option;main_product_* 含 option(与 normalizeOrderProduct 一致)
145
+ var optionSum = sumOptionUnitPrice(productOptionItem).toNumber();
146
+ var mainProductOriginalPrice = toPriceString(Number(sourceProductPrice) + optionSum);
147
+ var bundleOnlyComposite = composeLinePrice({
148
+ mainPrice: 0,
149
+ bundle: productBundle
150
+ });
151
+ var derivedMainSelling = Number(lineCompositeTotal) - Number(bundleOnlyComposite);
152
+ var mainProductSellingPrice = toPriceString(Number.isFinite(derivedMainSelling) && derivedMainSelling >= 0 ? derivedMainSelling : Number(mainProductOriginalPrice));
153
+ var metadata = _objectSpread(_objectSpread({
84
154
  unique: payload.unique,
85
155
  session: payload.session,
86
156
  form: payload.form,
@@ -90,9 +160,16 @@ export function transformBaseProductToOrderProduct(params) {
90
160
  duration: payload.duration,
91
161
  policy_id: payload.policy_id,
92
162
  source_shop_id: payload.source_shop_id,
93
- origin: origin,
94
- source_product_price: sourceProductPrice
95
- };
163
+ source_product_price: sourceProductPrice,
164
+ main_product_selling_price: mainProductSellingPrice,
165
+ main_product_original_price: mainProductOriginalPrice,
166
+ price_schema_version: 2
167
+ }, hasPriceOverride ? {
168
+ price_override: String(payload.price_override),
169
+ is_manual_discount: 1
170
+ } : {}), payload.bundle_edit !== undefined ? {
171
+ bundle_edit: payload.bundle_edit
172
+ } : {});
96
173
  if (uniqueIdentificationNumber) {
97
174
  metadata.unique_identification_number = String(uniqueIdentificationNumber);
98
175
  }
@@ -100,13 +177,17 @@ export function transformBaseProductToOrderProduct(params) {
100
177
  product_id: productId,
101
178
  product_variant_id: productVariantId,
102
179
  unique_identification_number: uniqueIdentificationNumber ? String(uniqueIdentificationNumber) : undefined,
103
- num: toSafePositiveInt((_payload$quantity = payload.quantity) !== null && _payload$quantity !== void 0 ? _payload$quantity : payload.num, 1),
104
- product_option_item: productOptionItem,
180
+ num: resolvedQuantity,
181
+ product_sku: _objectSpread(_objectSpread({}, payload.product_sku && _typeof(payload.product_sku) === 'object' ? payload.product_sku : {}), {}, {
182
+ option: productOptionItem
183
+ }),
105
184
  product_bundle: productBundle,
106
- selling_price: sourceProductPrice,
107
- original_price: sourceProductPrice,
108
- tax_fee: toPriceString((_ref16 = (_ref17 = (_payload$tax_fee = payload.tax_fee) !== null && _payload$tax_fee !== void 0 ? _payload$tax_fee : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.tax_fee) !== null && _ref17 !== void 0 ? _ref17 : origin === null || origin === void 0 ? void 0 : origin.tax_fee) !== null && _ref16 !== void 0 ? _ref16 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.tax_fee, '0.00'),
109
- is_charge_tax: toNumber((_ref18 = (_ref19 = (_payload$is_charge_ta = payload.is_charge_tax) !== null && _payload$is_charge_ta !== void 0 ? _payload$is_charge_ta : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.is_charge_tax) !== null && _ref19 !== void 0 ? _ref19 : origin === null || origin === void 0 ? void 0 : origin.is_charge_tax) !== null && _ref18 !== void 0 ? _ref18 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.is_charge_tax, 0),
185
+ discount_list: manualDiscountList,
186
+ // 折后行价由 normalizeOrderProduct 按 main + bundle 合成;手动改价时 bundle 已为分摊后单价
187
+ selling_price: lineCompositeTotal,
188
+ original_price: lineOriginalPrice,
189
+ tax_fee: toPriceString((_ref30 = (_ref31 = (_payload$tax_fee = payload.tax_fee) !== null && _payload$tax_fee !== void 0 ? _payload$tax_fee : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.tax_fee) !== null && _ref31 !== void 0 ? _ref31 : origin === null || origin === void 0 ? void 0 : origin.tax_fee) !== null && _ref30 !== void 0 ? _ref30 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.tax_fee, '0.00'),
190
+ is_charge_tax: toNumber((_ref32 = (_ref33 = (_payload$is_charge_ta = payload.is_charge_tax) !== null && _payload$is_charge_ta !== void 0 ? _payload$is_charge_ta : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.is_charge_tax) !== null && _ref33 !== void 0 ? _ref33 : origin === null || origin === void 0 ? void 0 : origin.is_charge_tax) !== null && _ref32 !== void 0 ? _ref32 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.is_charge_tax, 0),
110
191
  metadata: metadata,
111
192
  note: payload.note != null ? String(payload.note) : '',
112
193
  _origin: _objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
@@ -12,7 +12,7 @@ export declare function buildProductLineFingerprint(productOptionItem?: unknown,
12
12
  export declare function getSafeProductNum(num?: number): number;
13
13
  /**
14
14
  * removeProductFromOrder 仅传 SKU 时的通配 identity(对象上未声明选项键)。
15
- * 与显式 `product_option_item: []` 区分:后者只匹配「无选项」行。
15
+ * 与显式 `product_sku: { option: [] }` 区分:后者只匹配「无选项」行。
16
16
  */
17
17
  export declare function isSkuOnlyDeleteIdentity(x: BaseSalesOrderProductIdentity): boolean;
18
18
  /**