@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,72 +0,0 @@
1
- import { getSumCapacity } from './resources';
2
- import { TimeSlicesResult, TimeSlice, DurationSlice } from './timeSlices';
3
- /**
4
- * 上下文(与 info2 state.bookingConfig / state.service / state.date 一一对应)。
5
- *
6
- * 设计原则:所有助手函数都通过 context 显式拿数据,**不读 mini-redux**,
7
- * 让 OS 这层完全可在 Node 单测下运行(dayjs 在 Node 也是纯函数)。
8
- */
9
- export interface BookingCalcContext {
10
- /** 来自 `/core/board/management/config` 的整套配置;常用路径见 sliceTimeSlices / appointmentTimingPreference。 */
11
- bookingConfig?: any;
12
- /** 资源 origin map(id → resource origin)。 */
13
- resourcesOriginMap?: Record<string, any>;
14
- /** 资源全集列表(display_scope=all 时用)。 */
15
- resourcesOrigin?: any[];
16
- /** 当前选择的日期(dayjs 或 string)。 */
17
- date?: any;
18
- /** 上一个服务行(getServiceStartTimeAndEndTime 拼接续接 start_time 用)。可缺省。 */
19
- previousService?: any;
20
- /** 日历选中的资源 id(替代 info2 sessionStorage.serviceParams.resource_id)。 */
21
- resourceIdFromCalendar?: number;
22
- /** 资源自动分派开关(替代 info2 localStorage 'resource-auto-allocation');默认全开。 */
23
- isAutoAllocationOn?: (formId: any) => boolean;
24
- /** 当前预设开始时间(替代 info2 sessionStorage.serviceParams.start_date 取 HH:mm)。 */
25
- presetStartTime?: string;
26
- /** 店铺打烊时间(替代 info2 localStorage shopOpeningHours),默认 23:59。 */
27
- shopOpeningHours?: string;
28
- }
29
- /** 从 BookingContext.date 提取 HH:mm(仅当日期带有效时分时)。 */
30
- export declare function derivePresetStartTimeFromDate(date: any): string | undefined;
31
- /**
32
- * 时间切片对象(含灵活时长选项)。与 info2 `getTimeObj` 等价。
33
- */
34
- export declare function getTimeObj(params: {
35
- cacheItem: any;
36
- useStartTime?: string;
37
- useDuration?: number | string;
38
- ctx: BookingCalcContext;
39
- }): TimeSlicesResult & {
40
- timeSlices: TimeSlice[];
41
- durationSlicesBasedOnTime: DurationSlice[];
42
- };
43
- /**
44
- * 计算商品行 _extend(包含 start_time / endDate / duration / start_date / end_date / sub_type 等)。
45
- * 与 info2 `utilsByBooking.ts#getServiceStartTimeAndEndTime` 等价;显著差异:
46
- * - 不读 `state.service.value` / `mini-redux`,由 ctx.previousService 显式注入。
47
- * - 不读 `sessionStorage.serviceParams`,由 ctx.presetStartTime / ctx.resourceIdFromCalendar 注入。
48
- * - cacheItem.isCustomItem → 直接返回 `{ duration: null }`。
49
- */
50
- export declare function getServiceStartTimeAndEndTime(params: {
51
- cacheItem: any;
52
- timeObj: TimeSlicesResult;
53
- ctx: BookingCalcContext;
54
- }): any;
55
- /**
56
- * 综合:把 cacheItem 拼装出完整的 _extend / _data(资源 / 容量 / timeObj),并标记 autoClose。
57
- * 与 info2 `service/addService/utils.tsx#getProductExtend` 等价;剥 React `console.time` / JSX。
58
- *
59
- * 入参 ctx 必须至少给:bookingConfig / resourcesOriginMap / resourcesOrigin / date。
60
- */
61
- export declare function getProductExtend(params: {
62
- cacheItem: any;
63
- ctx: BookingCalcContext;
64
- isDisabledTime?: boolean;
65
- }): any;
66
- /**
67
- * 是否可自动关闭弹窗(不需要用户进 EditService 抽屉)。
68
- * 与 info2 `service/addService/utils.tsx#getIsAutoClose` 等价;
69
- * `getAutoAllocationStorage` 抽象为入参 `isAutoAllocationOn(formId)`。
70
- */
71
- export declare function getIsAutoClose(cacheItem: any, isAutoAllocationOn: (formId: any) => boolean): boolean;
72
- export { getSumCapacity };
@@ -1,339 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
5
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
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
- 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 _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; }
9
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
10
- 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); }
11
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
12
- 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."); }
13
- 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); }
14
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
15
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
16
- 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; }
17
- import dayjs from 'dayjs';
18
- import { formatResources, getResourceByIds, getSumCapacity, getUsableTime, setDefaultCapacitys, setDefaultResource } from "./resources";
19
- import { hasActualResourceSelection, productNeedsResourceExtend } from "./resourceSelection";
20
- import { isMultiDayProduct, isSessionProduct, getDays, getServiceTimes } from "./serviceTimes";
21
- import { sliceDayIntoFiveMinutes, findNextDuration, getEndDate } from "./timeSlices";
22
- import { flexibleObj, getDurationValue, isProductFlexibleDuration } from "./flexible";
23
-
24
- /**
25
- * 上下文(与 info2 state.bookingConfig / state.service / state.date 一一对应)。
26
- *
27
- * 设计原则:所有助手函数都通过 context 显式拿数据,**不读 mini-redux**,
28
- * 让 OS 这层完全可在 Node 单测下运行(dayjs 在 Node 也是纯函数)。
29
- */
30
-
31
- /** 从 BookingContext.date 提取 HH:mm(仅当日期带有效时分时)。 */
32
- export function derivePresetStartTimeFromDate(date) {
33
- if (date == null) return undefined;
34
- var d = dayjs(date);
35
- if (!d.isValid()) return undefined;
36
- var hhmm = d.format('HH:mm');
37
- if (hhmm === '00:00') return undefined;
38
- return hhmm;
39
- }
40
-
41
- /**
42
- * 取预约时间偏好(sequential / parallel);默认 sequential。
43
- */
44
- function getAppointmentTimingPreference(ctx) {
45
- var _ctx$bookingConfig;
46
- return (ctx === null || ctx === void 0 || (_ctx$bookingConfig = ctx.bookingConfig) === null || _ctx$bookingConfig === void 0 || (_ctx$bookingConfig = _ctx$bookingConfig.config) === null || _ctx$bookingConfig === void 0 || (_ctx$bookingConfig = _ctx$bookingConfig.information_tab) === null || _ctx$bookingConfig === void 0 ? void 0 : _ctx$bookingConfig.appointment_timing_preference) || 'sequential';
47
- }
48
-
49
- /**
50
- * 灵活时长选项(cacheItem.duration.type === 'flexible' 时)。
51
- */
52
- function getFlexibleOption(params) {
53
- var _cacheItem$_extend, _cacheItem$_extend2, _usable$_extend, _params$ctx;
54
- var cacheItem = params.cacheItem,
55
- useStartTime = params.useStartTime;
56
- var duration = getDurationValue(cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.duration);
57
- if (duration !== 'flexible') return null;
58
- var startDate = dayjs("".concat(dayjs(cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.start_date).format('YYYY-MM-DD'), " ").concat(useStartTime || (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 ? void 0 : _cacheItem$_extend2.start_time) || '00:00'));
59
- var usable = getUsableTime(cacheItem);
60
- var usableEndAt = usable !== null && usable !== void 0 && (_usable$_extend = usable._extend) !== null && _usable$_extend !== void 0 && (_usable$_extend = _usable$_extend.usableTime) !== null && _usable$_extend !== void 0 && _usable$_extend.end_at ? dayjs(usable._extend.usableTime.end_at) : null;
61
- var endDate = getEndDate(startDate, 'flexible', usableEndAt, (_params$ctx = params.ctx) === null || _params$ctx === void 0 ? void 0 : _params$ctx.shopOpeningHours);
62
- var timeValue = endDate.diff(startDate, 'minute');
63
- return {
64
- label: String(timeValue),
65
- value: flexibleObj.create(timeValue)
66
- };
67
- }
68
-
69
- /**
70
- * 时间切片对象(含灵活时长选项)。与 info2 `getTimeObj` 等价。
71
- */
72
- export function getTimeObj(params) {
73
- var _ctx$bookingConfig2;
74
- var cacheItem = params.cacheItem,
75
- useStartTime = params.useStartTime,
76
- useDuration = params.useDuration,
77
- ctx = params.ctx;
78
- var isMultiDay = isMultiDayProduct(cacheItem);
79
- var flexibleOption = getFlexibleOption({
80
- cacheItem: cacheItem,
81
- useStartTime: useStartTime,
82
- ctx: ctx
83
- });
84
- var baseSlices = sliceDayIntoFiveMinutes(ctx === null || ctx === void 0 || (_ctx$bookingConfig2 = ctx.bookingConfig) === null || _ctx$bookingConfig2 === void 0 || (_ctx$bookingConfig2 = _ctx$bookingConfig2.config) === null || _ctx$bookingConfig2 === void 0 || (_ctx$bookingConfig2 = _ctx$bookingConfig2.basic) === null || _ctx$bookingConfig2 === void 0 ? void 0 : _ctx$bookingConfig2.service_time, isMultiDay);
85
- var timeSlices = _toConsumableArray(baseSlices.timeSlices);
86
- var durationSlicesBasedOnTime = _toConsumableArray(baseSlices.durationSlicesBasedOnTime);
87
- if (flexibleOption) {
88
- durationSlicesBasedOnTime.unshift(flexibleOption);
89
- }
90
- if (useDuration && !durationSlicesBasedOnTime.some(function (d) {
91
- return d.value === useDuration;
92
- })) {
93
- durationSlicesBasedOnTime.unshift({
94
- label: String(useDuration),
95
- value: useDuration
96
- });
97
- }
98
- return {
99
- timeSlices: timeSlices,
100
- durationSlicesBasedOnTime: durationSlicesBasedOnTime
101
- };
102
- }
103
-
104
- /**
105
- * 计算商品行 _extend(包含 start_time / endDate / duration / start_date / end_date / sub_type 等)。
106
- * 与 info2 `utilsByBooking.ts#getServiceStartTimeAndEndTime` 等价;显著差异:
107
- * - 不读 `state.service.value` / `mini-redux`,由 ctx.previousService 显式注入。
108
- * - 不读 `sessionStorage.serviceParams`,由 ctx.presetStartTime / ctx.resourceIdFromCalendar 注入。
109
- * - cacheItem.isCustomItem → 直接返回 `{ duration: null }`。
110
- */
111
- export function getServiceStartTimeAndEndTime(params) {
112
- var _cacheItem$_extend3;
113
- var cacheItem = params.cacheItem,
114
- timeObj = params.timeObj,
115
- ctx = params.ctx;
116
- if (cacheItem !== null && cacheItem !== void 0 && cacheItem.isCustomItem) {
117
- return {
118
- duration: null
119
- };
120
- }
121
- var appointmentTimingPreference = getAppointmentTimingPreference(ctx);
122
- var lastServer = ctx.previousService || null;
123
- var resolveDuration = function resolveDuration() {
124
- var _cacheItem$duration;
125
- if (isMultiDayProduct(cacheItem)) return getDays(cacheItem, 'days');
126
- return findNextDuration(cacheItem.duration, timeObj.durationSlicesBasedOnTime, cacheItem === null || cacheItem === void 0 || (_cacheItem$duration = cacheItem.duration) === null || _cacheItem$duration === void 0 ? void 0 : _cacheItem$duration.value);
127
- };
128
- var _extend = {
129
- duration: resolveDuration()
130
- };
131
- if (lastServer) {
132
- var _lastServer$_extend, _lastServer$_extend2;
133
- var lastStart = (_lastServer$_extend = lastServer._extend) === null || _lastServer$_extend === void 0 ? void 0 : _lastServer$_extend.startDate;
134
- var lastEnd = (_lastServer$_extend2 = lastServer._extend) === null || _lastServer$_extend2 === void 0 ? void 0 : _lastServer$_extend2.endDate;
135
- if (appointmentTimingPreference === 'parallel') {
136
- _extend.start_time = dayjs(lastStart).format('HH:mm');
137
- } else if (dayjs(lastEnd).isAfter(dayjs(lastStart), 'day')) {
138
- var _timeObj$timeSlices;
139
- _extend.start_time = (_timeObj$timeSlices = timeObj.timeSlices[timeObj.timeSlices.length - 1]) === null || _timeObj$timeSlices === void 0 ? void 0 : _timeObj$timeSlices.value;
140
- } else {
141
- _extend.start_time = lastEnd ? dayjs(lastEnd).format('HH:mm') : dayjs().format('HH:mm');
142
- }
143
- } else {
144
- var presetStartTime = ctx.presetStartTime;
145
- // 与 info2 getServiceStartTimeAndEndTime 一致:日历/顶部日期带 HH:mm 时原样使用,
146
- // 不做 findNextSlice 栅格对齐(否则 01:47 会被抬到 01:50)。
147
- if (presetStartTime && presetStartTime !== '00:00') {
148
- _extend.start_time = presetStartTime;
149
- } else if (cacheItem.currentDefaultTime) {
150
- _extend.start_time = cacheItem.currentDefaultTime;
151
- } else {
152
- _extend.start_time = dayjs().format('HH:mm');
153
- }
154
- }
155
- _extend = _objectSpread(_objectSpread({}, _extend), cacheItem._extend);
156
- var _getServiceTimes = getServiceTimes(_objectSpread(_objectSpread({}, cacheItem), {}, {
157
- _extend: _extend
158
- })),
159
- startDate = _getServiceTimes.startDate,
160
- endDate = _getServiceTimes.endDate;
161
- _extend.startDate = startDate;
162
- _extend.endDate = endDate;
163
- if (isMultiDayProduct(cacheItem)) {
164
- var _extend$start_date, _extend$end_date;
165
- _extend.start_time = _extend.start_time || startDate.format('HH:mm');
166
- _extend.end_time = _extend.end_time || endDate.format('HH:mm');
167
- _extend.start_date = (_extend$start_date = _extend.start_date) !== null && _extend$start_date !== void 0 ? _extend$start_date : startDate;
168
- _extend.end_date = (_extend$end_date = _extend.end_date) !== null && _extend$end_date !== void 0 ? _extend$end_date : endDate;
169
- }
170
- var session = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend3 = cacheItem._extend) === null || _cacheItem$_extend3 === void 0 || (_cacheItem$_extend3 = _cacheItem$_extend3.other) === null || _cacheItem$_extend3 === void 0 ? void 0 : _cacheItem$_extend3.session;
171
- if (isSessionProduct(cacheItem) && session) {
172
- var baseDate = ctx.date ? dayjs(ctx.date) : dayjs();
173
- var startAt = dayjs("".concat(baseDate.format('YYYY-MM-DD'), " ").concat(dayjs(session.start_at).format('HH:mm:ss')));
174
- var endAt = dayjs("".concat(baseDate.format('YYYY-MM-DD'), " ").concat(dayjs(session.end_at).format('HH:mm:ss')));
175
- _extend.start_date = startAt;
176
- _extend.startDate = startAt;
177
- _extend.start_time = session.start_time;
178
- _extend.end_date = endAt;
179
- _extend.endDate = endAt;
180
- _extend.end_time = session.end_time;
181
- _extend.duration = getDays({
182
- _extend: _extend
183
- }, 'minutes');
184
- }
185
- return _extend;
186
- }
187
-
188
- /**
189
- * 综合:把 cacheItem 拼装出完整的 _extend / _data(资源 / 容量 / timeObj),并标记 autoClose。
190
- * 与 info2 `service/addService/utils.tsx#getProductExtend` 等价;剥 React `console.time` / JSX。
191
- *
192
- * 入参 ctx 必须至少给:bookingConfig / resourcesOriginMap / resourcesOrigin / date。
193
- */
194
- export function getProductExtend(params) {
195
- var _cacheItem$_extend4;
196
- var cacheItem = params.cacheItem,
197
- ctx = params.ctx,
198
- isDisabledTime = params.isDisabledTime;
199
- var isNew = cacheItem.new || !((_cacheItem$_extend4 = cacheItem._extend) !== null && _cacheItem$_extend4 !== void 0 && _cacheItem$_extend4.endDate);
200
- var _cacheItem = _objectSpread({}, cacheItem);
201
- var resourcesOriginMap = ctx.resourcesOriginMap || {};
202
- _cacheItem._data = {};
203
- if (isMultiDayProduct(cacheItem)) {
204
- var _cacheItem$_extend5;
205
- _cacheItem._extend = _cacheItem._extend || {};
206
- _cacheItem._extend.holder_id = (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend5 = cacheItem._extend) === null || _cacheItem$_extend5 === void 0 ? void 0 : _cacheItem$_extend5.holder_id) || [];
207
- _cacheItem._extend.sub_type = 'days';
208
- }
209
- if (isNew) {
210
- var _ctx$bookingConfig3;
211
- _cacheItem._data.timeObj = getTimeObj({
212
- cacheItem: cacheItem,
213
- ctx: ctx
214
- });
215
- _cacheItem._extend = getServiceStartTimeAndEndTime({
216
- cacheItem: cacheItem,
217
- timeObj: _cacheItem._data.timeObj,
218
- ctx: ctx
219
- });
220
- _cacheItem._data.capacitys = cacheItem.capacity;
221
- _cacheItem._data.resourcesOrigin = getResourceByIds(resourcesOriginMap, cacheItem, {
222
- resourceTab: ctx === null || ctx === void 0 || (_ctx$bookingConfig3 = ctx.bookingConfig) === null || _ctx$bookingConfig3 === void 0 || (_ctx$bookingConfig3 = _ctx$bookingConfig3.config) === null || _ctx$bookingConfig3 === void 0 ? void 0 : _ctx$bookingConfig3.resource_tab,
223
- resourcesOrigin: ctx.resourcesOrigin || []
224
- });
225
- _cacheItem._extend.capacity = setDefaultCapacitys({
226
- capacitys: _cacheItem._data.capacitys,
227
- cacheItem: _cacheItem
228
- });
229
- var _formatResources = formatResources({
230
- cacheItem: _cacheItem,
231
- resourcesOrigin: _cacheItem._data.resourcesOrigin
232
- }),
233
- list = _formatResources.list,
234
- maps = _formatResources.maps;
235
- _cacheItem._data.resources = list;
236
- _cacheItem._data.resourceMaps = maps;
237
- _cacheItem._extend.resource = setDefaultResource({
238
- cacheItem: _cacheItem,
239
- resources: _cacheItem._data.resources,
240
- resourceIdFromCalendar: ctx.resourceIdFromCalendar,
241
- isAutoAllocationOn: ctx.isAutoAllocationOn
242
- });
243
-
244
- // 灵活时长二次计算(资源默认选中后,按 usableTime 重算 flexible 分钟数)
245
- if (isProductFlexibleDuration(_cacheItem === null || _cacheItem === void 0 ? void 0 : _cacheItem.duration)) {
246
- var _cacheItem$_data$time;
247
- _cacheItem._data.timeObj = getTimeObj({
248
- cacheItem: _cacheItem,
249
- useStartTime: _cacheItem._extend.start_time,
250
- ctx: ctx
251
- });
252
- _cacheItem._extend.duration = (_cacheItem$_data$time = _cacheItem._data.timeObj) === null || _cacheItem$_data$time === void 0 || (_cacheItem$_data$time = _cacheItem$_data$time.durationSlicesBasedOnTime) === null || _cacheItem$_data$time === void 0 || (_cacheItem$_data$time = _cacheItem$_data$time[0]) === null || _cacheItem$_data$time === void 0 ? void 0 : _cacheItem$_data$time.value;
253
- var _getServiceTimes2 = getServiceTimes(_cacheItem),
254
- endDate = _getServiceTimes2.endDate;
255
- _cacheItem._extend.endDate = endDate;
256
- }
257
- _cacheItem.autoClose = getIsAutoClose(_cacheItem, ctx.isAutoAllocationOn || function () {
258
- return true;
259
- });
260
- if (_cacheItem._extend.bundle_edit !== undefined) {
261
- _cacheItem._extend.bundle_edit = 1;
262
- }
263
- if (!isDisabledTime) {
264
- _cacheItem._time = new Date().getTime();
265
- }
266
- } else {
267
- var _cacheItem$_extend7;
268
- if (!_cacheItem._data.capacitys) {
269
- _cacheItem._data.capacitys = cacheItem.capacity;
270
- }
271
- if (!_cacheItem._data.resourcesOrigin) {
272
- var _cacheItem$_extend6, _ctx$bookingConfig4;
273
- var extraResources = [];
274
- if (Array.isArray((_cacheItem$_extend6 = _cacheItem._extend) === null || _cacheItem$_extend6 === void 0 ? void 0 : _cacheItem$_extend6.event_resources)) {
275
- _cacheItem._extend.event_resources.forEach(function (er) {
276
- extraResources.push({
277
- form_id: er.form_id,
278
- id: er.relation_id
279
- });
280
- });
281
- }
282
- _cacheItem._data.resourcesOrigin = getResourceByIds(resourcesOriginMap, cacheItem, {
283
- extraResources: extraResources,
284
- resourceTab: ctx === null || ctx === void 0 || (_ctx$bookingConfig4 = ctx.bookingConfig) === null || _ctx$bookingConfig4 === void 0 || (_ctx$bookingConfig4 = _ctx$bookingConfig4.config) === null || _ctx$bookingConfig4 === void 0 ? void 0 : _ctx$bookingConfig4.resource_tab,
285
- resourcesOrigin: ctx.resourcesOrigin || []
286
- });
287
- }
288
- if (!_cacheItem._data.resources) {
289
- var _formatResources2 = formatResources({
290
- cacheItem: _cacheItem,
291
- resourcesOrigin: _cacheItem._data.resourcesOrigin
292
- }),
293
- _list = _formatResources2.list,
294
- _maps = _formatResources2.maps;
295
- _cacheItem._data.resources = _list;
296
- _cacheItem._data.resourceMaps = _maps;
297
- }
298
- _cacheItem._data.timeObj = getTimeObj({
299
- cacheItem: _cacheItem,
300
- useStartTime: (_cacheItem$_extend7 = _cacheItem._extend) === null || _cacheItem$_extend7 === void 0 ? void 0 : _cacheItem$_extend7.start_time,
301
- ctx: ctx
302
- });
303
- }
304
- return _cacheItem;
305
- }
306
-
307
- /**
308
- * 是否可自动关闭弹窗(不需要用户进 EditService 抽屉)。
309
- * 与 info2 `service/addService/utils.tsx#getIsAutoClose` 等价;
310
- * `getAutoAllocationStorage` 抽象为入参 `isAutoAllocationOn(formId)`。
311
- */
312
- export function getIsAutoClose(cacheItem, isAutoAllocationOn) {
313
- var _cacheItem$_data, _cacheItem$_extend8;
314
- if (productNeedsResourceExtend(cacheItem) && !hasActualResourceSelection(cacheItem)) {
315
- return false;
316
- }
317
- if (((_cacheItem$_data = cacheItem._data) === null || _cacheItem$_data === void 0 || (_cacheItem$_data = _cacheItem$_data.capacitys) === null || _cacheItem$_data === void 0 ? void 0 : _cacheItem$_data.type) !== 'custom') {
318
- var _cacheItem$_data2;
319
- var resources = (cacheItem === null || cacheItem === void 0 || (_cacheItem$_data2 = cacheItem._data) === null || _cacheItem$_data2 === void 0 ? void 0 : _cacheItem$_data2.resources) || [];
320
- if (resources.length === 1) {
321
- var _first$select_type;
322
- var first = resources[0];
323
- if (((_first$select_type = first.select_type) === null || _first$select_type === void 0 ? void 0 : _first$select_type.type) === 'single' && (first.default_resource || []).length > 0) {
324
- return true;
325
- }
326
- }
327
- }
328
- var entries = Object.entries(((_cacheItem$_extend8 = cacheItem._extend) === null || _cacheItem$_extend8 === void 0 ? void 0 : _cacheItem$_extend8.resource) || {});
329
- if (entries.length === 0) {
330
- return !productNeedsResourceExtend(cacheItem);
331
- }
332
- return entries.every(function (_ref) {
333
- var _ref2 = _slicedToArray(_ref, 2),
334
- key = _ref2[0],
335
- value = _ref2[1];
336
- return isAutoAllocationOn(key) && Array.isArray(value) && value.length > 0;
337
- });
338
- }
339
- export { getSumCapacity };
@@ -1,41 +0,0 @@
1
- /**
2
- * 结构化的「资源不可用」原因(替代 info2 `getErrorList` 输出的 i18n 文案 + type 字段)。
3
- *
4
- * 与 info2 type 字段映射:
5
- * - `no_product` ↔ type='products'
6
- * - `time_out_of_range` ↔ type='time'
7
- * - `count_out_of_range` ↔ type='limit'
8
- * - `resource_unbound` ↔ type='unbound'
9
- *
10
- * OS 这边不耦合 i18n 文案,UI 拿到 reason + params 后自行渲染(参考 docs/SDK 中给出的 i18n key 对照表)。
11
- */
12
- export type ResourceUnavailableReason = 'no_product' | 'time_out_of_range' | 'count_out_of_range' | 'resource_unbound';
13
- export interface ResourceError {
14
- reason: ResourceUnavailableReason;
15
- params: {
16
- /** 资源名(time / limit 用)。 */
17
- labelText?: string;
18
- /** 起始时间(time / limit 用,格式 'hh:mm A')。 */
19
- startText?: string;
20
- /** 结束时间(time / limit 用,格式 'hh:mm A')。 */
21
- endText?: string;
22
- /**
23
- * 结束时间是否跨到第二天。UI 收到 true 时可在 endText 前加 'tomorrow' / '明天' 前缀。
24
- * 与 info2 旧实现「endText = locales.getText('pisell1.text.tomorrow') + endText」等价。
25
- */
26
- isCrossDay?: boolean;
27
- };
28
- }
29
- /**
30
- * 替代 info2 `utilsByBooking.ts#getErrorList`,输出结构化错误。
31
- *
32
- * 行为对齐:
33
- * 1. cacheItem 没有 id → `no_product`(与 info2 `!cacheItem?.id` 分支等价)。
34
- * 2. 资源 null / 无 _extend → 返回 []。
35
- * 3. resource.usable=false 时:
36
- * - 没有 _extend.usableTime → `time_out_of_range`
37
- * - 有 usableTime 但 `_extend.isCountRange=false` → `count_out_of_range`
38
- * 4. resource.unbound=true → 追加 `resource_unbound`。
39
- * 5. 不再耦合 `_data.resourceMaps[form_id].type === 'single'` 判断(与 info2 实际未使用此变量一致)。
40
- */
41
- export declare function getResourceErrors(resource: any, cacheItem: any): ResourceError[];
@@ -1,74 +0,0 @@
1
- import dayjs from 'dayjs';
2
- import { getServiceTimes } from "./serviceTimes";
3
-
4
- /**
5
- * 结构化的「资源不可用」原因(替代 info2 `getErrorList` 输出的 i18n 文案 + type 字段)。
6
- *
7
- * 与 info2 type 字段映射:
8
- * - `no_product` ↔ type='products'
9
- * - `time_out_of_range` ↔ type='time'
10
- * - `count_out_of_range` ↔ type='limit'
11
- * - `resource_unbound` ↔ type='unbound'
12
- *
13
- * OS 这边不耦合 i18n 文案,UI 拿到 reason + params 后自行渲染(参考 docs/SDK 中给出的 i18n key 对照表)。
14
- */
15
-
16
- /**
17
- * 替代 info2 `utilsByBooking.ts#getErrorList`,输出结构化错误。
18
- *
19
- * 行为对齐:
20
- * 1. cacheItem 没有 id → `no_product`(与 info2 `!cacheItem?.id` 分支等价)。
21
- * 2. 资源 null / 无 _extend → 返回 []。
22
- * 3. resource.usable=false 时:
23
- * - 没有 _extend.usableTime → `time_out_of_range`
24
- * - 有 usableTime 但 `_extend.isCountRange=false` → `count_out_of_range`
25
- * 4. resource.unbound=true → 追加 `resource_unbound`。
26
- * 5. 不再耦合 `_data.resourceMaps[form_id].type === 'single'` 判断(与 info2 实际未使用此变量一致)。
27
- */
28
- export function getResourceErrors(resource, cacheItem) {
29
- if (!(cacheItem !== null && cacheItem !== void 0 && cacheItem.id)) {
30
- return [{
31
- reason: 'no_product',
32
- params: {}
33
- }];
34
- }
35
- if (!resource) return [];
36
- var list = [];
37
- if (!resource.usable) {
38
- var _resource$_extend, _resource$_extend2;
39
- var _getServiceTimes = getServiceTimes(cacheItem),
40
- startDate = _getServiceTimes.startDate,
41
- endDate = _getServiceTimes.endDate;
42
- var startText = startDate.format('hh:mm A');
43
- var endText = endDate.format('hh:mm A');
44
- var isCrossDay = dayjs(endDate).isAfter(startDate, 'day');
45
- if (!((_resource$_extend = resource._extend) !== null && _resource$_extend !== void 0 && _resource$_extend.usableTime)) {
46
- list.push({
47
- reason: 'time_out_of_range',
48
- params: {
49
- labelText: resource.labelText,
50
- startText: startText,
51
- endText: endText,
52
- isCrossDay: isCrossDay
53
- }
54
- });
55
- } else if (!((_resource$_extend2 = resource._extend) !== null && _resource$_extend2 !== void 0 && (_resource$_extend2 = _resource$_extend2.usableTime) !== null && _resource$_extend2 !== void 0 && (_resource$_extend2 = _resource$_extend2._extend) !== null && _resource$_extend2 !== void 0 && _resource$_extend2.isCountRange)) {
56
- list.push({
57
- reason: 'count_out_of_range',
58
- params: {
59
- labelText: resource.labelText,
60
- startText: startText,
61
- endText: endText,
62
- isCrossDay: isCrossDay
63
- }
64
- });
65
- }
66
- }
67
- if (resource.unbound) {
68
- list.push({
69
- reason: 'resource_unbound',
70
- params: {}
71
- });
72
- }
73
- return list;
74
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * 预约商品资源是否「需要补齐 / 已选中」——供 getProductExtend 门禁与 getIsAutoClose 共用。
3
- */
4
- /** 商品是否挂了生效的资源表单(product_resource.resources status=1)。 */
5
- export declare function productNeedsResourceExtend(cacheItem: any): boolean;
6
- /** `_extend.resource` 是否至少有一类表单选中了具体资源。 */
7
- export declare function hasActualResourceSelection(cacheItem: any): boolean;
@@ -1,24 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- /**
3
- * 预约商品资源是否「需要补齐 / 已选中」——供 getProductExtend 门禁与 getIsAutoClose 共用。
4
- */
5
-
6
- /** 商品是否挂了生效的资源表单(product_resource.resources status=1)。 */
7
- export function productNeedsResourceExtend(cacheItem) {
8
- var _cacheItem$product_re;
9
- var forms = cacheItem === null || cacheItem === void 0 || (_cacheItem$product_re = cacheItem.product_resource) === null || _cacheItem$product_re === void 0 ? void 0 : _cacheItem$product_re.resources;
10
- if (!Array.isArray(forms)) return false;
11
- return forms.some(function (d) {
12
- return Number(d === null || d === void 0 ? void 0 : d.status) === 1;
13
- });
14
- }
15
-
16
- /** `_extend.resource` 是否至少有一类表单选中了具体资源。 */
17
- export function hasActualResourceSelection(cacheItem) {
18
- var _cacheItem$_extend;
19
- var resource = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.resource;
20
- if (!resource || _typeof(resource) !== 'object') return false;
21
- return Object.values(resource).some(function (rows) {
22
- return Array.isArray(rows) && rows.length > 0;
23
- });
24
- }
@@ -1,80 +0,0 @@
1
- /**
2
- * 资源运行态计算 helper(搬自 info2 `utilsByBooking.ts` + `service/addService/utils.tsx`)。
3
- *
4
- * 本文件输入输出全部为 plain object,不依赖 React / locales / @pisell/icon / mini-redux。
5
- * 调用方传入:resource origin map(`/form/schedule` 返回) / cacheItem(含 `_extend.duration / _extend.start_date / _extend.start_time` 等)。
6
- *
7
- * 三个 info2 独有特性保留:
8
- * 1. `resource_display_scope='all'`:取全部资源
9
- * 2. `extraResources`:拖入未绑定资源时兼容渲染
10
- * 3. `getNoResource2()`:占位"无资源"行
11
- */
12
- /**
13
- * 从已选资源中取「最早结束」的 usableTime,供灵活时长计算上限。
14
- * 与 info2 `service/addService/utils.tsx#getUsableTime` 等价。
15
- */
16
- export declare function getUsableTime(cacheItem: any): any | null;
17
- /** Σ cacheItem._extend.capacity[].value × _extend.quantity。 */
18
- export declare function getSumCapacity(cacheItem: any, isCalcQuantity?: boolean): number;
19
- /**
20
- * 判断单个 time 是否可用,写回 `_extend` 标记位(isDateRange / isCountRange / isUsable / isMaxLimitRange)。
21
- * 与 info2 `utilsByBooking.ts#getResourceTimeIsUsable` 等价。
22
- */
23
- export declare function getResourceTimeIsUsable(item: any, cacheItem: any, resourceItem: any): any;
24
- /**
25
- * 在 resource.times 中找到最佳可用 time,并写回 `_extend.usableTime`。
26
- * 与 info2 `utilsByBooking.ts#formatTimes` 等价。
27
- */
28
- export declare function formatTimes(resourceItem: any, cacheItem: any): any;
29
- /**
30
- * 单个 resource 的整体可用性 + labelText 填充。
31
- * 与 info2 `utilsByBooking.ts#formatResource` 等价;不再接收 formatLabel 回调(OS 不渲染 JSX)。
32
- */
33
- export declare function formatResource(resourceItem: any, cacheItem?: any): any;
34
- /**
35
- * 把单个 resource origin 类型(如「技师」)的 renderList 中每个资源跑一遍 formatResource,
36
- * 并维护 unbound 标记(拖入未绑定资源时 UI 用)。
37
- * 与 info2 `service/addService/utils.tsx#formatResources` 等价(剥 JSX)。
38
- */
39
- export declare function formatResources(params: {
40
- cacheItem: any;
41
- resourcesOrigin: any[];
42
- }): {
43
- list: any[];
44
- maps: Record<string, any>;
45
- };
46
- /**
47
- * 计算每类资源的默认值(写入 cacheItem._extend.resource)。
48
- * 与 info2 `service/addService/utils.tsx#setDefaultResource` 等价;
49
- * `resourceIdFromCalendar` 替代原版 sessionStorage `serviceParams.resource_id` 读取。
50
- */
51
- export declare function setDefaultResource(params: {
52
- cacheItem: any;
53
- resources: any[];
54
- resourceIdFromCalendar?: number;
55
- isAutoAllocationOn?: (formId: any) => boolean;
56
- }): Record<string, any[]>;
57
- /**
58
- * 计算默认容量(与 info2 `setDefaultCapacitys` 等价)。
59
- * package:按 _extend.other.bundle 拆 quantity;custom:按 capacity.custom[].min;其他:[{id:0,value:1}]。
60
- */
61
- export declare function setDefaultCapacitys(params: {
62
- capacitys: any;
63
- cacheItem: any;
64
- }): Array<{
65
- id: number | string;
66
- value: number;
67
- name?: string;
68
- }>;
69
- /**
70
- * 通过商品 `product_resource.resources[]` 关联的 form/resource id,从 resourcesOriginMap 还原资源数据。
71
- * 与 info2 `service/addService/utils.tsx#getResourceByIds` 等价(保留三特性)。
72
- */
73
- export declare function getResourceByIds(resourcesOriginMap: Record<string, any>, cacheItem: any, extraParams?: {
74
- extraResources?: Array<{
75
- form_id: number | string;
76
- id: number;
77
- }>;
78
- resourcesOrigin?: any[];
79
- resourceTab?: Record<string, any>;
80
- }): any[];