@pisell/pisellos 2.2.243 → 2.2.244

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 (315) hide show
  1. package/dist/model/strategy/adapter/promotion/evaluator.js +2 -3
  2. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  3. package/dist/model/strategy/adapter/walletPass/utils.js +4 -7
  4. package/dist/modules/Cart/utils/cartProduct.js +3 -24
  5. package/dist/modules/Cart/utils/changePrice.js +11 -11
  6. package/dist/modules/Customer/index.d.ts +0 -20
  7. package/dist/modules/Customer/index.js +83 -172
  8. package/dist/modules/Customer/types.d.ts +0 -2
  9. package/dist/modules/Discount/index.js +3 -4
  10. package/dist/modules/Discount/types.d.ts +0 -1
  11. package/dist/modules/OpenData/index.d.ts +0 -8
  12. package/dist/modules/OpenData/index.js +17 -37
  13. package/dist/modules/Order/index.d.ts +18 -268
  14. package/dist/modules/Order/index.js +757 -3306
  15. package/dist/modules/Order/types.d.ts +31 -279
  16. package/dist/modules/Order/types.js +0 -38
  17. package/dist/modules/Order/utils.d.ts +5 -147
  18. package/dist/modules/Order/utils.js +103 -746
  19. package/dist/modules/Payment/index.d.ts +13 -10
  20. package/dist/modules/Payment/index.js +837 -467
  21. package/dist/modules/Payment/types.d.ts +0 -2
  22. package/dist/modules/Payment/utils.js +1 -2
  23. package/dist/modules/Payment/walletpass.js +7 -14
  24. package/dist/modules/ProductList/index.d.ts +12 -16
  25. package/dist/modules/ProductList/index.js +59 -133
  26. package/dist/modules/ProductList/types.d.ts +0 -14
  27. package/dist/modules/Quotation/index.d.ts +1 -0
  28. package/dist/modules/Quotation/index.js +22 -25
  29. package/dist/modules/Rules/index.d.ts +0 -4
  30. package/dist/modules/Rules/index.js +69 -93
  31. package/dist/modules/Rules/types.d.ts +0 -1
  32. package/dist/modules/SalesSummary/index.d.ts +25 -8
  33. package/dist/modules/SalesSummary/index.js +35 -86
  34. package/dist/modules/SalesSummary/types.d.ts +1 -4
  35. package/dist/modules/SalesSummary/utils.d.ts +25 -2
  36. package/dist/modules/SalesSummary/utils.js +162 -794
  37. package/dist/modules/Schedule/index.d.ts +0 -7
  38. package/dist/modules/Schedule/index.js +2 -24
  39. package/dist/modules/Summary/index.js +3 -4
  40. package/dist/modules/index.d.ts +0 -2
  41. package/dist/modules/index.js +1 -3
  42. package/dist/plugins/request.d.ts +0 -1
  43. package/dist/server/index.d.ts +1 -204
  44. package/dist/server/index.js +928 -3658
  45. package/dist/server/modules/index.d.ts +0 -2
  46. package/dist/server/modules/index.js +0 -2
  47. package/dist/server/modules/order/index.d.ts +4 -120
  48. package/dist/server/modules/order/index.js +483 -1779
  49. package/dist/server/modules/order/types.d.ts +3 -32
  50. package/dist/server/modules/order/types.js +0 -8
  51. package/dist/server/modules/order/utils/filterBookings.js +3 -26
  52. package/dist/server/modules/order/utils/filterOrders.js +8 -23
  53. package/dist/server/modules/products/index.d.ts +7 -34
  54. package/dist/server/modules/products/index.js +317 -631
  55. package/dist/server/modules/resource/index.d.ts +0 -2
  56. package/dist/server/modules/resource/index.js +3 -29
  57. package/dist/server/modules/schedule/index.d.ts +4 -4
  58. package/dist/server/modules/schedule/index.js +88 -111
  59. package/dist/solution/BaseSales/index.d.ts +9 -131
  60. package/dist/solution/BaseSales/index.js +447 -1944
  61. package/dist/solution/BaseSales/types.d.ts +6 -76
  62. package/dist/solution/BaseSales/types.js +4 -5
  63. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +0 -1
  64. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -105
  65. package/dist/solution/BaseSales/utils.d.ts +1 -1
  66. package/dist/solution/BaseSales/utils.js +21 -62
  67. package/dist/solution/BookingByStep/index.d.ts +1 -1
  68. package/dist/solution/BookingTicket/index.d.ts +10 -270
  69. package/dist/solution/BookingTicket/index.js +237 -1772
  70. package/dist/solution/BookingTicket/types.d.ts +1 -118
  71. package/dist/solution/BookingTicket/types.js +2 -41
  72. package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +0 -40
  73. package/dist/solution/BookingTicket/utils/bookingStatus.js +0 -70
  74. package/dist/solution/BookingTicket/utils/cartView.d.ts +1 -9
  75. package/dist/solution/BookingTicket/utils/cartView.js +7 -94
  76. package/dist/solution/BookingTicket/utils/scan/index.d.ts +0 -5
  77. package/dist/solution/BookingTicket/utils/scan/index.js +8 -20
  78. package/dist/solution/Checkout/appointmentDemo.json +1 -0
  79. package/dist/solution/Checkout/index.d.ts +0 -1
  80. package/dist/solution/Checkout/index.js +9 -10
  81. package/dist/solution/RegisterAndLogin/config.js +10 -2
  82. package/dist/solution/ScanOrder/index.d.ts +3 -9
  83. package/dist/solution/ScanOrder/index.js +134 -241
  84. package/dist/solution/ScanOrder/types.d.ts +5 -9
  85. package/dist/solution/ScanOrder/types.js +3 -2
  86. package/dist/solution/ScanOrder/utils.d.ts +1 -1
  87. package/dist/solution/ScanOrder/utils.js +22 -84
  88. package/dist/solution/VenueBooking/index.d.ts +2 -5
  89. package/dist/solution/VenueBooking/index.js +59 -110
  90. package/dist/solution/VenueBooking/sales-section-4-annotated.json +2 -0
  91. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  92. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
  93. package/dist/types/index.d.ts +0 -10
  94. package/lib/model/strategy/adapter/promotion/evaluator.js +1 -2
  95. package/lib/model/strategy/adapter/promotion/index.js +0 -49
  96. package/lib/model/strategy/adapter/walletPass/utils.js +2 -3
  97. package/lib/modules/Cart/utils/cartProduct.js +3 -20
  98. package/lib/modules/Cart/utils/changePrice.js +20 -12
  99. package/lib/modules/Customer/index.d.ts +0 -20
  100. package/lib/modules/Customer/index.js +11 -64
  101. package/lib/modules/Customer/types.d.ts +0 -2
  102. package/lib/modules/Discount/index.js +1 -5
  103. package/lib/modules/Discount/types.d.ts +0 -1
  104. package/lib/modules/OpenData/index.d.ts +0 -8
  105. package/lib/modules/OpenData/index.js +5 -19
  106. package/lib/modules/Order/index.d.ts +18 -268
  107. package/lib/modules/Order/index.js +344 -2149
  108. package/lib/modules/Order/types.d.ts +31 -279
  109. package/lib/modules/Order/types.js +0 -1
  110. package/lib/modules/Order/utils.d.ts +5 -147
  111. package/lib/modules/Order/utils.js +46 -614
  112. package/lib/modules/Payment/index.d.ts +13 -10
  113. package/lib/modules/Payment/index.js +150 -18
  114. package/lib/modules/Payment/types.d.ts +0 -2
  115. package/lib/modules/Payment/utils.js +1 -2
  116. package/lib/modules/Payment/walletpass.js +3 -7
  117. package/lib/modules/ProductList/index.d.ts +12 -16
  118. package/lib/modules/ProductList/index.js +4 -41
  119. package/lib/modules/ProductList/types.d.ts +0 -14
  120. package/lib/modules/Quotation/index.d.ts +1 -0
  121. package/lib/modules/Quotation/index.js +16 -19
  122. package/lib/modules/Rules/index.d.ts +0 -4
  123. package/lib/modules/Rules/index.js +120 -136
  124. package/lib/modules/Rules/types.d.ts +0 -1
  125. package/lib/modules/SalesSummary/index.d.ts +25 -8
  126. package/lib/modules/SalesSummary/index.js +4 -30
  127. package/lib/modules/SalesSummary/types.d.ts +1 -4
  128. package/lib/modules/SalesSummary/utils.d.ts +25 -2
  129. package/lib/modules/SalesSummary/utils.js +91 -645
  130. package/lib/modules/Schedule/index.d.ts +0 -7
  131. package/lib/modules/Schedule/index.js +1 -17
  132. package/lib/modules/Summary/index.js +4 -5
  133. package/lib/modules/index.d.ts +0 -2
  134. package/lib/modules/index.js +1 -5
  135. package/lib/plugins/request.d.ts +0 -1
  136. package/lib/server/index.d.ts +1 -204
  137. package/lib/server/index.js +57 -1888
  138. package/lib/server/modules/index.d.ts +0 -2
  139. package/lib/server/modules/index.js +0 -3
  140. package/lib/server/modules/order/index.d.ts +4 -120
  141. package/lib/server/modules/order/index.js +142 -919
  142. package/lib/server/modules/order/types.d.ts +3 -32
  143. package/lib/server/modules/order/utils/filterBookings.js +5 -24
  144. package/lib/server/modules/order/utils/filterOrders.js +6 -15
  145. package/lib/server/modules/products/index.d.ts +7 -34
  146. package/lib/server/modules/products/index.js +54 -189
  147. package/lib/server/modules/resource/index.d.ts +0 -2
  148. package/lib/server/modules/resource/index.js +3 -27
  149. package/lib/server/modules/schedule/index.d.ts +4 -4
  150. package/lib/server/modules/schedule/index.js +40 -47
  151. package/lib/solution/BaseSales/index.d.ts +9 -131
  152. package/lib/solution/BaseSales/index.js +63 -1106
  153. package/lib/solution/BaseSales/types.d.ts +6 -76
  154. package/lib/solution/BaseSales/types.js +1 -3
  155. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +0 -1
  156. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +18 -106
  157. package/lib/solution/BaseSales/utils.d.ts +1 -1
  158. package/lib/solution/BaseSales/utils.js +10 -54
  159. package/lib/solution/BookingByStep/index.d.ts +1 -1
  160. package/lib/solution/BookingTicket/index.d.ts +10 -270
  161. package/lib/solution/BookingTicket/index.js +29 -922
  162. package/lib/solution/BookingTicket/types.d.ts +1 -118
  163. package/lib/solution/BookingTicket/types.js +0 -11
  164. package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +0 -40
  165. package/lib/solution/BookingTicket/utils/bookingStatus.js +2 -44
  166. package/lib/solution/BookingTicket/utils/cartView.d.ts +1 -9
  167. package/lib/solution/BookingTicket/utils/cartView.js +6 -61
  168. package/lib/solution/BookingTicket/utils/scan/index.d.ts +0 -5
  169. package/lib/solution/BookingTicket/utils/scan/index.js +3 -17
  170. package/lib/solution/Checkout/appointmentDemo.json +1 -0
  171. package/lib/solution/Checkout/index.d.ts +0 -1
  172. package/lib/solution/Checkout/index.js +2 -1
  173. package/lib/solution/RegisterAndLogin/config.js +10 -2
  174. package/lib/solution/ScanOrder/index.d.ts +3 -9
  175. package/lib/solution/ScanOrder/index.js +70 -153
  176. package/lib/solution/ScanOrder/types.d.ts +5 -9
  177. package/lib/solution/ScanOrder/utils.d.ts +1 -1
  178. package/lib/solution/ScanOrder/utils.js +17 -83
  179. package/lib/solution/VenueBooking/index.d.ts +2 -5
  180. package/lib/solution/VenueBooking/index.js +17 -54
  181. package/lib/solution/VenueBooking/sales-section-4-annotated.json +2 -0
  182. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  183. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
  184. package/lib/types/index.d.ts +0 -10
  185. package/package.json +1 -1
  186. package/dist/modules/BookingContext/index.d.ts +0 -48
  187. package/dist/modules/BookingContext/index.js +0 -566
  188. package/dist/modules/BookingContext/types.d.ts +0 -102
  189. package/dist/modules/BookingContext/types.js +0 -51
  190. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  191. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -284
  192. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  193. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -145
  194. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -76
  195. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -218
  196. package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
  197. package/dist/modules/BookingContext/utils/flexible.js +0 -56
  198. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  199. package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
  200. package/dist/modules/BookingContext/utils/index.d.ts +0 -11
  201. package/dist/modules/BookingContext/utils/index.js +0 -11
  202. package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
  203. package/dist/modules/BookingContext/utils/noResource.js +0 -77
  204. package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +0 -1
  205. package/dist/modules/BookingContext/utils/orderLineDisplay.js +0 -36
  206. package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
  207. package/dist/modules/BookingContext/utils/productExtend.js +0 -339
  208. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  209. package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
  210. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  211. package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
  212. package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
  213. package/dist/modules/BookingContext/utils/resources.js +0 -486
  214. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  215. package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
  216. package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  217. package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
  218. package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  219. package/dist/modules/Order/utils/manualProductDiscount.js +0 -210
  220. package/dist/modules/SurchargeList/index.d.ts +0 -16
  221. package/dist/modules/SurchargeList/index.js +0 -162
  222. package/dist/modules/SurchargeList/types.d.ts +0 -11
  223. package/dist/modules/SurchargeList/types.js +0 -1
  224. package/dist/server/modules/payment/index.d.ts +0 -28
  225. package/dist/server/modules/payment/index.js +0 -305
  226. package/dist/server/modules/payment/types.d.ts +0 -9
  227. package/dist/server/modules/payment/types.js +0 -1
  228. package/dist/server/test.json +0 -713
  229. package/dist/server/utils/small-ticket.d.ts +0 -71
  230. package/dist/server/utils/small-ticket.js +0 -830
  231. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +0 -287
  232. package/dist/solution/BaseSales/utils/cartPromotion.js +0 -1438
  233. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  234. package/dist/solution/BaseSales/utils/quotationPrice.js +0 -237
  235. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -117
  236. package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
  237. package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts +0 -35
  238. package/dist/solution/BookingTicket/utils/addTimeAvailability.js +0 -95
  239. package/dist/solution/BookingTicket/utils/exampleData.d.ts +0 -123
  240. package/dist/solution/BookingTicket/utils/exampleData.js +0 -183
  241. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +0 -185
  242. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +0 -438
  243. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -36
  244. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +0 -399
  245. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -32
  246. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +0 -56
  247. package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +0 -21
  248. package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +0 -150
  249. package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts +0 -23
  250. package/dist/solution/BookingTicket/utils/sessionCatalogStale.js +0 -78
  251. package/lib/modules/BookingContext/index.d.ts +0 -48
  252. package/lib/modules/BookingContext/index.js +0 -368
  253. package/lib/modules/BookingContext/types.d.ts +0 -102
  254. package/lib/modules/BookingContext/types.js +0 -34
  255. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  256. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -276
  257. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  258. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -151
  259. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -76
  260. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -201
  261. package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
  262. package/lib/modules/BookingContext/utils/flexible.js +0 -80
  263. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  264. package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
  265. package/lib/modules/BookingContext/utils/index.d.ts +0 -11
  266. package/lib/modules/BookingContext/utils/index.js +0 -43
  267. package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
  268. package/lib/modules/BookingContext/utils/noResource.js +0 -90
  269. package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +0 -1
  270. package/lib/modules/BookingContext/utils/orderLineDisplay.js +0 -56
  271. package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
  272. package/lib/modules/BookingContext/utils/productExtend.js +0 -283
  273. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  274. package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
  275. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  276. package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
  277. package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
  278. package/lib/modules/BookingContext/utils/resources.js +0 -377
  279. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  280. package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
  281. package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  282. package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
  283. package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  284. package/lib/modules/Order/utils/manualProductDiscount.js +0 -206
  285. package/lib/modules/SurchargeList/index.d.ts +0 -16
  286. package/lib/modules/SurchargeList/index.js +0 -89
  287. package/lib/modules/SurchargeList/types.d.ts +0 -11
  288. package/lib/modules/SurchargeList/types.js +0 -17
  289. package/lib/server/modules/payment/index.d.ts +0 -28
  290. package/lib/server/modules/payment/index.js +0 -192
  291. package/lib/server/modules/payment/types.d.ts +0 -9
  292. package/lib/server/modules/payment/types.js +0 -17
  293. package/lib/server/test.json +0 -713
  294. package/lib/server/utils/small-ticket.d.ts +0 -71
  295. package/lib/server/utils/small-ticket.js +0 -781
  296. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +0 -287
  297. package/lib/solution/BaseSales/utils/cartPromotion.js +0 -992
  298. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  299. package/lib/solution/BaseSales/utils/quotationPrice.js +0 -277
  300. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -117
  301. package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
  302. package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +0 -35
  303. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +0 -125
  304. package/lib/solution/BookingTicket/utils/exampleData.d.ts +0 -123
  305. package/lib/solution/BookingTicket/utils/exampleData.js +0 -0
  306. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +0 -185
  307. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +0 -254
  308. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -36
  309. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +0 -168
  310. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -32
  311. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +0 -51
  312. package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +0 -21
  313. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +0 -127
  314. package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +0 -23
  315. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +0 -85
@@ -1,10 +1,12 @@
1
1
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
2
4
  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); }
3
5
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
4
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
5
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
6
6
  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; }
7
7
  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; }
8
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
9
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
8
10
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
11
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
10
12
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -20,101 +22,14 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
20
22
  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; }
21
23
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
22
24
  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); }
23
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
24
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
25
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
26
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
27
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
28
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
29
25
  import { BaseModule } from "../../modules/BaseModule";
30
- import { BaseSalesHookNames } from "./types";
31
26
  import { OrderModule } from "../../modules/Order";
32
27
  import Decimal from 'decimal.js';
33
- import { cloneDeep, mergeWith } from 'lodash-es';
34
28
  import { createModule } from "../BookingByStep/types";
35
- import { composeLinePrice, createUuidV4, ensureProductSku, getProductSkuOptions, sumOptionUnitPrice } from "../../modules/Order/utils";
29
+ import { composeLinePrice, sumOptionUnitPrice } from "../../modules/Order/utils";
36
30
  import dayjs from 'dayjs';
37
31
  export * from "./types";
38
- import { QuotationModule } from "../../modules/Quotation";
39
32
  import { transformBaseProductToOrderProduct as _transformBaseProductToOrderProduct } from "./utils/transformBaseProductToOrderProduct";
40
- import { calculateBaseSalesProductBookingPrice } from "./utils/quotationPrice";
41
- function isBaseSalesManualProductDiscountProduct(product) {
42
- var _product$metadata, _product$metadata2;
43
- return (product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.is_manual_discount) === true || (product === null || product === void 0 || (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.is_manual_discount) === 1 || ((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (item) {
44
- return (item === null || item === void 0 ? void 0 : item.type) === 'product';
45
- });
46
- }
47
- function getBaseSalesProductUid(product) {
48
- var _product$metadata3;
49
- var uid = (product === null || product === void 0 || (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
50
- if (uid === undefined || uid === null || uid === '') return null;
51
- return String(uid);
52
- }
53
- function preserveManualProductDiscountProducts(previousProducts, nextProducts) {
54
- var previousByUid = new Map();
55
- (previousProducts || []).forEach(function (product, index) {
56
- var uid = getBaseSalesProductUid(product);
57
- if (uid) previousByUid.set(uid, product);
58
- previousByUid.set("__index__:".concat(index), product);
59
- });
60
- return (nextProducts || []).map(function (product, index) {
61
- var uid = getBaseSalesProductUid(product);
62
- var previous = (uid ? previousByUid.get(uid) : undefined) || previousByUid.get("__index__:".concat(index));
63
- return previous && isBaseSalesManualProductDiscountProduct(previous) ? previous : product;
64
- });
65
- }
66
- function getBaseSalesUniqueArrayMetadataKey(key) {
67
- if (key === 'products' || key === 'bookings') return 'unique_identification_number';
68
- if (key === 'payments' || key === 'payment') return 'unique_payment_number';
69
- return null;
70
- }
71
- function getBaseSalesMetadataUid(item, metadataKey) {
72
- var _item$metadata$metada, _item$metadata;
73
- var uid = (_item$metadata$metada = item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata[metadataKey]) !== null && _item$metadata$metada !== void 0 ? _item$metadata$metada : item === null || item === void 0 ? void 0 : item[metadataKey];
74
- if (uid === undefined || uid === null || uid === '') return null;
75
- return String(uid);
76
- }
77
- function mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey) {
78
- var result = [];
79
- var indexByUid = new Map();
80
- var appendOrReplaceByUid = function appendOrReplaceByUid(item) {
81
- var clonedItem = cloneDeep(item);
82
- var uid = getBaseSalesMetadataUid(clonedItem, metadataKey);
83
- if (!uid) {
84
- result.push(clonedItem);
85
- return;
86
- }
87
- var existingIndex = indexByUid.get(uid);
88
- if (existingIndex !== undefined) {
89
- result[existingIndex] = clonedItem;
90
- return;
91
- }
92
- indexByUid.set(uid, result.length);
93
- result.push(clonedItem);
94
- };
95
- currentValue.forEach(appendOrReplaceByUid);
96
- loadedValue.forEach(appendOrReplaceByUid);
97
- return result;
98
- }
99
- function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord) {
100
- if (!currentTempOrder) return loadedRecord;
101
- var mergedRecord = mergeWith(cloneDeep(currentTempOrder), cloneDeep(loadedRecord || {}), function (currentValue, loadedValue, key) {
102
- if (Array.isArray(currentValue) && Array.isArray(loadedValue)) {
103
- var metadataKey = getBaseSalesUniqueArrayMetadataKey(key);
104
- if (metadataKey) {
105
- return mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey);
106
- }
107
- return [].concat(_toConsumableArray(cloneDeep(currentValue)), _toConsumableArray(cloneDeep(loadedValue)));
108
- }
109
- if (Array.isArray(loadedValue)) return cloneDeep(loadedValue);
110
- if (Array.isArray(currentValue) && loadedValue === undefined) {
111
- return cloneDeep(currentValue);
112
- }
113
- return undefined;
114
- });
115
- delete mergedRecord.request_unique_idempotency_token;
116
- return mergedRecord;
117
- }
118
33
  export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
119
34
  _inherits(BaseSalesImpl, _BaseModule);
120
35
  var _super = _createSuper(BaseSalesImpl);
@@ -128,7 +43,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
128
43
  _defineProperty(_assertThisInitialized(_this), "initializeOptions", {});
129
44
  _defineProperty(_assertThisInitialized(_this), "logger", void 0);
130
45
  // LoggerManager 实例
131
- _defineProperty(_assertThisInitialized(_this), "appPlugin", void 0);
132
46
  _defineProperty(_assertThisInitialized(_this), "store", {
133
47
  order: undefined
134
48
  });
@@ -142,20 +56,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
142
56
  _defineProperty(_assertThisInitialized(_this), "request", void 0);
143
57
  // 当前缓存中已加载的最新 SalesDetail;只读 getter 走它对外暴露详情数据。
144
58
  _defineProperty(_assertThisInitialized(_this), "currentSalesDetail", null);
145
- _defineProperty(_assertThisInitialized(_this), "discountConfigCacheKey", null);
146
- _defineProperty(_assertThisInitialized(_this), "hasManualDiscountSelection", false);
147
- _defineProperty(_assertThisInitialized(_this), "paymentMethodsCache", []);
148
59
  return _this;
149
60
  }
150
61
 
151
62
  /**
152
63
  * 子类可覆盖此方法以追加/收敛要注册的子模块。
153
- * 默认包含通用销售模块:products / order / salesSummary / schedule / payment / quotation
64
+ * 默认包含通用销售模块:products / order / salesSummary / schedule / payment。
154
65
  */
155
66
  _createClass(BaseSalesImpl, [{
156
67
  key: "getRegisteredModuleNames",
157
68
  value: function getRegisteredModuleNames() {
158
- return ['products', 'order', 'salesSummary', 'schedule', 'payment', 'quotation'];
69
+ return ['products', 'order', 'salesSummary', 'schedule', 'payment'];
159
70
  }
160
71
 
161
72
  /**
@@ -205,291 +116,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
205
116
  });
206
117
  }
207
118
  }
208
- }, {
209
- key: "hydrateOrderPaymentNames",
210
- value: function hydrateOrderPaymentNames(payments) {
211
- if (!payments.length) return [];
212
- if (!this.paymentMethodsCache.length) {
213
- return payments.map(function (payment) {
214
- return _objectSpread({}, payment);
215
- });
216
- }
217
- var paymentMethodById = new Map();
218
- var paymentMethodByCode = new Map();
219
- this.paymentMethodsCache.forEach(function (method) {
220
- if ((method === null || method === void 0 ? void 0 : method.id) !== undefined && (method === null || method === void 0 ? void 0 : method.id) !== null) {
221
- paymentMethodById.set(String(method.id), method);
222
- }
223
- if (method !== null && method !== void 0 && method.code) {
224
- paymentMethodByCode.set(String(method.code), method);
225
- }
226
- });
227
- return payments.map(function (payment) {
228
- var nextPayment = _objectSpread({}, payment);
229
- if (nextPayment.name) return nextPayment;
230
- var paymentMethod = paymentMethodById.get(String(nextPayment.custom_payment_id)) || paymentMethodByCode.get(String(nextPayment.code));
231
- if (!(paymentMethod !== null && paymentMethod !== void 0 && paymentMethod.name)) return nextPayment;
232
- return _objectSpread(_objectSpread({}, nextPayment), {}, {
233
- name: paymentMethod.name
234
- });
235
- });
236
- }
237
119
  }, {
238
120
  key: "payment",
239
121
  get: function get() {
240
122
  return this.store.payment;
241
123
  }
242
- }, {
243
- key: "getCurrentOrderCustomerId",
244
- value: function getCurrentOrderCustomerId() {
245
- var _this$store$order, _this$store$order$get;
246
- var tempOrder = (_this$store$order = this.store.order) === null || _this$store$order === void 0 || (_this$store$order$get = _this$store$order.getTempOrder) === null || _this$store$order$get === void 0 ? void 0 : _this$store$order$get.call(_this$store$order);
247
- var customerId = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id;
248
- if (customerId === null || customerId === undefined) return undefined;
249
- return customerId;
250
- }
251
- }, {
252
- key: "applyQuotationScheduleResolver",
253
- value: function applyQuotationScheduleResolver(quotation) {
254
- var scheduleModule = this.store.schedule;
255
- if (!scheduleModule) return;
256
- quotation.setScheduleResolver(function (id) {
257
- var _scheduleModule$getSc;
258
- var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || [];
259
- return schedules[0];
260
- });
261
- }
262
- }, {
263
- key: "loadQuotationForPriceQuery",
264
- value: function () {
265
- var _loadQuotationForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
266
- var _this$otherParams;
267
- return _regeneratorRuntime().wrap(function _callee$(_context) {
268
- while (1) switch (_context.prev = _context.next) {
269
- case 0:
270
- if (params.quotation) {
271
- _context.next = 2;
272
- break;
273
- }
274
- return _context.abrupt("return");
275
- case 2:
276
- this.applyQuotationScheduleResolver(params.quotation);
277
- _context.next = 5;
278
- return params.quotation.loadQuotations({
279
- channel: params.channel || ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel),
280
- customer_id: params.customer_id
281
- });
282
- case 5:
283
- case "end":
284
- return _context.stop();
285
- }
286
- }, _callee, this);
287
- }));
288
- function loadQuotationForPriceQuery(_x) {
289
- return _loadQuotationForPriceQuery.apply(this, arguments);
290
- }
291
- return loadQuotationForPriceQuery;
292
- }()
293
- }, {
294
- key: "getPriceQueryProductId",
295
- value: function getPriceQueryProductId(product) {
296
- var _product$product_id;
297
- var productId = Number((_product$product_id = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : product === null || product === void 0 ? void 0 : product.id);
298
- if (!Number.isFinite(productId)) return null;
299
- return productId;
300
- }
301
- }, {
302
- key: "getPriceQuerySchedule",
303
- value: function getPriceQuerySchedule(params) {
304
- var booking = params.booking || {};
305
- if (typeof booking.start_date === 'string' && booking.start_date.trim()) {
306
- var scheduleDate = booking.start_date.trim();
307
- var startTime = typeof booking.start_time === 'string' && booking.start_time.trim() ? booking.start_time.trim() : '00:00:00';
308
- var datetime = dayjs("".concat(scheduleDate, " ").concat(startTime));
309
- return {
310
- schedule_date: scheduleDate,
311
- schedule_datetime: datetime.isValid() ? datetime.format('YYYY-MM-DD HH:mm:ss') : "".concat(scheduleDate, " ").concat(startTime)
312
- };
313
- }
314
- if (typeof params.datetime === 'string' && params.datetime.trim()) {
315
- var _datetime = dayjs(params.datetime.trim());
316
- if (_datetime.isValid()) {
317
- return {
318
- schedule_date: _datetime.format('YYYY-MM-DD'),
319
- schedule_datetime: _datetime.format('YYYY-MM-DD HH:mm:ss')
320
- };
321
- }
322
- }
323
- var now = dayjs();
324
- return {
325
- schedule_date: now.format('YYYY-MM-DD'),
326
- schedule_datetime: now.format('YYYY-MM-DD HH:mm:ss')
327
- };
328
- }
329
- }, {
330
- key: "loadProductForPriceQuery",
331
- value: function () {
332
- var _loadProductForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params, customerId) {
333
- var product, productId, schedule, _this$otherParams2, _response$data, response, list;
334
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
335
- while (1) switch (_context2.prev = _context2.next) {
336
- case 0:
337
- product = params.product || {};
338
- productId = this.getPriceQueryProductId(product);
339
- if (!(productId === null || !this.request)) {
340
- _context2.next = 4;
341
- break;
342
- }
343
- return _context2.abrupt("return", null);
344
- case 4:
345
- schedule = this.getPriceQuerySchedule(params);
346
- _context2.prev = 5;
347
- _context2.next = 8;
348
- return this.request.post('/product/query', {
349
- ids: [productId],
350
- open_quotation: 1,
351
- open_bundle: 1,
352
- status: 'published',
353
- num: 1,
354
- skip: 1,
355
- customer_id: customerId,
356
- schedule_date: schedule.schedule_date,
357
- schedule_datetime: schedule.schedule_datetime,
358
- application_code: params.channel || ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.channel)
359
- }, {
360
- osServer: true,
361
- customToast: function customToast() {}
362
- });
363
- case 8:
364
- response = _context2.sent;
365
- list = (response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.list) || (response === null || response === void 0 ? void 0 : response.list) || [];
366
- if (Array.isArray(list)) {
367
- _context2.next = 12;
368
- break;
369
- }
370
- return _context2.abrupt("return", null);
371
- case 12:
372
- return _context2.abrupt("return", list.find(function (item) {
373
- var _item$id;
374
- return Number((_item$id = item === null || item === void 0 ? void 0 : item.id) !== null && _item$id !== void 0 ? _item$id : item === null || item === void 0 ? void 0 : item.product_id) === productId;
375
- }) || null);
376
- case 15:
377
- _context2.prev = 15;
378
- _context2.t0 = _context2["catch"](5);
379
- this.logWarning('loadProductForPriceQuery: 商品重查失败,使用入参 fallback', {
380
- productId: productId,
381
- error: _context2.t0 instanceof Error ? _context2.t0.message : String(_context2.t0)
382
- });
383
- return _context2.abrupt("return", null);
384
- case 19:
385
- case "end":
386
- return _context2.stop();
387
- }
388
- }, _callee2, this, [[5, 15]]);
389
- }));
390
- function loadProductForPriceQuery(_x2, _x3) {
391
- return _loadProductForPriceQuery.apply(this, arguments);
392
- }
393
- return loadProductForPriceQuery;
394
- }()
395
- }, {
396
- key: "getAuthoritativeBundleItems",
397
- value: function getAuthoritativeBundleItems(product) {
398
- if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) return product.product_bundle;
399
- var groups = Array.isArray(product === null || product === void 0 ? void 0 : product.bundle_group) ? product.bundle_group : Array.isArray(product === null || product === void 0 ? void 0 : product.bundleGroup) ? product.bundleGroup : [];
400
- return groups.flatMap(function (group) {
401
- var items = Array.isArray(group === null || group === void 0 ? void 0 : group.bundle_item) ? group.bundle_item : Array.isArray(group === null || group === void 0 ? void 0 : group.bundleItem) ? group.bundleItem : [];
402
- return items.map(function (item) {
403
- var _item$group_id, _ref, _item$bundle_group_id;
404
- return _objectSpread(_objectSpread({}, item), {}, {
405
- group_id: (_item$group_id = item === null || item === void 0 ? void 0 : item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : group === null || group === void 0 ? void 0 : group.id,
406
- bundle_group_id: (_ref = (_item$bundle_group_id = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id !== void 0 ? _item$bundle_group_id : item === null || item === void 0 ? void 0 : item.group_id) !== null && _ref !== void 0 ? _ref : group === null || group === void 0 ? void 0 : group.id
407
- });
408
- });
409
- });
410
- }
411
- }, {
412
- key: "findAuthoritativeBundleItem",
413
- value: function findAuthoritativeBundleItem(bundle, candidates) {
414
- var _bundle$bundle_id, _bundle$bundle_produc, _bundle$bundle_group_;
415
- var bundleId = (_bundle$bundle_id = bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle.id;
416
- if (bundleId != null) {
417
- var matchedById = candidates.find(function (item) {
418
- var _item$bundle_id;
419
- return String((_item$bundle_id = item === null || item === void 0 ? void 0 : item.bundle_id) !== null && _item$bundle_id !== void 0 ? _item$bundle_id : item === null || item === void 0 ? void 0 : item.id) === String(bundleId);
420
- });
421
- if (matchedById) return matchedById;
422
- }
423
- var productId = (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id;
424
- var groupId = (_bundle$bundle_group_ = bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle.group_id;
425
- return candidates.find(function (item) {
426
- var _item$bundle_product_, _item$bundle_group_id2;
427
- var itemProductId = (_item$bundle_product_ = item === null || item === void 0 ? void 0 : item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item === null || item === void 0 ? void 0 : item._bundle_product_id;
428
- var itemGroupId = (_item$bundle_group_id2 = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id2 !== void 0 ? _item$bundle_group_id2 : item === null || item === void 0 ? void 0 : item.group_id;
429
- if (productId == null || String(itemProductId) !== String(productId)) return false;
430
- if (groupId == null) return true;
431
- return String(itemGroupId) === String(groupId);
432
- }) || null;
433
- }
434
- }, {
435
- key: "getAuthoritativeBundleUnitPrice",
436
- value: function getAuthoritativeBundleUnitPrice(bundle) {
437
- var _ref2, _ref3, _ref4, _bundle$price;
438
- return (_ref2 = (_ref3 = (_ref4 = (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle.bundle_selling_price) !== null && _ref4 !== void 0 ? _ref4 : bundle.custom_price) !== null && _ref3 !== void 0 ? _ref3 : bundle.product_price) !== null && _ref2 !== void 0 ? _ref2 : bundle.base_price;
439
- }
440
- }, {
441
- key: "mergeProductForPriceQuery",
442
- value: function mergeProductForPriceQuery(product, authoritativeProduct) {
443
- var _this2 = this,
444
- _product$id,
445
- _ref5,
446
- _product$product_id2,
447
- _ref6,
448
- _product$product_vari,
449
- _ref7,
450
- _product$num,
451
- _ref8,
452
- _product$quantity,
453
- _product$metadata4;
454
- if (!authoritativeProduct) return product;
455
- var selectedBundles = Array.isArray(product.product_bundle) ? product.product_bundle : [];
456
- var authoritativeBundles = this.getAuthoritativeBundleItems(authoritativeProduct);
457
- var productBundle = selectedBundles.map(function (bundle) {
458
- var _authoritativeBundle$, _authoritativeBundle$2;
459
- var authoritativeBundle = _this2.findAuthoritativeBundleItem(bundle, authoritativeBundles);
460
- var unitPrice = authoritativeBundle ? _this2.getAuthoritativeBundleUnitPrice(authoritativeBundle) : undefined;
461
- if (unitPrice === undefined || unitPrice === null || unitPrice === '') return bundle;
462
- return _objectSpread(_objectSpread({}, bundle), {}, {
463
- price: unitPrice,
464
- bundle_selling_price: unitPrice,
465
- base_price: (_authoritativeBundle$ = authoritativeBundle === null || authoritativeBundle === void 0 ? void 0 : authoritativeBundle.base_price) !== null && _authoritativeBundle$ !== void 0 ? _authoritativeBundle$ : bundle.base_price,
466
- product_price: (_authoritativeBundle$2 = authoritativeBundle === null || authoritativeBundle === void 0 ? void 0 : authoritativeBundle.product_price) !== null && _authoritativeBundle$2 !== void 0 ? _authoritativeBundle$2 : bundle.product_price
467
- });
468
- });
469
- return _objectSpread(_objectSpread(_objectSpread({}, product), authoritativeProduct), {}, {
470
- id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : authoritativeProduct.id,
471
- product_id: (_ref5 = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : authoritativeProduct.product_id) !== null && _ref5 !== void 0 ? _ref5 : authoritativeProduct.id,
472
- product_variant_id: (_ref6 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : authoritativeProduct.product_variant_id) !== null && _ref6 !== void 0 ? _ref6 : 0,
473
- num: (_ref7 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref7 !== void 0 ? _ref7 : authoritativeProduct.num,
474
- quantity: (_ref8 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref8 !== void 0 ? _ref8 : authoritativeProduct.quantity,
475
- product_sku: function () {
476
- var authoritativeSku = ensureProductSku(authoritativeProduct);
477
- var productSku = ensureProductSku(product);
478
- var hasProductSku = product.product_sku && _typeof(product.product_sku) === 'object';
479
- return _objectSpread(_objectSpread(_objectSpread({}, authoritativeSku), productSku), {}, {
480
- option: hasProductSku ? productSku.option : authoritativeSku.option
481
- });
482
- }(),
483
- product_bundle: productBundle,
484
- metadata: (_product$metadata4 = product.metadata) !== null && _product$metadata4 !== void 0 ? _product$metadata4 : authoritativeProduct.metadata
485
- });
486
- }
487
- }, {
488
- key: "getSubmitOrderSalesChannel",
489
- value: function getSubmitOrderSalesChannel() {
490
- var _this$otherParams3;
491
- return (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.channel;
492
- }
493
124
 
494
125
  /**
495
126
  * 工厂入口:根据子模块名实例化对应模块。
@@ -499,9 +130,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
499
130
  }, {
500
131
  key: "createSubModule",
501
132
  value: function createSubModule(moduleName) {
502
- if (moduleName === 'quotation') {
503
- return new QuotationModule("".concat(this.name, "_quotation"));
504
- }
505
133
  return createModule(moduleName, this.name);
506
134
  }
507
135
  }, {
@@ -518,89 +146,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
518
146
  return optionHooks[moduleName] || ((_this$otherParams$mod = this.otherParams[moduleName]) === null || _this$otherParams$mod === void 0 ? void 0 : _this$otherParams$mod.hooks) || otherHooks[moduleName];
519
147
  }
520
148
 
521
- /**
522
- * 构造传给 BaseSales 子模块的完整运行态参数,保证初始化和后续同步语义一致。
523
- *
524
- * @example
525
- * const params = this.buildSubModuleOtherParams();
526
- * this.core.registerModule(orderModule, { otherParams: params });
527
- */
528
- }, {
529
- key: "buildSubModuleOtherParams",
530
- value: function buildSubModuleOtherParams() {
531
- return _objectSpread(_objectSpread({}, this.otherParams), {}, {
532
- salesSummaryModuleName: "".concat(this.name, "_salesSummary"),
533
- fatherModule: this.name,
534
- openCache: this.cacheId ? true : false,
535
- cacheId: this.cacheId
536
- });
537
- }
538
-
539
- /**
540
- * 将父级 otherParams 的变更显式同步给已注册的子模块。
541
- *
542
- * @example
543
- * await this.syncOtherParamsToSubModules({ channel: 'pos' });
544
- */
545
- }, {
546
- key: "syncOtherParamsToSubModules",
547
- value: (function () {
548
- var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(changedParams) {
549
- var _ref9,
550
- _ref9$cover,
551
- cover,
552
- nextSubModuleOtherParams,
553
- _args4 = arguments;
554
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
555
- while (1) switch (_context4.prev = _context4.next) {
556
- case 0:
557
- _ref9 = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {}, _ref9$cover = _ref9.cover, cover = _ref9$cover === void 0 ? false : _ref9$cover;
558
- nextSubModuleOtherParams = this.buildSubModuleOtherParams();
559
- _context4.next = 4;
560
- return Promise.all(Object.values(this.store).map( /*#__PURE__*/function () {
561
- var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(subModule) {
562
- var targetModule;
563
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
564
- while (1) switch (_context3.prev = _context3.next) {
565
- case 0:
566
- targetModule = subModule;
567
- if (!(!targetModule || typeof targetModule.updateOtherParams !== 'function')) {
568
- _context3.next = 3;
569
- break;
570
- }
571
- return _context3.abrupt("return");
572
- case 3:
573
- _context3.next = 5;
574
- return targetModule.updateOtherParams(nextSubModuleOtherParams, {
575
- changedParams: changedParams,
576
- cover: cover
577
- });
578
- case 5:
579
- case "end":
580
- return _context3.stop();
581
- }
582
- }, _callee3);
583
- }));
584
- return function (_x5) {
585
- return _ref10.apply(this, arguments);
586
- };
587
- }()));
588
- case 4:
589
- case "end":
590
- return _context4.stop();
591
- }
592
- }, _callee4, this);
593
- }));
594
- function syncOtherParamsToSubModules(_x4) {
595
- return _syncOtherParamsToSubModules.apply(this, arguments);
596
- }
597
- return syncOtherParamsToSubModules;
598
- }()
599
149
  /**
600
150
  * 读取 sessionStorage[this.name][cacheId],作为子模块 initialState 的来源。
601
151
  * sessionStorage 损坏时静默忽略,按空状态注册。
602
152
  */
603
- )
604
153
  }, {
605
154
  key: "readSessionCacheData",
606
155
  value: function readSessionCacheData() {
@@ -614,126 +163,77 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
614
163
  return {};
615
164
  }
616
165
  }
617
- }, {
618
- key: "getAppData",
619
- value: function getAppData(key) {
620
- var _this$appPlugin$getDa, _this$appPlugin, _app$models, _app$models$getStore, _app$models$getStore$, _app$models$getStore$2;
621
- var getData = (_this$appPlugin$getDa = (_this$appPlugin = this.appPlugin).getData) === null || _this$appPlugin$getDa === void 0 ? void 0 : _this$appPlugin$getDa.call(_this$appPlugin);
622
- if (typeof getData === 'function') return getData(key);
623
- var app = this.appPlugin.getApp();
624
- var coreData = app === null || app === void 0 || (_app$models = app.models) === null || _app$models === void 0 || (_app$models$getStore = _app$models.getStore) === null || _app$models$getStore === void 0 || (_app$models$getStore$ = (_app$models$getStore$2 = _app$models$getStore.call(_app$models)).getDataByModel) === null || _app$models$getStore$ === void 0 ? void 0 : _app$models$getStore$.call(_app$models$getStore$2, 'core', 'core');
625
- return coreData === null || coreData === void 0 ? void 0 : coreData[key];
626
- }
627
- }, {
628
- key: "syncAppDataToTempOrder",
629
- value: function syncAppDataToTempOrder(tempOrder) {
630
- var isPriceIncludeTax = this.getAppData('is_price_include_tax');
631
- var taxCountryCode = this.getAppData('tax_country_code');
632
- var currencyCode = this.getAppData('shop_currency_code');
633
- var currencySymbol = this.getAppData('shop_symbol');
634
- var isChanged = false;
635
- if (isPriceIncludeTax !== undefined) {
636
- var nextIsPriceIncludeTax = Number(isPriceIncludeTax);
637
- if ((nextIsPriceIncludeTax === 0 || nextIsPriceIncludeTax === 1) && tempOrder.is_price_include_tax !== nextIsPriceIncludeTax) {
638
- tempOrder.is_price_include_tax = nextIsPriceIncludeTax;
639
- isChanged = true;
640
- }
641
- }
642
- if (taxCountryCode !== undefined) {
643
- var nextTaxCountryCode = String(taxCountryCode || '');
644
- if (tempOrder.tax_country_code !== nextTaxCountryCode) {
645
- tempOrder.tax_country_code = nextTaxCountryCode;
646
- isChanged = true;
647
- }
648
- }
649
- if (currencyCode !== undefined) {
650
- var nextCurrencyCode = String(currencyCode || '');
651
- if (tempOrder.currency_code !== nextCurrencyCode) {
652
- tempOrder.currency_code = nextCurrencyCode;
653
- isChanged = true;
654
- }
655
- }
656
- if (currencySymbol !== undefined) {
657
- var nextCurrencySymbol = String(currencySymbol || '');
658
- if (tempOrder.currency_symbol !== nextCurrencySymbol) {
659
- tempOrder.currency_symbol = nextCurrencySymbol;
660
- isChanged = true;
661
- }
662
- }
663
- return isChanged;
664
- }
665
166
  }, {
666
167
  key: "initialize",
667
168
  value: function () {
668
- var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(core) {
669
- var _this$otherParams4,
670
- _this3 = this,
671
- _this$otherParams5;
169
+ var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core) {
170
+ var _this$otherParams,
171
+ _this2 = this;
672
172
  var options,
173
+ appPlugin,
673
174
  app,
674
175
  targetCacheData,
675
176
  moduleNames,
676
- _args5 = arguments;
677
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
678
- while (1) switch (_context5.prev = _context5.next) {
177
+ _args = arguments;
178
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
179
+ while (1) switch (_context.prev = _context.next) {
679
180
  case 0:
680
- options = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
181
+ options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
681
182
  this.core = core;
682
183
  this.initializeOptions = options || {};
683
184
  // this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
684
185
  this.otherParams = options.otherParams || {};
685
- this.cacheId = (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.cacheId;
186
+ this.cacheId = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.cacheId;
686
187
  this.window = core.getPlugin('window');
687
188
  this.request = core.getPlugin('request');
688
189
 
689
190
  // 获取 logger 实例
690
- this.appPlugin = core.getPlugin('app');
691
- if (this.appPlugin) {
692
- _context5.next = 10;
191
+ appPlugin = core.getPlugin('app');
192
+ if (appPlugin) {
193
+ _context.next = 10;
693
194
  break;
694
195
  }
695
196
  throw new Error('Checkout 解决方案需要 app 插件支持');
696
197
  case 10:
697
- app = this.appPlugin.getApp();
198
+ app = appPlugin.getApp();
698
199
  this.logger = app.logger;
699
200
  targetCacheData = this.readSessionCacheData();
700
201
  moduleNames = this.getRegisteredModuleNames();
701
202
  moduleNames.forEach(function (step) {
702
- var targetModule = _this3.createSubModule(step);
203
+ var targetModule = _this2.createSubModule(step);
703
204
  if (!targetModule) {
704
205
  throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
705
206
  }
706
- var hooks = _this3.getSubModuleHooks(step);
707
- _this3.store[step] = targetModule;
708
- _this3.core.registerModule(targetModule, _objectSpread(_objectSpread({
207
+ var hooks = _this2.getSubModuleHooks(step);
208
+ _this2.store[step] = targetModule;
209
+ _this2.core.registerModule(targetModule, _objectSpread(_objectSpread({
709
210
  initialState: (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {}
710
211
  }, hooks ? {
711
212
  hooks: hooks
712
213
  } : {}), {}, {
713
- otherParams: _this3.buildSubModuleOtherParams()
214
+ otherParams: _objectSpread(_objectSpread({}, _this2.otherParams), {}, {
215
+ salesSummaryModuleName: "".concat(_this2.name, "_salesSummary"),
216
+ fatherModule: _this2.name,
217
+ openCache: _this2.cacheId ? true : false,
218
+ cacheId: _this2.cacheId
219
+ })
714
220
  }));
715
221
  });
716
222
  if (!this.store.schedule) {
717
- _context5.next = 18;
223
+ _context.next = 18;
718
224
  break;
719
225
  }
720
- _context5.next = 18;
226
+ _context.next = 18;
721
227
  return this.store.schedule.loadAllSchedule();
722
228
  case 18:
723
- if (this.store.order && typeof ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.enableTempOrderPersist) === 'boolean') {
724
- this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
725
- }
726
- _context5.next = 21;
727
- return this.getPaymentMethodsAsync();
728
- case 21:
729
229
  this.core.effects.emit("".concat(this.name, ":onInited"), {});
730
- case 22:
230
+ case 19:
731
231
  case "end":
732
- return _context5.stop();
232
+ return _context.stop();
733
233
  }
734
- }, _callee5, this);
234
+ }, _callee, this);
735
235
  }));
736
- function initialize(_x6) {
236
+ function initialize(_x) {
737
237
  return _initialize.apply(this, arguments);
738
238
  }
739
239
  return initialize;
@@ -741,13 +241,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
741
241
  }, {
742
242
  key: "destroy",
743
243
  value: function () {
744
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
745
- var _this4 = this;
746
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
747
- while (1) switch (_context6.prev = _context6.next) {
244
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
245
+ var _this3 = this;
246
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
247
+ while (1) switch (_context2.prev = _context2.next) {
748
248
  case 0:
749
249
  Object.keys(this.store).forEach(function (key) {
750
- var sub = _this4.store[key];
250
+ var sub = _this3.store[key];
751
251
  if (sub && typeof sub.destroy === 'function') {
752
252
  try {
753
253
  sub.destroy();
@@ -757,15 +257,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
757
257
  }
758
258
  });
759
259
  this.currentSalesDetail = null;
760
- _context6.next = 4;
260
+ _context2.next = 4;
761
261
  return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
762
262
  case 4:
763
263
  _get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
764
264
  case 5:
765
265
  case "end":
766
- return _context6.stop();
266
+ return _context2.stop();
767
267
  }
768
- }, _callee6, this);
268
+ }, _callee2, this);
769
269
  }));
770
270
  function destroy() {
771
271
  return _destroy.apply(this, arguments);
@@ -774,7 +274,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
774
274
  }()
775
275
  /**
776
276
  * 加载销售订单到统一 tempOrder 工作区。
777
- * 统一通过 OrderModule sales detail lookup 加载订单详情。
277
+ * app.sqlite 时优先读取本地记录;本地未命中或 forceRemote=true 时再拉云端。
778
278
  *
779
279
  * 子类可在 `super.loadSalesDetail` 之后基于返回的 `sales` 做业务侧装配
780
280
  * (比如把 `sales.customer` 写入 CustomerModule、emit 业务 hook 等)。
@@ -782,14 +282,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
782
282
  }, {
783
283
  key: "loadSalesDetail",
784
284
  value: (function () {
785
- var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(orderIdOrParams) {
786
- var _ref11, _params$orderId;
787
- var params, externalSaleNumber, lookup, res, message, currentTempOrder, record, sales;
788
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
789
- while (1) switch (_context7.prev = _context7.next) {
285
+ var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(orderIdOrParams) {
286
+ var params, externalSaleNumber, localRecord, _sales, res, message, sales;
287
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
288
+ while (1) switch (_context3.prev = _context3.next) {
790
289
  case 0:
791
290
  if (this.store.order) {
792
- _context7.next = 2;
291
+ _context3.next = 2;
793
292
  break;
794
293
  }
795
294
  throw new Error('order 模块未初始化');
@@ -798,49 +297,108 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
798
297
  orderId: orderIdOrParams
799
298
  };
800
299
  externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
801
- lookup = (_ref11 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref11 !== void 0 ? _ref11 : params.orderNumber;
802
- if (!(lookup === undefined || lookup === null || lookup === '')) {
803
- _context7.next = 7;
300
+ if (params.forceRemote) {
301
+ _context3.next = 35;
804
302
  break;
805
303
  }
806
- throw new Error('加载销售详情需要 orderId、externalSaleNumber orderNumber');
807
- case 7:
808
- _context7.next = 9;
809
- return this.store.order.getSalesOrderByLookup({
810
- lookup: lookup,
811
- forceRemote: params.forceRemote
304
+ if (!(params.orderId !== undefined)) {
305
+ _context3.next = 11;
306
+ break;
307
+ }
308
+ _context3.next = 8;
309
+ return this.store.order.getLocalOrderByOrderId(params.orderId);
310
+ case 8:
311
+ _context3.t0 = _context3.sent;
312
+ _context3.next = 26;
313
+ break;
314
+ case 11:
315
+ if (!externalSaleNumber) {
316
+ _context3.next = 17;
317
+ break;
318
+ }
319
+ _context3.next = 14;
320
+ return this.store.order.getLocalOrderByExternalSaleNumber(externalSaleNumber);
321
+ case 14:
322
+ _context3.t1 = _context3.sent;
323
+ _context3.next = 25;
324
+ break;
325
+ case 17:
326
+ if (!params.orderNumber) {
327
+ _context3.next = 23;
328
+ break;
329
+ }
330
+ _context3.next = 20;
331
+ return this.store.order.getLocalOrderByOrderNumber(params.orderNumber);
332
+ case 20:
333
+ _context3.t2 = _context3.sent;
334
+ _context3.next = 24;
335
+ break;
336
+ case 23:
337
+ _context3.t2 = null;
338
+ case 24:
339
+ _context3.t1 = _context3.t2;
340
+ case 25:
341
+ _context3.t0 = _context3.t1;
342
+ case 26:
343
+ localRecord = _context3.t0;
344
+ if (!localRecord) {
345
+ _context3.next = 35;
346
+ break;
347
+ }
348
+ _context3.next = 30;
349
+ return this.store.order.hydrateTempOrderFromRecord(localRecord, {
350
+ recalcOnHydrate: false
812
351
  });
813
- case 9:
814
- res = _context7.sent;
352
+ case 30:
353
+ _sales = _context3.sent;
354
+ this.currentSalesDetail = _sales;
355
+ _context3.next = 34;
356
+ return this.core.effects.emit("".concat(this.name, ":onSalesOrderLoaded"), {
357
+ sales: _sales
358
+ });
359
+ case 34:
360
+ return _context3.abrupt("return", _sales);
361
+ case 35:
362
+ if (!(params.orderId === undefined || params.orderId === null)) {
363
+ _context3.next = 37;
364
+ break;
365
+ }
366
+ throw new Error('加载销售详情需要 orderId,或本地库中存在对应 externalSaleNumber/orderNumber');
367
+ case 37:
368
+ _context3.next = 39;
369
+ return this.store.order.getOrderInfoByRemote(Number(params.orderId));
370
+ case 39:
371
+ res = _context3.sent;
815
372
  if (!(!res || res.code !== 200)) {
816
- _context7.next = 13;
373
+ _context3.next = 43;
817
374
  break;
818
375
  }
819
- message = res && (res.message || res.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(lookup);
376
+ message = res && (res.message || res.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(params.orderId);
820
377
  throw new Error(message);
821
- case 13:
822
- currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
823
- record = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, res.data) : res.data;
824
- _context7.next = 17;
825
- return this.store.order.hydrateTempOrderFromRecord(record, {
378
+ case 43:
379
+ _context3.next = 45;
380
+ return this.store.order.hydrateTempOrderFromRecord(res.data, {
826
381
  recalcOnHydrate: false
827
382
  });
828
- case 17:
829
- sales = _context7.sent;
383
+ case 45:
384
+ sales = _context3.sent;
385
+ _context3.next = 48;
386
+ return this.store.order.saveDraft();
387
+ case 48:
830
388
  this.currentSalesDetail = sales;
831
- _context7.next = 21;
389
+ _context3.next = 51;
832
390
  return this.core.effects.emit("".concat(this.name, ":onSalesOrderLoaded"), {
833
391
  sales: sales
834
392
  });
835
- case 21:
836
- return _context7.abrupt("return", sales);
837
- case 22:
393
+ case 51:
394
+ return _context3.abrupt("return", sales);
395
+ case 52:
838
396
  case "end":
839
- return _context7.stop();
397
+ return _context3.stop();
840
398
  }
841
- }, _callee7, this);
399
+ }, _callee3, this);
842
400
  }));
843
- function loadSalesDetail(_x7) {
401
+ function loadSalesDetail(_x2) {
844
402
  return _loadSalesDetail.apply(this, arguments);
845
403
  }
846
404
  return loadSalesDetail;
@@ -913,45 +471,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
913
471
  }, {
914
472
  key: "getTempOrder",
915
473
  value: function getTempOrder() {
916
- var _this$store$order2;
917
- var result = ((_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 ? void 0 : _this$store$order2.getTempOrder()) || null;
474
+ var _this$store$order;
475
+ var result = ((_this$store$order = this.store.order) === null || _this$store$order === void 0 ? void 0 : _this$store$order.getTempOrder()) || null;
918
476
  return result;
919
477
  }
920
- }, {
921
- key: "replaceTempOrder",
922
- value: function () {
923
- var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(tempOrder) {
924
- var nextTempOrder;
925
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
926
- while (1) switch (_context8.prev = _context8.next) {
927
- case 0:
928
- if (this.store.order) {
929
- _context8.next = 2;
930
- break;
931
- }
932
- throw new Error('order 模块未初始化');
933
- case 2:
934
- _context8.next = 4;
935
- return this.store.order.replaceTempOrder(tempOrder);
936
- case 4:
937
- nextTempOrder = _context8.sent;
938
- _context8.next = 7;
939
- return this.effectsEmit('onTempOrderReplaced', {
940
- tempOrder: nextTempOrder
941
- });
942
- case 7:
943
- return _context8.abrupt("return", nextTempOrder);
944
- case 8:
945
- case "end":
946
- return _context8.stop();
947
- }
948
- }, _callee8, this);
949
- }));
950
- function replaceTempOrder(_x8) {
951
- return _replaceTempOrder.apply(this, arguments);
952
- }
953
- return replaceTempOrder;
954
- }()
955
478
  }, {
956
479
  key: "getOrderIdentity",
957
480
  value: function getOrderIdentity() {
@@ -985,21 +508,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
985
508
  }, {
986
509
  key: "updateTempOrderNote",
987
510
  value: function updateTempOrderNote(note) {
988
- var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
989
511
  try {
990
512
  if (!this.store.order) throw new Error('order 模块未初始化');
991
- var result = this.store.order.updateTempOrderNote(note, sync);
513
+ var result = this.store.order.updateTempOrderNote(note);
992
514
  return result;
993
515
  } catch (error) {
994
516
  throw error;
995
517
  }
996
518
  }
997
- }, {
998
- key: "updateRemoteOrderNote",
999
- value: function updateRemoteOrderNote(orderId, note) {
1000
- if (!this.store.order) throw new Error('order 模块未初始化');
1001
- this.store.order.syncTempOrderNoteToRemote(orderId, note);
1002
- }
1003
519
  }, {
1004
520
  key: "updateTempOrderShopDiscount",
1005
521
  value: function updateTempOrderShopDiscount(amount) {
@@ -1012,22 +528,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1012
528
  if (!this.store.order) throw new Error('order 模块未初始化');
1013
529
  return this.store.order.updateTempOrderContactsInfo(contactsInfo);
1014
530
  }
1015
-
1016
- /** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化。 */
1017
- }, {
1018
- key: "setEnableTempOrderPersist",
1019
- value: function setEnableTempOrderPersist(enabled) {
1020
- if (!this.store.order) throw new Error('order 模块未初始化');
1021
- this.store.order.setEnableTempOrderPersist(enabled);
1022
- }
1023
-
1024
- /** 是否允许 saveDraft 写入 IndexedDB 草稿。 */
1025
- }, {
1026
- key: "isTempOrderPersistEnabled",
1027
- value: function isTempOrderPersistEnabled() {
1028
- if (!this.store.order) return false;
1029
- return this.store.order.isTempOrderPersistEnabled();
1030
- }
1031
531
  }, {
1032
532
  key: "ensureTempOrder",
1033
533
  value: function ensureTempOrder() {
@@ -1039,40 +539,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1039
539
  }, {
1040
540
  key: "addNewOrder",
1041
541
  value: function () {
1042
- var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
542
+ var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
1043
543
  var tempOrder;
1044
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1045
- while (1) switch (_context9.prev = _context9.next) {
544
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
545
+ while (1) switch (_context4.prev = _context4.next) {
1046
546
  case 0:
1047
- _context9.prev = 0;
547
+ _context4.prev = 0;
1048
548
  if (this.store.order) {
1049
- _context9.next = 3;
549
+ _context4.next = 3;
1050
550
  break;
1051
551
  }
1052
552
  throw new Error('order 模块未初始化');
1053
553
  case 3:
1054
- _context9.next = 5;
554
+ _context4.next = 5;
1055
555
  return this.store.order.addNewOrder();
1056
556
  case 5:
1057
- tempOrder = _context9.sent;
1058
- if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
1059
- _context9.next = 10;
1060
- break;
1061
- }
1062
- this.store.order.persistTempOrder();
1063
- _context9.next = 10;
1064
- return this.store.order.saveDraft();
1065
- case 10:
1066
- return _context9.abrupt("return", tempOrder);
1067
- case 13:
1068
- _context9.prev = 13;
1069
- _context9.t0 = _context9["catch"](0);
1070
- throw _context9.t0;
1071
- case 16:
557
+ tempOrder = _context4.sent;
558
+ return _context4.abrupt("return", tempOrder);
559
+ case 9:
560
+ _context4.prev = 9;
561
+ _context4.t0 = _context4["catch"](0);
562
+ throw _context4.t0;
563
+ case 12:
1072
564
  case "end":
1073
- return _context9.stop();
565
+ return _context4.stop();
1074
566
  }
1075
- }, _callee9, this, [[0, 13]]);
567
+ }, _callee4, this, [[0, 9]]);
1076
568
  }));
1077
569
  function addNewOrder() {
1078
570
  return _addNewOrder.apply(this, arguments);
@@ -1082,22 +574,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1082
574
  }, {
1083
575
  key: "saveDraft",
1084
576
  value: function () {
1085
- var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
1086
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1087
- while (1) switch (_context10.prev = _context10.next) {
577
+ var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
578
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
579
+ while (1) switch (_context5.prev = _context5.next) {
1088
580
  case 0:
1089
581
  if (this.store.order) {
1090
- _context10.next = 2;
582
+ _context5.next = 2;
1091
583
  break;
1092
584
  }
1093
585
  throw new Error('order 模块未初始化');
1094
586
  case 2:
1095
- return _context10.abrupt("return", this.store.order.saveDraft());
587
+ return _context5.abrupt("return", this.store.order.saveDraft());
1096
588
  case 3:
1097
589
  case "end":
1098
- return _context10.stop();
590
+ return _context5.stop();
1099
591
  }
1100
- }, _callee10, this);
592
+ }, _callee5, this);
1101
593
  }));
1102
594
  function saveDraft() {
1103
595
  return _saveDraft.apply(this, arguments);
@@ -1108,113 +600,36 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1108
600
  }, {
1109
601
  key: "restoreOrder",
1110
602
  value: function () {
1111
- var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
603
+ var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
1112
604
  var tempOrder;
1113
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1114
- while (1) switch (_context11.prev = _context11.next) {
605
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
606
+ while (1) switch (_context6.prev = _context6.next) {
1115
607
  case 0:
1116
- _context11.prev = 0;
608
+ _context6.prev = 0;
1117
609
  if (this.store.order) {
1118
- _context11.next = 3;
610
+ _context6.next = 3;
1119
611
  break;
1120
612
  }
1121
613
  throw new Error('scanOrder 解决方案需要 order 模块支持');
1122
614
  case 3:
1123
615
  // this.store.resource = null;
1124
616
  tempOrder = this.store.order.restoreOrder();
1125
- this.currentSalesDetail = null;
1126
- this.discountConfigCacheKey = null;
1127
- this.hasManualDiscountSelection = false;
1128
- _context11.next = 9;
1129
- return this.effectsEmit('onTempOrderReplaced', {
1130
- tempOrder: tempOrder
1131
- });
1132
- case 9:
1133
- if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
1134
- _context11.next = 13;
1135
- break;
1136
- }
1137
- this.store.order.persistTempOrder();
1138
- _context11.next = 13;
1139
- return this.store.order.saveDraft();
1140
- case 13:
1141
- return _context11.abrupt("return", tempOrder);
1142
- case 16:
1143
- _context11.prev = 16;
1144
- _context11.t0 = _context11["catch"](0);
1145
- throw _context11.t0;
1146
- case 19:
617
+ return _context6.abrupt("return", tempOrder);
618
+ case 7:
619
+ _context6.prev = 7;
620
+ _context6.t0 = _context6["catch"](0);
621
+ throw _context6.t0;
622
+ case 10:
1147
623
  case "end":
1148
- return _context11.stop();
624
+ return _context6.stop();
1149
625
  }
1150
- }, _callee11, this, [[0, 16]]);
626
+ }, _callee6, this, [[0, 7]]);
1151
627
  }));
1152
628
  function restoreOrder() {
1153
629
  return _restoreOrder.apply(this, arguments);
1154
630
  }
1155
631
  return restoreOrder;
1156
632
  }()
1157
- /**
1158
- * 仅清空 tempOrder 购物车行(products / bookings / discount_list)。
1159
- * 同步清空内存中的 salesDetail 商品/预约视图,避免编辑态仍读到旧 bookings。
1160
- */
1161
- }, {
1162
- key: "clearOrderCartLines",
1163
- value: (function () {
1164
- var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1165
- var tempOrder;
1166
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1167
- while (1) switch (_context12.prev = _context12.next) {
1168
- case 0:
1169
- _context12.prev = 0;
1170
- if (this.store.order) {
1171
- _context12.next = 3;
1172
- break;
1173
- }
1174
- throw new Error('order 模块未初始化');
1175
- case 3:
1176
- _context12.next = 5;
1177
- return this.store.order.clearOrderCartLines();
1178
- case 5:
1179
- tempOrder = _context12.sent;
1180
- if (this.currentSalesDetail) {
1181
- this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
1182
- products: [],
1183
- bookings: [],
1184
- rootBooking: null,
1185
- bookingsByProductUid: {},
1186
- discount_list: []
1187
- });
1188
- }
1189
- _context12.next = 9;
1190
- return this.effectsEmit('onTempOrderReplaced', {
1191
- tempOrder: tempOrder
1192
- });
1193
- case 9:
1194
- if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
1195
- _context12.next = 13;
1196
- break;
1197
- }
1198
- this.store.order.persistTempOrder();
1199
- _context12.next = 13;
1200
- return this.store.order.saveDraft();
1201
- case 13:
1202
- return _context12.abrupt("return", tempOrder);
1203
- case 16:
1204
- _context12.prev = 16;
1205
- _context12.t0 = _context12["catch"](0);
1206
- throw _context12.t0;
1207
- case 19:
1208
- case "end":
1209
- return _context12.stop();
1210
- }
1211
- }, _callee12, this, [[0, 16]]);
1212
- }));
1213
- function clearOrderCartLines() {
1214
- return _clearOrderCartLines.apply(this, arguments);
1215
- }
1216
- return clearOrderCartLines;
1217
- }())
1218
633
  }, {
1219
634
  key: "getOrderProducts",
1220
635
  value: function getOrderProducts() {
@@ -1225,433 +640,38 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1225
640
  }, {
1226
641
  key: "getSummary",
1227
642
  value: function () {
1228
- var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
643
+ var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
1229
644
  var summary;
1230
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1231
- while (1) switch (_context13.prev = _context13.next) {
645
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
646
+ while (1) switch (_context7.prev = _context7.next) {
1232
647
  case 0:
1233
- _context13.prev = 0;
648
+ _context7.prev = 0;
1234
649
  if (this.store.order) {
1235
- _context13.next = 3;
650
+ _context7.next = 3;
1236
651
  break;
1237
652
  }
1238
653
  throw new Error('order 模块未初始化');
1239
654
  case 3:
1240
- _context13.next = 5;
655
+ _context7.next = 5;
1241
656
  return this.store.order.getOrderSummary();
1242
657
  case 5:
1243
- summary = _context13.sent;
1244
- return _context13.abrupt("return", summary);
658
+ summary = _context7.sent;
659
+ return _context7.abrupt("return", summary);
1245
660
  case 9:
1246
- _context13.prev = 9;
1247
- _context13.t0 = _context13["catch"](0);
1248
- throw _context13.t0;
661
+ _context7.prev = 9;
662
+ _context7.t0 = _context7["catch"](0);
663
+ throw _context7.t0;
1249
664
  case 12:
1250
665
  case "end":
1251
- return _context13.stop();
666
+ return _context7.stop();
1252
667
  }
1253
- }, _callee13, this, [[0, 9]]);
668
+ }, _callee7, this, [[0, 9]]);
1254
669
  }));
1255
670
  function getSummary() {
1256
671
  return _getSummary.apply(this, arguments);
1257
672
  }
1258
673
  return getSummary;
1259
674
  }()
1260
- }, {
1261
- key: "getHistoricalProductDiscountList",
1262
- value: function getHistoricalProductDiscountList(products) {
1263
- var _this5 = this;
1264
- var historyDiscountList = [];
1265
- products.forEach(function (item) {
1266
- if (!_this5.isPersistedOrderProduct(item)) return;
1267
- (item.discount_list || []).forEach(function (discount) {
1268
- var _discount$discount, _discount$metadata, _discount$discount2, _discount$discount3, _discount$discount4;
1269
- var discountId = ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id;
1270
- if (!discountId || !['good_pass', 'discount_card'].includes(discount.type)) return;
1271
- var quantity = item.quantity || item.num || item.product_quantity || 1;
1272
- var savedAmount = new Decimal(discount.amount || 0).times(quantity).plus((discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.product_discount_difference) || 0);
1273
- var index = historyDiscountList.findIndex(function (n) {
1274
- return n.id === discountId;
1275
- });
1276
- if (index !== -1) {
1277
- historyDiscountList[index] = _objectSpread(_objectSpread({}, historyDiscountList[index]), {}, {
1278
- amount: new Decimal(historyDiscountList[index].amount || 0).plus(discount.amount || 0).toNumber(),
1279
- savedAmount: savedAmount.plus(historyDiscountList[index].savedAmount || 0).toNumber()
1280
- });
1281
- return;
1282
- }
1283
- historyDiscountList.push(_objectSpread(_objectSpread({}, discount), {}, {
1284
- id: discountId,
1285
- tag: discount.tag || discount.type,
1286
- name: discount.name || ((_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 || (_discount$discount2 = _discount$discount2.title) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.auto),
1287
- format_title: ((_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.title) || discount.format_title,
1288
- isEditMode: true,
1289
- limited_relation_product_data: {},
1290
- savedAmount: savedAmount.toNumber(),
1291
- isAvailable: true,
1292
- isDisabled: true,
1293
- isSelected: true,
1294
- product_id: ((_discount$discount4 = discount.discount) === null || _discount$discount4 === void 0 ? void 0 : _discount$discount4.product_id) || discount.product_id
1295
- }));
1296
- });
1297
- });
1298
- return historyDiscountList;
1299
- }
1300
- }, {
1301
- key: "isPersistedOrderProduct",
1302
- value: function isPersistedOrderProduct(product) {
1303
- var _product$order_detail, _product$booking_id;
1304
- var orderDetailId = (_product$order_detail = product.order_detail_id) !== null && _product$order_detail !== void 0 ? _product$order_detail : product.orderDetailId;
1305
- if (orderDetailId !== undefined && orderDetailId !== null && orderDetailId !== '') {
1306
- return true;
1307
- }
1308
- var bookingId = (_product$booking_id = product.booking_id) !== null && _product$booking_id !== void 0 ? _product$booking_id : product.bookingId;
1309
- return bookingId !== undefined && bookingId !== null && bookingId !== '';
1310
- }
1311
- }, {
1312
- key: "mergeHistoricalDiscountList",
1313
- value: function mergeHistoricalDiscountList(discountList, products) {
1314
- var historyDiscountList = this.getHistoricalProductDiscountList(products);
1315
- var historyIds = new Set(historyDiscountList.map(function (discount) {
1316
- return discount.id;
1317
- }));
1318
- return [].concat(_toConsumableArray(historyDiscountList), _toConsumableArray((discountList || []).filter(function (discount) {
1319
- return !historyIds.has(discount.id);
1320
- })));
1321
- }
1322
- }, {
1323
- key: "shouldSkipAutoApplyFetchedDiscountsInEditMode",
1324
- value: function shouldSkipAutoApplyFetchedDiscountsInEditMode(params) {
1325
- var _this6 = this;
1326
- if (params.discountAction !== 'edit') return false;
1327
- if (!params.products.length) return false;
1328
- var hasDraftProduct = params.products.some(function (product) {
1329
- return !_this6.isPersistedOrderProduct(product);
1330
- });
1331
- if (hasDraftProduct) return false;
1332
- var hasSelectedDiscount = params.currentDiscountList.some(function (discount) {
1333
- return discount.isSelected || discount.isEditMode || discount.isManualSelect;
1334
- });
1335
- if (hasSelectedDiscount) return false;
1336
- return !params.nextDiscountList.some(function (discount) {
1337
- return discount.isSelected || discount.isEditMode || discount.isManualSelect;
1338
- });
1339
- }
1340
- }, {
1341
- key: "mergeCurrentDiscountSelectionState",
1342
- value: function mergeCurrentDiscountSelectionState(discountList, currentDiscountList) {
1343
- if (!currentDiscountList.length) return discountList;
1344
- var currentDiscountMap = new Map(currentDiscountList.map(function (discount) {
1345
- return [discount.id, discount];
1346
- }));
1347
- return discountList.map(function (discount) {
1348
- var currentDiscount = currentDiscountMap.get(discount.id);
1349
- if (!currentDiscount) return discount;
1350
- if (currentDiscount.isManualSelect) {
1351
- return _objectSpread(_objectSpread({}, discount), {}, {
1352
- isSelected: false,
1353
- isManualSelect: true
1354
- });
1355
- }
1356
- if (currentDiscount.isSelected) {
1357
- return _objectSpread(_objectSpread({}, discount), {}, {
1358
- isSelected: true,
1359
- isManualSelect: false
1360
- });
1361
- }
1362
- return discount;
1363
- });
1364
- }
1365
- }, {
1366
- key: "loadDiscountConfig",
1367
- value: function () {
1368
- var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
1369
- var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi, _discountModule$getOr, _discountModule$getDi2;
1370
- var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _tempOrder$holder, _tempOrder$holder2, _orderStore$summary, holders, result, _iterator, _step, _product$metadata5, _tempOrder$_extend3, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
1371
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1372
- while (1) switch (_context14.prev = _context14.next) {
1373
- case 0:
1374
- if (this.store.order) {
1375
- _context14.next = 2;
1376
- break;
1377
- }
1378
- throw new Error('order 模块未初始化');
1379
- case 2:
1380
- tempOrder = this.store.order.ensureTempOrder();
1381
- orderStore = this.store.order.store || {};
1382
- discountModule = orderStore.discount;
1383
- rulesModule = orderStore.rules;
1384
- orderId = tempOrder.order_id || ((_this$getOrderIdentit = this.getOrderIdentity) === null || _this$getOrderIdentit === void 0 || (_this$getOrderIdentit = _this$getOrderIdentit.call(this)) === null || _this$getOrderIdentit === void 0 ? void 0 : _this$getOrderIdentit.orderId);
1385
- customerId = Number((params === null || params === void 0 ? void 0 : params.customerId) || tempOrder.customer_id || ((_tempOrder$customer = tempOrder.customer) === null || _tempOrder$customer === void 0 ? void 0 : _tempOrder$customer.id) || ((_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend.customerSnapshot) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.id) || ((_tempOrder$_extend2 = tempOrder._extend) === null || _tempOrder$_extend2 === void 0 || (_tempOrder$_extend2 = _tempOrder$_extend2.customerSnapshot) === null || _tempOrder$_extend2 === void 0 ? void 0 : _tempOrder$_extend2.customer_id) || 0);
1386
- currentDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
1387
- originalDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
1388
- hasManualDiscountSelection = this.hasManualDiscountSelection || currentDiscountList.some(function (discount) {
1389
- return discount.isManualSelect;
1390
- });
1391
- discountAction = (params === null || params === void 0 ? void 0 : params.action) || (orderId ? 'edit' : 'create');
1392
- discountConfigCacheKey = [customerId, discountAction, Number(orderId) || 0].join(':');
1393
- preparedDiscountList = [];
1394
- if (!(customerId && customerId !== 1)) {
1395
- _context14.next = 25;
1396
- break;
1397
- }
1398
- if (!(this.discountConfigCacheKey === discountConfigCacheKey)) {
1399
- _context14.next = 19;
1400
- break;
1401
- }
1402
- preparedDiscountList = originalDiscountList;
1403
- _context14.next = 25;
1404
- break;
1405
- case 19:
1406
- _context14.next = 21;
1407
- return this.store.order.loadDiscountConfig({
1408
- customerId: customerId,
1409
- action: discountAction,
1410
- orderId: Number(orderId) || undefined,
1411
- apply: false
1412
- });
1413
- case 21:
1414
- preparedDiscountList = _context14.sent;
1415
- this.discountConfigCacheKey = discountConfigCacheKey;
1416
- _context14.next = 25;
1417
- return discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, preparedDiscountList);
1418
- case 25:
1419
- if (!(hasManualDiscountSelection && currentDiscountList.length)) {
1420
- _context14.next = 27;
1421
- break;
1422
- }
1423
- return _context14.abrupt("return", {
1424
- productList: tempOrder.products || [],
1425
- discountList: currentDiscountList
1426
- });
1427
- case 27:
1428
- nextDiscountList = this.mergeHistoricalDiscountList(preparedDiscountList || (discountModule === null || discountModule === void 0 || (_discountModule$getDi2 = discountModule.getDiscountList) === null || _discountModule$getDi2 === void 0 ? void 0 : _discountModule$getDi2.call(discountModule)) || [], tempOrder.products || []);
1429
- nextDiscountList = this.mergeCurrentDiscountSelectionState(nextDiscountList, currentDiscountList);
1430
- _context14.next = 31;
1431
- return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
1432
- case 31:
1433
- shouldSkipAutoApplyFetchedDiscounts = this.shouldSkipAutoApplyFetchedDiscountsInEditMode({
1434
- discountAction: discountAction,
1435
- products: tempOrder.products || [],
1436
- currentDiscountList: currentDiscountList,
1437
- nextDiscountList: nextDiscountList
1438
- });
1439
- if (!shouldSkipAutoApplyFetchedDiscounts) {
1440
- _context14.next = 40;
1441
- break;
1442
- }
1443
- _context14.next = 35;
1444
- return this.store.order.recalculateSummary({
1445
- createIfMissing: true
1446
- });
1447
- case 35:
1448
- _summary = _context14.sent;
1449
- this.store.order.persistTempOrder();
1450
- _context14.next = 39;
1451
- return this.effectsEmit('onDiscountApplied', {
1452
- productList: tempOrder.products || [],
1453
- discountList: nextDiscountList,
1454
- selectedDiscountList: tempOrder.discount_list || [],
1455
- tempOrder: tempOrder
1456
- });
1457
- case 39:
1458
- return _context14.abrupt("return", {
1459
- productList: tempOrder.products || [],
1460
- discountList: nextDiscountList
1461
- });
1462
- case 40:
1463
- if (!rulesModule) {
1464
- _context14.next = 76;
1465
- break;
1466
- }
1467
- holders = (_tempOrder$holder = tempOrder.holder) !== null && _tempOrder$holder !== void 0 && _tempOrder$holder.form_record_id ? [{
1468
- form_record_id: tempOrder.holder.form_record_id
1469
- }] : [];
1470
- result = rulesModule.calcDiscount({
1471
- productList: tempOrder.products,
1472
- discountList: nextDiscountList,
1473
- holders: holders,
1474
- isFormSubject: !!((_tempOrder$holder2 = tempOrder.holder) !== null && _tempOrder$holder2 !== void 0 && _tempOrder$holder2.type) && tempOrder.holder.type === 'form',
1475
- orderTotalAmount: Number(((_orderStore$summary = orderStore.summary) === null || _orderStore$summary === void 0 ? void 0 : _orderStore$summary.total_amount) || 0)
1476
- }) || {
1477
- productList: tempOrder.products,
1478
- discountList: nextDiscountList
1479
- };
1480
- if (result.productList) {
1481
- tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
1482
- }
1483
- _iterator = _createForOfIteratorHelper(tempOrder.products || []);
1484
- _context14.prev = 45;
1485
- _iterator.s();
1486
- case 47:
1487
- if ((_step = _iterator.n()).done) {
1488
- _context14.next = 62;
1489
- break;
1490
- }
1491
- product = _step.value;
1492
- productUid = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number;
1493
- runtimeOrigin = productUid ? (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3.productsByUid) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3[productUid]) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.origin : undefined;
1494
- if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
1495
- _context14.next = 53;
1496
- break;
1497
- }
1498
- return _context14.abrupt("continue", 60);
1499
- case 53:
1500
- totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
1501
- return sum + Number(pd.amount || 0);
1502
- }, 0);
1503
- optionSum = sumOptionUnitPrice(getProductSkuOptions(product));
1504
- sourcePrice = (_product$metadata$sou = (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : '0';
1505
- newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
1506
- newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
1507
- if (product.metadata) {
1508
- product.metadata.main_product_selling_price = newMainSellingPrice;
1509
- product.metadata.price_schema_version = 2;
1510
- }
1511
- product.selling_price = composeLinePrice({
1512
- mainPrice: newMainSellingPrice,
1513
- bundle: product.product_bundle
1514
- });
1515
- case 60:
1516
- _context14.next = 47;
1517
- break;
1518
- case 62:
1519
- _context14.next = 67;
1520
- break;
1521
- case 64:
1522
- _context14.prev = 64;
1523
- _context14.t0 = _context14["catch"](45);
1524
- _iterator.e(_context14.t0);
1525
- case 67:
1526
- _context14.prev = 67;
1527
- _iterator.f();
1528
- return _context14.finish(67);
1529
- case 70:
1530
- if (!result.discountList) {
1531
- _context14.next = 76;
1532
- break;
1533
- }
1534
- nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
1535
- OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
1536
- _context14.next = 75;
1537
- return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
1538
- case 75:
1539
- tempOrder.discount_list = nextDiscountList.filter(function (discount) {
1540
- return discount.isSelected;
1541
- });
1542
- case 76:
1543
- _context14.next = 78;
1544
- return this.store.order.recalculateSummary({
1545
- createIfMissing: true
1546
- });
1547
- case 78:
1548
- summary = _context14.sent;
1549
- this.store.order.persistTempOrder();
1550
- _context14.next = 82;
1551
- return this.effectsEmit('onDiscountApplied', {
1552
- productList: tempOrder.products || [],
1553
- discountList: nextDiscountList,
1554
- selectedDiscountList: tempOrder.discount_list || [],
1555
- tempOrder: tempOrder
1556
- });
1557
- case 82:
1558
- return _context14.abrupt("return", {
1559
- productList: tempOrder.products || [],
1560
- discountList: nextDiscountList
1561
- });
1562
- case 83:
1563
- case "end":
1564
- return _context14.stop();
1565
- }
1566
- }, _callee14, this, [[45, 64, 67, 70]]);
1567
- }));
1568
- function loadDiscountConfig(_x9) {
1569
- return _loadDiscountConfig.apply(this, arguments);
1570
- }
1571
- return loadDiscountConfig;
1572
- }()
1573
- }, {
1574
- key: "bestDiscount",
1575
- value: function () {
1576
- var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(cb) {
1577
- var _discountModule$getOr2, _discountModule$getDi3;
1578
- var tempOrder, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _tempOrder$holder3, _tempOrder$holder4, _orderStore$summary2, holders;
1579
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1580
- while (1) switch (_context15.prev = _context15.next) {
1581
- case 0:
1582
- if (this.store.order) {
1583
- _context15.next = 2;
1584
- break;
1585
- }
1586
- throw new Error('order 模块未初始化');
1587
- case 2:
1588
- tempOrder = this.store.order.ensureTempOrder();
1589
- orderStore = this.store.order.store || {};
1590
- discountModule = orderStore.discount;
1591
- rulesModule = orderStore.rules;
1592
- originalDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getOr2 = discountModule.getOriginalDiscountList) === null || _discountModule$getOr2 === void 0 ? void 0 : _discountModule$getOr2.call(discountModule)) || this.getDiscountList();
1593
- currentDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getDi3 = discountModule.getDiscountList) === null || _discountModule$getDi3 === void 0 ? void 0 : _discountModule$getDi3.call(discountModule)) || [];
1594
- nextDiscountList = this.mergeHistoricalDiscountList(originalDiscountList || [], tempOrder.products || []);
1595
- result = {
1596
- productList: tempOrder.products || [],
1597
- discountList: nextDiscountList
1598
- };
1599
- _context15.next = 12;
1600
- return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
1601
- case 12:
1602
- if (!rulesModule) {
1603
- _context15.next = 23;
1604
- break;
1605
- }
1606
- holders = (_tempOrder$holder3 = tempOrder.holder) !== null && _tempOrder$holder3 !== void 0 && _tempOrder$holder3.form_record_id ? [{
1607
- form_record_id: tempOrder.holder.form_record_id
1608
- }] : [];
1609
- result = rulesModule.calcDiscount({
1610
- productList: tempOrder.products,
1611
- discountList: nextDiscountList,
1612
- holders: holders,
1613
- isFormSubject: !!((_tempOrder$holder4 = tempOrder.holder) !== null && _tempOrder$holder4 !== void 0 && _tempOrder$holder4.type) && tempOrder.holder.type === 'form',
1614
- orderTotalAmount: Number(((_orderStore$summary2 = orderStore.summary) === null || _orderStore$summary2 === void 0 ? void 0 : _orderStore$summary2.total_amount) || 0)
1615
- }) || result;
1616
- if (result.productList) {
1617
- tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
1618
- }
1619
- if (!result.discountList) {
1620
- _context15.next = 23;
1621
- break;
1622
- }
1623
- nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
1624
- OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
1625
- _context15.next = 21;
1626
- return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
1627
- case 21:
1628
- tempOrder.discount_list = nextDiscountList.filter(function (discount) {
1629
- return discount.isSelected;
1630
- });
1631
- result = {
1632
- productList: tempOrder.products,
1633
- discountList: nextDiscountList
1634
- };
1635
- case 23:
1636
- _context15.next = 25;
1637
- return this.store.order.recalculateSummary({
1638
- createIfMissing: true
1639
- });
1640
- case 25:
1641
- this.store.order.persistTempOrder();
1642
- cb === null || cb === void 0 || cb(result);
1643
- return _context15.abrupt("return", result);
1644
- case 28:
1645
- case "end":
1646
- return _context15.stop();
1647
- }
1648
- }, _callee15, this);
1649
- }));
1650
- function bestDiscount(_x10) {
1651
- return _bestDiscount.apply(this, arguments);
1652
- }
1653
- return bestDiscount;
1654
- }()
1655
675
  }, {
1656
676
  key: "getDiscountList",
1657
677
  value: function getDiscountList() {
@@ -1661,49 +681,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1661
681
  }, {
1662
682
  key: "scanPromotionCode",
1663
683
  value: function () {
1664
- var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(code, customerId) {
684
+ var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(code, customerId) {
1665
685
  var raw;
1666
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1667
- while (1) switch (_context16.prev = _context16.next) {
686
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
687
+ while (1) switch (_context8.prev = _context8.next) {
1668
688
  case 0:
1669
- _context16.prev = 0;
689
+ _context8.prev = 0;
1670
690
  if (this.store.order) {
1671
- _context16.next = 3;
691
+ _context8.next = 3;
1672
692
  break;
1673
693
  }
1674
694
  throw new Error('order 模块未初始化');
1675
695
  case 3:
1676
- _context16.next = 5;
696
+ _context8.next = 5;
1677
697
  return this.store.order.scanCode(code, customerId);
1678
698
  case 5:
1679
- raw = _context16.sent;
699
+ raw = _context8.sent;
1680
700
  if (!raw.isAvailable) {
1681
- _context16.next = 10;
701
+ _context8.next = 10;
1682
702
  break;
1683
703
  }
1684
- _context16.next = 9;
704
+ _context8.next = 9;
1685
705
  return this.store.order.recalculateSummary({
1686
706
  createIfMissing: true
1687
707
  });
1688
708
  case 9:
1689
709
  this.store.order.persistTempOrder();
1690
710
  case 10:
1691
- return _context16.abrupt("return", {
711
+ return _context8.abrupt("return", {
1692
712
  isAvailable: raw.isAvailable,
1693
713
  type: raw.type,
1694
714
  unavailableReason: raw.unavailableReason
1695
715
  });
1696
716
  case 13:
1697
- _context16.prev = 13;
1698
- _context16.t0 = _context16["catch"](0);
1699
- throw _context16.t0;
717
+ _context8.prev = 13;
718
+ _context8.t0 = _context8["catch"](0);
719
+ throw _context8.t0;
1700
720
  case 16:
1701
721
  case "end":
1702
- return _context16.stop();
722
+ return _context8.stop();
1703
723
  }
1704
- }, _callee16, this, [[0, 13]]);
724
+ }, _callee8, this, [[0, 13]]);
1705
725
  }));
1706
- function scanPromotionCode(_x11, _x12) {
726
+ function scanPromotionCode(_x3, _x4) {
1707
727
  return _scanPromotionCode.apply(this, arguments);
1708
728
  }
1709
729
  return scanPromotionCode;
@@ -1711,14 +731,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1711
731
  }, {
1712
732
  key: "setDiscountSelected",
1713
733
  value: function () {
1714
- var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
1715
- var _tempOrder$holder5, list, updated, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder6, result, beforeSelectedIds, _iterator2, _step2, d, selectedResourceIds, _iterator3, _step3, _product$metadata8, _tempOrder$_extend4, _product$metadata$sou2, _product$metadata9, _product$metadata10, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
1716
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1717
- while (1) switch (_context17.prev = _context17.next) {
734
+ var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
735
+ var _tempOrder$holder, list, updated, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds, _iterator, _step, d, selectedResourceIds, _iterator2, _step2, _product$metadata, _tempOrder$_extend, _product$metadata2, _product$metadata$sou, _product$metadata3, _product$metadata4, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
736
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
737
+ while (1) switch (_context9.prev = _context9.next) {
1718
738
  case 0:
1719
- _context17.prev = 0;
739
+ _context9.prev = 0;
1720
740
  if (this.store.order) {
1721
- _context17.next = 3;
741
+ _context9.next = 3;
1722
742
  break;
1723
743
  }
1724
744
  throw new Error('order 模块未初始化');
@@ -1730,24 +750,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1730
750
  isManualSelect: !params.isSelected
1731
751
  }) : d;
1732
752
  });
1733
- this.hasManualDiscountSelection = true;
1734
753
  tempOrder = this.store.order.ensureTempOrder();
1735
754
  orderStore = this.store.order.store || {};
1736
755
  discountModule = orderStore.discount;
1737
756
  rulesModule = orderStore.rules;
1738
- holders = (_tempOrder$holder5 = tempOrder.holder) !== null && _tempOrder$holder5 !== void 0 && _tempOrder$holder5.form_record_id ? [{
757
+ holders = (_tempOrder$holder = tempOrder.holder) !== null && _tempOrder$holder !== void 0 && _tempOrder$holder.form_record_id ? [{
1739
758
  form_record_id: tempOrder.holder.form_record_id
1740
759
  }] : [];
1741
760
  nextDiscountList = updated;
1742
- _context17.next = 14;
761
+ _context9.next = 13;
1743
762
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
1744
- case 14:
763
+ case 13:
1745
764
  if (rulesModule) {
1746
765
  result = rulesModule.calcDiscount({
1747
766
  productList: tempOrder.products,
1748
767
  discountList: updated,
1749
768
  holders: holders,
1750
- isFormSubject: !!((_tempOrder$holder6 = tempOrder.holder) !== null && _tempOrder$holder6 !== void 0 && _tempOrder$holder6.type) && tempOrder.holder.type === 'form'
769
+ isFormSubject: !!((_tempOrder$holder2 = tempOrder.holder) !== null && _tempOrder$holder2 !== void 0 && _tempOrder$holder2.type) && tempOrder.holder.type === 'form'
1751
770
  }, {
1752
771
  discountId: params.discountId,
1753
772
  isSelected: params.isSelected
@@ -1756,7 +775,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1756
775
  discountList: updated
1757
776
  };
1758
777
  if (result !== null && result !== void 0 && result.productList) {
1759
- tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
778
+ tempOrder.products = result.productList;
1760
779
  }
1761
780
  if (result !== null && result !== void 0 && result.discountList) {
1762
781
  nextDiscountList = result.discountList;
@@ -1766,19 +785,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1766
785
  }).map(function (d) {
1767
786
  return d.id;
1768
787
  }));
1769
- _iterator2 = _createForOfIteratorHelper(nextDiscountList);
788
+ _iterator = _createForOfIteratorHelper(nextDiscountList);
1770
789
  try {
1771
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1772
- d = _step2.value;
790
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
791
+ d = _step.value;
1773
792
  if (d.isSelected && !beforeSelectedIds.has(d.id)) {
1774
793
  d.isSelected = false;
1775
- d.isManualSelect = true;
1776
794
  }
1777
795
  }
1778
796
  } catch (err) {
1779
- _iterator2.e(err);
797
+ _iterator.e(err);
1780
798
  } finally {
1781
- _iterator2.f();
799
+ _iterator.f();
1782
800
  }
1783
801
  }
1784
802
  }
@@ -1788,23 +806,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1788
806
  }).map(function (d) {
1789
807
  return d.id;
1790
808
  }));
1791
- _iterator3 = _createForOfIteratorHelper(tempOrder.products);
1792
- _context17.prev = 17;
1793
- _iterator3.s();
1794
- case 19:
1795
- if ((_step3 = _iterator3.n()).done) {
1796
- _context17.next = 35;
809
+ _iterator2 = _createForOfIteratorHelper(tempOrder.products);
810
+ _context9.prev = 16;
811
+ _iterator2.s();
812
+ case 18:
813
+ if ((_step2 = _iterator2.n()).done) {
814
+ _context9.next = 34;
1797
815
  break;
1798
816
  }
1799
- product = _step3.value;
1800
- productUid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
1801
- runtimeOrigin = productUid ? (_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4.productsByUid) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4[productUid]) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.origin : undefined;
1802
- if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
1803
- _context17.next = 25;
817
+ product = _step2.value;
818
+ productUid = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.unique_identification_number;
819
+ runtimeOrigin = productUid ? (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend.productsByUid) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend[productUid]) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.origin : undefined;
820
+ if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || (_product$metadata2 = product.metadata) !== null && _product$metadata2 !== void 0 && _product$metadata2.is_manual_discount)) {
821
+ _context9.next = 24;
1804
822
  break;
1805
823
  }
1806
- return _context17.abrupt("continue", 33);
1807
- case 25:
824
+ return _context9.abrupt("continue", 32);
825
+ case 24:
1808
826
  product.discount_list = (product.discount_list || []).filter(function (pd) {
1809
827
  var _pd$discount$resource, _pd$discount;
1810
828
  var rid = (_pd$discount$resource = (_pd$discount = pd.discount) === null || _pd$discount === void 0 ? void 0 : _pd$discount.resource_id) !== null && _pd$discount$resource !== void 0 ? _pd$discount$resource : pd.id;
@@ -1816,8 +834,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1816
834
  totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
1817
835
  return sum + (pd.amount || 0);
1818
836
  }, 0); // TODO 这块逻辑需要拿掉
1819
- optionSum = sumOptionUnitPrice(getProductSkuOptions(product));
1820
- sourcePrice = (_product$metadata$sou2 = (_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.source_product_price) !== null && _product$metadata$sou2 !== void 0 ? _product$metadata$sou2 : ((_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri2 = product.original_price) !== null && _product$original_pri2 !== void 0 ? _product$original_pri2 : '0';
837
+ optionSum = sumOptionUnitPrice(product.product_option_item);
838
+ sourcePrice = (_product$metadata$sou = (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : '0';
1821
839
  newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
1822
840
  newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
1823
841
  if (product.metadata) {
@@ -1828,134 +846,66 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1828
846
  mainPrice: newMainSellingPrice,
1829
847
  bundle: product.product_bundle
1830
848
  });
1831
- case 33:
1832
- _context17.next = 19;
849
+ case 32:
850
+ _context9.next = 18;
1833
851
  break;
1834
- case 35:
1835
- _context17.next = 40;
852
+ case 34:
853
+ _context9.next = 39;
1836
854
  break;
1837
- case 37:
1838
- _context17.prev = 37;
1839
- _context17.t0 = _context17["catch"](17);
1840
- _iterator3.e(_context17.t0);
1841
- case 40:
1842
- _context17.prev = 40;
1843
- _iterator3.f();
1844
- return _context17.finish(40);
1845
- case 43:
855
+ case 36:
856
+ _context9.prev = 36;
857
+ _context9.t0 = _context9["catch"](16);
858
+ _iterator2.e(_context9.t0);
859
+ case 39:
860
+ _context9.prev = 39;
861
+ _iterator2.f();
862
+ return _context9.finish(39);
863
+ case 42:
1846
864
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
1847
- _context17.next = 46;
865
+ _context9.next = 45;
1848
866
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
1849
- case 46:
867
+ case 45:
1850
868
  tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
1851
869
  return d.isSelected;
1852
870
  });
1853
- _context17.next = 49;
871
+ _context9.next = 48;
1854
872
  return this.store.order.recalculateSummary({
1855
873
  createIfMissing: true
1856
874
  });
1857
- case 49:
875
+ case 48:
1858
876
  this.store.order.persistTempOrder();
1859
- this.effectsEmit('onDiscountApplied', {
1860
- productList: tempOrder.products,
1861
- discountList: nextDiscountList,
1862
- selectedDiscountList: tempOrder.discount_list,
1863
- tempOrder: tempOrder
1864
- });
1865
- _context17.next = 56;
877
+ _context9.next = 54;
1866
878
  break;
1867
- case 53:
1868
- _context17.prev = 53;
1869
- _context17.t1 = _context17["catch"](0);
1870
- throw _context17.t1;
1871
- case 56:
879
+ case 51:
880
+ _context9.prev = 51;
881
+ _context9.t1 = _context9["catch"](0);
882
+ throw _context9.t1;
883
+ case 54:
1872
884
  case "end":
1873
- return _context17.stop();
885
+ return _context9.stop();
1874
886
  }
1875
- }, _callee17, this, [[0, 53], [17, 37, 40, 43]]);
887
+ }, _callee9, this, [[0, 51], [16, 36, 39, 42]]);
1876
888
  }));
1877
- function setDiscountSelected(_x13) {
889
+ function setDiscountSelected(_x5) {
1878
890
  return _setDiscountSelected.apply(this, arguments);
1879
891
  }
1880
892
  return setDiscountSelected;
1881
893
  }()
1882
- }, {
1883
- key: "applyDiscountCalculationResult",
1884
- value: function () {
1885
- var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(result) {
1886
- var tempOrder, orderStore, discountModule;
1887
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1888
- while (1) switch (_context18.prev = _context18.next) {
1889
- case 0:
1890
- _context18.prev = 0;
1891
- if (this.store.order) {
1892
- _context18.next = 3;
1893
- break;
1894
- }
1895
- throw new Error('order 模块未初始化');
1896
- case 3:
1897
- if (result) {
1898
- _context18.next = 5;
1899
- break;
1900
- }
1901
- return _context18.abrupt("return");
1902
- case 5:
1903
- tempOrder = this.store.order.ensureTempOrder();
1904
- orderStore = this.store.order.store || {};
1905
- discountModule = orderStore.discount;
1906
- if (result.productList) {
1907
- tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
1908
- }
1909
- if (!result.discountList) {
1910
- _context18.next = 14;
1911
- break;
1912
- }
1913
- OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
1914
- _context18.next = 13;
1915
- return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(result.discountList);
1916
- case 13:
1917
- tempOrder.discount_list = result.discountList.filter(function (discount) {
1918
- return discount.isSelected;
1919
- });
1920
- case 14:
1921
- _context18.next = 16;
1922
- return this.store.order.recalculateSummary({
1923
- createIfMissing: true
1924
- });
1925
- case 16:
1926
- this.store.order.persistTempOrder();
1927
- _context18.next = 22;
1928
- break;
1929
- case 19:
1930
- _context18.prev = 19;
1931
- _context18.t0 = _context18["catch"](0);
1932
- throw _context18.t0;
1933
- case 22:
1934
- case "end":
1935
- return _context18.stop();
1936
- }
1937
- }, _callee18, this, [[0, 19]]);
1938
- }));
1939
- function applyDiscountCalculationResult(_x14) {
1940
- return _applyDiscountCalculationResult.apply(this, arguments);
1941
- }
1942
- return applyDiscountCalculationResult;
1943
- }()
1944
894
  }, {
1945
895
  key: "submitScanOrder",
1946
896
  value: function () {
1947
- var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
1948
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1949
- while (1) switch (_context19.prev = _context19.next) {
897
+ var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
898
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
899
+ while (1) switch (_context10.prev = _context10.next) {
1950
900
  case 0:
1951
- return _context19.abrupt("return", this.submitSalesOrder(params));
901
+ return _context10.abrupt("return", this.submitSalesOrder(params));
1952
902
  case 1:
1953
903
  case "end":
1954
- return _context19.stop();
904
+ return _context10.stop();
1955
905
  }
1956
- }, _callee19, this);
906
+ }, _callee10, this);
1957
907
  }));
1958
- function submitScanOrder(_x15) {
908
+ function submitScanOrder(_x6) {
1959
909
  return _submitScanOrder.apply(this, arguments);
1960
910
  }
1961
911
  return submitScanOrder;
@@ -1969,246 +919,67 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1969
919
  }, {
1970
920
  key: "submitSalesOrder",
1971
921
  value: (function () {
1972
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
1973
- var _this$otherParams6, _this$otherParams7, _this$otherParams8, _this$otherParams9;
1974
- var inferredPaymentStatus, submitParams;
1975
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1976
- while (1) switch (_context20.prev = _context20.next) {
922
+ var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
923
+ var _this$otherParams2, _this$otherParams3, _this$otherParams4, _this$otherParams5;
924
+ var submitParams;
925
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
926
+ while (1) switch (_context11.prev = _context11.next) {
1977
927
  case 0:
1978
928
  if (this.store.order) {
1979
- _context20.next = 2;
929
+ _context11.next = 2;
1980
930
  break;
1981
931
  }
1982
932
  throw new Error('BaseSales 解决方案需要 order 模块支持');
1983
933
  case 2:
1984
- // this.store.order.persistTempOrder();
1985
- inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
934
+ this.store.order.persistTempOrder();
1986
935
  submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
1987
936
  cacheId: this.cacheId,
1988
- platform: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform,
1989
- businessCode: ((_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) || ((_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code),
1990
- channel: this.getSubmitOrderSalesChannel(),
1991
- type: (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.type,
1992
- request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
937
+ platform: (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.platform,
938
+ businessCode: (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.businessCode,
939
+ channel: (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.channel,
940
+ type: (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.type
1993
941
  }, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
1994
942
  payments: params.payments
1995
- } : {}), inferredPaymentStatus !== undefined ? {
1996
- paymentStatus: inferredPaymentStatus
943
+ } : {}), (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined ? {
944
+ paymentStatus: params.paymentStatus
1997
945
  } : {}), (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined ? {
1998
946
  smallTicketDataFlag: params.smallTicketDataFlag
1999
947
  } : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
2000
948
  enhancePayload: params.enhancePayload
2001
949
  } : {});
2002
- return _context20.abrupt("return", this.store.order.submitTempOrder(submitParams));
950
+ return _context11.abrupt("return", this.store.order.submitTempOrder(submitParams));
2003
951
  case 5:
2004
952
  case "end":
2005
- return _context20.stop();
953
+ return _context11.stop();
2006
954
  }
2007
- }, _callee20, this);
955
+ }, _callee11, this);
2008
956
  }));
2009
- function submitSalesOrder(_x16) {
957
+ function submitSalesOrder(_x7) {
2010
958
  return _submitSalesOrder.apply(this, arguments);
2011
959
  }
2012
960
  return submitSalesOrder;
2013
961
  }())
2014
- }, {
2015
- key: "submitTempOrderAsync",
2016
- value: function () {
2017
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
2018
- var _this$otherParams10, _this$otherParams11, _this$otherParams12, _this$otherParams13;
2019
- var inferredPaymentStatus, submitParams;
2020
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2021
- while (1) switch (_context21.prev = _context21.next) {
2022
- case 0:
2023
- if (this.store.order) {
2024
- _context21.next = 2;
2025
- break;
2026
- }
2027
- throw new Error('BaseSales 解决方案需要 order 模块支持');
2028
- case 2:
2029
- inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
2030
- submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
2031
- cacheId: this.cacheId,
2032
- platform: (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform,
2033
- businessCode: ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code),
2034
- channel: this.getSubmitOrderSalesChannel(),
2035
- type: (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.type
2036
- }, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
2037
- payments: params.payments
2038
- } : {}), inferredPaymentStatus !== undefined ? {
2039
- paymentStatus: inferredPaymentStatus
2040
- } : {}), (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined ? {
2041
- smallTicketDataFlag: params.smallTicketDataFlag
2042
- } : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
2043
- enhancePayload: params.enhancePayload
2044
- } : {});
2045
- return _context21.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
2046
- case 5:
2047
- case "end":
2048
- return _context21.stop();
2049
- }
2050
- }, _callee21, this);
2051
- }));
2052
- function submitTempOrderAsync(_x17) {
2053
- return _submitTempOrderAsync.apply(this, arguments);
2054
- }
2055
- return submitTempOrderAsync;
2056
- }()
2057
- }, {
2058
- key: "printLocalOrderReceipt",
2059
- value: function () {
2060
- var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(lookup) {
2061
- var _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17;
2062
- var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order3, _data;
2063
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2064
- while (1) switch (_context22.prev = _context22.next) {
2065
- case 0:
2066
- if (this.store.order) {
2067
- _context22.next = 2;
2068
- break;
2069
- }
2070
- throw new Error('BaseSales 解决方案需要 order 模块支持');
2071
- case 2:
2072
- hasLookup = lookup !== undefined && lookup !== null && lookup !== '';
2073
- lookupPayload = typeof lookup === 'number' ? {
2074
- order_id: lookup
2075
- } : {
2076
- external_sale_number: lookup
2077
- };
2078
- context = {
2079
- platform: (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.platform,
2080
- businessCode: ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.businessCode) || ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.business_code),
2081
- channel: this.getSubmitOrderSalesChannel(),
2082
- type: (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.type
2083
- };
2084
- payload = hasLookup ? _objectSpread(_objectSpread({}, lookupPayload), {}, {
2085
- lookup_order_from_db: 1,
2086
- small_ticket_data_flag: 1,
2087
- platform: context.platform,
2088
- business_code: context.businessCode,
2089
- order_sales_channel: context.channel,
2090
- type: context.type
2091
- }) : this.store.order.buildCurrentSubmitPayloadForLocalPrint({
2092
- cacheId: this.cacheId,
2093
- platform: context.platform,
2094
- businessCode: context.businessCode,
2095
- channel: context.channel,
2096
- type: context.type
2097
- });
2098
- _context22.next = 8;
2099
- return this.request.post('/local/print-order', payload, {
2100
- osServer: true,
2101
- customToast: function customToast() {}
2102
- });
2103
- case 8:
2104
- response = _context22.sent;
2105
- if (hasLookup) {
2106
- _context22.next = 12;
2107
- break;
2108
- }
2109
- _context22.next = 12;
2110
- return (_this$store$order$app = (_this$store$order3 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order3, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
2111
- case 12:
2112
- return _context22.abrupt("return", response);
2113
- case 13:
2114
- case "end":
2115
- return _context22.stop();
2116
- }
2117
- }, _callee22, this);
2118
- }));
2119
- function printLocalOrderReceipt(_x18) {
2120
- return _printLocalOrderReceipt.apply(this, arguments);
2121
- }
2122
- return printLocalOrderReceipt;
2123
- }()
2124
- }, {
2125
- key: "getSubmitPaymentStatus",
2126
- value: function getSubmitPaymentStatus(paymentStatus) {
2127
- var _this$store$order4, _this$store$order4$ge;
2128
- if (paymentStatus !== undefined) return paymentStatus;
2129
- var amountSnapshot = (_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 || (_this$store$order4$ge = _this$store$order4.getOrderAmountSnapshot) === null || _this$store$order4$ge === void 0 ? void 0 : _this$store$order4$ge.call(_this$store$order4);
2130
- if (!amountSnapshot) return undefined;
2131
- try {
2132
- return new Decimal(amountSnapshot.amountGap || 0).lte(0) ? 'paid' : undefined;
2133
- } catch (_unused2) {
2134
- return undefined;
2135
- }
2136
- }
2137
962
  }, {
2138
963
  key: "syncPaymentsToOrder",
2139
964
  value: function () {
2140
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
2141
- var _ref12, _params$businessCode, _this$otherParams18, _this$otherParams19, _params$channel;
2142
- var businessCode, channel, syncParams, syncState, payments, syncResult;
2143
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2144
- while (1) switch (_context23.prev = _context23.next) {
965
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params) {
966
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
967
+ while (1) switch (_context12.prev = _context12.next) {
2145
968
  case 0:
2146
969
  if (this.store.order) {
2147
- _context23.next = 2;
970
+ _context12.next = 2;
2148
971
  break;
2149
972
  }
2150
973
  throw new Error('order 模块未初始化');
2151
974
  case 2:
2152
- businessCode = (_ref12 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.businessCode) !== null && _ref12 !== void 0 ? _ref12 : (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.business_code;
2153
- channel = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel();
2154
- syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), businessCode !== undefined ? {
2155
- businessCode: businessCode
2156
- } : {}), channel !== undefined ? {
2157
- channel: channel
2158
- } : {});
2159
- syncState = this.store.order.getOrderSyncState();
2160
- if (!(params.submitWhenPaid && syncState === 'submitting')) {
2161
- _context23.next = 8;
2162
- break;
2163
- }
2164
- return _context23.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
2165
- case 8:
2166
- payments = params.payments || [];
2167
- _context23.next = 11;
2168
- return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
2169
- payments: payments,
2170
- params: syncParams,
2171
- amountSnapshot: this.store.order.getOrderAmountSnapshot(),
2172
- orderSnapshot: this.store.order.getOrderSnapshot()
2173
- });
2174
- case 11:
2175
- _context23.prev = 11;
2176
- _context23.next = 14;
2177
- return this.store.order.syncPaymentsToOrder(syncParams);
2178
- case 14:
2179
- syncResult = _context23.sent;
2180
- _context23.next = 17;
2181
- return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
2182
- ok: true,
2183
- syncResult: syncResult,
2184
- payments: this.store.order.getOrderPayments(),
2185
- params: syncParams,
2186
- amountSnapshot: this.store.order.getOrderAmountSnapshot(),
2187
- orderSnapshot: this.store.order.getOrderSnapshot()
2188
- });
2189
- case 17:
2190
- return _context23.abrupt("return", syncResult);
2191
- case 20:
2192
- _context23.prev = 20;
2193
- _context23.t0 = _context23["catch"](11);
2194
- _context23.next = 24;
2195
- return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
2196
- ok: false,
2197
- error: _context23.t0,
2198
- payments: this.store.order.getOrderPayments(),
2199
- params: syncParams,
2200
- amountSnapshot: this.store.order.getOrderAmountSnapshot(),
2201
- orderSnapshot: this.store.order.getOrderSnapshot()
2202
- });
2203
- case 24:
2204
- throw _context23.t0;
2205
- case 25:
975
+ return _context12.abrupt("return", this.store.order.syncPaymentsToOrder(params));
976
+ case 3:
2206
977
  case "end":
2207
- return _context23.stop();
978
+ return _context12.stop();
2208
979
  }
2209
- }, _callee23, this, [[11, 20]]);
980
+ }, _callee12, this);
2210
981
  }));
2211
- function syncPaymentsToOrder(_x19) {
982
+ function syncPaymentsToOrder(_x8) {
2212
983
  return _syncPaymentsToOrder.apply(this, arguments);
2213
984
  }
2214
985
  return syncPaymentsToOrder;
@@ -2217,8 +988,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2217
988
  key: "getOrderPayments",
2218
989
  value: function getOrderPayments() {
2219
990
  if (!this.store.order) return [];
2220
- var payments = this.store.order.getOrderPayments();
2221
- return this.hydrateOrderPaymentNames(payments);
991
+ return this.store.order.getOrderPayments();
2222
992
  }
2223
993
 
2224
994
  /** 覆盖当前订单支付项,内部由 OrderModule 清洗为 Sales 协议字段。 */
@@ -2233,51 +1003,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2233
1003
  }, {
2234
1004
  key: "addOrderPayment",
2235
1005
  value: function addOrderPayment(payment) {
2236
- var _this$otherParams20,
2237
- _paymentRecord$paymen,
2238
- _paymentRecord$create,
2239
- _this7 = this;
2240
1006
  if (!this.store.order) throw new Error('order 模块未初始化');
2241
- var paymentRecord = payment;
2242
- var paymentAmount = new Decimal(paymentRecord.amount || 0);
2243
- if (paymentAmount.isZero()) {
2244
- this.logWarning('addOrderPayment: 支付金额为 0,跳过添加支付项', {
2245
- payment: paymentRecord
2246
- });
2247
- return this.store.order.getOrderPayments();
2248
- }
2249
- var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
2250
- var shopWalletPassId = (_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.shop_wallet_pass_id;
2251
- if (shopWalletPassId !== undefined && shopWalletPassId !== null) {
2252
- metadata.shop_wallet_pass_id = shopWalletPassId;
2253
- }
2254
- if (!metadata.unique_payment_number) {
2255
- metadata.unique_payment_number = createUuidV4();
2256
- }
2257
- var paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
2258
- var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
2259
- var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
2260
- var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread({}, paymentRecord), {}, {
2261
- metadata: metadata,
2262
- payment_time: paymentTime,
2263
- created_at: createdAt
2264
- }));
2265
- var amountSnapshot = this.store.order.getOrderAmountSnapshot();
2266
- var syncState = this.store.order.getOrderSyncState();
2267
- if (amountSnapshot && syncState !== 'submitting') {
2268
- var paymentStatus = Number(amountSnapshot.amountGap || 0) <= 0 ? 'paid' : 'partially_paid';
2269
- void this.syncPaymentsToOrder({
2270
- payments: payments,
2271
- paymentStatus: paymentStatus,
2272
- submitWhenPaid: true,
2273
- smallTicketDataFlag: 1
2274
- }).catch(function (error) {
2275
- _this7.logError('auto sync payments failed', {
2276
- error: error instanceof Error ? error.message : String(error)
2277
- });
2278
- });
2279
- } else {}
2280
- return payments;
1007
+ return this.store.order.addOrderPayment(payment);
2281
1008
  }
2282
1009
 
2283
1010
  /** 更新当前订单中的指定支付项。 */
@@ -2306,25 +1033,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2306
1033
  }, {
2307
1034
  key: "getWalletProductList",
2308
1035
  value: function getWalletProductList() {
2309
- var _this$store$order5, _tempOrder$products, _tempOrder$products2;
2310
- var tempOrder = (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 ? void 0 : _this$store$order5.getTempOrder();
1036
+ var _this$store$order2, _tempOrder$products;
1037
+ var tempOrder = (_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 ? void 0 : _this$store$order2.getTempOrder();
2311
1038
  if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return [];
2312
- // 过滤出有 product_id的商品来,如果没有代表他是自定义商品,不需要参与 wallet
2313
- var products = tempOrder === null || tempOrder === void 0 || (_tempOrder$products2 = tempOrder.products) === null || _tempOrder$products2 === void 0 ? void 0 : _tempOrder$products2.filter(function (n) {
2314
- return n.product_id;
2315
- });
2316
- var walletProducts = products.map(function (product) {
2317
- var _product$product_vari2, _product$is_charge_ta, _product$holder_id, _metadata$main_produc, _metadata$main_produc2;
1039
+ return tempOrder.products.map(function (product) {
1040
+ var _product$product_vari, _product$is_charge_ta, _product$holder_id, _metadata$main_produc, _metadata$main_produc2;
2318
1041
  var metadata = product.metadata || {};
2319
1042
  return {
2320
1043
  product_id: product.product_id,
2321
- product_variant_id: String((_product$product_vari2 = product.product_variant_id) !== null && _product$product_vari2 !== void 0 ? _product$product_vari2 : ''),
1044
+ product_variant_id: String((_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : ''),
2322
1045
  quantity: product.num || 1,
2323
1046
  is_price_include_tax: tempOrder.is_price_include_tax,
2324
1047
  is_charge_tax: (_product$is_charge_ta = product.is_charge_tax) !== null && _product$is_charge_ta !== void 0 ? _product$is_charge_ta : 0,
2325
1048
  tax_fee: product.tax_fee,
2326
1049
  selling_price: Number(product.selling_price || 0),
2327
- discount_list: product.discount_list || [],
2328
1050
  holder_id: (_product$holder_id = product.holder_id) !== null && _product$holder_id !== void 0 ? _product$holder_id : metadata.holder_id,
2329
1051
  original_price: product.original_price,
2330
1052
  main_product_original_price: (_metadata$main_produc = metadata.main_product_original_price) !== null && _metadata$main_produc !== void 0 ? _metadata$main_produc : product.original_price,
@@ -2335,14 +1057,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2335
1057
  surcharge_rounding_remainder: metadata.surcharge_rounding_remainder
2336
1058
  },
2337
1059
  product_bundle: (product.product_bundle || []).map(function (bundle) {
2338
- var _bundle$bundle_id2, _bundle$bundle_produc2, _bundle$bundle_group_2;
2339
1060
  var bundleMetadata = bundle.metadata || {};
2340
1061
  return {
2341
1062
  is_price_include_tax: tempOrder.is_price_include_tax,
2342
- // 套餐子项在 tempOrder 上常为 id(如 1718),prepare/deduction 协议要求 bundle_id
2343
- bundle_id: (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id,
2344
- bundle_product_id: (_bundle$bundle_produc2 = bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle._bundle_product_id,
2345
- bundle_group_id: (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id,
1063
+ bundle_id: bundle.bundle_id,
1064
+ bundle_product_id: bundle.bundle_product_id,
2346
1065
  bundle_variant_id: bundle.bundle_variant_id,
2347
1066
  price_type: bundle.price_type,
2348
1067
  price_type_ext: bundle.price_type_ext,
@@ -2359,25 +1078,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2359
1078
  })
2360
1079
  };
2361
1080
  });
2362
- return walletProducts;
2363
1081
  }
2364
1082
  }, {
2365
1083
  key: "initWalletData",
2366
1084
  value: function () {
2367
- var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
2368
- var _params$order_wait_pa, _ref13, _tempOrder$is_price_i;
1085
+ var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(params) {
1086
+ var _params$order_wait_pa, _ref, _tempOrder$is_price_i;
2369
1087
  var snapshot, tempOrder, amount, walletBusinessData, result;
2370
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2371
- while (1) switch (_context24.prev = _context24.next) {
1088
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1089
+ while (1) switch (_context13.prev = _context13.next) {
2372
1090
  case 0:
2373
1091
  if (this.store.order) {
2374
- _context24.next = 2;
1092
+ _context13.next = 2;
2375
1093
  break;
2376
1094
  }
2377
1095
  throw new Error('order 模块未初始化');
2378
1096
  case 2:
2379
1097
  if (this.store.payment) {
2380
- _context24.next = 4;
1098
+ _context13.next = 4;
2381
1099
  break;
2382
1100
  }
2383
1101
  throw new Error('payment 模块未初始化');
@@ -2386,10 +1104,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2386
1104
  tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
2387
1105
  amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
2388
1106
  if (!(!tempOrder || !amount)) {
2389
- _context24.next = 9;
1107
+ _context13.next = 9;
2390
1108
  break;
2391
1109
  }
2392
- return _context24.abrupt("return", {
1110
+ return _context13.abrupt("return", {
2393
1111
  walletRecommendList: [],
2394
1112
  userIdentificationCodes: [],
2395
1113
  transformList: [],
@@ -2408,15 +1126,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2408
1126
  },
2409
1127
  products: this.getWalletProductList(),
2410
1128
  order_wait_pay_amount: (_params$order_wait_pa = params === null || params === void 0 ? void 0 : params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : Number(amount.amountGap || 0),
2411
- is_price_include_tax: (_ref13 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref13 !== void 0 ? _ref13 : 1
1129
+ is_price_include_tax: (_ref = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref !== void 0 ? _ref : 1
2412
1130
  }, snapshot.identity.orderId ? {
2413
1131
  payment_order_id: String(snapshot.identity.orderId)
2414
1132
  } : {});
2415
- _context24.next = 12;
1133
+ _context13.next = 12;
2416
1134
  return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
2417
1135
  case 12:
2418
- result = _context24.sent;
2419
- _context24.next = 15;
1136
+ result = _context13.sent;
1137
+ _context13.next = 15;
2420
1138
  return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
2421
1139
  orderId: snapshot.identity.orderId,
2422
1140
  customerId: walletBusinessData.customer_id,
@@ -2428,14 +1146,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2428
1146
  timestamp: Date.now()
2429
1147
  });
2430
1148
  case 15:
2431
- return _context24.abrupt("return", result);
1149
+ return _context13.abrupt("return", result);
2432
1150
  case 16:
2433
1151
  case "end":
2434
- return _context24.stop();
1152
+ return _context13.stop();
2435
1153
  }
2436
- }, _callee24, this);
1154
+ }, _callee13, this);
2437
1155
  }));
2438
- function initWalletData(_x20) {
1156
+ function initWalletData(_x9) {
2439
1157
  return _initWalletData.apply(this, arguments);
2440
1158
  }
2441
1159
  return initWalletData;
@@ -2462,48 +1180,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2462
1180
  }, {
2463
1181
  key: "getPaymentMethodsAsync",
2464
1182
  value: (function () {
2465
- var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
2466
- var response, paymentMethods;
2467
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2468
- while (1) switch (_context25.prev = _context25.next) {
1183
+ var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1184
+ var response;
1185
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1186
+ while (1) switch (_context14.prev = _context14.next) {
2469
1187
  case 0:
2470
- _context25.prev = 0;
2471
- _context25.next = 3;
2472
- return this.request.get('/pay/custom-payment/all', {
2473
- filterPaymentMethods: true
2474
- }, {
2475
- osServer: true
2476
- });
2477
- case 3:
2478
- response = _context25.sent;
2479
- paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
2480
- this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
2481
- return _context25.abrupt("return", this.getPaymentMethods());
2482
- case 9:
2483
- _context25.prev = 9;
2484
- _context25.t0 = _context25["catch"](0);
2485
- this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
2486
- error: _context25.t0 instanceof Error ? _context25.t0.message : String(_context25.t0)
2487
- });
2488
- return _context25.abrupt("return", this.getPaymentMethods());
2489
- case 13:
1188
+ if (!this.store.payment) {
1189
+ _context14.next = 2;
1190
+ break;
1191
+ }
1192
+ return _context14.abrupt("return", this.store.payment.getPayMethodListAsync());
1193
+ case 2:
1194
+ _context14.next = 4;
1195
+ return this.request.get('/pay/custom-payment/all');
1196
+ case 4:
1197
+ response = _context14.sent;
1198
+ return _context14.abrupt("return", (response === null || response === void 0 ? void 0 : response.data) || []);
1199
+ case 6:
2490
1200
  case "end":
2491
- return _context25.stop();
1201
+ return _context14.stop();
2492
1202
  }
2493
- }, _callee25, this, [[0, 9]]);
1203
+ }, _callee14, this);
2494
1204
  }));
2495
1205
  function getPaymentMethodsAsync() {
2496
1206
  return _getPaymentMethodsAsync.apply(this, arguments);
2497
1207
  }
2498
1208
  return getPaymentMethodsAsync;
2499
- }() /** 同步读取初始化时缓存的支付方式列表。 */)
2500
- }, {
2501
- key: "getPaymentMethods",
2502
- value: function getPaymentMethods() {
2503
- return _toConsumableArray(this.paymentMethodsCache);
2504
- }
2505
-
2506
- /** 轻量舍入能力,供现金支付 UI 计算 rounding_amount。 */
1209
+ }() /** 轻量舍入能力,供现金支付 UI 计算 rounding_amount。 */)
2507
1210
  }, {
2508
1211
  key: "roundAmount",
2509
1212
  value: function roundAmount(params) {
@@ -2538,49 +1241,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2538
1241
  }, {
2539
1242
  key: "sendCustomerPayLink",
2540
1243
  value: (function () {
2541
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
2542
- var orderIds, _ref14, _ref15, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
2543
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2544
- while (1) switch (_context26.prev = _context26.next) {
1244
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
1245
+ var orderIds, _ref2, _ref3, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
1246
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1247
+ while (1) switch (_context15.prev = _context15.next) {
2545
1248
  case 0:
2546
1249
  if (this.store.order) {
2547
- _context26.next = 2;
1250
+ _context15.next = 2;
2548
1251
  break;
2549
1252
  }
2550
1253
  throw new Error('order 模块未初始化');
2551
1254
  case 2:
2552
1255
  orderIds = params.order_ids || params.orderIds || [];
2553
1256
  if (!(!orderIds.length || params.submitBeforeSend)) {
2554
- _context26.next = 11;
1257
+ _context15.next = 11;
2555
1258
  break;
2556
1259
  }
2557
- _context26.next = 6;
1260
+ _context15.next = 6;
2558
1261
  return this.submitSalesOrder({
2559
1262
  smallTicketDataFlag: 1
2560
1263
  });
2561
1264
  case 6:
2562
- submitResult = _context26.sent;
2563
- orderId = (_ref14 = (_ref15 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref15 !== void 0 ? _ref15 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref14 !== void 0 ? _ref14 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
1265
+ submitResult = _context15.sent;
1266
+ orderId = (_ref2 = (_ref3 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref3 !== void 0 ? _ref3 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref2 !== void 0 ? _ref2 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
2564
1267
  if (orderId) {
2565
- _context26.next = 10;
1268
+ _context15.next = 10;
2566
1269
  break;
2567
1270
  }
2568
1271
  throw new Error('本地订单提交云端失败,无法发送支付链接');
2569
1272
  case 10:
2570
1273
  orderIds = [orderId];
2571
1274
  case 11:
2572
- return _context26.abrupt("return", this.store.order.sendCustomerPayLink({
1275
+ return _context15.abrupt("return", this.store.order.sendCustomerPayLink({
2573
1276
  emails: params.emails,
2574
1277
  notify_action: params.notify_action,
2575
1278
  order_ids: orderIds
2576
1279
  }));
2577
1280
  case 12:
2578
1281
  case "end":
2579
- return _context26.stop();
1282
+ return _context15.stop();
2580
1283
  }
2581
- }, _callee26, this);
1284
+ }, _callee15, this);
2582
1285
  }));
2583
- function sendCustomerPayLink(_x21) {
1286
+ function sendCustomerPayLink(_x10) {
2584
1287
  return _sendCustomerPayLink.apply(this, arguments);
2585
1288
  }
2586
1289
  return sendCustomerPayLink;
@@ -2590,162 +1293,76 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2590
1293
  value: function transformBaseProductToOrderProduct(params) {
2591
1294
  return _transformBaseProductToOrderProduct(params);
2592
1295
  }
2593
- }, {
2594
- key: "calculateProductBookingPrice",
2595
- value: function () {
2596
- var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
2597
- var _params$customer_id;
2598
- var quotation, customerId, authoritativeProduct, product;
2599
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2600
- while (1) switch (_context27.prev = _context27.next) {
2601
- case 0:
2602
- quotation = this.store.quotation;
2603
- customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
2604
- _context27.next = 4;
2605
- return this.loadProductForPriceQuery(params, customerId);
2606
- case 4:
2607
- authoritativeProduct = _context27.sent;
2608
- product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
2609
- _context27.next = 8;
2610
- return this.loadQuotationForPriceQuery({
2611
- quotation: quotation,
2612
- customer_id: customerId,
2613
- channel: params.channel
2614
- });
2615
- case 8:
2616
- return _context27.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
2617
- product: product,
2618
- fallback_price: authoritativeProduct ? undefined : params.fallback_price,
2619
- customer_id: customerId,
2620
- quotation: quotation
2621
- })));
2622
- case 9:
2623
- case "end":
2624
- return _context27.stop();
2625
- }
2626
- }, _callee27, this);
2627
- }));
2628
- function calculateProductBookingPrice(_x22) {
2629
- return _calculateProductBookingPrice.apply(this, arguments);
2630
- }
2631
- return calculateProductBookingPrice;
2632
- }()
2633
1296
  }, {
2634
1297
  key: "addProductToOrder",
2635
1298
  value: function () {
2636
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(product, booking) {
1299
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(product, booking) {
2637
1300
  var products;
2638
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2639
- while (1) switch (_context28.prev = _context28.next) {
1301
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1302
+ while (1) switch (_context16.prev = _context16.next) {
2640
1303
  case 0:
2641
- _context28.prev = 0;
1304
+ _context16.prev = 0;
2642
1305
  if (this.store.order) {
2643
- _context28.next = 3;
1306
+ _context16.next = 3;
2644
1307
  break;
2645
1308
  }
2646
1309
  throw new Error('order 模块未初始化');
2647
1310
  case 3:
2648
- _context28.next = 5;
1311
+ _context16.next = 5;
2649
1312
  return this.store.order.addProductToOrder(product, booking);
2650
1313
  case 5:
2651
- products = _context28.sent;
2652
- return _context28.abrupt("return", products);
1314
+ products = _context16.sent;
1315
+ return _context16.abrupt("return", products);
2653
1316
  case 9:
2654
- _context28.prev = 9;
2655
- _context28.t0 = _context28["catch"](0);
2656
- throw _context28.t0;
1317
+ _context16.prev = 9;
1318
+ _context16.t0 = _context16["catch"](0);
1319
+ throw _context16.t0;
2657
1320
  case 12:
2658
1321
  case "end":
2659
- return _context28.stop();
1322
+ return _context16.stop();
2660
1323
  }
2661
- }, _callee28, this, [[0, 9]]);
1324
+ }, _callee16, this, [[0, 9]]);
2662
1325
  }));
2663
- function addProductToOrder(_x23, _x24) {
1326
+ function addProductToOrder(_x11, _x12) {
2664
1327
  return _addProductToOrder.apply(this, arguments);
2665
1328
  }
2666
1329
  return addProductToOrder;
2667
1330
  }()
2668
1331
  }, {
2669
- key: "updateOrderProduct",
1332
+ key: "updateProductInOrder",
2670
1333
  value: function () {
2671
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
1334
+ var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
2672
1335
  var products;
2673
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2674
- while (1) switch (_context29.prev = _context29.next) {
2675
- case 0:
2676
- _context29.prev = 0;
2677
- if (this.store.order) {
2678
- _context29.next = 3;
2679
- break;
2680
- }
2681
- throw new Error('order 模块未初始化');
2682
- case 3:
2683
- _context29.next = 5;
2684
- return this.store.order.updateOrderProduct(params);
2685
- case 5:
2686
- products = _context29.sent;
2687
- return _context29.abrupt("return", products);
2688
- case 9:
2689
- _context29.prev = 9;
2690
- _context29.t0 = _context29["catch"](0);
2691
- throw _context29.t0;
2692
- case 12:
2693
- case "end":
2694
- return _context29.stop();
2695
- }
2696
- }, _callee29, this, [[0, 9]]);
2697
- }));
2698
- function updateOrderProduct(_x25) {
2699
- return _updateOrderProduct.apply(this, arguments);
2700
- }
2701
- return updateOrderProduct;
2702
- }()
2703
- }, {
2704
- key: "updateOrderProductQuantity",
2705
- value: function () {
2706
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
2707
- var products;
2708
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2709
- while (1) switch (_context30.prev = _context30.next) {
1336
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1337
+ while (1) switch (_context17.prev = _context17.next) {
2710
1338
  case 0:
2711
- _context30.prev = 0;
1339
+ _context17.prev = 0;
2712
1340
  if (this.store.order) {
2713
- _context30.next = 3;
1341
+ _context17.next = 3;
2714
1342
  break;
2715
1343
  }
2716
1344
  throw new Error('order 模块未初始化');
2717
1345
  case 3:
2718
- _context30.next = 5;
2719
- return this.store.order.updateOrderProductQuantity(params);
1346
+ _context17.next = 5;
1347
+ return this.store.order.updateProductInOrder(params);
2720
1348
  case 5:
2721
- products = _context30.sent;
2722
- return _context30.abrupt("return", products);
1349
+ products = _context17.sent;
1350
+ return _context17.abrupt("return", products);
2723
1351
  case 9:
2724
- _context30.prev = 9;
2725
- _context30.t0 = _context30["catch"](0);
2726
- throw _context30.t0;
1352
+ _context17.prev = 9;
1353
+ _context17.t0 = _context17["catch"](0);
1354
+ throw _context17.t0;
2727
1355
  case 12:
2728
1356
  case "end":
2729
- return _context30.stop();
1357
+ return _context17.stop();
2730
1358
  }
2731
- }, _callee30, this, [[0, 9]]);
1359
+ }, _callee17, this, [[0, 9]]);
2732
1360
  }));
2733
- function updateOrderProductQuantity(_x26) {
2734
- return _updateOrderProductQuantity.apply(this, arguments);
1361
+ function updateProductInOrder(_x13) {
1362
+ return _updateProductInOrder.apply(this, arguments);
2735
1363
  }
2736
- return updateOrderProductQuantity;
1364
+ return updateProductInOrder;
2737
1365
  }()
2738
- }, {
2739
- key: "updateOrderBooking",
2740
- value: function updateOrderBooking(params) {
2741
- try {
2742
- if (!this.store.order) throw new Error('order 模块未初始化');
2743
- return this.store.order.updateOrderBooking(params);
2744
- } catch (error) {
2745
- throw error;
2746
- }
2747
- }
2748
-
2749
1366
  /**
2750
1367
  * 设置单行商品备注(与整单 `updateTempOrderNote` 区分)。
2751
1368
  * 多行同 SKU 时必须传入与删除/更新一致的 unique_identification_number。
@@ -2753,12 +1370,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2753
1370
  }, {
2754
1371
  key: "setOrderProductLineNote",
2755
1372
  value: (function () {
2756
- var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(identity, note) {
1373
+ var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(identity, note) {
2757
1374
  var params, products;
2758
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2759
- while (1) switch (_context31.prev = _context31.next) {
1375
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1376
+ while (1) switch (_context18.prev = _context18.next) {
2760
1377
  case 0:
2761
- _context31.prev = 0;
1378
+ _context18.prev = 0;
2762
1379
  params = {
2763
1380
  product_id: identity.product_id,
2764
1381
  product_variant_id: identity.product_variant_id,
@@ -2769,189 +1386,81 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2769
1386
  if (identity.unique_identification_number !== undefined) {
2770
1387
  params.unique_identification_number = identity.unique_identification_number;
2771
1388
  }
2772
- if (identity.product_sku !== undefined) {
2773
- params.product_sku = identity.product_sku;
1389
+ if (identity.product_option_item !== undefined) {
1390
+ params.product_option_item = identity.product_option_item;
2774
1391
  }
2775
1392
  if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
2776
- _context31.next = 7;
2777
- return this.updateOrderProduct(params);
1393
+ _context18.next = 7;
1394
+ return this.updateProductInOrder(params);
2778
1395
  case 7:
2779
- products = _context31.sent;
2780
- return _context31.abrupt("return", products);
1396
+ products = _context18.sent;
1397
+ return _context18.abrupt("return", products);
2781
1398
  case 11:
2782
- _context31.prev = 11;
2783
- _context31.t0 = _context31["catch"](0);
2784
- throw _context31.t0;
1399
+ _context18.prev = 11;
1400
+ _context18.t0 = _context18["catch"](0);
1401
+ throw _context18.t0;
2785
1402
  case 14:
2786
1403
  case "end":
2787
- return _context31.stop();
1404
+ return _context18.stop();
2788
1405
  }
2789
- }, _callee31, this, [[0, 11]]);
1406
+ }, _callee18, this, [[0, 11]]);
2790
1407
  }));
2791
- function setOrderProductLineNote(_x27, _x28) {
1408
+ function setOrderProductLineNote(_x14, _x15) {
2792
1409
  return _setOrderProductLineNote.apply(this, arguments);
2793
1410
  }
2794
1411
  return setOrderProductLineNote;
2795
- }()
2796
- /**
2797
- * 批量删除购物车行,末尾仅一次促销重算。
2798
- *
2799
- * @example
2800
- * await baseSales.removeProductsFromOrder([identityA, identityB]);
2801
- */
2802
- )
1412
+ }())
2803
1413
  }, {
2804
- key: "removeProductsFromOrder",
2805
- value: (function () {
2806
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(identities) {
2807
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2808
- while (1) switch (_context32.prev = _context32.next) {
1414
+ key: "removeProductFromOrder",
1415
+ value: function () {
1416
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(identity) {
1417
+ var products;
1418
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1419
+ while (1) switch (_context19.prev = _context19.next) {
2809
1420
  case 0:
2810
- _context32.prev = 0;
1421
+ _context19.prev = 0;
2811
1422
  if (this.store.order) {
2812
- _context32.next = 3;
1423
+ _context19.next = 3;
2813
1424
  break;
2814
1425
  }
2815
1426
  throw new Error('order 模块未初始化');
2816
1427
  case 3:
2817
- _context32.next = 5;
2818
- return this.store.order.removeProductsFromOrder(identities);
1428
+ _context19.next = 5;
1429
+ return this.store.order.removeProductFromOrder(identity);
2819
1430
  case 5:
2820
- return _context32.abrupt("return", _context32.sent);
2821
- case 8:
2822
- _context32.prev = 8;
2823
- _context32.t0 = _context32["catch"](0);
2824
- throw _context32.t0;
2825
- case 11:
2826
- case "end":
2827
- return _context32.stop();
2828
- }
2829
- }, _callee32, this, [[0, 8]]);
2830
- }));
2831
- function removeProductsFromOrder(_x29) {
2832
- return _removeProductsFromOrder.apply(this, arguments);
2833
- }
2834
- return removeProductsFromOrder;
2835
- }())
2836
- }, {
2837
- key: "removeProductFromOrder",
2838
- value: function () {
2839
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(identity) {
2840
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2841
- while (1) switch (_context33.prev = _context33.next) {
2842
- case 0:
2843
- return _context33.abrupt("return", this.removeProductsFromOrder([identity]));
2844
- case 1:
1431
+ products = _context19.sent;
1432
+ return _context19.abrupt("return", products);
1433
+ case 9:
1434
+ _context19.prev = 9;
1435
+ _context19.t0 = _context19["catch"](0);
1436
+ throw _context19.t0;
1437
+ case 12:
2845
1438
  case "end":
2846
- return _context33.stop();
1439
+ return _context19.stop();
2847
1440
  }
2848
- }, _callee33, this);
1441
+ }, _callee19, this, [[0, 9]]);
2849
1442
  }));
2850
- function removeProductFromOrder(_x30) {
1443
+ function removeProductFromOrder(_x16) {
2851
1444
  return _removeProductFromOrder.apply(this, arguments);
2852
1445
  }
2853
1446
  return removeProductFromOrder;
2854
- }() // ─── 促销/赠品 透传(迁移自 booking usePromotion) ────────────────
2855
- /**
2856
- * 注入促销评估器到底层 OrderModule。
2857
- *
2858
- * @example
2859
- * solution.setPromotionEvaluator(appHelper.utils.promotionEvaluator);
2860
- */
2861
- }, {
2862
- key: "setPromotionEvaluator",
2863
- value: function setPromotionEvaluator(evaluator) {
2864
- if (!this.store.order) throw new Error('order 模块未初始化');
2865
- this.store.order.setPromotionEvaluator(evaluator);
2866
- }
2867
-
2868
- /**
2869
- * 注入赠品选择 resolver。UI 层(SalesSdk)通过 bridge 提供。
2870
- *
2871
- * @example
2872
- * solution.setGiftSelectResolver(async (ctx) => bridge.request(ctx));
2873
- */
2874
- }, {
2875
- key: "setGiftSelectResolver",
2876
- value: function setGiftSelectResolver(resolver) {
2877
- if (!this.store.order) throw new Error('order 模块未初始化');
2878
- this.store.order.setGiftSelectResolver(resolver);
2879
- }
2880
-
2881
- /**
2882
- * 为商品目录追加促销标签,供 SalesSdkProductProvider 等商品列表入口复用。
2883
- *
2884
- * @example
2885
- * const products = solution.appendPromotionTags(catalogProducts);
2886
- */
2887
- }, {
2888
- key: "appendPromotionTags",
2889
- value: function appendPromotionTags(products) {
2890
- if (!this.store.order) throw new Error('order 模块未初始化');
2891
- return this.store.order.appendPromotionTags(products);
2892
- }
2893
-
2894
- /**
2895
- * 主动触发一次促销应用(一般写路径会自动触发,少数场景如客户切换后可手动调)。
2896
- */
2897
- }, {
2898
- key: "applyPromotion",
2899
- value: (function () {
2900
- var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
2901
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2902
- while (1) switch (_context34.prev = _context34.next) {
2903
- case 0:
2904
- if (this.store.order) {
2905
- _context34.next = 2;
2906
- break;
2907
- }
2908
- throw new Error('order 模块未初始化');
2909
- case 2:
2910
- _context34.next = 4;
2911
- return this.store.order.applyPromotion();
2912
- case 4:
2913
- case "end":
2914
- return _context34.stop();
2915
- }
2916
- }, _callee34, this);
2917
- }));
2918
- function applyPromotion() {
2919
- return _applyPromotion.apply(this, arguments);
2920
- }
2921
- return applyPromotion;
2922
- }() /** 最近一次促销计算输出的未满足提示。 */)
2923
- }, {
2924
- key: "getUnfulfilledPromotions",
2925
- value: function getUnfulfilledPromotions() {
2926
- var _this$store$order6;
2927
- return ((_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getUnfulfilledPromotions()) || [];
2928
- }
2929
-
2930
- /** 最近一次促销计算输出的赠品操作 diff。 */
2931
- }, {
2932
- key: "getLastGiftActions",
2933
- value: function getLastGiftActions() {
2934
- var _this$store$order7;
2935
- return ((_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getLastGiftActions()) || null;
2936
- }
2937
-
2938
- // 获取商品列表
1447
+ }() // 获取商品列表
2939
1448
  // TODO 需要跟 webpos 内的对齐一下
2940
1449
  }, {
2941
1450
  key: "getProductList",
2942
1451
  value: function () {
2943
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
2944
- var _this$otherParams21;
1452
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1453
+ var _this$otherParams6;
2945
1454
  var menu_list_ids, _this$store$products, res;
2946
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
2947
- while (1) switch (_context35.prev = _context35.next) {
1455
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1456
+ while (1) switch (_context20.prev = _context20.next) {
2948
1457
  case 0:
2949
1458
  // 可以直接通过配置里的 menu 读取
2950
- menu_list_ids = ((_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 || (_this$otherParams21 = _this$otherParams21.dineInConfig) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21['menu.associated_menus'].map(function (n) {
1459
+ menu_list_ids = ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 || (_this$otherParams6 = _this$otherParams6.dineInConfig) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6['menu.associated_menus'].map(function (n) {
2951
1460
  return Number(n.value);
2952
1461
  })) || [];
2953
- _context35.prev = 1;
2954
- _context35.next = 4;
1462
+ _context20.prev = 1;
1463
+ _context20.next = 4;
2955
1464
  return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
2956
1465
  menu_list_ids: menu_list_ids,
2957
1466
  cacheId: this.cacheId,
@@ -2959,17 +1468,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2959
1468
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
2960
1469
  });
2961
1470
  case 4:
2962
- res = _context35.sent;
2963
- return _context35.abrupt("return", res);
1471
+ res = _context20.sent;
1472
+ return _context20.abrupt("return", res);
2964
1473
  case 8:
2965
- _context35.prev = 8;
2966
- _context35.t0 = _context35["catch"](1);
2967
- throw _context35.t0;
1474
+ _context20.prev = 8;
1475
+ _context20.t0 = _context20["catch"](1);
1476
+ throw _context20.t0;
2968
1477
  case 11:
2969
1478
  case "end":
2970
- return _context35.stop();
1479
+ return _context20.stop();
2971
1480
  }
2972
- }, _callee35, this, [[1, 8]]);
1481
+ }, _callee20, this, [[1, 8]]);
2973
1482
  }));
2974
1483
  function getProductList() {
2975
1484
  return _getProductList.apply(this, arguments);
@@ -2984,33 +1493,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2984
1493
  }, {
2985
1494
  key: "setOtherParams",
2986
1495
  value: function () {
2987
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
2988
- var _this$otherParams22;
2989
- var _ref16,
2990
- _ref16$cover,
1496
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
1497
+ var _ref4,
1498
+ _ref4$cover,
2991
1499
  cover,
2992
- _args36 = arguments;
2993
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2994
- while (1) switch (_context36.prev = _context36.next) {
1500
+ _args21 = arguments;
1501
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1502
+ while (1) switch (_context21.prev = _context21.next) {
2995
1503
  case 0:
2996
- _ref16 = _args36.length > 1 && _args36[1] !== undefined ? _args36[1] : {}, _ref16$cover = _ref16.cover, cover = _ref16$cover === void 0 ? false : _ref16$cover;
1504
+ _ref4 = _args21.length > 1 && _args21[1] !== undefined ? _args21[1] : {}, _ref4$cover = _ref4.cover, cover = _ref4$cover === void 0 ? false : _ref4$cover;
2997
1505
  if (cover) {
2998
- this.otherParams = _objectSpread({}, params);
1506
+ this.otherParams = params;
2999
1507
  } else {
3000
1508
  this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
3001
1509
  }
3002
- this.cacheId = (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.cacheId;
3003
- _context36.next = 5;
3004
- return this.syncOtherParamsToSubModules(params, {
3005
- cover: cover
3006
- });
3007
- case 5:
1510
+ case 2:
3008
1511
  case "end":
3009
- return _context36.stop();
1512
+ return _context21.stop();
3010
1513
  }
3011
- }, _callee36, this);
1514
+ }, _callee21, this);
3012
1515
  }));
3013
- function setOtherParams(_x31) {
1516
+ function setOtherParams(_x17) {
3014
1517
  return _setOtherParams.apply(this, arguments);
3015
1518
  }
3016
1519
  return setOtherParams;