@pisell/pisellos 3.0.76 → 3.0.78

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 (314) hide show
  1. package/dist/core/index.js +1 -2
  2. package/dist/effects/index.d.ts +3 -5
  3. package/dist/effects/index.js +8 -40
  4. package/dist/modules/Account/index.js +3 -2
  5. package/dist/modules/AccountList/index.d.ts +1 -7
  6. package/dist/modules/AccountList/index.js +14 -81
  7. package/dist/modules/AccountList/types.d.ts +0 -28
  8. package/dist/modules/AccountList/types.js +0 -8
  9. package/dist/modules/BaseModule.d.ts +0 -3
  10. package/dist/modules/BaseModule.js +0 -15
  11. package/dist/modules/Cart/index.d.ts +0 -1
  12. package/dist/modules/Cart/index.js +1 -2
  13. package/dist/modules/Date/types.d.ts +3 -1
  14. package/dist/modules/Discount/index.d.ts +0 -1
  15. package/dist/modules/Discount/index.js +1 -1
  16. package/dist/modules/Guests/index.js +9 -9
  17. package/dist/modules/Order/index.d.ts +1 -25
  18. package/dist/modules/Order/index.js +3 -224
  19. package/dist/modules/Order/types.d.ts +0 -45
  20. package/dist/modules/Order/types.js +0 -8
  21. package/dist/modules/Order/utils.js +1 -1
  22. package/dist/modules/Payment/index.d.ts +9 -184
  23. package/dist/modules/Payment/index.js +109 -2084
  24. package/dist/modules/Payment/types.d.ts +30 -772
  25. package/dist/modules/Payment/types.js +12 -236
  26. package/dist/modules/ProductList/index.d.ts +1 -12
  27. package/dist/modules/ProductList/index.js +6 -29
  28. package/dist/modules/Resource/index.js +1 -1
  29. package/dist/modules/Rules/index.d.ts +4 -3
  30. package/dist/modules/Rules/index.js +121 -78
  31. package/dist/modules/Rules/types.d.ts +6 -1
  32. package/dist/modules/Rules/types.js +8 -0
  33. package/dist/modules/Schedule/index.d.ts +0 -9
  34. package/dist/modules/Schedule/index.js +0 -77
  35. package/dist/modules/index.d.ts +0 -1
  36. package/dist/modules/index.js +0 -1
  37. package/dist/plugins/window.d.ts +0 -1
  38. package/dist/solution/BookingByStep/index.d.ts +17 -0
  39. package/dist/solution/BookingByStep/index.js +525 -190
  40. package/dist/solution/BookingByStep/utils/products.d.ts +0 -6
  41. package/dist/solution/BookingByStep/utils/products.js +0 -10
  42. package/dist/solution/BookingByStep/utils/resources.js +4 -0
  43. package/dist/solution/BuyTickets/index.js +8 -7
  44. package/dist/solution/ShopDiscount/index.d.ts +12 -10
  45. package/dist/solution/ShopDiscount/index.js +64 -110
  46. package/dist/solution/ShopDiscount/types.d.ts +0 -8
  47. package/dist/solution/ShopDiscount/utils.js +1 -0
  48. package/dist/solution/index.d.ts +0 -2
  49. package/dist/solution/index.js +1 -3
  50. package/dist/types/index.d.ts +1 -4
  51. package/lib/core/index.js +1 -1
  52. package/lib/effects/index.d.ts +3 -5
  53. package/lib/effects/index.js +1 -17
  54. package/lib/modules/Account/index.js +3 -2
  55. package/lib/modules/AccountList/index.d.ts +1 -7
  56. package/lib/modules/AccountList/index.js +0 -27
  57. package/lib/modules/AccountList/types.d.ts +0 -28
  58. package/lib/modules/BaseModule.d.ts +0 -3
  59. package/lib/modules/BaseModule.js +0 -9
  60. package/lib/modules/Cart/index.d.ts +0 -1
  61. package/lib/modules/Cart/index.js +2 -5
  62. package/lib/modules/Date/types.d.ts +3 -1
  63. package/lib/modules/Discount/index.d.ts +0 -1
  64. package/lib/modules/Discount/index.js +1 -1
  65. package/lib/modules/Guests/index.js +9 -9
  66. package/lib/modules/Order/index.d.ts +1 -25
  67. package/lib/modules/Order/index.js +1 -186
  68. package/lib/modules/Order/types.d.ts +0 -45
  69. package/lib/modules/Order/utils.js +1 -1
  70. package/lib/modules/Payment/index.d.ts +9 -184
  71. package/lib/modules/Payment/index.js +51 -1084
  72. package/lib/modules/Payment/types.d.ts +30 -772
  73. package/lib/modules/Payment/types.js +6 -79
  74. package/lib/modules/ProductList/index.d.ts +1 -12
  75. package/lib/modules/ProductList/index.js +5 -31
  76. package/lib/modules/Resource/index.js +1 -1
  77. package/lib/modules/Rules/index.d.ts +4 -3
  78. package/lib/modules/Rules/index.js +64 -43
  79. package/lib/modules/Rules/types.d.ts +6 -1
  80. package/lib/modules/Rules/types.js +11 -2
  81. package/lib/modules/Schedule/index.d.ts +0 -9
  82. package/lib/modules/Schedule/index.js +0 -60
  83. package/lib/modules/index.d.ts +0 -1
  84. package/lib/modules/index.js +0 -2
  85. package/lib/plugins/window.d.ts +0 -1
  86. package/lib/solution/BookingByStep/index.d.ts +17 -0
  87. package/lib/solution/BookingByStep/index.js +325 -60
  88. package/lib/solution/BookingByStep/utils/products.d.ts +0 -6
  89. package/lib/solution/BookingByStep/utils/products.js +2 -8
  90. package/lib/solution/BookingByStep/utils/resources.js +4 -1
  91. package/lib/solution/BuyTickets/index.js +8 -7
  92. package/lib/solution/ShopDiscount/index.d.ts +12 -10
  93. package/lib/solution/ShopDiscount/index.js +30 -51
  94. package/lib/solution/ShopDiscount/types.d.ts +0 -8
  95. package/lib/solution/index.d.ts +0 -2
  96. package/lib/solution/index.js +1 -5
  97. package/lib/types/index.d.ts +1 -4
  98. package/package.json +1 -3
  99. package/dist/modules/Customer/constants.d.ts +0 -7
  100. package/dist/modules/Customer/constants.js +0 -12
  101. package/dist/modules/Customer/index.d.ts +0 -122
  102. package/dist/modules/Customer/index.js +0 -696
  103. package/dist/modules/Customer/types.d.ts +0 -146
  104. package/dist/modules/Customer/types.js +0 -41
  105. package/dist/modules/Payment/cash.d.ts +0 -19
  106. package/dist/modules/Payment/cash.js +0 -97
  107. package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts +0 -22
  108. package/dist/modules/Payment/cashRecommendationAlgorithm.js +0 -423
  109. package/dist/modules/Payment/eftpos.d.ts +0 -11
  110. package/dist/modules/Payment/eftpos.js +0 -80
  111. package/dist/modules/Payment/mx51.d.ts +0 -0
  112. package/dist/modules/Payment/mx51.js +0 -0
  113. package/dist/modules/Payment/utils.d.ts +0 -17
  114. package/dist/modules/Payment/utils.js +0 -62
  115. package/dist/modules/Payment/walletpass.d.ts +0 -99
  116. package/dist/modules/Payment/walletpass.js +0 -711
  117. package/dist/plugins/app-types/app/app.d.ts +0 -83
  118. package/dist/plugins/app-types/app/const.d.ts +0 -4
  119. package/dist/plugins/app-types/app/index.d.ts +0 -14
  120. package/dist/plugins/app-types/applicationManager/application.d.ts +0 -50
  121. package/dist/plugins/app-types/applicationManager/index.d.ts +0 -13
  122. package/dist/plugins/app-types/config.d.ts +0 -3
  123. package/dist/plugins/app-types/cookie/index.d.ts +0 -13
  124. package/dist/plugins/app-types/data/index.d.ts +0 -8
  125. package/dist/plugins/app-types/history/config.d.ts +0 -24
  126. package/dist/plugins/app-types/history/index.d.ts +0 -20
  127. package/dist/plugins/app-types/history/type.d.ts +0 -2
  128. package/dist/plugins/app-types/hooks/index.d.ts +0 -12
  129. package/dist/plugins/app-types/hooks/useDelayedValue/index.d.ts +0 -2
  130. package/dist/plugins/app-types/hooks/useDispatch/index.d.ts +0 -2
  131. package/dist/plugins/app-types/hooks/useLowCode/index.d.ts +0 -13
  132. package/dist/plugins/app-types/hooks/useStore/index.d.ts +0 -6
  133. package/dist/plugins/app-types/index.d.ts +0 -6
  134. package/dist/plugins/app-types/indexDB/index.d.ts +0 -178
  135. package/dist/plugins/app-types/locales/en.d.ts +0 -3
  136. package/dist/plugins/app-types/locales/index.d.ts +0 -37
  137. package/dist/plugins/app-types/locales/original.d.ts +0 -3
  138. package/dist/plugins/app-types/locales/type.d.ts +0 -19
  139. package/dist/plugins/app-types/locales/zh-CN.d.ts +0 -3
  140. package/dist/plugins/app-types/locales/zh-HK.d.ts +0 -3
  141. package/dist/plugins/app-types/logger/feishu.d.ts +0 -11
  142. package/dist/plugins/app-types/logger/index.d.ts +0 -122
  143. package/dist/plugins/app-types/menuManager/hooks.d.ts +0 -17
  144. package/dist/plugins/app-types/menuManager/index.d.ts +0 -28
  145. package/dist/plugins/app-types/models/global.d.ts +0 -32
  146. package/dist/plugins/app-types/models/index.d.ts +0 -45
  147. package/dist/plugins/app-types/models/type.d.ts +0 -2
  148. package/dist/plugins/app-types/package.json +0 -15
  149. package/dist/plugins/app-types/plugin/index.d.ts +0 -0
  150. package/dist/plugins/app-types/pubsub/example.d.ts +0 -5
  151. package/dist/plugins/app-types/pubsub/index.d.ts +0 -63
  152. package/dist/plugins/app-types/request/cache.d.ts +0 -46
  153. package/dist/plugins/app-types/request/cancelToken.d.ts +0 -38
  154. package/dist/plugins/app-types/request/config.d.ts +0 -3
  155. package/dist/plugins/app-types/request/constants.d.ts +0 -2
  156. package/dist/plugins/app-types/request/index.d.ts +0 -24
  157. package/dist/plugins/app-types/request/pisell2Request.d.ts +0 -6
  158. package/dist/plugins/app-types/request/type.d.ts +0 -41
  159. package/dist/plugins/app-types/request/utils.d.ts +0 -46
  160. package/dist/plugins/app-types/routes/config.d.ts +0 -7
  161. package/dist/plugins/app-types/routes/index.d.ts +0 -28
  162. package/dist/plugins/app-types/socket/components/SocketMonitorPage.d.ts +0 -6
  163. package/dist/plugins/app-types/socket/components/index.d.ts +0 -2
  164. package/dist/plugins/app-types/socket/constants.d.ts +0 -33
  165. package/dist/plugins/app-types/socket/events.d.ts +0 -31
  166. package/dist/plugins/app-types/socket/heartbeat.d.ts +0 -66
  167. package/dist/plugins/app-types/socket/index.d.ts +0 -61
  168. package/dist/plugins/app-types/socket/monitor.d.ts +0 -169
  169. package/dist/plugins/app-types/socket/reconnect.d.ts +0 -61
  170. package/dist/plugins/app-types/socket/socket.d.ts +0 -129
  171. package/dist/plugins/app-types/socket/types.d.ts +0 -85
  172. package/dist/plugins/app-types/storage/index.d.ts +0 -17
  173. package/dist/plugins/app-types/tasks/index.d.ts +0 -77
  174. package/dist/plugins/app-types/tasks/type.d.ts +0 -62
  175. package/dist/plugins/app-types/tasks/useTasks.d.ts +0 -5
  176. package/dist/plugins/app-types/type.d.ts +0 -2
  177. package/dist/plugins/app-types/variables/VariablesProvider.d.ts +0 -7
  178. package/dist/plugins/app-types/variables/config.d.ts +0 -3
  179. package/dist/plugins/app-types/variables/index.d.ts +0 -6
  180. package/dist/plugins/app-types/variables/type.d.ts +0 -2
  181. package/dist/plugins/app-types/website/index.d.ts +0 -6
  182. package/dist/plugins/app.d.ts +0 -8
  183. package/dist/plugins/app.js +0 -1
  184. package/dist/solution/BookingTicket/index.d.ts +0 -184
  185. package/dist/solution/BookingTicket/index.js +0 -698
  186. package/dist/solution/BookingTicket/types.d.ts +0 -68
  187. package/dist/solution/BookingTicket/types.js +0 -43
  188. package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +0 -22
  189. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +0 -159
  190. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +0 -22
  191. package/dist/solution/BookingTicket/utils/scan/handleScan.js +0 -189
  192. package/dist/solution/BookingTicket/utils/scan/index.d.ts +0 -85
  193. package/dist/solution/BookingTicket/utils/scan/index.js +0 -294
  194. package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +0 -78
  195. package/dist/solution/BookingTicket/utils/scan/scanCache.js +0 -305
  196. package/dist/solution/Checkout/appointmentDemo.json +0 -1
  197. package/dist/solution/Checkout/index.d.ts +0 -432
  198. package/dist/solution/Checkout/index.js +0 -4452
  199. package/dist/solution/Checkout/types.d.ts +0 -727
  200. package/dist/solution/Checkout/types.js +0 -104
  201. package/dist/solution/Checkout/utils/index.d.ts +0 -121
  202. package/dist/solution/Checkout/utils/index.js +0 -511
  203. package/dist/utils/task.d.ts +0 -40
  204. package/dist/utils/task.js +0 -171
  205. package/dist/utils/watch.d.ts +0 -102
  206. package/dist/utils/watch.js +0 -294
  207. package/lib/modules/Customer/constants.d.ts +0 -7
  208. package/lib/modules/Customer/constants.js +0 -39
  209. package/lib/modules/Customer/index.d.ts +0 -122
  210. package/lib/modules/Customer/index.js +0 -439
  211. package/lib/modules/Customer/types.d.ts +0 -146
  212. package/lib/modules/Customer/types.js +0 -37
  213. package/lib/modules/Payment/cash.d.ts +0 -19
  214. package/lib/modules/Payment/cash.js +0 -64
  215. package/lib/modules/Payment/cashRecommendationAlgorithm.d.ts +0 -22
  216. package/lib/modules/Payment/cashRecommendationAlgorithm.js +0 -342
  217. package/lib/modules/Payment/eftpos.d.ts +0 -11
  218. package/lib/modules/Payment/eftpos.js +0 -51
  219. package/lib/modules/Payment/mx51.d.ts +0 -0
  220. package/lib/modules/Payment/mx51.js +0 -0
  221. package/lib/modules/Payment/utils.d.ts +0 -17
  222. package/lib/modules/Payment/utils.js +0 -67
  223. package/lib/modules/Payment/walletpass.d.ts +0 -99
  224. package/lib/modules/Payment/walletpass.js +0 -484
  225. package/lib/plugins/app-types/app/app.d.ts +0 -83
  226. package/lib/plugins/app-types/app/const.d.ts +0 -4
  227. package/lib/plugins/app-types/app/index.d.ts +0 -14
  228. package/lib/plugins/app-types/applicationManager/application.d.ts +0 -50
  229. package/lib/plugins/app-types/applicationManager/index.d.ts +0 -13
  230. package/lib/plugins/app-types/config.d.ts +0 -3
  231. package/lib/plugins/app-types/cookie/index.d.ts +0 -13
  232. package/lib/plugins/app-types/data/index.d.ts +0 -8
  233. package/lib/plugins/app-types/history/config.d.ts +0 -24
  234. package/lib/plugins/app-types/history/index.d.ts +0 -20
  235. package/lib/plugins/app-types/history/type.d.ts +0 -2
  236. package/lib/plugins/app-types/hooks/index.d.ts +0 -12
  237. package/lib/plugins/app-types/hooks/useDelayedValue/index.d.ts +0 -2
  238. package/lib/plugins/app-types/hooks/useDispatch/index.d.ts +0 -2
  239. package/lib/plugins/app-types/hooks/useLowCode/index.d.ts +0 -13
  240. package/lib/plugins/app-types/hooks/useStore/index.d.ts +0 -6
  241. package/lib/plugins/app-types/index.d.ts +0 -6
  242. package/lib/plugins/app-types/indexDB/index.d.ts +0 -178
  243. package/lib/plugins/app-types/locales/en.d.ts +0 -3
  244. package/lib/plugins/app-types/locales/index.d.ts +0 -37
  245. package/lib/plugins/app-types/locales/original.d.ts +0 -3
  246. package/lib/plugins/app-types/locales/type.d.ts +0 -19
  247. package/lib/plugins/app-types/locales/zh-CN.d.ts +0 -3
  248. package/lib/plugins/app-types/locales/zh-HK.d.ts +0 -3
  249. package/lib/plugins/app-types/logger/feishu.d.ts +0 -11
  250. package/lib/plugins/app-types/logger/index.d.ts +0 -122
  251. package/lib/plugins/app-types/menuManager/hooks.d.ts +0 -17
  252. package/lib/plugins/app-types/menuManager/index.d.ts +0 -28
  253. package/lib/plugins/app-types/models/global.d.ts +0 -32
  254. package/lib/plugins/app-types/models/index.d.ts +0 -45
  255. package/lib/plugins/app-types/models/type.d.ts +0 -2
  256. package/lib/plugins/app-types/package.json +0 -15
  257. package/lib/plugins/app-types/plugin/index.d.ts +0 -0
  258. package/lib/plugins/app-types/pubsub/example.d.ts +0 -5
  259. package/lib/plugins/app-types/pubsub/index.d.ts +0 -63
  260. package/lib/plugins/app-types/request/cache.d.ts +0 -46
  261. package/lib/plugins/app-types/request/cancelToken.d.ts +0 -38
  262. package/lib/plugins/app-types/request/config.d.ts +0 -3
  263. package/lib/plugins/app-types/request/constants.d.ts +0 -2
  264. package/lib/plugins/app-types/request/index.d.ts +0 -24
  265. package/lib/plugins/app-types/request/pisell2Request.d.ts +0 -6
  266. package/lib/plugins/app-types/request/type.d.ts +0 -41
  267. package/lib/plugins/app-types/request/utils.d.ts +0 -46
  268. package/lib/plugins/app-types/routes/config.d.ts +0 -7
  269. package/lib/plugins/app-types/routes/index.d.ts +0 -28
  270. package/lib/plugins/app-types/socket/components/SocketMonitorPage.d.ts +0 -6
  271. package/lib/plugins/app-types/socket/components/index.d.ts +0 -2
  272. package/lib/plugins/app-types/socket/constants.d.ts +0 -33
  273. package/lib/plugins/app-types/socket/events.d.ts +0 -31
  274. package/lib/plugins/app-types/socket/heartbeat.d.ts +0 -66
  275. package/lib/plugins/app-types/socket/index.d.ts +0 -61
  276. package/lib/plugins/app-types/socket/monitor.d.ts +0 -169
  277. package/lib/plugins/app-types/socket/reconnect.d.ts +0 -61
  278. package/lib/plugins/app-types/socket/socket.d.ts +0 -129
  279. package/lib/plugins/app-types/socket/types.d.ts +0 -85
  280. package/lib/plugins/app-types/storage/index.d.ts +0 -17
  281. package/lib/plugins/app-types/tasks/index.d.ts +0 -77
  282. package/lib/plugins/app-types/tasks/type.d.ts +0 -62
  283. package/lib/plugins/app-types/tasks/useTasks.d.ts +0 -5
  284. package/lib/plugins/app-types/type.d.ts +0 -2
  285. package/lib/plugins/app-types/variables/VariablesProvider.d.ts +0 -7
  286. package/lib/plugins/app-types/variables/config.d.ts +0 -3
  287. package/lib/plugins/app-types/variables/index.d.ts +0 -6
  288. package/lib/plugins/app-types/variables/type.d.ts +0 -2
  289. package/lib/plugins/app-types/website/index.d.ts +0 -6
  290. package/lib/plugins/app.d.ts +0 -8
  291. package/lib/plugins/app.js +0 -17
  292. package/lib/solution/BookingTicket/index.d.ts +0 -184
  293. package/lib/solution/BookingTicket/index.js +0 -426
  294. package/lib/solution/BookingTicket/types.d.ts +0 -68
  295. package/lib/solution/BookingTicket/types.js +0 -72
  296. package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +0 -22
  297. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +0 -117
  298. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +0 -22
  299. package/lib/solution/BookingTicket/utils/scan/handleScan.js +0 -132
  300. package/lib/solution/BookingTicket/utils/scan/index.d.ts +0 -85
  301. package/lib/solution/BookingTicket/utils/scan/index.js +0 -216
  302. package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +0 -78
  303. package/lib/solution/BookingTicket/utils/scan/scanCache.js +0 -231
  304. package/lib/solution/Checkout/appointmentDemo.json +0 -1
  305. package/lib/solution/Checkout/index.d.ts +0 -432
  306. package/lib/solution/Checkout/index.js +0 -2776
  307. package/lib/solution/Checkout/types.d.ts +0 -727
  308. package/lib/solution/Checkout/types.js +0 -63
  309. package/lib/solution/Checkout/utils/index.d.ts +0 -121
  310. package/lib/solution/Checkout/utils/index.js +0 -362
  311. package/lib/utils/task.d.ts +0 -40
  312. package/lib/utils/task.js +0 -109
  313. package/lib/utils/watch.d.ts +0 -102
  314. package/lib/utils/watch.js +0 -217
@@ -29,9 +29,9 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
29
29
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
30
30
  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); }
31
31
  import { BaseModule } from "../../modules/BaseModule";
32
- import { createModule } from "./types";
32
+ import { BookingByStepHooks, createModule } from "./types";
33
33
  import { formatProductToCartItem, createCartItemOrigin, getUniqueId, handleVariantProduct, formatDateToCartItem, formatAccountToCartItem } from "../../modules/Cart/utils";
34
- import { getAvailableProductResources, isSessionProduct } from "./utils/products";
34
+ import { getAvailableProductResources } from "./utils/products";
35
35
  import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem, getOthersSelectedResources, getOthersCartSelectedResources, filterScheduleByDateRange, checkSessionProductLeadTime, sortCombinedResources, filterResourcesByFormItem, checkTwoResourcesIntersection, isConflict } from "./utils/resources";
36
36
  import dayjs from 'dayjs';
37
37
  import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
@@ -118,7 +118,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
118
118
  this.otherData = ((_data$this$otherParam = data[this.otherParams.cacheId]) === null || _data$this$otherParam === void 0 || (_data$this$otherParam = _data$this$otherParam[this.name]) === null || _data$this$otherParam === void 0 ? void 0 : _data$this$otherParam['otherData']) || {};
119
119
  }
120
120
  }
121
- moduleArr = ['accountList', 'cart', 'schedule', 'summary', 'step', 'products', 'date', 'order'];
121
+ moduleArr = ['accountList', 'cart', 'schedule', 'summary', 'step', 'products', 'date', 'order', 'payment'];
122
122
  moduleArr.forEach(function (step) {
123
123
  var targetModule = createModule(step, _this2.name);
124
124
  if (targetModule) {
@@ -137,7 +137,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
137
137
  }
138
138
  });
139
139
  this.store.schedule.loadAllSchedule();
140
- this.core.effects.emit("".concat(this.name, ":onInited"), {});
140
+ this.core.effects.emit(BookingByStepHooks.onInited, {});
141
141
  case 19:
142
142
  case "end":
143
143
  return _context.stop();
@@ -238,29 +238,19 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
238
238
  key: "loadProducts",
239
239
  value: (function () {
240
240
  var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
241
- var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, schedule_date, res;
241
+ var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, schedule_date;
242
242
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
243
243
  while (1) switch (_context2.prev = _context2.next) {
244
244
  case 0:
245
245
  _ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, schedule_date = _ref.schedule_date;
246
- _context2.next = 3;
247
- return this.store.products.loadProducts({
246
+ return _context2.abrupt("return", this.store.products.loadProducts({
248
247
  category_ids: category_ids,
249
248
  product_ids: product_ids,
250
249
  collection: collection,
251
250
  schedule_date: schedule_date,
252
251
  cacheId: this.cacheId
253
- });
254
- case 3:
255
- res = _context2.sent;
256
- // 预拉取当天的资源数据
257
- this.getAvailableDate({
258
- startDate: schedule_date || dayjs().format('YYYY-MM-DD'),
259
- endDate: schedule_date || dayjs().format('YYYY-MM-DD'),
260
- products: _toConsumableArray(res)
261
- });
262
- return _context2.abrupt("return", res);
263
- case 6:
252
+ }));
253
+ case 2:
264
254
  case "end":
265
255
  return _context2.stop();
266
256
  }
@@ -292,7 +282,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
292
282
  value: (function () {
293
283
  var _loadProductByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref2) {
294
284
  var _schedule$product_ids;
295
- var date, _ref2$product_ids, product_ids, _ref2$category_ids, category_ids, scheduleList, newProductIds, schedule, otherProductsIds, allProductIds, res;
285
+ var date, _ref2$product_ids, product_ids, _ref2$category_ids, category_ids, scheduleList, newProductIds, schedule, otherProductsIds, allProductIds;
296
286
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
297
287
  while (1) switch (_context3.prev = _context3.next) {
298
288
  case 0:
@@ -339,9 +329,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
339
329
  schedule_date: date
340
330
  });
341
331
  case 10:
342
- res = _context3.sent;
343
- return _context3.abrupt("return", res);
344
- case 12:
332
+ return _context3.abrupt("return", _context3.sent);
333
+ case 11:
345
334
  case "end":
346
335
  return _context3.stop();
347
336
  }
@@ -1161,16 +1150,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1161
1150
  var productData = _objectSpread(_objectSpread({}, origin), {}, {
1162
1151
  product_variant_id: product_variant_id
1163
1152
  });
1164
- debugger;
1165
- // 保护,如果进来的是 session 商品,则必须要有 date 和时间片,否则不允许添加
1166
- if (isSessionProduct(productData)) {
1167
- if (!date || !date.startTime || !date.endTime) {
1168
- return {
1169
- success: false,
1170
- errorCode: 'date_or_time_required'
1171
- };
1172
- }
1173
- }
1174
1153
 
1175
1154
  // 库存检测
1176
1155
  var currentCartItems = this.store.cart.getItems();
@@ -1256,14 +1235,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1256
1235
  _this6.store.cart.removeItem(n._id);
1257
1236
  });
1258
1237
  }
1259
- // // 如果 date.startTime 和 dateRange 里的 startTime 不一样,需要修正 dateRange
1260
- // const dateRange = this.store.date.getDateRange()
1261
- // if (dateRange?.[0] && !dayjs(dateRange[0].date).isSame(dayjs(date.startTime), 'day')) {
1262
- // this.setDateRange([
1263
- // { date: dayjs(date.startTime).format('YYYY-MM-DD'), status: 'available', week: '', weekNum: 0 },
1264
- // { date: dayjs(date.endTime).format('YYYY-MM-DD'), status: 'available', week: '', weekNum: 0 },
1265
- // ]);
1266
- // }
1267
1238
  }
1268
1239
  }
1269
1240
  }, {
@@ -2060,6 +2031,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2060
2031
  key: "getTimeSlotByAllResources",
2061
2032
  value: function getTimeSlotByAllResources(resources_code) {
2062
2033
  var _dateRange,
2034
+ _dateRange2,
2063
2035
  _this12 = this,
2064
2036
  _cartItems$,
2065
2037
  _cartItems$2,
@@ -2115,6 +2087,23 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2115
2087
  }
2116
2088
  });
2117
2089
  }
2090
+ // 检查通过购物车 renderList 加入的资源数据里 times 的正确性,如果不对则需要修正
2091
+ if ((_dateRange2 = dateRange) !== null && _dateRange2 !== void 0 && (_dateRange2 = _dateRange2[0]) !== null && _dateRange2 !== void 0 && _dateRange2.date && resources.length) {
2092
+ var _dateRange3;
2093
+ var currentDate = (_dateRange3 = dateRange) === null || _dateRange3 === void 0 || (_dateRange3 = _dateRange3[0]) === null || _dateRange3 === void 0 ? void 0 : _dateRange3.date;
2094
+ var theDateResources = this.store.date.getResourcesListByDate(currentDate);
2095
+ resources.forEach(function (item) {
2096
+ var noCurrentDateTimes = item.times.some(function (n) {
2097
+ return dayjs(n.start_at).isSame(dayjs(currentDate), 'day');
2098
+ });
2099
+ if (!noCurrentDateTimes) {
2100
+ var _theDateResources$fin;
2101
+ item.times = (theDateResources === null || theDateResources === void 0 || (_theDateResources$fin = theDateResources.find(function (n) {
2102
+ return n.id === item.id;
2103
+ })) === null || _theDateResources$fin === void 0 ? void 0 : _theDateResources$fin.times) || [];
2104
+ }
2105
+ });
2106
+ }
2118
2107
  var resourcesMap = getResourcesMap(resources);
2119
2108
  var duration = 0;
2120
2109
  // duration = 不同账号的最长时间
@@ -2187,12 +2176,26 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2187
2176
  }
2188
2177
  // 计算容量的辅助函数
2189
2178
  var calculateCapacityFromCartItems = function calculateCapacityFromCartItems(items) {
2190
- return items.reduce(function (total, item) {
2191
- return total + (getCapacityInfoByCartItem(item).currentCapacity || 0);
2192
- }, 0);
2179
+ var _items$0$_resourceOri;
2180
+ // 还需要增加一个判断,maxCapacity 必须是我单个人里选择的资源只有同一种的情况下才可以累加,否则单个账号都是 1
2181
+ var firstResource = (_items$0$_resourceOri = items[0]._resourceOrigin) === null || _items$0$_resourceOri === void 0 ? void 0 : _items$0$_resourceOri[0].id;
2182
+ var sameResourceLength = items.filter(function (item) {
2183
+ var _item$_resourceOrigin;
2184
+ return ((_item$_resourceOrigin = item._resourceOrigin) === null || _item$_resourceOrigin === void 0 ? void 0 : _item$_resourceOrigin[0].id) === firstResource;
2185
+ }).length;
2186
+ if (sameResourceLength === items.length) {
2187
+ return 1;
2188
+ }
2189
+ // 找出单个购物车里最大的需求 capacity 即可
2190
+ return Math.max.apply(Math, _toConsumableArray(items.map(function (item) {
2191
+ return getCapacityInfoByCartItem(item).currentCapacity || 1;
2192
+ })));
2193
+ // return items.reduce((total, item) => {
2194
+ // return total + (getCapacityInfoByCartItem(item).currentCapacity || 0);
2195
+ // }, 0);
2193
2196
  };
2194
2197
 
2195
- // 如果是多个预约,去要求助几个 holder 下最大的需求容量capacity
2198
+ // 如果是多个人预约,去要求出几个 holder 下最大的商品需求容量capacity
2196
2199
  var maxCapacity = 1;
2197
2200
  if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
2198
2201
  accountList.forEach(function (account) {
@@ -2220,13 +2223,257 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2220
2223
  });
2221
2224
  return timeSlots;
2222
2225
  }
2226
+ // 从购物车中获取已经分配好第一步资源的所有时间片,批量版本,用于给日期提供能否高亮的判断
2227
+ }, {
2228
+ key: "getTimeSlotByAllResourcesForDate",
2229
+ value: function () {
2230
+ var _getTimeSlotByAllResourcesForDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(_ref10) {
2231
+ var _this13 = this,
2232
+ _cartItems$5,
2233
+ _cartItems$6,
2234
+ _this$shopStore$get2;
2235
+ var resources_code, startDate, endDate, resources, cartItems, resourceIds, resourcesTypeId, isSingleResource, maxCutOffTime, maxCutOffTimeValue, duration, accountList, checkDuration, resourcesUseableMap, hasFlexibleDuration, operating_day_boundary, maxBlockThreshold, calculateCapacityFromCartItems, maxCapacity, arr, today, _loop2, i;
2236
+ return _regeneratorRuntime().wrap(function _callee24$(_context25) {
2237
+ while (1) switch (_context25.prev = _context25.next) {
2238
+ case 0:
2239
+ resources_code = _ref10.resources_code, startDate = _ref10.startDate, endDate = _ref10.endDate;
2240
+ // 如果 end_date 距离start_date小于 30 天,自动追加 end_date 为今天往后的 30 天
2241
+ if (dayjs(endDate).diff(dayjs(startDate), 'day') < 30) {
2242
+ endDate = dayjs(startDate).add(30, 'day').format('YYYY-MM-DD');
2243
+ }
2244
+ // 预请求资源数据,防止日期超过之前选择的范围
2245
+ _context25.next = 4;
2246
+ return this.getAvailableDate({
2247
+ startDate: startDate,
2248
+ endDate: endDate,
2249
+ useCache: true
2250
+ });
2251
+ case 4:
2252
+ // 取出购物车中所有一已选择的第一步资源
2253
+ resources = [];
2254
+ cartItems = this.store.cart.getItems().filter(function (n) {
2255
+ return !isNormalProduct(n._productOrigin);
2256
+ }); // if (cartItems?.[0].start_date) return [];
2257
+ resourceIds = [];
2258
+ resourcesTypeId = undefined;
2259
+ isSingleResource = false; // 找出购物车里最大的 cut_off_time
2260
+ maxCutOffTime = undefined;
2261
+ maxCutOffTimeValue = dayjs();
2262
+ cartItems.forEach(function (item) {
2263
+ var _item$_productOrigin17, _item$_productOrigin18, _item$_productOrigin19, _item$_productOrigin20;
2264
+ (_item$_productOrigin17 = item._productOrigin) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.product_resource) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.resources) === null || _item$_productOrigin17 === void 0 || _item$_productOrigin17.forEach(function (n) {
2265
+ // TODO: 少了个 status 的判断
2266
+ if (n.code === resources_code) {
2267
+ resources.push.apply(resources, _toConsumableArray(n.renderList || []));
2268
+ isSingleResource = n.type === 'single';
2269
+ }
2270
+ });
2271
+ // item._origin.resources?.forEach((n: any) => {
2272
+ // resourceIds.push(n.relation_id);
2273
+ // });
2274
+ if (item.resource_id && !resourceIds.includes(item.resource_id)) {
2275
+ resourceIds.push(item.resource_id);
2276
+ }
2277
+ resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin18 = item._productOrigin) === null || _item$_productOrigin18 === void 0 || (_item$_productOrigin18 = _item$_productOrigin18.product_resource) === null || _item$_productOrigin18 === void 0 || (_item$_productOrigin18 = _item$_productOrigin18.resources) === null || _item$_productOrigin18 === void 0 || (_item$_productOrigin18 = _item$_productOrigin18.find(function (n) {
2278
+ return n.code === resources_code;
2279
+ })) === null || _item$_productOrigin18 === void 0 ? void 0 : _item$_productOrigin18.id;
2280
+ if ((_item$_productOrigin19 = item._productOrigin) !== null && _item$_productOrigin19 !== void 0 && _item$_productOrigin19.cut_off_time && ((_item$_productOrigin20 = item._productOrigin) === null || _item$_productOrigin20 === void 0 ? void 0 : _item$_productOrigin20.cut_off_time.type) === 'advance') {
2281
+ var currentCutOffTime = dayjs().add(item._productOrigin.cut_off_time.unit, item._productOrigin.cut_off_time.unit_type);
2282
+ if (currentCutOffTime.isAfter(maxCutOffTimeValue, 'minute')) {
2283
+ maxCutOffTimeValue = currentCutOffTime;
2284
+ maxCutOffTime = item._productOrigin.cut_off_time;
2285
+ }
2286
+ }
2287
+ });
2223
2288
 
2224
- // 提交时间切片,绑定到对应购物车的商品上,更新购物车---只有 duration 商品
2289
+ // 保护: 如果 resources 为空则直接 return
2290
+ if (resources.length) {
2291
+ _context25.next = 14;
2292
+ break;
2293
+ }
2294
+ return _context25.abrupt("return", []);
2295
+ case 14:
2296
+ duration = 0; // duration = 不同账号的最长时间
2297
+ accountList = this.store.accountList.getAccounts();
2298
+ checkDuration = function checkDuration(cartItems) {
2299
+ var accountDuration = 0;
2300
+ cartItems.forEach(function (item) {
2301
+ // 单个预约累加账号 多个预约取最大值
2302
+ if (isSingleResource) {
2303
+ var _item$_productOrigin21;
2304
+ accountDuration += ((_item$_productOrigin21 = item._productOrigin) === null || _item$_productOrigin21 === void 0 || (_item$_productOrigin21 = _item$_productOrigin21.duration) === null || _item$_productOrigin21 === void 0 ? void 0 : _item$_productOrigin21.value) || 10;
2305
+ } else {
2306
+ var _item$_productOrigin22;
2307
+ if (accountDuration < (((_item$_productOrigin22 = item._productOrigin) === null || _item$_productOrigin22 === void 0 || (_item$_productOrigin22 = _item$_productOrigin22.duration) === null || _item$_productOrigin22 === void 0 ? void 0 : _item$_productOrigin22.value) || 10)) {
2308
+ var _item$_productOrigin23;
2309
+ accountDuration = ((_item$_productOrigin23 = item._productOrigin) === null || _item$_productOrigin23 === void 0 || (_item$_productOrigin23 = _item$_productOrigin23.duration) === null || _item$_productOrigin23 === void 0 ? void 0 : _item$_productOrigin23.value) || 10;
2310
+ }
2311
+ }
2312
+ });
2313
+ if (accountDuration > duration) {
2314
+ duration = accountDuration;
2315
+ }
2316
+ };
2317
+ if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
2318
+ accountList.forEach(function (account) {
2319
+ var cartItems = _this13.store.cart.getCartByAccount(account.getId());
2320
+ checkDuration(cartItems);
2321
+ });
2322
+ } else {
2323
+ checkDuration(cartItems);
2324
+ }
2325
+ // 如果 cartItem 上既没有时间,也没有资源,认为外部属于异常调用,直接丢一个空数组出去
2326
+ // 同时 session 类商品的流程也不应该调用这个方法
2327
+ if (!(!(cartItems !== null && cartItems !== void 0 && (_cartItems$5 = cartItems[0]) !== null && _cartItems$5 !== void 0 && _cartItems$5.start_date) && !(cartItems !== null && cartItems !== void 0 && (_cartItems$6 = cartItems[0]) !== null && _cartItems$6 !== void 0 && _cartItems$6.resource_id) || !(cartItems !== null && cartItems !== void 0 && cartItems[0].duration))) {
2328
+ _context25.next = 20;
2329
+ break;
2330
+ }
2331
+ return _context25.abrupt("return", []);
2332
+ case 20:
2333
+ resourcesUseableMap = {};
2334
+ hasFlexibleDuration = cartItems.some(function (item) {
2335
+ var _item$_productOrigin24;
2336
+ return ((_item$_productOrigin24 = item._productOrigin) === null || _item$_productOrigin24 === void 0 || (_item$_productOrigin24 = _item$_productOrigin24.duration) === null || _item$_productOrigin24 === void 0 ? void 0 : _item$_productOrigin24.type) === 'flexible';
2337
+ });
2338
+ operating_day_boundary = (_this$shopStore$get2 = this.shopStore.get('core')) === null || _this$shopStore$get2 === void 0 || (_this$shopStore$get2 = _this$shopStore$get2.core) === null || _this$shopStore$get2 === void 0 ? void 0 : _this$shopStore$get2.operating_day_boundary; // 如果有 hasFlexibleDuration,需要把动态时长商品(可能是多个,取最长的那个最低禁止购买时长)的最低禁止购买时长作为 split 的值
2339
+ maxBlockThreshold = 0;
2340
+ if (hasFlexibleDuration) {
2341
+ maxBlockThreshold = cartItems.reduce(function (max, item) {
2342
+ var _item$_productOrigin25;
2343
+ // 如果开启了灵活时长商品配置,则取 block_threshold 的值
2344
+ if ((_item$_productOrigin25 = item._productOrigin) !== null && _item$_productOrigin25 !== void 0 && (_item$_productOrigin25 = _item$_productOrigin25.duration) !== null && _item$_productOrigin25 !== void 0 && (_item$_productOrigin25 = _item$_productOrigin25.flexible_config) !== null && _item$_productOrigin25 !== void 0 && _item$_productOrigin25.is_enable_minimum_duration) {
2345
+ var _item$_productOrigin26;
2346
+ return Math.max(max, ((_item$_productOrigin26 = item._productOrigin) === null || _item$_productOrigin26 === void 0 || (_item$_productOrigin26 = _item$_productOrigin26.duration) === null || _item$_productOrigin26 === void 0 || (_item$_productOrigin26 = _item$_productOrigin26.flexible_config) === null || _item$_productOrigin26 === void 0 ? void 0 : _item$_productOrigin26.block_threshold) || 0);
2347
+ }
2348
+ return 0;
2349
+ }, 0);
2350
+ }
2351
+ // 计算容量的辅助函数
2352
+ calculateCapacityFromCartItems = function calculateCapacityFromCartItems(items) {
2353
+ var _items$0$_resourceOri2;
2354
+ // 还需要增加一个判断,maxCapacity 必须是我单个人里选择的资源只有同一种的情况下才可以累加,否则单个账号都是 1
2355
+ var firstResource = (_items$0$_resourceOri2 = items[0]._resourceOrigin) === null || _items$0$_resourceOri2 === void 0 ? void 0 : _items$0$_resourceOri2[0].id;
2356
+ var sameResourceLength = items.filter(function (item) {
2357
+ var _item$_resourceOrigin2;
2358
+ return ((_item$_resourceOrigin2 = item._resourceOrigin) === null || _item$_resourceOrigin2 === void 0 ? void 0 : _item$_resourceOrigin2[0].id) === firstResource;
2359
+ }).length;
2360
+ if (sameResourceLength !== items.length) {
2361
+ return 1;
2362
+ }
2363
+ // 找出单个购物车里最大的需求 capacity 即可
2364
+ return Math.max.apply(Math, _toConsumableArray(items.map(function (item) {
2365
+ return getCapacityInfoByCartItem(item).currentCapacity || 1;
2366
+ })));
2367
+ }; // 如果是多个预约,去要求出几个 holder 下最大的需求容量capacity
2368
+ maxCapacity = 1;
2369
+ if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
2370
+ accountList.forEach(function (account) {
2371
+ var accountCartItems = _this13.store.cart.getCartByAccount(account.getId());
2372
+ var currentCapacity = calculateCapacityFromCartItems(accountCartItems);
2373
+ if (currentCapacity > maxCapacity) {
2374
+ maxCapacity = currentCapacity;
2375
+ }
2376
+ });
2377
+ } else {
2378
+ maxCapacity = calculateCapacityFromCartItems(cartItems);
2379
+ }
2380
+ arr = [];
2381
+ today = dayjs().startOf('day'); // 计算 start_date 到 end_date 之间的所有日期,遍历他们并且计算每一天的可用
2382
+ _loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
2383
+ var currentDate, theDateResources, resourcesMap, timeSlots;
2384
+ return _regeneratorRuntime().wrap(function _loop2$(_context24) {
2385
+ while (1) switch (_context24.prev = _context24.next) {
2386
+ case 0:
2387
+ currentDate = i.format('YYYY-MM-DD');
2388
+ theDateResources = _this13.store.date.getResourcesListByDate(currentDate);
2389
+ resources.forEach(function (item) {
2390
+ var _theDateResources$fin2;
2391
+ item.times = (theDateResources === null || theDateResources === void 0 || (_theDateResources$fin2 = theDateResources.find(function (n) {
2392
+ return n.id === item.id;
2393
+ })) === null || _theDateResources$fin2 === void 0 ? void 0 : _theDateResources$fin2.times) || [];
2394
+ });
2395
+ resourcesMap = getResourcesMap(resources); // 如果日期已经过期则直接标记为不可用
2396
+ if (!i.isBefore(today)) {
2397
+ _context24.next = 7;
2398
+ break;
2399
+ }
2400
+ arr.push({
2401
+ date: currentDate,
2402
+ status: 'unavailable',
2403
+ week: i.format('ddd'),
2404
+ weekNum: i.day()
2405
+ });
2406
+ return _context24.abrupt("return", 1);
2407
+ case 7:
2408
+ timeSlots = getTimeSlicesByResources({
2409
+ resourceIds: resourceIds,
2410
+ resourcesMap: resourcesMap,
2411
+ duration: duration,
2412
+ currentDate: currentDate,
2413
+ split: 10,
2414
+ resourcesUseableMap: resourcesUseableMap,
2415
+ capacity: maxCapacity,
2416
+ cut_off_time: maxCutOffTime,
2417
+ hasFlexibleDuration: hasFlexibleDuration,
2418
+ operating_day_boundary: operating_day_boundary,
2419
+ maxBlockThreshold: maxBlockThreshold
2420
+ });
2421
+ if (timeSlots.length > 0) {
2422
+ arr.push({
2423
+ date: currentDate,
2424
+ status: 'available',
2425
+ week: i.format('ddd'),
2426
+ weekNum: i.day()
2427
+ });
2428
+ } else {
2429
+ arr.push({
2430
+ date: currentDate,
2431
+ status: 'unavailable',
2432
+ week: i.format('ddd'),
2433
+ weekNum: i.day()
2434
+ });
2435
+ }
2436
+ case 9:
2437
+ case "end":
2438
+ return _context24.stop();
2439
+ }
2440
+ }, _loop2);
2441
+ });
2442
+ i = dayjs(startDate);
2443
+ case 32:
2444
+ if (!i.isBefore(dayjs(endDate))) {
2445
+ _context25.next = 39;
2446
+ break;
2447
+ }
2448
+ return _context25.delegateYield(_loop2(), "t0", 34);
2449
+ case 34:
2450
+ if (!_context25.t0) {
2451
+ _context25.next = 36;
2452
+ break;
2453
+ }
2454
+ return _context25.abrupt("continue", 36);
2455
+ case 36:
2456
+ i = i.add(1, 'day');
2457
+ _context25.next = 32;
2458
+ break;
2459
+ case 39:
2460
+ return _context25.abrupt("return", arr);
2461
+ case 40:
2462
+ case "end":
2463
+ return _context25.stop();
2464
+ }
2465
+ }, _callee24, this);
2466
+ }));
2467
+ function getTimeSlotByAllResourcesForDate(_x19) {
2468
+ return _getTimeSlotByAllResourcesForDate.apply(this, arguments);
2469
+ }
2470
+ return getTimeSlotByAllResourcesForDate;
2471
+ }() // 提交时间切片,绑定到对应购物车的商品上,更新购物车---只有 duration 商品
2225
2472
  }, {
2226
2473
  key: "submitTimeSlot",
2227
2474
  value: function submitTimeSlot(timeSlots) {
2228
- var _this$shopStore$get2,
2229
- _this13 = this;
2475
+ var _this$shopStore$get3,
2476
+ _this14 = this;
2230
2477
  // 以账号为维度处理数据。购物车里每一项的 startTime应该是前一个商品的 endTime,如果是第一个商品则用 timeSlots.start_at
2231
2478
  var cartItems = this.store.cart.getItems().filter(function (n) {
2232
2479
  return !isNormalProduct(n._productOrigin);
@@ -2246,7 +2493,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2246
2493
  }, {});
2247
2494
 
2248
2495
  // 店铺营业结束时间
2249
- var operating_day_boundary = (_this$shopStore$get2 = this.shopStore.get('core')) === null || _this$shopStore$get2 === void 0 || (_this$shopStore$get2 = _this$shopStore$get2.core) === null || _this$shopStore$get2 === void 0 ? void 0 : _this$shopStore$get2.operating_day_boundary;
2496
+ var operating_day_boundary = (_this$shopStore$get3 = this.shopStore.get('core')) === null || _this$shopStore$get3 === void 0 || (_this$shopStore$get3 = _this$shopStore$get3.core) === null || _this$shopStore$get3 === void 0 ? void 0 : _this$shopStore$get3.operating_day_boundary;
2250
2497
 
2251
2498
  // 处理每个账号的商品
2252
2499
  Object.values(itemsByAccount).forEach(function (accountItems) {
@@ -2256,10 +2503,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2256
2503
  var osWarnTips = [];
2257
2504
  var newResources = cloneDeep(item._origin.resources);
2258
2505
  newResources.forEach(function (resource) {
2259
- var _item$_productOrigin17;
2506
+ var _item$_productOrigin27;
2260
2507
  // 如果商品配置的是灵活时长,开始时间设置为提交的时间,结束时间从资源的可用最晚时间和店铺营业结束时间里取一个最早的
2261
- if (((_item$_productOrigin17 = item._productOrigin) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.duration) === null || _item$_productOrigin17 === void 0 ? void 0 : _item$_productOrigin17.type) === 'flexible') {
2262
- var _allResources$find, _item$_productOrigin18, _item$_productOrigin19;
2508
+ if (((_item$_productOrigin27 = item._productOrigin) === null || _item$_productOrigin27 === void 0 || (_item$_productOrigin27 = _item$_productOrigin27.duration) === null || _item$_productOrigin27 === void 0 ? void 0 : _item$_productOrigin27.type) === 'flexible') {
2509
+ var _allResources$find, _item$_productOrigin28, _item$_productOrigin29;
2263
2510
  item.duration = {
2264
2511
  type: 'minutes',
2265
2512
  value: 10
@@ -2289,19 +2536,19 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2289
2536
  resource.endTime = formattedEndTime.format('YYYY-MM-DD HH:mm');
2290
2537
  // 如果是动态时长商品,并且当前选择的时间的结束时间小于了最低提示时长(warningThreshold),则追加一个提示
2291
2538
  // 如果currentStartTime + warningThreshold 大于 currentEndTime,且 osWarnTips 没有pisell2.product.card.closing-soon.warning 这一项,则加入这一项
2292
- if ((_item$_productOrigin18 = item._productOrigin) !== null && _item$_productOrigin18 !== void 0 && (_item$_productOrigin18 = _item$_productOrigin18.duration) !== null && _item$_productOrigin18 !== void 0 && (_item$_productOrigin18 = _item$_productOrigin18.flexible_config) !== null && _item$_productOrigin18 !== void 0 && _item$_productOrigin18.is_enable_minimum_duration && dayjs(currentStartTime).add(((_item$_productOrigin19 = item._productOrigin) === null || _item$_productOrigin19 === void 0 || (_item$_productOrigin19 = _item$_productOrigin19.duration) === null || _item$_productOrigin19 === void 0 || (_item$_productOrigin19 = _item$_productOrigin19.flexible_config) === null || _item$_productOrigin19 === void 0 ? void 0 : _item$_productOrigin19.warning_threshold) || 0, 'minutes').isAfter(dayjs(formattedEndTime))) {
2539
+ if ((_item$_productOrigin28 = item._productOrigin) !== null && _item$_productOrigin28 !== void 0 && (_item$_productOrigin28 = _item$_productOrigin28.duration) !== null && _item$_productOrigin28 !== void 0 && (_item$_productOrigin28 = _item$_productOrigin28.flexible_config) !== null && _item$_productOrigin28 !== void 0 && _item$_productOrigin28.is_enable_minimum_duration && dayjs(currentStartTime).add(((_item$_productOrigin29 = item._productOrigin) === null || _item$_productOrigin29 === void 0 || (_item$_productOrigin29 = _item$_productOrigin29.duration) === null || _item$_productOrigin29 === void 0 || (_item$_productOrigin29 = _item$_productOrigin29.flexible_config) === null || _item$_productOrigin29 === void 0 ? void 0 : _item$_productOrigin29.warning_threshold) || 0, 'minutes').isAfter(dayjs(formattedEndTime))) {
2293
2540
  if (!osWarnTips.includes('pisell2.product.card.closing-soon.warning')) {
2294
2541
  osWarnTips.push('pisell2.product.card.closing-soon.warning');
2295
2542
  }
2296
2543
  }
2297
2544
  } else {
2298
- var _item$_productOrigin20;
2545
+ var _item$_productOrigin30;
2299
2546
  resource.startTime = currentStartTime;
2300
- resource.endTime = dayjs(currentStartTime).add(((_item$_productOrigin20 = item._productOrigin) === null || _item$_productOrigin20 === void 0 || (_item$_productOrigin20 = _item$_productOrigin20.duration) === null || _item$_productOrigin20 === void 0 ? void 0 : _item$_productOrigin20.value) || 10, 'minutes').format('YYYY-MM-DD HH:mm');
2547
+ resource.endTime = dayjs(currentStartTime).add(((_item$_productOrigin30 = item._productOrigin) === null || _item$_productOrigin30 === void 0 || (_item$_productOrigin30 = _item$_productOrigin30.duration) === null || _item$_productOrigin30 === void 0 ? void 0 : _item$_productOrigin30.value) || 10, 'minutes').format('YYYY-MM-DD HH:mm');
2301
2548
  }
2302
2549
  // delete resource.times;
2303
2550
  });
2304
- _this13.store.cart.updateItem({
2551
+ _this14.store.cart.updateItem({
2305
2552
  _id: item._id,
2306
2553
  resources: newResources,
2307
2554
  osWarnTips: osWarnTips
@@ -2345,42 +2592,42 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2345
2592
  }, {
2346
2593
  key: "openProductDetail",
2347
2594
  value: function () {
2348
- var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(productId) {
2595
+ var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(productId) {
2349
2596
  var targetProductData, newScheduleArr, dateRange;
2350
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2351
- while (1) switch (_context24.prev = _context24.next) {
2597
+ return _regeneratorRuntime().wrap(function _callee25$(_context26) {
2598
+ while (1) switch (_context26.prev = _context26.next) {
2352
2599
  case 0:
2353
- _context24.next = 2;
2600
+ _context26.next = 2;
2354
2601
  return this.store.products.getProduct(productId);
2355
2602
  case 2:
2356
- targetProductData = _context24.sent;
2603
+ targetProductData = _context26.sent;
2357
2604
  if (!targetProductData) {
2358
- _context24.next = 17;
2605
+ _context26.next = 17;
2359
2606
  break;
2360
2607
  }
2361
2608
  this.store.currentProduct = targetProductData;
2362
2609
  this.store.currentProductMeta = {};
2363
2610
  // 资源预加载,如果是 duration 类型的商品,且是先选日期的流程,在这里预拉取资源数据
2364
2611
  if (!targetProductData['schedule.ids']) {
2365
- _context24.next = 12;
2612
+ _context26.next = 12;
2366
2613
  break;
2367
2614
  }
2368
2615
  newScheduleArr = this.getScheduleDataByIds(targetProductData['schedule.ids']);
2369
2616
  if (!this.store.currentProductMeta) this.store.currentProductMeta = {};
2370
2617
  this.store.currentProductMeta.schedule = newScheduleArr;
2371
- _context24.next = 17;
2618
+ _context26.next = 17;
2372
2619
  break;
2373
2620
  case 12:
2374
2621
  if (!targetProductData.duration) {
2375
- _context24.next = 17;
2622
+ _context26.next = 17;
2376
2623
  break;
2377
2624
  }
2378
2625
  dateRange = this.store.date.getDateRange(); // 如果不是先选日期的流程 duration 商品就啥也不做
2379
2626
  if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
2380
- _context24.next = 16;
2627
+ _context26.next = 16;
2381
2628
  break;
2382
2629
  }
2383
- return _context24.abrupt("return");
2630
+ return _context26.abrupt("return");
2384
2631
  case 16:
2385
2632
  // this.store.date.getResourceDates({
2386
2633
  // query: {
@@ -2396,11 +2643,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2396
2643
  });
2397
2644
  case 17:
2398
2645
  case "end":
2399
- return _context24.stop();
2646
+ return _context26.stop();
2400
2647
  }
2401
- }, _callee24, this);
2648
+ }, _callee25, this);
2402
2649
  }));
2403
- function openProductDetail(_x19) {
2650
+ function openProductDetail(_x20) {
2404
2651
  return _openProductDetail.apply(this, arguments);
2405
2652
  }
2406
2653
  return openProductDetail;
@@ -2417,14 +2664,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2417
2664
  // 通过商品和 schedule 来获取视频可用的时间片、时间片内资源可用的数据
2418
2665
  }, {
2419
2666
  key: "getTimeslotBySchedule",
2420
- value: function getTimeslotBySchedule(_ref10) {
2667
+ value: function getTimeslotBySchedule(_ref11) {
2421
2668
  var _this$store$currentPr2,
2422
2669
  _targetProductData$pr,
2423
- _this14 = this;
2424
- var date = _ref10.date,
2425
- scheduleIds = _ref10.scheduleIds,
2426
- resources = _ref10.resources,
2427
- product = _ref10.product;
2670
+ _targetProductData$pr2,
2671
+ _this15 = this;
2672
+ var date = _ref11.date,
2673
+ scheduleIds = _ref11.scheduleIds,
2674
+ resources = _ref11.resources,
2675
+ product = _ref11.product;
2428
2676
  var targetProduct = this.store.currentProduct;
2429
2677
  // 如果外面传递了product 优先用外面的
2430
2678
  var targetProductData = product || targetProduct;
@@ -2463,7 +2711,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2463
2711
  var firstEnabledResourceId = targetProductData === null || targetProductData === void 0 || (_targetProductData$pr = targetProductData.product_resource) === null || _targetProductData$pr === void 0 || (_targetProductData$pr = _targetProductData$pr.resources) === null || _targetProductData$pr === void 0 || (_targetProductData$pr = _targetProductData$pr.find(function (n) {
2464
2712
  return n.status === 1;
2465
2713
  })) === null || _targetProductData$pr === void 0 ? void 0 : _targetProductData$pr.id;
2466
-
2714
+ var firstEnabledResourceConfig = targetProductData === null || targetProductData === void 0 || (_targetProductData$pr2 = targetProductData.product_resource) === null || _targetProductData$pr2 === void 0 || (_targetProductData$pr2 = _targetProductData$pr2.resources) === null || _targetProductData$pr2 === void 0 ? void 0 : _targetProductData$pr2.find(function (n) {
2715
+ return n.status === 1 && n.id === firstEnabledResourceId;
2716
+ });
2717
+ var isMultipleBooking = (firstEnabledResourceConfig === null || firstEnabledResourceConfig === void 0 ? void 0 : firstEnabledResourceConfig.type) === 'multiple';
2467
2718
  // 计算每个日程切片下日程可用的资源的容量总和
2468
2719
  var formatScheduleTimeSlots = scheduleTimeSlots.map(function (item) {
2469
2720
  // 用来计算资源的可使用情况,针对单个schedule 时间片
@@ -2471,6 +2722,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2471
2722
  var count = 0;
2472
2723
  var bookingLeft = 0;
2473
2724
  var summaryCount = 0;
2725
+ var summaryConfigCount = 0;
2474
2726
  // 遍历所有资源
2475
2727
  allProductResources === null || allProductResources === void 0 || allProductResources.forEach(function (m) {
2476
2728
  // 遍历所有资源的上工时间片
@@ -2519,6 +2771,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2519
2771
  }
2520
2772
  currentResourcesTimeSlotCanUsedArr.push(res.usable);
2521
2773
  });
2774
+ if (m.form_id === firstEnabledResourceId) {
2775
+ // 确认当前资源是单个预约还是多个预约,单个预约则只需要计数,多个预约才添加容量
2776
+ if (isMultipleBooking) {
2777
+ summaryConfigCount += m.capacity;
2778
+ } else {
2779
+ summaryConfigCount += 1;
2780
+ }
2781
+ }
2522
2782
  // 在已经选定时间的情况下,只要canUseTime如果有一个 false 那就不可用
2523
2783
  if (!currentResourcesTimeSlotCanUsedArr.some(function (n) {
2524
2784
  return n === false;
@@ -2535,7 +2795,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2535
2795
  }
2536
2796
  });
2537
2797
  // 容量检测
2538
- var cartItems = _this14.store.cart.getItems();
2798
+ var cartItems = _this15.store.cart.getItems();
2539
2799
  productResources.forEach(function (n) {
2540
2800
  // 单个预约检测规则:
2541
2801
  // 1、跟我一样的商品同一时间在购物车里不可以超过我最少的那种资源的关联的资源个数
@@ -2554,13 +2814,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2554
2814
  }
2555
2815
  // 规则 2
2556
2816
  var otherCartItems = cartItems.filter(function (m) {
2557
- var _m$_productOrigin2, _targetProductData$id2;
2558
- return ((_m$_productOrigin2 = m._productOrigin) === null || _m$_productOrigin2 === void 0 || (_m$_productOrigin2 = _m$_productOrigin2.id) === null || _m$_productOrigin2 === void 0 ? void 0 : _m$_productOrigin2.toString()) !== (targetProductData === null || targetProductData === void 0 || (_targetProductData$id2 = targetProductData.id) === null || _targetProductData$id2 === void 0 ? void 0 : _targetProductData$id2.toString()) && "".concat(m.start_date, " ").concat(m.start_time) === item.start && "".concat(m.start_date, " ").concat(m.end_time) === item.end;
2817
+ var _m$_productOrigin2, _targetProductData$id2, _m$_productOrigin3;
2818
+ var isTimeMatch = ((_m$_productOrigin2 = m._productOrigin) === null || _m$_productOrigin2 === void 0 || (_m$_productOrigin2 = _m$_productOrigin2.id) === null || _m$_productOrigin2 === void 0 ? void 0 : _m$_productOrigin2.toString()) !== (targetProductData === null || targetProductData === void 0 || (_targetProductData$id2 = targetProductData.id) === null || _targetProductData$id2 === void 0 ? void 0 : _targetProductData$id2.toString()) && "".concat(m.start_date, " ").concat(m.start_time) === item.start && "".concat(m.start_date, " ").concat(m.end_time) === item.end;
2819
+ var isResourceMatch = (_m$_productOrigin3 = m._productOrigin) === null || _m$_productOrigin3 === void 0 || (_m$_productOrigin3 = _m$_productOrigin3.product_resource) === null || _m$_productOrigin3 === void 0 || (_m$_productOrigin3 = _m$_productOrigin3.resources) === null || _m$_productOrigin3 === void 0 ? void 0 : _m$_productOrigin3.find(function (m) {
2820
+ return m.type === n.type && m.status === 1;
2821
+ });
2822
+ return isTimeMatch && isResourceMatch;
2559
2823
  });
2560
2824
  otherCartItems.forEach(function (m) {
2561
- var _m$_productOrigin3;
2562
- var sameTypeResources = (_m$_productOrigin3 = m._productOrigin) === null || _m$_productOrigin3 === void 0 || (_m$_productOrigin3 = _m$_productOrigin3.product_resource) === null || _m$_productOrigin3 === void 0 || (_m$_productOrigin3 = _m$_productOrigin3.resources) === null || _m$_productOrigin3 === void 0 ? void 0 : _m$_productOrigin3.find(function (m) {
2563
- return m.type === n.type;
2825
+ var _m$_productOrigin4;
2826
+ var sameTypeResources = (_m$_productOrigin4 = m._productOrigin) === null || _m$_productOrigin4 === void 0 || (_m$_productOrigin4 = _m$_productOrigin4.product_resource) === null || _m$_productOrigin4 === void 0 || (_m$_productOrigin4 = _m$_productOrigin4.resources) === null || _m$_productOrigin4 === void 0 ? void 0 : _m$_productOrigin4.find(function (m) {
2827
+ return m.type === n.type && m.status === 1;
2564
2828
  });
2565
2829
  var sameTypeResourcesSet = new Set([].concat(_toConsumableArray((sameTypeResources === null || sameTypeResources === void 0 ? void 0 : sameTypeResources.optional_resource) || []), _toConsumableArray((sameTypeResources === null || sameTypeResources === void 0 ? void 0 : sameTypeResources.default_resource) || [])));
2566
2830
  // 把sameTypeResourcesSet 加到currentResourcesSet
@@ -2569,7 +2833,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2569
2833
  });
2570
2834
  });
2571
2835
  // 先确定是否每一个currentResourcesSet在这个时间点的 event_list 都是空的,如果不是空的还需要把他踢出currentResourcesSet
2572
- var currentDataResources = _this14.store.date.getResourcesListByDate(dayjs(item.start).format('YYYY-MM-DD'));
2836
+ var currentDataResources = _this15.store.date.getResourcesListByDate(dayjs(item.start).format('YYYY-MM-DD'));
2573
2837
  currentDataResources === null || currentDataResources === void 0 || currentDataResources.forEach(function (m) {
2574
2838
  if (currentResourcesSet.has(m.id)) {
2575
2839
  var mTimes = m.times.filter(function (n) {
@@ -2591,8 +2855,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2591
2855
  // 多个预约的检测规则:
2592
2856
  // 规则1、跟我一样的商品同一时间在购物车需要的容量总数不可以超过我配置的资源的 capacity 之和
2593
2857
  var _sameCartItems = cartItems.filter(function (m) {
2594
- var _m$_productOrigin4, _targetProductData$id3;
2595
- return ((_m$_productOrigin4 = m._productOrigin) === null || _m$_productOrigin4 === void 0 || (_m$_productOrigin4 = _m$_productOrigin4.id) === null || _m$_productOrigin4 === void 0 ? void 0 : _m$_productOrigin4.toString()) === (targetProductData === null || targetProductData === void 0 || (_targetProductData$id3 = targetProductData.id) === null || _targetProductData$id3 === void 0 ? void 0 : _targetProductData$id3.toString()) && "".concat(m.start_date, " ").concat(m.start_time) === item.start && "".concat(m.start_date, " ").concat(m.end_time) === item.end;
2858
+ var _m$_productOrigin5, _targetProductData$id3;
2859
+ return ((_m$_productOrigin5 = m._productOrigin) === null || _m$_productOrigin5 === void 0 || (_m$_productOrigin5 = _m$_productOrigin5.id) === null || _m$_productOrigin5 === void 0 ? void 0 : _m$_productOrigin5.toString()) === (targetProductData === null || targetProductData === void 0 || (_targetProductData$id3 = targetProductData.id) === null || _targetProductData$id3 === void 0 ? void 0 : _targetProductData$id3.toString()) && "".concat(m.start_date, " ").concat(m.start_time) === item.start && "".concat(m.start_date, " ").concat(m.end_time) === item.end;
2596
2860
  });
2597
2861
  var sameCartNeedCapacity = _sameCartItems.reduce(function (acc, curr) {
2598
2862
  return acc + getCapacityInfoByCartItem(curr).currentCapacity;
@@ -2617,8 +2881,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2617
2881
  return !m.onlyComputed;
2618
2882
  }));
2619
2883
  otherSameTimesCartItems.forEach(function (m) {
2620
- var _m$_productOrigin5;
2621
- var productResources = getResourcesByProduct(getResourcesMap((targetResourceDate === null || targetResourceDate === void 0 ? void 0 : targetResourceDate.resource) || []), ((_m$_productOrigin5 = m._productOrigin) === null || _m$_productOrigin5 === void 0 || (_m$_productOrigin5 = _m$_productOrigin5.product_resource) === null || _m$_productOrigin5 === void 0 ? void 0 : _m$_productOrigin5.resources) || [], selectedResources, 1);
2884
+ var _m$_productOrigin6;
2885
+ var productResources = getResourcesByProduct(getResourcesMap((targetResourceDate === null || targetResourceDate === void 0 ? void 0 : targetResourceDate.resource) || []), ((_m$_productOrigin6 = m._productOrigin) === null || _m$_productOrigin6 === void 0 || (_m$_productOrigin6 = _m$_productOrigin6.product_resource) === null || _m$_productOrigin6 === void 0 ? void 0 : _m$_productOrigin6.resources) || [], selectedResources, 1);
2622
2886
  productResources.forEach(function (m) {
2623
2887
  if (m.id === n.id) {
2624
2888
  m.renderList.forEach(function (n) {
@@ -2673,6 +2937,28 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2673
2937
  });
2674
2938
  var startDayJs = dayjs(item.start);
2675
2939
  var endDayJs = dayjs(item.end);
2940
+
2941
+ // 状态
2942
+ // 如果是isMultipleBooking
2943
+ // lots_of_space: summaryCount / summaryConfigCount > 0.5
2944
+ // filling_up_fast: summaryCount / summaryConfigCount <= 0.5 && summaryCount > 0
2945
+ // sold_out: bookingLeft = 0
2946
+ // 如果不是isMultipleBooking
2947
+ // lots_of_space: bookingLeft / summaryConfigCount > 0.5
2948
+ // filling_up_fast: bookingLeft / summaryConfigCount <= 0.5 && count > 0
2949
+ // sold_out: bookingLeft = 0
2950
+ var timeStatus = 'sold_out';
2951
+ if (bookingLeft === 0) timeStatus = 'sold_out';else if (isMultipleBooking) {
2952
+ if (summaryConfigCount === 0) timeStatus = 'sold_out';else {
2953
+ var usageRatio = summaryCount / summaryConfigCount;
2954
+ if (usageRatio > 0.5) timeStatus = 'lots_of_space';else if (summaryCount > 0) timeStatus = 'filling_up_fast';else timeStatus = 'sold_out';
2955
+ }
2956
+ } else {
2957
+ if (summaryConfigCount === 0) timeStatus = 'sold_out';else {
2958
+ var _usageRatio = bookingLeft / summaryConfigCount;
2959
+ if (_usageRatio > 0.5) timeStatus = 'lots_of_space';else if (count > 0) timeStatus = 'filling_up_fast';else timeStatus = 'sold_out';
2960
+ }
2961
+ }
2676
2962
  return {
2677
2963
  start_time: startDayJs.format('HH:mm'),
2678
2964
  end_time: endDayJs.format('HH:mm'),
@@ -2680,7 +2966,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2680
2966
  end_at: endDayJs,
2681
2967
  count: count,
2682
2968
  left: bookingLeft,
2683
- summaryCount: summaryCount
2969
+ summaryCount: summaryCount,
2970
+ status: timeStatus
2684
2971
  };
2685
2972
  });
2686
2973
  return formatScheduleTimeSlots;
@@ -2721,7 +3008,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2721
3008
  }));
2722
3009
 
2723
3010
  // 与其他资源的时间段求交集
2724
- var _loop2 = function _loop2() {
3011
+ var _loop3 = function _loop3() {
2725
3012
  var currentResourceSlots = allTimeSlots[i];
2726
3013
  var intersections = [];
2727
3014
 
@@ -2750,7 +3037,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2750
3037
  }));
2751
3038
  };
2752
3039
  for (var i = 1; i < allTimeSlots.length; i++) {
2753
- if (_loop2()) continue;
3040
+ if (_loop3()) continue;
2754
3041
  }
2755
3042
 
2756
3043
  // 格式化返回结果
@@ -2766,7 +3053,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2766
3053
  }, {
2767
3054
  key: "checkMaxDurationCapacity",
2768
3055
  value: function checkMaxDurationCapacity() {
2769
- var _this15 = this;
3056
+ var _this16 = this;
2770
3057
  var cartItems = this.store.cart.getItems().filter(function (item) {
2771
3058
  return !isNormalProduct(item._productOrigin);
2772
3059
  });
@@ -2805,6 +3092,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2805
3092
  itemsByResourceType[resourceCode] = [];
2806
3093
  }
2807
3094
  // 避免重复添加同一个商品
3095
+ // 如果之前添加过的依赖相同资源的跟我现在是同一个 holder,也不需要重复添加
3096
+ if (itemsByResourceType[resourceCode].find(function (item) {
3097
+ return item.holder_id === cartItem.holder_id;
3098
+ })) {
3099
+ return;
3100
+ }
2808
3101
  if (!itemsByResourceType[resourceCode].find(function (item) {
2809
3102
  return item._id === cartItem._id;
2810
3103
  })) {
@@ -2856,7 +3149,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2856
3149
  var processedCartItemIds = new Set();
2857
3150
 
2858
3151
  // 先检查所有资源类型,收集可用数量信息
2859
- var _loop3 = function _loop3() {
3152
+ var _loop4 = function _loop4() {
2860
3153
  var _resourceTypeConfig;
2861
3154
  var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
2862
3155
  resourceCode = _Object$entries$_i[0],
@@ -2972,7 +3265,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2972
3265
  }));
2973
3266
 
2974
3267
  // 找到所有资源都可用的时间段
2975
- var commonTimeSlots = _this15.findCommonAvailableTimeSlots(resourcesOfThisType);
3268
+ var commonTimeSlots = _this16.findCommonAvailableTimeSlots(resourcesOfThisType);
2976
3269
  console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u7684\u516C\u5171\u65F6\u95F4\u6BB5:"), commonTimeSlots);
2977
3270
  if (commonTimeSlots.length === 0) {
2978
3271
  console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u6CA1\u6709\u516C\u5171\u53EF\u7528\u65F6\u95F4\u6BB5"));
@@ -3003,7 +3296,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3003
3296
  },
3004
3297
  _ret2;
3005
3298
  for (var _i = 0, _Object$entries = Object.entries(itemsByResourceType); _i < _Object$entries.length; _i++) {
3006
- _ret2 = _loop3();
3299
+ _ret2 = _loop4();
3007
3300
  if (_ret2) return _ret2.v;
3008
3301
  }
3009
3302
 
@@ -3047,7 +3340,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3047
3340
  cartItemsByTimeSlot[timeSlotKey].push(cartItem);
3048
3341
  });
3049
3342
  // 检查每个时间段是否有足够的资源容量
3050
- var _loop4 = function _loop4() {
3343
+ var _loop5 = function _loop5() {
3051
3344
  var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
3052
3345
  timeSlotKey = _Object$entries2$_i[0],
3053
3346
  itemsInTimeSlot = _Object$entries2$_i[1];
@@ -3065,8 +3358,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3065
3358
  var resourcesIdSet = new Set();
3066
3359
 
3067
3360
  // 获取资源数据
3068
- var dateRange = _this15.store.date.getDateRange();
3069
- var resourcesDates = _this15.store.date.getDateList();
3361
+ var dateRange = _this16.store.date.getDateRange();
3362
+ var resourcesDates = _this16.store.date.getDateList();
3070
3363
  var targetResourceDate = resourcesDates.find(function (n) {
3071
3364
  return n.date === startDate;
3072
3365
  });
@@ -3103,7 +3396,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3103
3396
  },
3104
3397
  _ret3;
3105
3398
  for (var _i2 = 0, _Object$entries2 = Object.entries(cartItemsByTimeSlot); _i2 < _Object$entries2.length; _i2++) {
3106
- _ret3 = _loop4();
3399
+ _ret3 = _loop5();
3107
3400
  if (_ret3 === 0) continue;
3108
3401
  if (_ret3) return _ret3.v;
3109
3402
  }
@@ -3122,17 +3415,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3122
3415
  */
3123
3416
  }, {
3124
3417
  key: "convertProductToCartItem",
3125
- value: function convertProductToCartItem(_ref11) {
3126
- var product = _ref11.product,
3127
- date = _ref11.date,
3128
- account = _ref11.account;
3129
- var _ref12 = product || {},
3130
- bundle = _ref12.bundle,
3131
- options = _ref12.options,
3132
- origin = _ref12.origin,
3133
- product_variant_id = _ref12.product_variant_id,
3134
- _ref12$quantity = _ref12.quantity,
3135
- quantity = _ref12$quantity === void 0 ? 1 : _ref12$quantity;
3418
+ value: function convertProductToCartItem(_ref12) {
3419
+ var product = _ref12.product,
3420
+ date = _ref12.date,
3421
+ account = _ref12.account;
3422
+ var _ref13 = product || {},
3423
+ bundle = _ref13.bundle,
3424
+ options = _ref13.options,
3425
+ origin = _ref13.origin,
3426
+ product_variant_id = _ref13.product_variant_id,
3427
+ _ref13$quantity = _ref13.quantity,
3428
+ quantity = _ref13$quantity === void 0 ? 1 : _ref13$quantity;
3136
3429
 
3137
3430
  // 处理商品数据,类似 addProductToCart 中的逻辑
3138
3431
  var productData = _objectSpread(_objectSpread({}, origin), {}, {
@@ -3187,11 +3480,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3187
3480
  }
3188
3481
  }, {
3189
3482
  key: "checkMaxDurationCapacityForDetailNums",
3190
- value: function checkMaxDurationCapacityForDetailNums(_ref13) {
3191
- var _this16 = this;
3192
- var product = _ref13.product,
3193
- date = _ref13.date,
3194
- account = _ref13.account;
3483
+ value: function checkMaxDurationCapacityForDetailNums(_ref14) {
3484
+ var _this17 = this;
3485
+ var product = _ref14.product,
3486
+ date = _ref14.date,
3487
+ account = _ref14.account;
3195
3488
  var cartItems = this.store.cart.getItems().filter(function (item) {
3196
3489
  return !isNormalProduct(item._productOrigin);
3197
3490
  });
@@ -3289,7 +3582,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3289
3582
  var processedCartItemIds = new Set();
3290
3583
 
3291
3584
  // 先检查所有资源类型,收集可用数量信息
3292
- var _loop5 = function _loop5() {
3585
+ var _loop6 = function _loop6() {
3293
3586
  var _resourceTypeConfig2;
3294
3587
  var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2),
3295
3588
  resourceCode = _Object$entries3$_i[0],
@@ -3405,7 +3698,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3405
3698
  }));
3406
3699
 
3407
3700
  // 找到所有资源都可用的时间段
3408
- var commonTimeSlots = _this16.findCommonAvailableTimeSlots(resourcesOfThisType);
3701
+ var commonTimeSlots = _this17.findCommonAvailableTimeSlots(resourcesOfThisType);
3409
3702
  console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u7684\u516C\u5171\u65F6\u95F4\u6BB5:"), commonTimeSlots);
3410
3703
  if (commonTimeSlots.length === 0) {
3411
3704
  console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u6CA1\u6709\u516C\u5171\u53EF\u7528\u65F6\u95F4\u6BB5"));
@@ -3436,7 +3729,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3436
3729
  },
3437
3730
  _ret4;
3438
3731
  for (var _i3 = 0, _Object$entries3 = Object.entries(itemsByResourceType); _i3 < _Object$entries3.length; _i3++) {
3439
- _ret4 = _loop5();
3732
+ _ret4 = _loop6();
3440
3733
  if (_ret4) return _ret4.v;
3441
3734
  }
3442
3735
 
@@ -3480,7 +3773,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3480
3773
  cartItemsByTimeSlot[timeSlotKey].push(cartItem);
3481
3774
  });
3482
3775
  // 检查每个时间段是否有足够的资源容量
3483
- var _loop6 = function _loop6() {
3776
+ var _loop7 = function _loop7() {
3484
3777
  var _Object$entries4$_i = _slicedToArray(_Object$entries4[_i4], 2),
3485
3778
  timeSlotKey = _Object$entries4$_i[0],
3486
3779
  itemsInTimeSlot = _Object$entries4$_i[1];
@@ -3499,7 +3792,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3499
3792
 
3500
3793
  // 获取资源数据
3501
3794
  // const dateRange = this.store.date.getDateRange();
3502
- var resourcesDates = _this16.store.date.getDateList();
3795
+ var resourcesDates = _this17.store.date.getDateList();
3503
3796
  var targetResourceDate = resourcesDates.find(function (n) {
3504
3797
  return n.date === startDate;
3505
3798
  });
@@ -3536,7 +3829,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3536
3829
  },
3537
3830
  _ret5;
3538
3831
  for (var _i4 = 0, _Object$entries4 = Object.entries(cartItemsByTimeSlot); _i4 < _Object$entries4.length; _i4++) {
3539
- _ret5 = _loop6();
3832
+ _ret5 = _loop7();
3540
3833
  if (_ret5 === 0) continue;
3541
3834
  if (_ret5) return _ret5.v;
3542
3835
  }
@@ -3569,41 +3862,41 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3569
3862
  }, {
3570
3863
  key: "getProductTypeById",
3571
3864
  value: function () {
3572
- var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(id) {
3865
+ var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(id) {
3573
3866
  var productData, _productData$schedule;
3574
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
3575
- while (1) switch (_context25.prev = _context25.next) {
3867
+ return _regeneratorRuntime().wrap(function _callee26$(_context27) {
3868
+ while (1) switch (_context27.prev = _context27.next) {
3576
3869
  case 0:
3577
- _context25.next = 2;
3870
+ _context27.next = 2;
3578
3871
  return this.store.products.getProduct(id);
3579
3872
  case 2:
3580
- productData = _context25.sent;
3873
+ productData = _context27.sent;
3581
3874
  if (!productData) {
3582
- _context25.next = 9;
3875
+ _context27.next = 9;
3583
3876
  break;
3584
3877
  }
3585
3878
  if (!productData.duration) {
3586
- _context25.next = 6;
3879
+ _context27.next = 6;
3587
3880
  break;
3588
3881
  }
3589
- return _context25.abrupt("return", 'duration');
3882
+ return _context27.abrupt("return", 'duration');
3590
3883
  case 6:
3591
3884
  if (!((_productData$schedule = productData['schedule.ids']) !== null && _productData$schedule !== void 0 && _productData$schedule.length)) {
3592
- _context25.next = 8;
3885
+ _context27.next = 8;
3593
3886
  break;
3594
3887
  }
3595
- return _context25.abrupt("return", 'session');
3888
+ return _context27.abrupt("return", 'session');
3596
3889
  case 8:
3597
- return _context25.abrupt("return", 'normal');
3890
+ return _context27.abrupt("return", 'normal');
3598
3891
  case 9:
3599
- return _context25.abrupt("return", 'normal');
3892
+ return _context27.abrupt("return", 'normal');
3600
3893
  case 10:
3601
3894
  case "end":
3602
- return _context25.stop();
3895
+ return _context27.stop();
3603
3896
  }
3604
- }, _callee25, this);
3897
+ }, _callee26, this);
3605
3898
  }));
3606
- function getProductTypeById(_x20) {
3899
+ function getProductTypeById(_x21) {
3607
3900
  return _getProductTypeById.apply(this, arguments);
3608
3901
  }
3609
3902
  return getProductTypeById;
@@ -3723,12 +4016,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3723
4016
  }, {
3724
4017
  key: "getTimeslotsScheduleByDateRange",
3725
4018
  value: (function () {
3726
- var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(_ref14) {
4019
+ var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(_ref15) {
3727
4020
  var startDate, endDate, scheduleIds, resources, dates, currentDate, end, results, _i5, _dates, date;
3728
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
3729
- while (1) switch (_context26.prev = _context26.next) {
4021
+ return _regeneratorRuntime().wrap(function _callee27$(_context28) {
4022
+ while (1) switch (_context28.prev = _context28.next) {
3730
4023
  case 0:
3731
- startDate = _ref14.startDate, endDate = _ref14.endDate, scheduleIds = _ref14.scheduleIds, resources = _ref14.resources;
4024
+ startDate = _ref15.startDate, endDate = _ref15.endDate, scheduleIds = _ref15.scheduleIds, resources = _ref15.resources;
3732
4025
  console.log('appoimentBooking-session-date-getTimeslotsScheduleByDateRange', {
3733
4026
  startDate: startDate,
3734
4027
  endDate: endDate,
@@ -3753,14 +4046,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3753
4046
  resources: resources
3754
4047
  });
3755
4048
  }
3756
- return _context26.abrupt("return", results);
4049
+ return _context28.abrupt("return", results);
3757
4050
  case 9:
3758
4051
  case "end":
3759
- return _context26.stop();
4052
+ return _context28.stop();
3760
4053
  }
3761
- }, _callee26, this);
4054
+ }, _callee27, this);
3762
4055
  }));
3763
- function getTimeslotsScheduleByDateRange(_x21) {
4056
+ function getTimeslotsScheduleByDateRange(_x22) {
3764
4057
  return _getTimeslotsScheduleByDateRange.apply(this, arguments);
3765
4058
  }
3766
4059
  return getTimeslotsScheduleByDateRange;
@@ -3768,7 +4061,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3768
4061
  }, {
3769
4062
  key: "getAvailableDateForSessionOptimize",
3770
4063
  value: function () {
3771
- var _getAvailableDateForSessionOptimize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
4064
+ var _getAvailableDateForSessionOptimize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
3772
4065
  var _this$store$currentPr3, _this$store$currentPr4, _tempProducts;
3773
4066
  var params,
3774
4067
  startDate,
@@ -3787,12 +4080,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3787
4080
  openResources,
3788
4081
  allProductResources,
3789
4082
  targetSchedules,
3790
- _loop7,
3791
- _args28 = arguments;
3792
- return _regeneratorRuntime().wrap(function _callee27$(_context28) {
3793
- while (1) switch (_context28.prev = _context28.next) {
4083
+ _loop8,
4084
+ _args30 = arguments;
4085
+ return _regeneratorRuntime().wrap(function _callee28$(_context30) {
4086
+ while (1) switch (_context30.prev = _context30.next) {
3794
4087
  case 0:
3795
- params = _args28.length > 0 && _args28[0] !== undefined ? _args28[0] : {};
4088
+ params = _args30.length > 0 && _args30[0] !== undefined ? _args30[0] : {};
3796
4089
  // 开始日期如果小于今天,直接以今天当做开始日期
3797
4090
  startDate = params.startDate, endDate = params.endDate; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
3798
4091
  if (dayjs(startDate).isBefore(dayjs(), 'day') && (dayjs(endDate).isAfter(dayjs(), 'day') || dayjs(endDate).isSame(dayjs(), 'day'))) {
@@ -3817,15 +4110,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3817
4110
  // 先去读缓存结果,因为正常 UI 调用的是 7 天,而下面我会直接计算 30 天(最少也是 14 天),所以先去读缓存结果,如果缓存结果存在,则直接返回
3818
4111
  cache = (_this$store$currentPr3 = this.store.currentProductMeta) === null || _this$store$currentPr3 === void 0 ? void 0 : _this$store$currentPr3['timeSlotBySchedule'];
3819
4112
  if (!cache) {
3820
- _context28.next = 13;
4113
+ _context30.next = 13;
3821
4114
  break;
3822
4115
  }
3823
4116
  if (!(dayjs(params.startDate).isSameOrAfter(dayjs(cache.startDate), 'day') && dayjs(params.endDate).isSameOrBefore(dayjs(cache.endDate), 'day'))) {
3824
- _context28.next = 13;
4117
+ _context30.next = 13;
3825
4118
  break;
3826
4119
  }
3827
4120
  this.store.date.setDateList(cache.dateList);
3828
- return _context28.abrupt("return", {
4121
+ return _context30.abrupt("return", {
3829
4122
  dateList: cache.dateList,
3830
4123
  firstAvailableDate: cache.firstAvailableDate
3831
4124
  });
@@ -3835,7 +4128,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3835
4128
  schedule = (_this$store$currentPr4 = this.store.currentProductMeta) === null || _this$store$currentPr4 === void 0 ? void 0 : _this$store$currentPr4['schedule'];
3836
4129
  filteredSchedule = filterScheduleByDateRange(schedule, startDate || '', endDate || ''); // 1.后端返回的数据,确定资源在每一天的可用和使用情况
3837
4130
  tempResourceIds = getResourcesIdsByProduct(tempProducts);
3838
- _context28.next = 19;
4131
+ _context30.next = 19;
3839
4132
  return this.store.date.fetchResourceDates({
3840
4133
  query: {
3841
4134
  start_date: startDate || '',
@@ -3844,7 +4137,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3844
4137
  }
3845
4138
  });
3846
4139
  case 19:
3847
- res = _context28.sent;
4140
+ res = _context30.sent;
3848
4141
  // 2. 商品 schedule 数据,确定日程在每一天的时间片
3849
4142
  // 3. 把后端返回的和 schedule 的数据进行合并,确定每一天的可用和使用情况
3850
4143
  dates = [];
@@ -3864,13 +4157,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3864
4157
  }
3865
4158
  });
3866
4159
  targetSchedules = this.store.schedule.getScheduleListByIds(tempProducts['schedule.ids']);
3867
- _loop7 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop7() {
3868
- var currentDateStr, status, _checkSessionProductL, latestStartDate, earliestEndDate, scheduleByDate, minTimeMaxTime, scheduleTimeSlots, timesSlotCanUse;
3869
- return _regeneratorRuntime().wrap(function _loop7$(_context27) {
3870
- while (1) switch (_context27.prev = _context27.next) {
4160
+ _loop8 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop8() {
4161
+ var currentDateStr, status, summaryCount, availableCount, _checkSessionProductL, latestStartDate, earliestEndDate, scheduleByDate, minTimeMaxTime, scheduleTimeSlots, timesSlotCanUse, dateStatus, usageRatio;
4162
+ return _regeneratorRuntime().wrap(function _loop8$(_context29) {
4163
+ while (1) switch (_context29.prev = _context29.next) {
3871
4164
  case 0:
3872
4165
  currentDateStr = currentDate.format('YYYY-MM-DD');
3873
- status = 'available'; // 1. 检查商品的提前量等情况是否满足
4166
+ status = 'available';
4167
+ summaryCount = 0;
4168
+ availableCount = 0; // 1. 检查商品的提前量等情况是否满足
3874
4169
  _checkSessionProductL = checkSessionProductLeadTime(tempProducts), latestStartDate = _checkSessionProductL.latestStartDate, earliestEndDate = _checkSessionProductL.earliestEndDate;
3875
4170
  if (latestStartDate || earliestEndDate) {
3876
4171
  // 如果时间在最早开始时间之前,则设置为不可用
@@ -3896,17 +4191,25 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3896
4191
  if (status === 'available') {
3897
4192
  minTimeMaxTime = calcMinTimeMaxTimeBySchedules(targetSchedules, {}, currentDateStr);
3898
4193
  scheduleTimeSlots = getAllSortedDateRanges(minTimeMaxTime); // 同一天内多个时间片下 只要有一个可用则视为可用
3899
- timesSlotCanUse = scheduleTimeSlots.some(function (item) {
4194
+ timesSlotCanUse = false;
4195
+ scheduleTimeSlots.forEach(function (item) {
3900
4196
  // 用来计算资源的可使用情况,针对单个schedule 时间片
3901
4197
  var resourcesUseableMap = {};
3902
4198
  // 遍历产品下启用的资源
3903
4199
  // 必须要保证每种类型的资源都至少有一个能够在对应时间点被选择
3904
- return openResources.every(function (resource) {
4200
+ // 求出第一个资源的剩余量和总量
4201
+ // 剩余量=每个资源在每个时间片内剩余之和
4202
+ // 总量=每个资源在每个时间片内资源总量之和
4203
+ var isAllResourceTypesUseable = true;
4204
+ openResources.forEach(function (resource) {
4205
+ // if (!isAllResourceTypesUseable) return;
4206
+
3905
4207
  // 获取当前资源类型的资源列表
3906
4208
  var currentResourcesList = allProductResources.filter(function (n) {
3907
4209
  return n.form_id === resource.resource_type_id;
3908
4210
  });
3909
- return currentResourcesList === null || currentResourcesList === void 0 ? void 0 : currentResourcesList.some(function (m) {
4211
+ var isAnyResourceUseableInType = false;
4212
+ currentResourcesList === null || currentResourcesList === void 0 || currentResourcesList.forEach(function (m) {
3910
4213
  // 遍历所有资源的上工时间片
3911
4214
  // m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
3912
4215
  // time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
@@ -3914,12 +4217,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3914
4217
  var mTimes = m.times.filter(function (n) {
3915
4218
  return !dayjs(n.start_at).isAfter(dayjs(item.start), 'minute') && !dayjs(n.end_at).isBefore(dayjs(item.end), 'minute');
3916
4219
  });
4220
+
3917
4221
  // 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
3918
- if (mTimes.length === 0) {
3919
- return;
4222
+ if (mTimes.length === 0) return;
4223
+ // 如果资源可用则把他的容量纳入总计
4224
+ if (resource.type === 'multiple') {
4225
+ summaryCount += m.capacity;
4226
+ } else {
4227
+ summaryCount += 1;
3920
4228
  }
3921
- var targetCanUseTimes = mTimes.some(function (childTiem) {
4229
+ var isAnyTimeSliceUseable = false;
4230
+ mTimes.forEach(function (childTiem) {
3922
4231
  var _tempProducts3;
4232
+ if (isAnyTimeSliceUseable) return;
4233
+
3923
4234
  // 挨个去匹配某个工作时间段结合当前日程时间,资源能不能用,有多少容量能用
3924
4235
  var res = getIsUsableByTimeItem({
3925
4236
  timeSlice: {
@@ -3937,11 +4248,21 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3937
4248
  if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
3938
4249
  resourcesUseableMap[m.id] = res.usable;
3939
4250
  }
3940
- return res.usable && !m.onlyComputed;
4251
+ if (res.usable && !m.onlyComputed) {
4252
+ isAnyTimeSliceUseable = true;
4253
+ if (resource.type === 'multiple') {
4254
+ availableCount += res.remainingCapacity;
4255
+ } else {
4256
+ availableCount += 1;
4257
+ }
4258
+ }
4259
+ ;
3941
4260
  });
3942
- return targetCanUseTimes;
4261
+ if (isAnyTimeSliceUseable) isAnyResourceUseableInType = true;
3943
4262
  });
4263
+ if (!isAnyResourceUseableInType) isAllResourceTypesUseable = false;
3944
4264
  });
4265
+ if (isAllResourceTypesUseable) timesSlotCanUse = true;
3945
4266
  });
3946
4267
  if (!timesSlotCanUse) {
3947
4268
  status = 'unavailable';
@@ -3950,41 +4271,55 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3950
4271
  firstAvailableDate = currentDateStr;
3951
4272
  }
3952
4273
  }
4274
+ // 状态: lots_of_space: availableCount / summaryCount > 0.5
4275
+ // filling_up_fast: availableCount / summaryCount <= 0.5 && availableCount > 0
4276
+ // sold_out: summaryCount = 0
4277
+ // unavailable: summaryCount > 0 && availableCount = 0
4278
+
4279
+ if (status === 'unavailable') {
4280
+ // dateStatus = 'unavailable'
4281
+ if (availableCount === 0 && summaryCount > 0) dateStatus = 'sold_out';else dateStatus = 'unavailable';
4282
+ } else {
4283
+ usageRatio = availableCount / summaryCount;
4284
+ if (usageRatio > 0.5) dateStatus = 'lots_of_space';else dateStatus = 'filling_up_fast';
4285
+ }
3953
4286
  dates.push({
3954
4287
  date: dayjs(currentDate).format('YYYY-MM-DD'),
3955
4288
  week: dayjs(currentDate).format('ddd'),
3956
4289
  weekNum: dayjs(currentDate).day(),
3957
- status: status
4290
+ summaryCount: summaryCount,
4291
+ availableCount: availableCount,
4292
+ status: dateStatus
3958
4293
  });
3959
4294
 
3960
4295
  // 如果 firstAvailableDate 距离 startDate 大于 14 天了,则后面就不需要再找了,也是一种性能保护
3961
4296
  if (!(firstAvailableDate && dayjs(currentDate).diff(dayjs(startDate), 'day') > 31)) {
3962
- _context27.next = 9;
4297
+ _context29.next = 12;
3963
4298
  break;
3964
4299
  }
3965
- return _context27.abrupt("return", 1);
3966
- case 9:
4300
+ return _context29.abrupt("return", 1);
4301
+ case 12:
3967
4302
  currentDate = dayjs(currentDate).add(1, 'day');
3968
- case 10:
4303
+ case 13:
3969
4304
  case "end":
3970
- return _context27.stop();
4305
+ return _context29.stop();
3971
4306
  }
3972
- }, _loop7);
4307
+ }, _loop8);
3973
4308
  });
3974
4309
  case 28:
3975
4310
  if (!(dayjs(currentDate).isBefore(dayjs(endDate), 'day') || dayjs(currentDate).isSame(dayjs(endDate), 'day'))) {
3976
- _context28.next = 34;
4311
+ _context30.next = 34;
3977
4312
  break;
3978
4313
  }
3979
- return _context28.delegateYield(_loop7(), "t0", 30);
4314
+ return _context30.delegateYield(_loop8(), "t0", 30);
3980
4315
  case 30:
3981
- if (!_context28.t0) {
3982
- _context28.next = 32;
4316
+ if (!_context30.t0) {
4317
+ _context30.next = 32;
3983
4318
  break;
3984
4319
  }
3985
- return _context28.abrupt("break", 34);
4320
+ return _context30.abrupt("break", 34);
3986
4321
  case 32:
3987
- _context28.next = 28;
4322
+ _context30.next = 28;
3988
4323
  break;
3989
4324
  case 34:
3990
4325
  // 最终把资源数据也加到日期内
@@ -3999,15 +4334,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3999
4334
  startDate: startDate,
4000
4335
  endDate: dayjs(currentDate).format('YYYY-MM-DD')
4001
4336
  };
4002
- return _context28.abrupt("return", {
4337
+ return _context30.abrupt("return", {
4003
4338
  dateList: dates,
4004
4339
  firstAvailableDate: firstAvailableDate
4005
4340
  });
4006
4341
  case 39:
4007
4342
  case "end":
4008
- return _context28.stop();
4343
+ return _context30.stop();
4009
4344
  }
4010
- }, _callee27, this);
4345
+ }, _callee28, this);
4011
4346
  }));
4012
4347
  function getAvailableDateForSessionOptimize() {
4013
4348
  return _getAvailableDateForSessionOptimize.apply(this, arguments);
@@ -4054,18 +4389,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
4054
4389
  }, {
4055
4390
  key: "getContactInfo",
4056
4391
  value: (function () {
4057
- var _getContactInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
4058
- return _regeneratorRuntime().wrap(function _callee28$(_context29) {
4059
- while (1) switch (_context29.prev = _context29.next) {
4392
+ var _getContactInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
4393
+ return _regeneratorRuntime().wrap(function _callee29$(_context31) {
4394
+ while (1) switch (_context31.prev = _context31.next) {
4060
4395
  case 0:
4061
- return _context29.abrupt("return", this.request.get('/customer/metadata', params));
4396
+ return _context31.abrupt("return", this.request.get('/customer/metadata', params));
4062
4397
  case 1:
4063
4398
  case "end":
4064
- return _context29.stop();
4399
+ return _context31.stop();
4065
4400
  }
4066
- }, _callee28, this);
4401
+ }, _callee29, this);
4067
4402
  }));
4068
- function getContactInfo(_x22) {
4403
+ function getContactInfo(_x23) {
4069
4404
  return _getContactInfo.apply(this, arguments);
4070
4405
  }
4071
4406
  return getContactInfo;