@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
@@ -95,7 +95,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
95
95
  "step",
96
96
  "products",
97
97
  "date",
98
- "order"
98
+ "order",
99
+ "payment"
99
100
  ];
100
101
  moduleArr.forEach((step) => {
101
102
  var _a2, _b2;
@@ -116,7 +117,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
116
117
  }
117
118
  });
118
119
  this.store.schedule.loadAllSchedule();
119
- this.core.effects.emit(`${this.name}:onInited`, {});
120
+ this.core.effects.emit(import_types.BookingByStepHooks.onInited, {});
120
121
  }
121
122
  // 初始化step
122
123
  initStep(stepList) {
@@ -185,19 +186,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
185
186
  collection = [],
186
187
  schedule_date
187
188
  }) {
188
- const res = await this.store.products.loadProducts({
189
+ return this.store.products.loadProducts({
189
190
  category_ids,
190
191
  product_ids,
191
192
  collection,
192
193
  schedule_date,
193
194
  cacheId: this.cacheId
194
195
  });
195
- this.getAvailableDate({
196
- startDate: schedule_date || (0, import_dayjs.default)().format("YYYY-MM-DD"),
197
- endDate: schedule_date || (0, import_dayjs.default)().format("YYYY-MM-DD"),
198
- products: [...res]
199
- });
200
- return res;
201
196
  }
202
197
  /**
203
198
  * 通过 schedule 来读取商品,适用于 session 类商品
@@ -234,12 +229,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
234
229
  const allProductIds = [...newProductIds, ...otherProductsIds].filter(
235
230
  (n, index, self) => self.indexOf(n) === index
236
231
  );
237
- const res = await this.loadProducts({
232
+ return await this.loadProducts({
238
233
  product_ids: allProductIds,
239
234
  category_ids,
240
235
  schedule_date: date
241
236
  });
242
- return res;
243
237
  }
244
238
  /**
245
239
  * 更新完商品数据、切换日期、或者在较后的流程里登录了,检测当前购物车里是否有商品,如果有,则需要更新购物车里的商品价格
@@ -606,12 +600,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
606
600
  quantity = 1
607
601
  } = product || {};
608
602
  const productData = { ...origin, product_variant_id };
609
- debugger;
610
- if ((0, import_products.isSessionProduct)(productData)) {
611
- if (!date || !date.startTime || !date.endTime) {
612
- return { success: false, errorCode: "date_or_time_required" };
613
- }
614
- }
615
603
  const currentCartItems = this.store.cart.getItems();
616
604
  const stockCheckResult = (0, import_stock.checkProductStock)({
617
605
  productData,
@@ -1405,7 +1393,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1405
1393
  }
1406
1394
  // 从购物车中获取已经分配好第一步资源的所有时间片
1407
1395
  getTimeSlotByAllResources(resources_code) {
1408
- var _a, _b, _c, _d, _e, _f, _g, _h;
1396
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
1409
1397
  let dateRange = this.store.date.getDateRange();
1410
1398
  const resources = [];
1411
1399
  const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
@@ -1415,7 +1403,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1415
1403
  let maxCutOffTime = void 0;
1416
1404
  let maxCutOffTimeValue = (0, import_dayjs.default)();
1417
1405
  cartItems.forEach((item) => {
1418
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i;
1406
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
1419
1407
  (_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
1420
1408
  if (n.code === resources_code) {
1421
1409
  resources.push(...n.renderList || []);
@@ -1428,7 +1416,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1428
1416
  resourcesTypeId = (_g2 = (_f2 = (_e2 = (_d2 = item == null ? void 0 : item._productOrigin) == null ? void 0 : _d2.product_resource) == null ? void 0 : _e2.resources) == null ? void 0 : _f2.find(
1429
1417
  (n) => n.code === resources_code
1430
1418
  )) == null ? void 0 : _g2.id;
1431
- if (((_h2 = item._productOrigin) == null ? void 0 : _h2.cut_off_time) && ((_i = item._productOrigin) == null ? void 0 : _i.cut_off_time.type) === "advance") {
1419
+ if (((_h2 = item._productOrigin) == null ? void 0 : _h2.cut_off_time) && ((_i2 = item._productOrigin) == null ? void 0 : _i2.cut_off_time.type) === "advance") {
1432
1420
  const currentCutOffTime = (0, import_dayjs.default)().add(
1433
1421
  item._productOrigin.cut_off_time.unit,
1434
1422
  item._productOrigin.cut_off_time.unit_type
@@ -1446,6 +1434,19 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1446
1434
  }
1447
1435
  });
1448
1436
  }
1437
+ if (((_c = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _c.date) && resources.length) {
1438
+ const currentDate = (_d = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _d.date;
1439
+ const theDateResources = this.store.date.getResourcesListByDate(currentDate);
1440
+ resources.forEach((item) => {
1441
+ var _a2;
1442
+ const noCurrentDateTimes = item.times.some((n) => {
1443
+ return (0, import_dayjs.default)(n.start_at).isSame((0, import_dayjs.default)(currentDate), "day");
1444
+ });
1445
+ if (!noCurrentDateTimes) {
1446
+ item.times = ((_a2 = theDateResources == null ? void 0 : theDateResources.find((n) => n.id === item.id)) == null ? void 0 : _a2.times) || [];
1447
+ }
1448
+ });
1449
+ }
1449
1450
  const resourcesMap = (0, import_utils2.getResourcesMap)(resources);
1450
1451
  let duration = 0;
1451
1452
  const accountList = this.store.accountList.getAccounts();
@@ -1473,7 +1474,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1473
1474
  } else {
1474
1475
  checkDuration(cartItems);
1475
1476
  }
1476
- if (!((_c = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _c.start_date) && !((_d = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _d.resource_id) || !(cartItems == null ? void 0 : cartItems[0].duration)) {
1477
+ if (!((_e = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _e.start_date) && !((_f = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _f.resource_id) || !(cartItems == null ? void 0 : cartItems[0].duration)) {
1477
1478
  return [];
1478
1479
  }
1479
1480
  if ((cartItems == null ? void 0 : cartItems[0].start_date) && !dateRange) {
@@ -1485,7 +1486,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1485
1486
  weekNum: 0
1486
1487
  },
1487
1488
  {
1488
- date: ((_e = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _e.end_date) || ((_f = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _f.start_date) || "",
1489
+ date: ((_g = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _g.end_date) || ((_h = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _h.start_date) || "",
1489
1490
  status: "available",
1490
1491
  week: "",
1491
1492
  weekNum: 0
@@ -1499,26 +1500,38 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1499
1500
  return ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.type) === "flexible";
1500
1501
  }
1501
1502
  );
1502
- let operating_day_boundary = (_h = (_g = this.shopStore.get("core")) == null ? void 0 : _g.core) == null ? void 0 : _h.operating_day_boundary;
1503
+ let operating_day_boundary = (_j = (_i = this.shopStore.get("core")) == null ? void 0 : _i.core) == null ? void 0 : _j.operating_day_boundary;
1503
1504
  let maxBlockThreshold = 0;
1504
1505
  if (hasFlexibleDuration) {
1505
1506
  maxBlockThreshold = cartItems.reduce((max, item) => {
1506
1507
  var _a2, _b2, _c2, _d2, _e2, _f2;
1507
1508
  if ((_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.flexible_config) == null ? void 0 : _c2.is_enable_minimum_duration) {
1508
- return Math.max(max, ((_f2 = (_e2 = (_d2 = item._productOrigin) == null ? void 0 : _d2.duration) == null ? void 0 : _e2.flexible_config) == null ? void 0 : _f2.block_threshold) || 0);
1509
+ return Math.max(
1510
+ max,
1511
+ ((_f2 = (_e2 = (_d2 = item._productOrigin) == null ? void 0 : _d2.duration) == null ? void 0 : _e2.flexible_config) == null ? void 0 : _f2.block_threshold) || 0
1512
+ );
1509
1513
  }
1510
1514
  return 0;
1511
1515
  }, 0);
1512
1516
  }
1513
1517
  const calculateCapacityFromCartItems = (items) => {
1514
- return items.reduce((total, item) => {
1515
- return total + ((0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 0);
1516
- }, 0);
1518
+ var _a2;
1519
+ const firstResource = (_a2 = items[0]._resourceOrigin) == null ? void 0 : _a2[0].id;
1520
+ const sameResourceLength = items.filter((item) => {
1521
+ var _a3;
1522
+ return ((_a3 = item._resourceOrigin) == null ? void 0 : _a3[0].id) === firstResource;
1523
+ }).length;
1524
+ if (sameResourceLength === items.length) {
1525
+ return 1;
1526
+ }
1527
+ return Math.max(...items.map((item) => (0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 1));
1517
1528
  };
1518
1529
  let maxCapacity = 1;
1519
1530
  if (cartItems == null ? void 0 : cartItems[0].holder_id) {
1520
1531
  accountList.forEach((account) => {
1521
- const accountCartItems = this.store.cart.getCartByAccount(account.getId());
1532
+ const accountCartItems = this.store.cart.getCartByAccount(
1533
+ account.getId()
1534
+ );
1522
1535
  const currentCapacity = calculateCapacityFromCartItems(accountCartItems);
1523
1536
  if (currentCapacity > maxCapacity) {
1524
1537
  maxCapacity = currentCapacity;
@@ -1542,6 +1555,172 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1542
1555
  });
1543
1556
  return timeSlots;
1544
1557
  }
1558
+ // 从购物车中获取已经分配好第一步资源的所有时间片,批量版本,用于给日期提供能否高亮的判断
1559
+ async getTimeSlotByAllResourcesForDate({ resources_code, startDate, endDate }) {
1560
+ var _a, _b, _c, _d;
1561
+ if ((0, import_dayjs.default)(endDate).diff((0, import_dayjs.default)(startDate), "day") < 30) {
1562
+ endDate = (0, import_dayjs.default)(startDate).add(30, "day").format("YYYY-MM-DD");
1563
+ }
1564
+ await this.getAvailableDate({
1565
+ startDate,
1566
+ endDate,
1567
+ useCache: true
1568
+ });
1569
+ const resources = [];
1570
+ const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
1571
+ const resourceIds = [];
1572
+ let resourcesTypeId = void 0;
1573
+ let isSingleResource = false;
1574
+ let maxCutOffTime = void 0;
1575
+ let maxCutOffTimeValue = (0, import_dayjs.default)();
1576
+ cartItems.forEach((item) => {
1577
+ var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i;
1578
+ (_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
1579
+ if (n.code === resources_code) {
1580
+ resources.push(...n.renderList || []);
1581
+ isSingleResource = n.type === "single";
1582
+ }
1583
+ });
1584
+ if (item.resource_id && !resourceIds.includes(item.resource_id)) {
1585
+ resourceIds.push(item.resource_id);
1586
+ }
1587
+ resourcesTypeId = (_g = (_f = (_e = (_d2 = item == null ? void 0 : item._productOrigin) == null ? void 0 : _d2.product_resource) == null ? void 0 : _e.resources) == null ? void 0 : _f.find(
1588
+ (n) => n.code === resources_code
1589
+ )) == null ? void 0 : _g.id;
1590
+ if (((_h = item._productOrigin) == null ? void 0 : _h.cut_off_time) && ((_i = item._productOrigin) == null ? void 0 : _i.cut_off_time.type) === "advance") {
1591
+ const currentCutOffTime = (0, import_dayjs.default)().add(
1592
+ item._productOrigin.cut_off_time.unit,
1593
+ item._productOrigin.cut_off_time.unit_type
1594
+ );
1595
+ if (currentCutOffTime.isAfter(maxCutOffTimeValue, "minute")) {
1596
+ maxCutOffTimeValue = currentCutOffTime;
1597
+ maxCutOffTime = item._productOrigin.cut_off_time;
1598
+ }
1599
+ }
1600
+ });
1601
+ if (!resources.length)
1602
+ return [];
1603
+ let duration = 0;
1604
+ const accountList = this.store.accountList.getAccounts();
1605
+ const checkDuration = (cartItems2) => {
1606
+ let accountDuration = 0;
1607
+ cartItems2.forEach((item) => {
1608
+ var _a2, _b2, _c2, _d2, _e, _f;
1609
+ if (isSingleResource) {
1610
+ accountDuration += ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10;
1611
+ } else {
1612
+ if (accountDuration < (((_d2 = (_c2 = item._productOrigin) == null ? void 0 : _c2.duration) == null ? void 0 : _d2.value) || 10)) {
1613
+ accountDuration = ((_f = (_e = item._productOrigin) == null ? void 0 : _e.duration) == null ? void 0 : _f.value) || 10;
1614
+ }
1615
+ }
1616
+ });
1617
+ if (accountDuration > duration) {
1618
+ duration = accountDuration;
1619
+ }
1620
+ };
1621
+ if (cartItems == null ? void 0 : cartItems[0].holder_id) {
1622
+ accountList.forEach((account) => {
1623
+ const cartItems2 = this.store.cart.getCartByAccount(account.getId());
1624
+ checkDuration(cartItems2);
1625
+ });
1626
+ } else {
1627
+ checkDuration(cartItems);
1628
+ }
1629
+ if (!((_a = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _a.start_date) && !((_b = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _b.resource_id) || !(cartItems == null ? void 0 : cartItems[0].duration)) {
1630
+ return [];
1631
+ }
1632
+ const resourcesUseableMap = {};
1633
+ const hasFlexibleDuration = cartItems.some(
1634
+ (item) => {
1635
+ var _a2, _b2;
1636
+ return ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.type) === "flexible";
1637
+ }
1638
+ );
1639
+ let operating_day_boundary = (_d = (_c = this.shopStore.get("core")) == null ? void 0 : _c.core) == null ? void 0 : _d.operating_day_boundary;
1640
+ let maxBlockThreshold = 0;
1641
+ if (hasFlexibleDuration) {
1642
+ maxBlockThreshold = cartItems.reduce((max, item) => {
1643
+ var _a2, _b2, _c2, _d2, _e, _f;
1644
+ if ((_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.flexible_config) == null ? void 0 : _c2.is_enable_minimum_duration) {
1645
+ return Math.max(max, ((_f = (_e = (_d2 = item._productOrigin) == null ? void 0 : _d2.duration) == null ? void 0 : _e.flexible_config) == null ? void 0 : _f.block_threshold) || 0);
1646
+ }
1647
+ return 0;
1648
+ }, 0);
1649
+ }
1650
+ const calculateCapacityFromCartItems = (items) => {
1651
+ var _a2;
1652
+ const firstResource = (_a2 = items[0]._resourceOrigin) == null ? void 0 : _a2[0].id;
1653
+ const sameResourceLength = items.filter((item) => {
1654
+ var _a3;
1655
+ return ((_a3 = item._resourceOrigin) == null ? void 0 : _a3[0].id) === firstResource;
1656
+ }).length;
1657
+ if (sameResourceLength !== items.length) {
1658
+ return 1;
1659
+ }
1660
+ return Math.max(...items.map((item) => (0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 1));
1661
+ };
1662
+ let maxCapacity = 1;
1663
+ if (cartItems == null ? void 0 : cartItems[0].holder_id) {
1664
+ accountList.forEach((account) => {
1665
+ const accountCartItems = this.store.cart.getCartByAccount(account.getId());
1666
+ const currentCapacity = calculateCapacityFromCartItems(accountCartItems);
1667
+ if (currentCapacity > maxCapacity) {
1668
+ maxCapacity = currentCapacity;
1669
+ }
1670
+ });
1671
+ } else {
1672
+ maxCapacity = calculateCapacityFromCartItems(cartItems);
1673
+ }
1674
+ const arr = [];
1675
+ const today = (0, import_dayjs.default)().startOf("day");
1676
+ for (let i = (0, import_dayjs.default)(startDate); i.isBefore((0, import_dayjs.default)(endDate)); i = i.add(1, "day")) {
1677
+ const currentDate = i.format("YYYY-MM-DD");
1678
+ const theDateResources = this.store.date.getResourcesListByDate(currentDate);
1679
+ resources.forEach((item) => {
1680
+ var _a2;
1681
+ item.times = ((_a2 = theDateResources == null ? void 0 : theDateResources.find((n) => n.id === item.id)) == null ? void 0 : _a2.times) || [];
1682
+ });
1683
+ const resourcesMap = (0, import_utils2.getResourcesMap)(resources);
1684
+ if (i.isBefore(today)) {
1685
+ arr.push({
1686
+ date: currentDate,
1687
+ status: "unavailable",
1688
+ week: i.format("ddd"),
1689
+ weekNum: i.day()
1690
+ });
1691
+ continue;
1692
+ }
1693
+ const timeSlots = (0, import_resources.getTimeSlicesByResources)({
1694
+ resourceIds,
1695
+ resourcesMap,
1696
+ duration,
1697
+ currentDate,
1698
+ split: 10,
1699
+ resourcesUseableMap,
1700
+ capacity: maxCapacity,
1701
+ cut_off_time: maxCutOffTime,
1702
+ hasFlexibleDuration,
1703
+ operating_day_boundary,
1704
+ maxBlockThreshold
1705
+ });
1706
+ if (timeSlots.length > 0) {
1707
+ arr.push({
1708
+ date: currentDate,
1709
+ status: "available",
1710
+ week: i.format("ddd"),
1711
+ weekNum: i.day()
1712
+ });
1713
+ } else {
1714
+ arr.push({
1715
+ date: currentDate,
1716
+ status: "unavailable",
1717
+ week: i.format("ddd"),
1718
+ weekNum: i.day()
1719
+ });
1720
+ }
1721
+ }
1722
+ return arr;
1723
+ }
1545
1724
  // 提交时间切片,绑定到对应购物车的商品上,更新购物车---只有 duration 商品
1546
1725
  submitTimeSlot(timeSlots) {
1547
1726
  var _a, _b;
@@ -1685,7 +1864,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1685
1864
  resources,
1686
1865
  product
1687
1866
  }) {
1688
- var _a, _b, _c, _d, _e;
1867
+ var _a, _b, _c, _d, _e, _f, _g;
1689
1868
  const targetProduct = this.store.currentProduct;
1690
1869
  const targetProductData = product || targetProduct;
1691
1870
  let targetSchedules = [];
@@ -1731,11 +1910,16 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1731
1910
  const firstEnabledResourceId = (_e = (_d = (_c = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.find(
1732
1911
  (n) => n.status === 1
1733
1912
  )) == null ? void 0 : _e.id;
1913
+ const firstEnabledResourceConfig = (_g = (_f = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _f.resources) == null ? void 0 : _g.find(
1914
+ (n) => n.status === 1 && n.id === firstEnabledResourceId
1915
+ );
1916
+ const isMultipleBooking = (firstEnabledResourceConfig == null ? void 0 : firstEnabledResourceConfig.type) === "multiple";
1734
1917
  const formatScheduleTimeSlots = scheduleTimeSlots.map((item) => {
1735
1918
  const resourcesUseableMap = {};
1736
1919
  let count = 0;
1737
1920
  let bookingLeft = 0;
1738
1921
  let summaryCount = 0;
1922
+ let summaryConfigCount = 0;
1739
1923
  allProductResources == null ? void 0 : allProductResources.forEach((m) => {
1740
1924
  let currentResourcesCount = 0;
1741
1925
  let currentResourcesSummaryCount = 0;
@@ -1771,6 +1955,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1771
1955
  }
1772
1956
  currentResourcesTimeSlotCanUsedArr.push(res.usable);
1773
1957
  });
1958
+ if (m.form_id === firstEnabledResourceId) {
1959
+ if (isMultipleBooking) {
1960
+ summaryConfigCount += m.capacity;
1961
+ } else {
1962
+ summaryConfigCount += 1;
1963
+ }
1964
+ }
1774
1965
  if (!currentResourcesTimeSlotCanUsedArr.some(
1775
1966
  (n) => n === false
1776
1967
  ) && // 只统计第一种资源的容量和 left
@@ -1797,13 +1988,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1797
1988
  count = 0;
1798
1989
  summaryCount = 0;
1799
1990
  }
1800
- const otherCartItems = cartItems2.filter((m) => {
1801
- var _a2, _b2, _c2;
1802
- return ((_b2 = (_a2 = m._productOrigin) == null ? void 0 : _a2.id) == null ? void 0 : _b2.toString()) !== ((_c2 = targetProductData == null ? void 0 : targetProductData.id) == null ? void 0 : _c2.toString()) && `${m.start_date} ${m.start_time}` === item.start && `${m.start_date} ${m.end_time}` === item.end;
1803
- });
1991
+ let otherCartItems = cartItems2.filter(
1992
+ (m) => {
1993
+ var _a2, _b2, _c2, _d2, _e2, _f2;
1994
+ const isTimeMatch = ((_b2 = (_a2 = m._productOrigin) == null ? void 0 : _a2.id) == null ? void 0 : _b2.toString()) !== ((_c2 = targetProductData == null ? void 0 : targetProductData.id) == null ? void 0 : _c2.toString()) && `${m.start_date} ${m.start_time}` === item.start && `${m.start_date} ${m.end_time}` === item.end;
1995
+ const isResourceMatch = (_f2 = (_e2 = (_d2 = m._productOrigin) == null ? void 0 : _d2.product_resource) == null ? void 0 : _e2.resources) == null ? void 0 : _f2.find((m2) => m2.type === n.type && m2.status === 1);
1996
+ return isTimeMatch && isResourceMatch;
1997
+ }
1998
+ );
1804
1999
  otherCartItems.forEach((m) => {
1805
2000
  var _a2, _b2, _c2;
1806
- const sameTypeResources = (_c2 = (_b2 = (_a2 = m._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.find((m2) => m2.type === n.type);
2001
+ const sameTypeResources = (_c2 = (_b2 = (_a2 = m._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.find((m2) => m2.type === n.type && m2.status === 1);
1807
2002
  const sameTypeResourcesSet = /* @__PURE__ */ new Set([...(sameTypeResources == null ? void 0 : sameTypeResources.optional_resource) || [], ...(sameTypeResources == null ? void 0 : sameTypeResources.default_resource) || []]);
1808
2003
  sameTypeResourcesSet.forEach((resource) => currentResourcesSet.add(resource));
1809
2004
  });
@@ -1884,6 +2079,34 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1884
2079
  });
1885
2080
  const startDayJs = (0, import_dayjs.default)(item.start);
1886
2081
  const endDayJs = (0, import_dayjs.default)(item.end);
2082
+ let timeStatus = "sold_out";
2083
+ if (bookingLeft === 0)
2084
+ timeStatus = "sold_out";
2085
+ else if (isMultipleBooking) {
2086
+ if (summaryConfigCount === 0)
2087
+ timeStatus = "sold_out";
2088
+ else {
2089
+ const usageRatio = summaryCount / summaryConfigCount;
2090
+ if (usageRatio > 0.5)
2091
+ timeStatus = "lots_of_space";
2092
+ else if (summaryCount > 0)
2093
+ timeStatus = "filling_up_fast";
2094
+ else
2095
+ timeStatus = "sold_out";
2096
+ }
2097
+ } else {
2098
+ if (summaryConfigCount === 0)
2099
+ timeStatus = "sold_out";
2100
+ else {
2101
+ const usageRatio = bookingLeft / summaryConfigCount;
2102
+ if (usageRatio > 0.5)
2103
+ timeStatus = "lots_of_space";
2104
+ else if (count > 0)
2105
+ timeStatus = "filling_up_fast";
2106
+ else
2107
+ timeStatus = "sold_out";
2108
+ }
2109
+ }
1887
2110
  return {
1888
2111
  start_time: startDayJs.format("HH:mm"),
1889
2112
  end_time: endDayJs.format("HH:mm"),
@@ -1891,7 +2114,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1891
2114
  end_at: endDayJs,
1892
2115
  count,
1893
2116
  left: bookingLeft,
1894
- summaryCount
2117
+ summaryCount,
2118
+ status: timeStatus
1895
2119
  };
1896
2120
  });
1897
2121
  return formatScheduleTimeSlots;
@@ -1977,6 +2201,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1977
2201
  if (!itemsByResourceType[resourceCode]) {
1978
2202
  itemsByResourceType[resourceCode] = [];
1979
2203
  }
2204
+ if (itemsByResourceType[resourceCode].find((item) => item.holder_id === cartItem.holder_id)) {
2205
+ return;
2206
+ }
1980
2207
  if (!itemsByResourceType[resourceCode].find((item) => item._id === cartItem._id)) {
1981
2208
  itemsByResourceType[resourceCode].push(cartItem);
1982
2209
  }
@@ -2662,6 +2889,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2662
2889
  while ((0, import_dayjs.default)(currentDate).isBefore((0, import_dayjs.default)(endDate), "day") || (0, import_dayjs.default)(currentDate).isSame((0, import_dayjs.default)(endDate), "day")) {
2663
2890
  const currentDateStr = currentDate.format("YYYY-MM-DD");
2664
2891
  let status = "available";
2892
+ let summaryCount = 0;
2893
+ let availableCount = 0;
2665
2894
  const { latestStartDate, earliestEndDate } = (0, import_resources.checkSessionProductLeadTime)(tempProducts);
2666
2895
  if (latestStartDate || earliestEndDate) {
2667
2896
  if (latestStartDate && (0, import_dayjs.default)(currentDate).isBefore(latestStartDate, "day")) {
@@ -2686,43 +2915,64 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2686
2915
  currentDateStr
2687
2916
  );
2688
2917
  const scheduleTimeSlots = (0, import_utils3.getAllSortedDateRanges)(minTimeMaxTime);
2689
- const timesSlotCanUse = scheduleTimeSlots.some((item) => {
2918
+ let timesSlotCanUse = false;
2919
+ scheduleTimeSlots.forEach((item) => {
2690
2920
  const resourcesUseableMap = {};
2691
- return openResources.every((resource) => {
2921
+ let isAllResourceTypesUseable = true;
2922
+ openResources.forEach((resource) => {
2692
2923
  const currentResourcesList = allProductResources.filter(
2693
2924
  (n) => n.form_id === resource.resource_type_id
2694
2925
  );
2695
- return currentResourcesList == null ? void 0 : currentResourcesList.some((m) => {
2926
+ let isAnyResourceUseableInType = false;
2927
+ currentResourcesList == null ? void 0 : currentResourcesList.forEach((m) => {
2696
2928
  const mTimes = m.times.filter((n) => {
2697
2929
  return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(item.start), "minute") && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(item.end), "minute");
2698
2930
  });
2699
- if (mTimes.length === 0) {
2931
+ if (mTimes.length === 0)
2700
2932
  return;
2933
+ if (resource.type === "multiple") {
2934
+ summaryCount += m.capacity;
2935
+ } else {
2936
+ summaryCount += 1;
2701
2937
  }
2702
- const targetCanUseTimes = mTimes.some(
2703
- (childTiem) => {
2704
- const res2 = (0, import_resources.getIsUsableByTimeItem)({
2705
- timeSlice: {
2706
- start_time: item.start,
2707
- end_time: item.end,
2708
- start_at: (0, import_dayjs.default)(item.start),
2709
- end_at: (0, import_dayjs.default)(item.end)
2710
- },
2711
- time: childTiem,
2712
- resource: m,
2713
- currentCount: 1,
2714
- resourcesUseableMap,
2715
- cut_off_time: tempProducts == null ? void 0 : tempProducts.cut_off_time
2716
- });
2717
- if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res2.reason !== "capacityOnly") {
2718
- resourcesUseableMap[m.id] = res2.usable;
2938
+ let isAnyTimeSliceUseable = false;
2939
+ mTimes.forEach((childTiem) => {
2940
+ if (isAnyTimeSliceUseable)
2941
+ return;
2942
+ const res2 = (0, import_resources.getIsUsableByTimeItem)({
2943
+ timeSlice: {
2944
+ start_time: item.start,
2945
+ end_time: item.end,
2946
+ start_at: (0, import_dayjs.default)(item.start),
2947
+ end_at: (0, import_dayjs.default)(item.end)
2948
+ },
2949
+ time: childTiem,
2950
+ resource: m,
2951
+ currentCount: 1,
2952
+ resourcesUseableMap,
2953
+ cut_off_time: tempProducts == null ? void 0 : tempProducts.cut_off_time
2954
+ });
2955
+ if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res2.reason !== "capacityOnly") {
2956
+ resourcesUseableMap[m.id] = res2.usable;
2957
+ }
2958
+ if (res2.usable && !m.onlyComputed) {
2959
+ isAnyTimeSliceUseable = true;
2960
+ if (resource.type === "multiple") {
2961
+ availableCount += res2.remainingCapacity;
2962
+ } else {
2963
+ availableCount += 1;
2719
2964
  }
2720
- return res2.usable && !m.onlyComputed;
2721
2965
  }
2722
- );
2723
- return targetCanUseTimes;
2966
+ ;
2967
+ });
2968
+ if (isAnyTimeSliceUseable)
2969
+ isAnyResourceUseableInType = true;
2724
2970
  });
2971
+ if (!isAnyResourceUseableInType)
2972
+ isAllResourceTypesUseable = false;
2725
2973
  });
2974
+ if (isAllResourceTypesUseable)
2975
+ timesSlotCanUse = true;
2726
2976
  });
2727
2977
  if (!timesSlotCanUse) {
2728
2978
  status = "unavailable";
@@ -2731,11 +2981,26 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2731
2981
  firstAvailableDate = currentDateStr;
2732
2982
  }
2733
2983
  }
2984
+ let dateStatus;
2985
+ if (status === "unavailable") {
2986
+ if (availableCount === 0 && summaryCount > 0)
2987
+ dateStatus = "sold_out";
2988
+ else
2989
+ dateStatus = "unavailable";
2990
+ } else {
2991
+ const usageRatio = availableCount / summaryCount;
2992
+ if (usageRatio > 0.5)
2993
+ dateStatus = "lots_of_space";
2994
+ else
2995
+ dateStatus = "filling_up_fast";
2996
+ }
2734
2997
  dates.push({
2735
2998
  date: (0, import_dayjs.default)(currentDate).format("YYYY-MM-DD"),
2736
2999
  week: (0, import_dayjs.default)(currentDate).format("ddd"),
2737
3000
  weekNum: (0, import_dayjs.default)(currentDate).day(),
2738
- status
3001
+ summaryCount,
3002
+ availableCount,
3003
+ status: dateStatus
2739
3004
  });
2740
3005
  if (firstAvailableDate && (0, import_dayjs.default)(currentDate).diff((0, import_dayjs.default)(startDate), "day") > 31) {
2741
3006
  break;
@@ -9,9 +9,3 @@ export declare const getAvailableProductResources: (products: ProductData[]) =>
9
9
  rules: any[];
10
10
  resourcesMap: Record<number, ProductResourceItem>;
11
11
  };
12
- /**
13
- * 判断商品是否是 session 商品
14
- * @param product 商品数据
15
- * @returns 是否是 session 商品
16
- */
17
- export declare const isSessionProduct: (product: ProductData) => boolean;
@@ -19,8 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/solution/BookingByStep/utils/products.ts
20
20
  var products_exports = {};
21
21
  __export(products_exports, {
22
- getAvailableProductResources: () => getAvailableProductResources,
23
- isSessionProduct: () => isSessionProduct
22
+ getAvailableProductResources: () => getAvailableProductResources
24
23
  });
25
24
  module.exports = __toCommonJS(products_exports);
26
25
  var getAvailableProductResources = (products) => {
@@ -58,12 +57,7 @@ var getAvailableProductResources = (products) => {
58
57
  });
59
58
  return { resourceIds: [...new Set(resourceIds)], rules, resourcesMap };
60
59
  };
61
- var isSessionProduct = (product) => {
62
- var _a;
63
- return (((_a = product == null ? void 0 : product["schedule.ids"]) == null ? void 0 : _a.length) ?? 0) > 0;
64
- };
65
60
  // Annotate the CommonJS export names for ESM import in node:
66
61
  0 && (module.exports = {
67
- getAvailableProductResources,
68
- isSessionProduct
62
+ getAvailableProductResources
69
63
  });
@@ -353,7 +353,10 @@ var getTimeSlicesByResource = ({
353
353
  });
354
354
  times.forEach((time) => {
355
355
  const startTime = (0, import_dayjs.default)(`${time.start_at}`);
356
- const endTime = (0, import_dayjs.default)(`${time.end_at}`);
356
+ let endTime = (0, import_dayjs.default)(`${time.end_at}`);
357
+ if (endTime.isAfter((0, import_dayjs.default)(currentDate).endOf("day"))) {
358
+ endTime = (0, import_dayjs.default)(currentDate).endOf("day");
359
+ }
357
360
  let currentStart = startTime;
358
361
  while (true) {
359
362
  const currentEnd = currentStart.add(duration, "minute");