@pisell/pisellos 0.0.569 → 0.10.2

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 (328) hide show
  1. package/dist/core/index.js +10 -6
  2. package/dist/index.d.ts +0 -1
  3. package/dist/index.js +0 -3
  4. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  5. package/dist/model/strategy/adapter/walletPass/evaluator.js +7 -5
  6. package/dist/model/strategy/adapter/walletPass/example.js +26 -3
  7. package/dist/model/strategy/adapter/walletPass/index.js +5 -5
  8. package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -3
  9. package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -26
  10. package/dist/model/strategy/adapter/walletPass/utils.js +17 -92
  11. package/dist/model/strategy/strategy-example.js +19 -5
  12. package/dist/modules/BaseModule.d.ts +1 -1
  13. package/dist/modules/BaseModule.js +8 -10
  14. package/dist/modules/Cart/index.js +3 -0
  15. package/dist/modules/Cart/utils/cartProduct.js +1 -0
  16. package/dist/modules/Cart/utils/cartResource.js +0 -2
  17. package/dist/modules/Cart/utils/changePrice.js +9 -16
  18. package/dist/modules/Date/index.js +5 -1
  19. package/dist/modules/Discount/index.d.ts +0 -1
  20. package/dist/modules/Discount/index.js +7 -22
  21. package/dist/modules/Discount/types.d.ts +0 -1
  22. package/dist/modules/OpenData/index.js +2 -0
  23. package/dist/modules/Order/index.js +70 -40
  24. package/dist/modules/Payment/index.js +162 -97
  25. package/dist/modules/Payment/types.d.ts +4 -8
  26. package/dist/modules/Payment/walletpass.d.ts +0 -2
  27. package/dist/modules/Payment/walletpass.js +5 -4
  28. package/dist/modules/ProductList/index.d.ts +1 -1
  29. package/dist/modules/ProductList/index.js +3 -12
  30. package/dist/modules/ProductList/types.d.ts +0 -1
  31. package/dist/modules/Rules/index.js +126 -427
  32. package/dist/modules/SalesSummary/utils.js +1 -2
  33. package/dist/modules/Schedule/getDateIsInSchedule.js +0 -5
  34. package/dist/modules/Schedule/index.js +1 -0
  35. package/dist/modules/Schedule/utils.js +1 -0
  36. package/dist/modules/Step/index.js +1 -0
  37. package/dist/modules/Summary/utils.js +22 -43
  38. package/dist/plugins/request.js +4 -1
  39. package/dist/plugins/window.js +6 -2
  40. package/dist/server/index.js +129 -97
  41. package/dist/server/modules/menu/index.js +41 -32
  42. package/dist/server/modules/order/index.js +4 -2
  43. package/dist/server/modules/products/index.js +42 -24
  44. package/dist/server/modules/quotation/index.js +38 -29
  45. package/dist/server/modules/resource/index.js +4 -3
  46. package/dist/server/modules/schedule/index.js +35 -27
  47. package/dist/server/utils/product.js +1 -0
  48. package/dist/solution/BaseSales/index.js +41 -38
  49. package/dist/solution/BookingByStep/index.d.ts +1 -1
  50. package/dist/solution/BookingByStep/index.js +60 -11
  51. package/dist/solution/BookingByStep/utils/capacity.js +11 -1
  52. package/dist/solution/BookingByStep/utils/resources.js +3 -1
  53. package/dist/solution/BookingByStep/utils/timeslots.js +43 -2
  54. package/dist/solution/BookingTicket/index.d.ts +1 -1
  55. package/dist/solution/BookingTicket/index.js +2 -0
  56. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +7 -6
  57. package/dist/solution/BookingTicket/utils/scan/handleScan.js +31 -25
  58. package/dist/solution/BookingTicket/utils/scan/index.js +10 -6
  59. package/dist/solution/BuyTickets/index.js +12 -9
  60. package/dist/solution/Checkout/index.js +252 -177
  61. package/dist/solution/Checkout/utils/index.js +16 -4
  62. package/dist/solution/RegisterAndLogin/index.js +76 -30
  63. package/dist/solution/ScanOrder/index.js +60 -50
  64. package/dist/solution/ShopDiscount/index.js +14 -15
  65. package/dist/solution/ShopDiscount/types.d.ts +4 -5
  66. package/dist/solution/ShopDiscount/utils.d.ts +0 -9
  67. package/dist/solution/ShopDiscount/utils.js +0 -9
  68. package/dist/solution/VenueBooking/index.d.ts +3 -31
  69. package/dist/solution/VenueBooking/index.js +496 -651
  70. package/dist/solution/VenueBooking/types.d.ts +1 -3
  71. package/dist/solution/VenueBooking/types.js +0 -1
  72. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  73. package/dist/solution/VenueBooking/utils/dateSummary.js +25 -12
  74. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
  75. package/dist/solution/VenueBooking/utils/timeSlot.js +4 -9
  76. package/dist/types/index.d.ts +1 -1
  77. package/dist/utils/task.js +18 -15
  78. package/dist/utils/watch.js +1 -0
  79. package/lib/apis/picoding.js +0 -2
  80. package/lib/core/index.js +132 -130
  81. package/lib/effects/index.js +57 -46
  82. package/lib/index.d.ts +0 -1
  83. package/lib/index.js +50 -92
  84. package/lib/model/index.js +21 -14
  85. package/lib/model/strategy/adapter/dataVariant/adapter.js +50 -38
  86. package/lib/model/strategy/adapter/dataVariant/evaluator.js +236 -162
  87. package/lib/model/strategy/adapter/dataVariant/examples.js +237 -229
  88. package/lib/model/strategy/adapter/dataVariant/index.js +34 -39
  89. package/lib/model/strategy/adapter/dataVariant/type.js +28 -57
  90. package/lib/model/strategy/adapter/index.js +64 -100
  91. package/lib/model/strategy/adapter/itemRule/adapter.js +144 -156
  92. package/lib/model/strategy/adapter/itemRule/evaluator.js +48 -36
  93. package/lib/model/strategy/adapter/itemRule/examples.js +225 -295
  94. package/lib/model/strategy/adapter/itemRule/index.js +57 -83
  95. package/lib/model/strategy/adapter/itemRule/type.js +36 -97
  96. package/lib/model/strategy/adapter/promotion/adapter.js +63 -84
  97. package/lib/model/strategy/adapter/promotion/evaluator.js +231 -381
  98. package/lib/model/strategy/adapter/promotion/examples.js +159 -139
  99. package/lib/model/strategy/adapter/promotion/index.js +49 -1
  100. package/lib/model/strategy/adapter/promotion/type.js +35 -199
  101. package/lib/model/strategy/adapter/type.js +16 -4
  102. package/lib/model/strategy/adapter/walletPass/evaluator.js +152 -180
  103. package/lib/model/strategy/adapter/walletPass/example.js +190 -217
  104. package/lib/model/strategy/adapter/walletPass/index.js +51 -75
  105. package/lib/model/strategy/adapter/walletPass/locales.js +58 -36
  106. package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -3
  107. package/lib/model/strategy/adapter/walletPass/type.js +16 -4
  108. package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -26
  109. package/lib/model/strategy/adapter/walletPass/utils.js +383 -678
  110. package/lib/model/strategy/engine.js +168 -270
  111. package/lib/model/strategy/index.js +34 -49
  112. package/lib/model/strategy/strategy-example.js +239 -243
  113. package/lib/model/strategy/type.js +40 -100
  114. package/lib/modules/Account/index.js +53 -39
  115. package/lib/modules/Account/types.js +33 -20
  116. package/lib/modules/AccountList/index.js +154 -116
  117. package/lib/modules/AccountList/types.js +31 -30
  118. package/lib/modules/AccountList/utils.js +30 -18
  119. package/lib/modules/BaseModule.d.ts +1 -1
  120. package/lib/modules/BaseModule.js +46 -25
  121. package/lib/modules/BookingContext/index.js +136 -158
  122. package/lib/modules/BookingContext/types.js +32 -46
  123. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +143 -131
  124. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +82 -75
  125. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +150 -170
  126. package/lib/modules/BookingContext/utils/flexible.js +55 -38
  127. package/lib/modules/BookingContext/utils/formatResourceList.js +34 -19
  128. package/lib/modules/BookingContext/utils/index.js +41 -124
  129. package/lib/modules/BookingContext/utils/noResource.js +70 -58
  130. package/lib/modules/BookingContext/utils/orderLineDisplay.js +41 -14
  131. package/lib/modules/BookingContext/utils/productExtend.js +155 -202
  132. package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
  133. package/lib/modules/BookingContext/utils/resourceSelection.js +41 -19
  134. package/lib/modules/BookingContext/utils/resources.js +167 -209
  135. package/lib/modules/BookingContext/utils/serviceTimes.js +116 -115
  136. package/lib/modules/BookingContext/utils/timeSlices.js +80 -70
  137. package/lib/modules/Cart/index.js +124 -170
  138. package/lib/modules/Cart/types.js +51 -46
  139. package/lib/modules/Cart/utils/cartAccount.js +39 -40
  140. package/lib/modules/Cart/utils/cartDate.js +61 -56
  141. package/lib/modules/Cart/utils/cartDiscount.js +33 -28
  142. package/lib/modules/Cart/utils/cartNote.js +32 -27
  143. package/lib/modules/Cart/utils/cartProduct.js +251 -321
  144. package/lib/modules/Cart/utils/cartRelationForms.js +35 -29
  145. package/lib/modules/Cart/utils/cartResource.js +78 -72
  146. package/lib/modules/Cart/utils/changePrice.js +50 -28
  147. package/lib/modules/Cart/utils/index.js +48 -106
  148. package/lib/modules/Customer/constants.js +34 -13
  149. package/lib/modules/Customer/index.js +169 -232
  150. package/lib/modules/Customer/types.js +35 -38
  151. package/lib/modules/Date/index.js +115 -116
  152. package/lib/modules/Date/types.js +28 -16
  153. package/lib/modules/Date/utils.js +123 -174
  154. package/lib/modules/Discount/index.d.ts +0 -1
  155. package/lib/modules/Discount/index.js +128 -130
  156. package/lib/modules/Discount/types.d.ts +0 -1
  157. package/lib/modules/Discount/types.js +31 -9
  158. package/lib/modules/Guests/index.js +56 -30
  159. package/lib/modules/Guests/types.js +33 -23
  160. package/lib/modules/Holder/index.js +189 -209
  161. package/lib/modules/Holder/types.js +16 -4
  162. package/lib/modules/Holder/utils.js +49 -20
  163. package/lib/modules/OpenData/index.js +76 -69
  164. package/lib/modules/OpenData/types.js +16 -4
  165. package/lib/modules/OpenData/utils.js +78 -44
  166. package/lib/modules/Order/index.js +1909 -1572
  167. package/lib/modules/Order/types.js +35 -78
  168. package/lib/modules/Order/utils/bundleDiscountHydration.js +74 -41
  169. package/lib/modules/Order/utils/manualProductDiscount.js +123 -124
  170. package/lib/modules/Order/utils/orderCollectionIdentity.js +210 -148
  171. package/lib/modules/Order/utils.js +634 -799
  172. package/lib/modules/Payment/cash.js +33 -20
  173. package/lib/modules/Payment/cashRecommendationAlgorithm.js +76 -145
  174. package/lib/modules/Payment/eftpos.js +30 -16
  175. package/lib/modules/Payment/index.js +378 -518
  176. package/lib/modules/Payment/mx51.js +0 -1
  177. package/lib/modules/Payment/types.d.ts +4 -8
  178. package/lib/modules/Payment/types.js +107 -216
  179. package/lib/modules/Payment/utils.js +48 -51
  180. package/lib/modules/Payment/walletpass.d.ts +0 -2
  181. package/lib/modules/Payment/walletpass.js +211 -226
  182. package/lib/modules/Product/index.js +46 -51
  183. package/lib/modules/Product/types.js +16 -4
  184. package/lib/modules/Product/utils.js +33 -32
  185. package/lib/modules/ProductList/index.d.ts +1 -1
  186. package/lib/modules/ProductList/index.js +117 -117
  187. package/lib/modules/ProductList/types.d.ts +0 -1
  188. package/lib/modules/ProductList/types.js +31 -9
  189. package/lib/modules/Quotation/index.js +100 -66
  190. package/lib/modules/Quotation/types.js +16 -4
  191. package/lib/modules/Resource/index.js +59 -27
  192. package/lib/modules/Resource/types.js +32 -22
  193. package/lib/modules/Resource/utils.js +38 -30
  194. package/lib/modules/ResourcePlanner/index.js +61 -60
  195. package/lib/modules/ResourcePlanner/planner.js +384 -346
  196. package/lib/modules/ResourcePlanner/types.js +16 -4
  197. package/lib/modules/Rules/index.js +903 -1475
  198. package/lib/modules/Rules/types.js +40 -17
  199. package/lib/modules/SalesSummary/index.js +90 -85
  200. package/lib/modules/SalesSummary/types.js +16 -4
  201. package/lib/modules/SalesSummary/utils.js +427 -351
  202. package/lib/modules/ScanOrderLogger/index.js +79 -59
  203. package/lib/modules/ScanOrderLogger/providers/feishu.js +78 -54
  204. package/lib/modules/ScanOrderLogger/providers/grafana.js +36 -13
  205. package/lib/modules/ScanOrderLogger/types.js +16 -4
  206. package/lib/modules/Schedule/getDateIsInSchedule.js +163 -339
  207. package/lib/modules/Schedule/index.js +114 -100
  208. package/lib/modules/Schedule/type.js +16 -4
  209. package/lib/modules/Schedule/types.js +16 -4
  210. package/lib/modules/Schedule/utils.js +291 -433
  211. package/lib/modules/Step/index.js +52 -40
  212. package/lib/modules/Step/tyeps.js +16 -4
  213. package/lib/modules/Summary/index.js +71 -66
  214. package/lib/modules/Summary/types.js +16 -4
  215. package/lib/modules/Summary/utils.js +418 -791
  216. package/lib/modules/SurchargeList/index.js +60 -46
  217. package/lib/modules/SurchargeList/types.js +16 -4
  218. package/lib/modules/index.js +63 -245
  219. package/lib/plugins/app.js +16 -4
  220. package/lib/plugins/index.js +25 -36
  221. package/lib/plugins/request.js +126 -137
  222. package/lib/plugins/shopStore.js +16 -4
  223. package/lib/plugins/user.js +16 -4
  224. package/lib/plugins/window.js +179 -171
  225. package/lib/server/index.js +2337 -2675
  226. package/lib/server/modules/floor-plan/index.js +123 -102
  227. package/lib/server/modules/floor-plan/types.js +30 -15
  228. package/lib/server/modules/index.js +68 -106
  229. package/lib/server/modules/menu/index.js +122 -146
  230. package/lib/server/modules/menu/types.js +31 -18
  231. package/lib/server/modules/order/index.js +642 -567
  232. package/lib/server/modules/order/types.js +32 -117
  233. package/lib/server/modules/order/utils/filterBookings.js +194 -219
  234. package/lib/server/modules/order/utils/filterOrders.js +92 -118
  235. package/lib/server/modules/payment/index.js +83 -59
  236. package/lib/server/modules/payment/types.js +16 -4
  237. package/lib/server/modules/products/index.js +459 -575
  238. package/lib/server/modules/products/types.js +34 -44
  239. package/lib/server/modules/quotation/index.js +172 -137
  240. package/lib/server/modules/quotation/types.js +31 -21
  241. package/lib/server/modules/resource/index.js +184 -213
  242. package/lib/server/modules/resource/types.js +33 -42
  243. package/lib/server/modules/schedule/index.js +123 -135
  244. package/lib/server/modules/schedule/types.js +21 -14
  245. package/lib/server/modules/schedule/utils.js +163 -334
  246. package/lib/server/types.js +16 -4
  247. package/lib/server/utils/index.js +23 -25
  248. package/lib/server/utils/product.js +139 -196
  249. package/lib/server/utils/schedule.js +41 -34
  250. package/lib/server/utils/small-ticket.js +456 -478
  251. package/lib/server/utils/time.js +49 -40
  252. package/lib/solution/BaseSales/index.js +1016 -850
  253. package/lib/solution/BaseSales/types.js +37 -41
  254. package/lib/solution/BaseSales/utils/cartPromotion.js +460 -611
  255. package/lib/solution/BaseSales/utils/parseSalesResponse.js +105 -85
  256. package/lib/solution/BaseSales/utils/quotationPrice.js +114 -56
  257. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +143 -102
  258. package/lib/solution/BaseSales/utils.js +140 -155
  259. package/lib/solution/BookingByStep/index.d.ts +1 -1
  260. package/lib/solution/BookingByStep/index.js +1340 -1530
  261. package/lib/solution/BookingByStep/types.js +99 -40
  262. package/lib/solution/BookingByStep/utils/capacity.js +160 -192
  263. package/lib/solution/BookingByStep/utils/products.js +52 -42
  264. package/lib/solution/BookingByStep/utils/resources.js +330 -527
  265. package/lib/solution/BookingByStep/utils/stock.js +44 -65
  266. package/lib/solution/BookingByStep/utils/timeslots.js +131 -129
  267. package/lib/solution/BookingTicket/index.d.ts +1 -1
  268. package/lib/solution/BookingTicket/index.js +459 -543
  269. package/lib/solution/BookingTicket/types.js +77 -99
  270. package/lib/solution/BookingTicket/utils/addProductDecision.js +184 -219
  271. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +89 -58
  272. package/lib/solution/BookingTicket/utils/bookingStatus.js +78 -107
  273. package/lib/solution/BookingTicket/utils/cartView.js +94 -110
  274. package/lib/solution/BookingTicket/utils/exampleData.js +0 -185
  275. package/lib/solution/BookingTicket/utils/orderCustomer.js +41 -18
  276. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +86 -219
  277. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +93 -144
  278. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +91 -79
  279. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +41 -54
  280. package/lib/solution/BookingTicket/utils/scan/handleScan.js +81 -84
  281. package/lib/solution/BookingTicket/utils/scan/index.js +104 -98
  282. package/lib/solution/BookingTicket/utils/scan/scanCache.js +43 -90
  283. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +64 -52
  284. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +58 -56
  285. package/lib/solution/BuyTickets/index.js +70 -67
  286. package/lib/solution/BuyTickets/types.js +38 -22
  287. package/lib/solution/Checkout/index.js +1158 -1451
  288. package/lib/solution/Checkout/types.js +61 -91
  289. package/lib/solution/Checkout/utils/index.js +156 -228
  290. package/lib/solution/PlaceOrder/index.js +0 -55
  291. package/lib/solution/RegisterAndLogin/config.js +460 -493
  292. package/lib/solution/RegisterAndLogin/index.js +630 -633
  293. package/lib/solution/RegisterAndLogin/types.js +76 -189
  294. package/lib/solution/RegisterAndLogin/utils.js +125 -183
  295. package/lib/solution/Sales/index.js +320 -317
  296. package/lib/solution/Sales/types.js +33 -27
  297. package/lib/solution/ScanOrder/index.js +862 -831
  298. package/lib/solution/ScanOrder/types.js +34 -33
  299. package/lib/solution/ScanOrder/utils.js +371 -406
  300. package/lib/solution/ShopDiscount/index.js +233 -235
  301. package/lib/solution/ShopDiscount/types.d.ts +4 -5
  302. package/lib/solution/ShopDiscount/types.js +37 -15
  303. package/lib/solution/ShopDiscount/utils.d.ts +0 -9
  304. package/lib/solution/ShopDiscount/utils.js +172 -309
  305. package/lib/solution/UnifiedBookingSales/index.js +405 -379
  306. package/lib/solution/UnifiedBookingSales/types.js +31 -12
  307. package/lib/solution/VenueBooking/index.d.ts +3 -31
  308. package/lib/solution/VenueBooking/index.js +916 -967
  309. package/lib/solution/VenueBooking/types.d.ts +1 -3
  310. package/lib/solution/VenueBooking/types.js +39 -20
  311. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  312. package/lib/solution/VenueBooking/utils/dateSummary.js +62 -25
  313. package/lib/solution/VenueBooking/utils/resource.js +54 -31
  314. package/lib/solution/VenueBooking/utils/slotMerge.js +107 -94
  315. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
  316. package/lib/solution/VenueBooking/utils/timeSlot.js +133 -138
  317. package/lib/solution/VenueBooking/utils.js +67 -130
  318. package/lib/solution/index.js +41 -124
  319. package/lib/store/createStore.js +29 -32
  320. package/lib/types/index.d.ts +1 -1
  321. package/lib/types/index.js +16 -4
  322. package/lib/utils/task.js +36 -36
  323. package/lib/utils/watch.js +47 -81
  324. package/package.json +2 -4
  325. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  326. package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
  327. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  328. package/lib/solution/VenueBooking/utils/smartPricing.js +0 -192
@@ -1,143 +1,107 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/solution/BookingByStep/utils/resources.ts
30
+ var resources_exports = {};
31
+ __export(resources_exports, {
32
+ checkSessionProductLeadTime: () => checkSessionProductLeadTime,
33
+ checkTwoResourcesIntersection: () => checkTwoResourcesIntersection,
34
+ filterResourcesByFormItem: () => filterResourcesByFormItem,
35
+ filterScheduleByDateRange: () => filterScheduleByDateRange,
36
+ formatResources: () => formatResources,
37
+ getIsUsableByTimeItem: () => getIsUsableByTimeItem,
38
+ getOthersCartSelectedResources: () => getOthersCartSelectedResources,
39
+ getOthersSelectedResources: () => getOthersSelectedResources,
40
+ getResourcesByIds: () => getResourcesByIds,
41
+ getResourcesByProduct: () => getResourcesByProduct,
42
+ getResourcesIdsByProduct: () => getResourcesIdsByProduct,
43
+ getTimeSlicesByResource: () => getTimeSlicesByResource,
44
+ getTimeSlicesByResources: () => getTimeSlicesByResources,
45
+ getTimesIntersection: () => getTimesIntersection,
46
+ isConflict: () => isConflict,
47
+ mergeSubResourcesTimeSlices: () => mergeSubResourcesTimeSlices,
48
+ sortCombinedResources: () => sortCombinedResources
5
49
  });
6
- exports.checkSessionProductLeadTime = checkSessionProductLeadTime;
7
- exports.checkTwoResourcesIntersection = checkTwoResourcesIntersection;
8
- exports.filterResourcesByFormItem = filterResourcesByFormItem;
9
- exports.filterScheduleByDateRange = filterScheduleByDateRange;
10
- exports.getResourcesByProduct = exports.getResourcesByIds = exports.getOthersSelectedResources = exports.getOthersCartSelectedResources = exports.getIsUsableByTimeItem = exports.formatResources = void 0;
11
- exports.getResourcesIdsByProduct = getResourcesIdsByProduct;
12
- exports.mergeSubResourcesTimeSlices = exports.isConflict = exports.getTimesIntersection = exports.getTimeSlicesByResources = exports.getTimeSlicesByResource = void 0;
13
- exports.sortCombinedResources = sortCombinedResources;
14
- var _dayjs = _interopRequireDefault(require("dayjs"));
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
- /**
17
- * 1. 获取资源列表
18
- * 2. 根据当前选择的商品过滤出来对应的资源列表 getResourcesByProduct
19
- * 3. 格式化资源相关 格式化资源列表 --> 格式化资源 --> 获取时间切片列表 --> 判断单个时间切片是否可用 formatResources
20
- *
21
- */
22
-
23
- /**
24
- * @title: 获取重叠剩余量
25
- * @description:
26
- * @param {any} eventList
27
- * @param {number} current
28
- * @return {*}
29
- * @Author: zhiwei.Wang
30
- */
31
- const getUseableEventCount = (eventList, current) => {
50
+ module.exports = __toCommonJS(resources_exports);
51
+ var import_dayjs = __toESM(require("dayjs"));
52
+ var getUseableEventCount = (eventList, current) => {
32
53
  return (eventList || []).reduce((pre, event) => {
33
54
  return pre - event.pax;
34
55
  }, current || 0);
35
56
  };
36
-
37
- /**
38
- * @title: 判断两个时间段是否有重叠
39
- * @description:
40
- * @param {object} event
41
- * @param {object} current
42
- * @return {*}
43
- * @Author: zhiwei.Wang
44
- */
45
- const isConflict = (event, current) => {
46
- const eventStart = (0, _dayjs.default)(event.start_at);
47
- const eventEnd = (0, _dayjs.default)(event.end_at);
48
- const currentStart = (0, _dayjs.default)(current.start_at);
57
+ var isConflict = (event, current) => {
58
+ const eventStart = (0, import_dayjs.default)(event.start_at);
59
+ const eventEnd = (0, import_dayjs.default)(event.end_at);
60
+ const currentStart = (0, import_dayjs.default)(current.start_at);
49
61
  const _isBefore = currentStart.isBefore(eventEnd);
50
62
  let _isAfter = true;
51
-
52
- // 如果传递结束时间,则比对结束时间
53
63
  if (current.end_at) {
54
- const currentEnd = (0, _dayjs.default)(current.end_at);
64
+ const currentEnd = (0, import_dayjs.default)(current.end_at);
55
65
  _isAfter = currentEnd.isAfter(eventStart);
56
66
  }
57
-
58
- // 检查是否有重叠
59
67
  return _isBefore && _isAfter;
60
68
  };
61
-
62
- /**
63
- * @title: 判断传入日期是否在当前日期之后
64
- * @description:
65
- * @param {any} date
66
- * @param {any} today
67
- * @return {*}
68
- * @Author: zhiwei.Wang
69
- */
70
- exports.isConflict = isConflict;
71
- const checkAfterToDay = (date, today = (0, _dayjs.default)()) => {
72
- return (0, _dayjs.default)(date).isAfter((0, _dayjs.default)(today));
69
+ var checkAfterToDay = (date, today = (0, import_dayjs.default)()) => {
70
+ return (0, import_dayjs.default)(date).isAfter((0, import_dayjs.default)(today));
73
71
  };
74
-
75
- /**
76
- * @title: 格式化资源, 添加自定义参数
77
- * @description:
78
- * @param {any} resourceItem
79
- * @return {*}
80
- * @Author: zhiwei.Wang
81
- * @Date: 2024-01-09 13:40
82
- */
83
- const formatResource = (resourceItem, booking) => {
84
- // 当前资源
85
- let _resourceItem = {
86
- ...resourceItem
87
- };
88
-
89
- // 格式化times里面的数据
72
+ var formatResource = (resourceItem, booking) => {
73
+ let _resourceItem = { ...resourceItem };
90
74
  _resourceItem.timeSlices = getTimeSlicesByResource({
91
75
  resource: _resourceItem,
92
76
  duration: booking.duration,
93
77
  split: 10,
94
- currentDate: (0, _dayjs.default)().format('YYYY-MM-DD')
78
+ currentDate: (0, import_dayjs.default)().format("YYYY-MM-DD")
95
79
  });
96
-
97
- // 格式化label
98
80
  _resourceItem.labelText = _resourceItem.main_field;
99
81
  return _resourceItem;
100
82
  };
101
-
102
- /**
103
- * @title: 判断资源容量是否可用
104
- * @description:
105
- * @param {object} param1
106
- * @return {*}
107
- * @Author: zhiwei.Wang
108
- */
109
- const checkCapacity = ({
83
+ var checkCapacity = ({
110
84
  event_list,
111
85
  timeSlice,
112
86
  resource,
113
87
  currentCount = 1
114
88
  }) => {
115
- // 单个预约:如果当前资源容量不足以满足需求的容量,且当前资源是没有被占用的,返回资源不可用标记,但在外部运算会通过 reason=capacityOnly 来处理组合资源可用
116
- // 多个预约:只需判断容量是否足够
117
- const isMultipleBooking = resource.resourceType === 'multiple';
89
+ const isMultipleBooking = resource.resourceType === "multiple";
118
90
  if (currentCount > resource.capacity && (isMultipleBooking || !isMultipleBooking && event_list.length === 0)) {
119
91
  return {
120
92
  status: false,
121
93
  capacity: resource.capacity,
122
- reason: 'capacityOnly'
94
+ reason: "capacityOnly"
123
95
  };
124
96
  }
125
- let conflict = (event_list || []).filter(d => {
126
- return isConflict({
127
- start_at: d.start_at,
128
- end_at: d.end_at
129
- }, {
130
- start_at: timeSlice.start_at,
131
- end_at: timeSlice.end_at
132
- });
97
+ let conflict = (event_list || []).filter((d) => {
98
+ return isConflict(
99
+ { start_at: d.start_at, end_at: d.end_at },
100
+ { start_at: timeSlice.start_at, end_at: timeSlice.end_at }
101
+ );
133
102
  });
134
-
135
- // 减去重叠的总量
136
103
  let conflictCount = getUseableEventCount(conflict, resource.capacity);
137
-
138
- // 同一时间段内只能进行一个预约,无论容量是否已满。
139
- if (resource.resourceType === 'single') {
140
- // 0代表着不重叠,则满足条件
104
+ if (resource.resourceType === "single") {
141
105
  if (conflict.length === 0) {
142
106
  return {
143
107
  status: true,
@@ -150,7 +114,6 @@ const checkCapacity = ({
150
114
  };
151
115
  }
152
116
  } else {
153
- // 当前预约量 <= 总剩余容量
154
117
  if (currentCount <= conflictCount) {
155
118
  return {
156
119
  status: true,
@@ -164,15 +127,7 @@ const checkCapacity = ({
164
127
  }
165
128
  }
166
129
  };
167
-
168
- /**
169
- * @title: 获取时间切片是否可用
170
- * @description: 根据时间切片、资源、当前预约量判断时间切片是否可用
171
- * @param {any} param1
172
- * @return {*}
173
- * @Author: zhiwei.Wang
174
- */
175
- const getIsUsableByTimeItem = ({
130
+ var getIsUsableByTimeItem = ({
176
131
  timeSlice,
177
132
  time,
178
133
  resource,
@@ -180,34 +135,26 @@ const getIsUsableByTimeItem = ({
180
135
  resourcesUseableMap = {},
181
136
  cut_off_time
182
137
  }) => {
138
+ var _a;
183
139
  let status = {
184
140
  afterToDay: false,
185
141
  capacity: false,
186
142
  usable: false,
187
143
  remainingCapacity: 0,
188
144
  // 剩余容量
189
- reason: ''
145
+ reason: ""
190
146
  };
191
- // 最早可预约时间为 当前日期之后并且提前量之后
192
- let earliest = (0, _dayjs.default)();
147
+ let earliest = (0, import_dayjs.default)();
193
148
  let canBookingForOngoing = false;
194
- const {
195
- unit,
196
- unit_type,
197
- type,
198
- ongoing
199
- } = cut_off_time || {};
200
- // 允许购买已开始的活动
201
- if (type === 'ongoing' && ongoing?.type === 'after_start') {
202
- // 如果timeSlice.start_at 小于当前时间,判断当前时间是否在如果timeSlice.start_at+ongoing.unit之间
203
- // 即,如果现在是15:30,timeSlice.start_at是15:00,ongoing.unit是60分钟,则允许预约
204
- if ((0, _dayjs.default)(timeSlice.start_at).isBefore((0, _dayjs.default)())) {
205
- if (earliest.isBefore((0, _dayjs.default)(timeSlice.start_at).add(ongoing.unit, 'minute'))) {
149
+ const { unit, unit_type, type, ongoing } = cut_off_time || {};
150
+ if (type === "ongoing" && (ongoing == null ? void 0 : ongoing.type) === "after_start") {
151
+ if ((0, import_dayjs.default)(timeSlice.start_at).isBefore((0, import_dayjs.default)())) {
152
+ if (earliest.isBefore((0, import_dayjs.default)(timeSlice.start_at).add(ongoing.unit, "minute"))) {
206
153
  canBookingForOngoing = true;
207
154
  }
208
155
  }
209
- } else if (type === 'ongoing' && ongoing?.type === 'before_end') {
210
- if ((0, _dayjs.default)(timeSlice.end_at).isAfter(earliest)) {
156
+ } else if (type === "ongoing" && (ongoing == null ? void 0 : ongoing.type) === "before_end") {
157
+ if ((0, import_dayjs.default)(timeSlice.end_at).isAfter(earliest)) {
211
158
  canBookingForOngoing = true;
212
159
  }
213
160
  } else {
@@ -215,28 +162,25 @@ const getIsUsableByTimeItem = ({
215
162
  earliest = earliest.add(unit, unit_type);
216
163
  }
217
164
  }
218
- // 不可预约提前量时间之前的
219
165
  if (!checkAfterToDay(timeSlice.start_at, earliest) && !canBookingForOngoing) {
220
166
  return status;
221
167
  }
222
168
  status.afterToDay = true;
223
169
  const checkCapacityResult = checkCapacity({
224
- event_list: time?.event_list,
170
+ event_list: time == null ? void 0 : time.event_list,
225
171
  timeSlice,
226
172
  resource,
227
173
  currentCount
228
174
  });
229
- if (resource.combined_resource?.status) {
230
- // 组合资源中子资源是否可用
175
+ if ((_a = resource.combined_resource) == null ? void 0 : _a.status) {
231
176
  const resourceIds = resource.combined_resource.resource_ids;
232
- resourceIds.forEach(id => {
233
- // 只要有一个子资源不可用,整个组合资源都不可用
234
- if (resourcesUseableMap?.[id] === false) {
177
+ resourceIds.forEach((id) => {
178
+ if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[id]) === false) {
235
179
  checkCapacityResult.status = false;
236
180
  }
237
181
  });
238
182
  }
239
- status.reason = checkCapacityResult.reason || '';
183
+ status.reason = checkCapacityResult.reason || "";
240
184
  if (!checkCapacityResult.status) {
241
185
  return status;
242
186
  }
@@ -245,113 +189,116 @@ const getIsUsableByTimeItem = ({
245
189
  status.usable = true;
246
190
  return status;
247
191
  };
248
-
249
- /**
250
- * @title: 获取商品下绑定的资源列表
251
- * @description:
252
- * @param {any} resourcesMap
253
- * @param {any} product
254
- * @return {*}
255
- * @Author: zhiwei.Wang
256
- */
257
- exports.getIsUsableByTimeItem = getIsUsableByTimeItem;
258
- const getResourcesByProduct = (resourcesMap, resources, selectedResources, capacity = 1) => {
192
+ var getResourcesByProduct = (resourcesMap, resources, selectedResources, capacity = 1) => {
259
193
  return (resources || []).reduce((acc, item) => {
260
- if (item?.status == 1) {
194
+ if ((item == null ? void 0 : item.status) == 1) {
261
195
  const form_id = item.id;
262
- // 去重 可选资源和必选资源可能会有重复的
263
- item.optional_resource = (item.optional_resource || []).filter(d => item.default_resource.indexOf(d) == -1);
264
- let optional_resource = item.optional_resource.reduce((childAcc, d) => {
265
- // 如果其他资源选择过,并且这个资源是单个预约,则不可以选中此资源
266
- // TODO: 如果容量超了这里怎么处理?
267
- const isSelectSingleResources = resourcesMap[d]?.resourceType === 'single' && selectedResources.includes(resourcesMap[d].id);
268
- if (resourcesMap[d] && !isSelectSingleResources) {
269
- // 拼装组合资源的数据
270
- const combiningResources = [];
271
- if (resourcesMap[d].combined_resource && resourcesMap[d].combined_resource.status === 1) {
272
- resourcesMap[d].combined_resource.resource_ids.forEach(id => {
273
- if (resourcesMap[id]) {
274
- combiningResources.push(resourcesMap[id]);
275
- childAcc.push(Object.assign({}, resourcesMap[id], {
276
- form_id: form_id,
277
- resourceType: item.type,
278
- children: combiningResources,
279
- onlyComputed: true,
280
- // 是否是只用来计算用,组合资源里,假设商品只关联了组合资源没关联子资源,需要通过这个计算来在后面从 renderList 里删除这个资源
281
- metadata: {
282
- ...resourcesMap[id].metadata,
283
- combined_resource: resourcesMap[id].combined_resource,
284
- form_name: item.title,
285
- resource_name: resourcesMap[id].main_field
196
+ item.optional_resource = (item.optional_resource || []).filter(
197
+ (d) => item.default_resource.indexOf(d) == -1
198
+ );
199
+ let optional_resource = item.optional_resource.reduce(
200
+ (childAcc, d) => {
201
+ var _a;
202
+ const isSelectSingleResources = ((_a = resourcesMap[d]) == null ? void 0 : _a.resourceType) === "single" && selectedResources.includes(resourcesMap[d].id);
203
+ if (resourcesMap[d] && !isSelectSingleResources) {
204
+ const combiningResources = [];
205
+ if (resourcesMap[d].combined_resource && resourcesMap[d].combined_resource.status === 1) {
206
+ resourcesMap[d].combined_resource.resource_ids.forEach(
207
+ (id) => {
208
+ if (resourcesMap[id]) {
209
+ combiningResources.push(resourcesMap[id]);
210
+ childAcc.push(
211
+ Object.assign({}, resourcesMap[id], {
212
+ form_id,
213
+ resourceType: item.type,
214
+ children: combiningResources,
215
+ onlyComputed: true,
216
+ // 是否是只用来计算用,组合资源里,假设商品只关联了组合资源没关联子资源,需要通过这个计算来在后面从 renderList 里删除这个资源
217
+ metadata: {
218
+ ...resourcesMap[id].metadata,
219
+ combined_resource: resourcesMap[id].combined_resource,
220
+ form_name: item.title,
221
+ resource_name: resourcesMap[id].main_field
222
+ }
223
+ })
224
+ );
286
225
  }
287
- }));
288
- }
289
- });
290
- }
291
- childAcc.push(Object.assign({}, resourcesMap[d], {
292
- form_id: form_id,
293
- resourceType: item.type,
294
- children: combiningResources,
295
- metadata: {
296
- ...resourcesMap[d].metadata,
297
- combined_resource: resourcesMap[d].combined_resource,
298
- form_name: item.title,
299
- resource_name: resourcesMap[d].main_field
226
+ }
227
+ );
300
228
  }
301
- }));
302
- }
303
- return childAcc;
304
- }, []);
305
- let default_resource = item.default_resource.reduce((childAcc, d) => {
306
- const isSelectSingleResources = resourcesMap[d]?.resourceType === 'single' && selectedResources.includes(resourcesMap[d].id);
307
- if (resourcesMap[d] && !isSelectSingleResources) {
308
- // 拼装组合资源的数据
309
- const combiningResources = [];
310
- if (resourcesMap[d].combined_resource && resourcesMap[d].combined_resource.status === 1) {
311
- resourcesMap[d].combined_resource.resource_ids.forEach(id => {
312
- if (resourcesMap[id]) {
313
- combiningResources.push(resourcesMap[id]);
314
- childAcc.push(Object.assign({}, resourcesMap[id], {
315
- form_id: form_id,
316
- resourceType: item.type,
317
- children: combiningResources,
318
- onlyComputed: true,
319
- // 是否是只用来计算用,组合资源里,假设商品只关联了组合资源没关联子资源,需要通过这个计算来在后面从 renderList 里删除这个资源
320
- metadata: {
321
- ...resourcesMap[id].metadata,
322
- combined_resource: resourcesMap[id].combined_resource,
323
- form_name: item.title,
324
- resource_name: resourcesMap[id].main_field
325
- }
326
- }));
327
- }
328
- });
229
+ childAcc.push(
230
+ Object.assign({}, resourcesMap[d], {
231
+ form_id,
232
+ resourceType: item.type,
233
+ children: combiningResources,
234
+ metadata: {
235
+ ...resourcesMap[d].metadata,
236
+ combined_resource: resourcesMap[d].combined_resource,
237
+ form_name: item.title,
238
+ resource_name: resourcesMap[d].main_field
239
+ }
240
+ })
241
+ );
329
242
  }
330
- childAcc.push(Object.assign({}, resourcesMap[d], {
331
- form_id: form_id,
332
- resourceType: item.type,
333
- is_default: 1,
334
- children: combiningResources,
335
- metadata: {
336
- ...resourcesMap[d].metadata,
337
- combined_resource: resourcesMap[d].combined_resource,
338
- form_name: item.title,
339
- resource_name: resourcesMap[d].main_field
243
+ return childAcc;
244
+ },
245
+ []
246
+ );
247
+ let default_resource = item.default_resource.reduce(
248
+ (childAcc, d) => {
249
+ var _a;
250
+ const isSelectSingleResources = ((_a = resourcesMap[d]) == null ? void 0 : _a.resourceType) === "single" && selectedResources.includes(resourcesMap[d].id);
251
+ if (resourcesMap[d] && !isSelectSingleResources) {
252
+ const combiningResources = [];
253
+ if (resourcesMap[d].combined_resource && resourcesMap[d].combined_resource.status === 1) {
254
+ resourcesMap[d].combined_resource.resource_ids.forEach(
255
+ (id) => {
256
+ if (resourcesMap[id]) {
257
+ combiningResources.push(resourcesMap[id]);
258
+ childAcc.push(
259
+ Object.assign({}, resourcesMap[id], {
260
+ form_id,
261
+ resourceType: item.type,
262
+ children: combiningResources,
263
+ onlyComputed: true,
264
+ // 是否是只用来计算用,组合资源里,假设商品只关联了组合资源没关联子资源,需要通过这个计算来在后面从 renderList 里删除这个资源
265
+ metadata: {
266
+ ...resourcesMap[id].metadata,
267
+ combined_resource: resourcesMap[id].combined_resource,
268
+ form_name: item.title,
269
+ resource_name: resourcesMap[id].main_field
270
+ }
271
+ })
272
+ );
273
+ }
274
+ }
275
+ );
340
276
  }
341
- }));
342
- }
343
- return childAcc;
344
- }, []);
345
- // 合并渲染
277
+ childAcc.push(
278
+ Object.assign({}, resourcesMap[d], {
279
+ form_id,
280
+ resourceType: item.type,
281
+ is_default: 1,
282
+ children: combiningResources,
283
+ metadata: {
284
+ ...resourcesMap[d].metadata,
285
+ combined_resource: resourcesMap[d].combined_resource,
286
+ form_name: item.title,
287
+ resource_name: resourcesMap[d].main_field
288
+ }
289
+ })
290
+ );
291
+ }
292
+ return childAcc;
293
+ },
294
+ []
295
+ );
346
296
  item.renderList = optional_resource.concat(default_resource);
347
- // renderList里 times 的每一项需要匹配一下当前时间,如果 times 里最小的end_at小于当前时间,则这个资源应该从 renderList 删除
348
- item.renderList = item.renderList.filter(d => {
297
+ item.renderList = item.renderList.filter((d) => {
349
298
  const latestTime = d.times.reduce((latest, current) => {
350
- return (0, _dayjs.default)(current.end_at).isAfter((0, _dayjs.default)(latest.end_at)) ? current : latest;
299
+ return (0, import_dayjs.default)(current.end_at).isAfter((0, import_dayjs.default)(latest.end_at)) ? current : latest;
351
300
  }, d.times[0]);
352
- // TODO,在这拉时间切片出来,如果可用 timeSlots.length > 1 才可以被选择
353
- // 当前资源的配置容量需要大于当前需求的 capacity
354
- return (0, _dayjs.default)(latestTime.end_at).isAfter((0, _dayjs.default)()) && d.capacity >= capacity;
301
+ return (0, import_dayjs.default)(latestTime.end_at).isAfter((0, import_dayjs.default)()) && d.capacity >= capacity;
355
302
  });
356
303
  item.form_id = form_id;
357
304
  acc.push(item);
@@ -359,16 +306,7 @@ const getResourcesByProduct = (resourcesMap, resources, selectedResources, capac
359
306
  return acc;
360
307
  }, []);
361
308
  };
362
-
363
- /**
364
- * @title: 获取资源列表
365
- * @description:
366
- * @return {*}
367
- * @Author: zhiwei.Wang
368
- * @Date: 2024-01-09 13:38
369
- */
370
- exports.getResourcesByProduct = getResourcesByProduct;
371
- const formatResources = ({
309
+ var formatResources = ({
372
310
  booking,
373
311
  resources
374
312
  }) => {
@@ -377,39 +315,30 @@ const formatResources = ({
377
315
  let maps = {};
378
316
  for (let item of _list) {
379
317
  let renderListMaps = {};
380
- item.renderList = item.renderList.map(d => {
318
+ item.renderList = item.renderList.map((d) => {
381
319
  let res = formatResource(d, booking);
382
320
  renderListMaps[res.id] = res;
383
321
  return res;
384
322
  });
385
323
  maps[item.form_id] = {
386
324
  ...item,
387
- renderListMaps: renderListMaps
325
+ renderListMaps
388
326
  };
389
327
  }
390
- return {
391
- list: _list,
392
- maps: maps
393
- };
394
- } catch (err) {}
328
+ return { list: _list, maps };
329
+ } catch (err) {
330
+ console.log("formatResourcesErr", err);
331
+ }
395
332
  return {
396
333
  list: [],
397
334
  maps: {}
398
335
  };
399
336
  };
400
-
401
- /**
402
- * @title: 获取资源的时间切片列表
403
- * @description:
404
- * @return {*}
405
- * @Author: zhiwei.Wang
406
- */
407
- exports.formatResources = formatResources;
408
- const getTimeSlicesByResource = ({
337
+ var getTimeSlicesByResource = ({
409
338
  resource,
410
339
  duration,
411
340
  split = 10,
412
- currentDate = (0, _dayjs.default)(),
341
+ currentDate = (0, import_dayjs.default)(),
413
342
  capacity,
414
343
  resourcesUseableMap = {},
415
344
  cut_off_time,
@@ -417,45 +346,26 @@ const getTimeSlicesByResource = ({
417
346
  operating_day_boundary,
418
347
  maxBlockThreshold
419
348
  }) => {
420
- let {
421
- times
422
- } = resource;
423
-
424
- // 存储所有时间切片
349
+ let { times } = resource;
425
350
  const timeSlices = [];
426
- // times 先以开始时间为准做个排序,时间早的先循环
427
351
  times.sort((a, b) => {
428
- return (0, _dayjs.default)(a.start_at).diff((0, _dayjs.default)(b.start_at), 'minute');
352
+ return (0, import_dayjs.default)(a.start_at).diff((0, import_dayjs.default)(b.start_at), "minute");
429
353
  });
430
-
431
- // 处理每个时间范围
432
- times.forEach(time => {
433
- // 创建今天的日期字符串,用于构建完整的日期时间
434
- // const today = dayjs(currentDate).format('YYYY-MM-DD');
435
-
436
- // 解析开始和结束时间
437
- const startTime = (0, _dayjs.default)(`${time.start_at}`);
438
- let endTime = (0, _dayjs.default)(`${time.end_at}`);
439
- // 结束时间要做修复,如果time.end_at 是超过了 currentDate 的那一天,则把 end_at 设置为 currentDate 那一天的 23:59:59
440
- if (endTime.isAfter((0, _dayjs.default)(currentDate).endOf('day'))) {
441
- endTime = (0, _dayjs.default)(currentDate).endOf('day');
354
+ times.forEach((time) => {
355
+ const startTime = (0, import_dayjs.default)(`${time.start_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");
442
359
  }
443
-
444
- // 当前切片的开始时间
445
360
  let currentStart = startTime;
446
-
447
- // 生成时间切片
448
361
  while (true) {
449
- // 计算当前切片的结束时间
450
- const currentEnd = currentStart.add(duration, 'minute');
451
-
452
- // 如果结束时间超过了时间范围的结束时间,则停止
362
+ const currentEnd = currentStart.add(duration, "minute");
453
363
  if (currentEnd.isAfter(endTime)) {
454
364
  break;
455
365
  }
456
366
  const timeSlice = {
457
- start_time: currentStart.format('HH:mm'),
458
- end_time: currentEnd.format('HH:mm'),
367
+ start_time: currentStart.format("HH:mm"),
368
+ end_time: currentEnd.format("HH:mm"),
459
369
  start_at: currentStart,
460
370
  end_at: currentEnd
461
371
  };
@@ -464,54 +374,39 @@ const getTimeSlicesByResource = ({
464
374
  time,
465
375
  resource,
466
376
  currentCount: capacity || 1,
467
- resourcesUseableMap: resourcesUseableMap,
377
+ resourcesUseableMap,
468
378
  cut_off_time
469
379
  });
470
- if (resourcesUseableMap?.[resource.id] !== false) {
380
+ if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[resource.id]) !== false) {
471
381
  resourcesUseableMap[resource.id] = _status.usable;
472
382
  }
473
383
  if (_status.usable) {
474
- // 如果有hasFlexibleDuration,且timeSlice.start_at 大于等于operating_day_boundary,则不添加时间切片
475
- const operatingBoundaryDateTime = operating_day_boundary?.type === 'start_time' ? '23:59' : operating_day_boundary?.time;
476
- if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= (operatingBoundaryDateTime || '23:59')) {
384
+ const operatingBoundaryDateTime = (operating_day_boundary == null ? void 0 : operating_day_boundary.type) === "start_time" ? "23:59" : operating_day_boundary == null ? void 0 : operating_day_boundary.time;
385
+ if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= (operatingBoundaryDateTime || "23:59")) {
477
386
  break;
478
387
  }
479
- // 如果有配置了最低禁止购买时长,则需要判断时间切片是否在最低禁止购买时长内
480
- // 看一下endTime和operatingBoundaryDateTime哪个早,哪个早用哪个去比较
481
- const operatingBoundaryDateTimeObj = (0, _dayjs.default)(`${endTime.format('YYYY-MM-DD')} ${operatingBoundaryDateTime}`);
388
+ const operatingBoundaryDateTimeObj = (0, import_dayjs.default)(`${endTime.format("YYYY-MM-DD")} ${operatingBoundaryDateTime}`);
482
389
  const earlyTime = endTime.isBefore(operatingBoundaryDateTimeObj) ? endTime : operatingBoundaryDateTimeObj;
483
- if (hasFlexibleDuration && operating_day_boundary && maxBlockThreshold && timeSlice.start_at.add(maxBlockThreshold || 0, 'minutes').isAfter(earlyTime)) {
390
+ if (hasFlexibleDuration && operating_day_boundary && maxBlockThreshold && timeSlice.start_at.add(maxBlockThreshold || 0, "minutes").isAfter(earlyTime)) {
484
391
  break;
485
392
  }
486
- // 添加时间切片 09:00 ~ 10:00 09:20 ~ 10:20 09:00 ~ 10:00 09:20 ~ 10:20 11:00 ~ 12:00 11:20 ~ 12:20
487
393
  timeSlices.push({
488
394
  ...timeSlice,
489
395
  // 这里需要补充这个时间段内是否可预约
490
- _status: _status
396
+ _status
491
397
  });
492
398
  }
493
- // 移动到下一个开始时间(增加10分钟)
494
- currentStart = currentStart.add(split, 'minute');
399
+ currentStart = currentStart.add(split, "minute");
495
400
  }
496
401
  });
497
402
  return timeSlices;
498
403
  };
499
-
500
- /**
501
- * @title: 获取时间切片列表的交集
502
- * @description: 注意: 需要将多个时间切片列表合并在一起,然后判断交集
503
- * @param {TimeSliceItem} times 多个时间切片
504
- * @param {number} count 交集次数, 符合此次数的会返回
505
- * @return {*}
506
- * @Author: zhiwei.Wang
507
- */
508
- exports.getTimeSlicesByResource = getTimeSlicesByResource;
509
- const getTimesIntersection = (times, count) => {
404
+ var getTimesIntersection = (times, count) => {
510
405
  let obj = times.reduce((acc, item) => {
511
406
  let _key = `${item.start_time}-${item.end_time}`;
512
407
  if (!acc[_key]) {
513
408
  acc[_key] = {
514
- item: item,
409
+ item,
515
410
  count: 1
516
411
  };
517
412
  } else {
@@ -519,44 +414,24 @@ const getTimesIntersection = (times, count) => {
519
414
  }
520
415
  return acc;
521
416
  }, {});
522
-
523
- // 过滤出符合交集次数的
524
- return Object.values(obj).filter(d => d.count >= count).map(d => d.item);
417
+ return Object.values(obj).filter((d) => d.count >= count).map((d) => d.item);
525
418
  };
526
-
527
- /**
528
- * @title: 根据ids筛选资源列表
529
- * @description:
530
- * @param {any} resourcesMap
531
- * @param {any} ids
532
- * @return {*}
533
- * @Author: zhiwei.Wang
534
- * @Date: 2024-09-19 20:23
535
- */
536
- exports.getTimesIntersection = getTimesIntersection;
537
- const getResourcesByIds = (resourcesMap, ids) => {
538
- return (ids || []).map(id => resourcesMap[id]);
419
+ var getResourcesByIds = (resourcesMap, ids) => {
420
+ return (ids || []).map((id) => resourcesMap[id]);
539
421
  };
540
-
541
- /**
542
- * @title: 合并子资源的时间切片至组合资源
543
- * @description:
544
- * @param {ResourceItem[]} resources
545
- * @param {Record<string, ResourceItem>} resourcesMap
546
- * @return {*}
547
- * @Author: zhiwei.Wang
548
- */
549
- exports.getResourcesByIds = getResourcesByIds;
550
- const mergeSubResourcesTimeSlices = (resources, resourcesMap) => {
551
- return resources.forEach(item => {
552
- if (item?.combined_resource?.status === 1) {
553
- item?.combined_resource?.resource_ids.forEach(id => {
422
+ var mergeSubResourcesTimeSlices = (resources, resourcesMap) => {
423
+ return resources.forEach((item) => {
424
+ var _a, _b;
425
+ if (((_a = item == null ? void 0 : item.combined_resource) == null ? void 0 : _a.status) === 1) {
426
+ (_b = item == null ? void 0 : item.combined_resource) == null ? void 0 : _b.resource_ids.forEach((id) => {
554
427
  const subResource = resourcesMap[id];
555
428
  if (subResource) {
556
- subResource.times.forEach(time => {
557
- const fatherResourcesTime = item.times.find(n => n.start_at === time.start_at && n.end_at === time.end_at);
429
+ subResource.times.forEach((time) => {
430
+ const fatherResourcesTime = item.times.find(
431
+ (n) => n.start_at === time.start_at && n.end_at === time.end_at
432
+ );
558
433
  if (fatherResourcesTime) {
559
- fatherResourcesTime.event_list.push(...(time.event_list || []));
434
+ fatherResourcesTime.event_list.push(...time.event_list || []);
560
435
  }
561
436
  });
562
437
  }
@@ -564,17 +439,7 @@ const mergeSubResourcesTimeSlices = (resources, resourcesMap) => {
564
439
  }
565
440
  });
566
441
  };
567
-
568
- /**
569
- * @title: 根据资源id列表获取时间切片
570
- * @description: 传入一个技师id列表, 找出技师列表中公共的时间切片
571
- * @param {ResourceItem} resources
572
- * @param {CartItem} cart
573
- * @return {*}
574
- * @Author: zhiwei.Wang
575
- */
576
- exports.mergeSubResourcesTimeSlices = mergeSubResourcesTimeSlices;
577
- const getTimeSlicesByResources = ({
442
+ var getTimeSlicesByResources = ({
578
443
  resourceIds,
579
444
  resourcesMap,
580
445
  duration,
@@ -587,181 +452,129 @@ const getTimeSlicesByResources = ({
587
452
  operating_day_boundary,
588
453
  maxBlockThreshold
589
454
  }) => {
590
- // 获取资源列表
591
455
  let resources = getResourcesByIds(resourcesMap, resourceIds);
592
456
  mergeSubResourcesTimeSlices(resources, resourcesMap);
593
- // 资源排下序,把单个资源靠前,组合资源排在后面
594
457
  resources.sort((a, b) => {
595
- const aIsCombined = a.metadata?.combined_resource?.status === 1;
596
- const bIsCombined = b.metadata?.combined_resource?.status === 1;
597
- if (aIsCombined && !bIsCombined) return 1;
598
- if (!aIsCombined && bIsCombined) return -1;
458
+ var _a, _b, _c, _d;
459
+ const aIsCombined = ((_b = (_a = a.metadata) == null ? void 0 : _a.combined_resource) == null ? void 0 : _b.status) === 1;
460
+ const bIsCombined = ((_d = (_c = b.metadata) == null ? void 0 : _c.combined_resource) == null ? void 0 : _d.status) === 1;
461
+ if (aIsCombined && !bIsCombined)
462
+ return 1;
463
+ if (!aIsCombined && bIsCombined)
464
+ return -1;
599
465
  return 0;
600
466
  });
601
-
602
- // 获取资源列表中所有的时间切片
603
- let timeSliceList = resources.reduce((acc, item) => {
604
- return acc.concat(getTimeSlicesByResource({
605
- resource: item,
606
- duration: duration,
607
- split: split,
608
- currentDate: currentDate,
609
- capacity: capacity,
610
- resourcesUseableMap: resourcesUseableMap,
611
- cut_off_time: cut_off_time,
612
- hasFlexibleDuration,
613
- operating_day_boundary,
614
- maxBlockThreshold
615
- }));
616
- }, []);
617
-
618
- // 获取时间切片列表的交集
467
+ let timeSliceList = resources.reduce(
468
+ (acc, item) => {
469
+ return acc.concat(
470
+ getTimeSlicesByResource({
471
+ resource: item,
472
+ duration,
473
+ split,
474
+ currentDate,
475
+ capacity,
476
+ resourcesUseableMap,
477
+ cut_off_time,
478
+ hasFlexibleDuration,
479
+ operating_day_boundary,
480
+ maxBlockThreshold
481
+ })
482
+ );
483
+ },
484
+ []
485
+ );
619
486
  let intersection = getTimesIntersection(timeSliceList, resources.length);
620
487
  return intersection;
621
488
  };
622
-
623
- /**
624
- * @title: 获取其他人的已选资源
625
- * @description:
626
- * @param {CartItem[]} cartItems
627
- * @param {number | string} accountId
628
- * @return {*}
629
- * @Author: jinglin.tan
630
- */
631
- exports.getTimeSlicesByResources = getTimeSlicesByResources;
632
- const getOthersSelectedResources = (cartItems, accountId, resourcesMap) => {
489
+ var getOthersSelectedResources = (cartItems, accountId, resourcesMap) => {
633
490
  return cartItems.reduce((acc, d) => {
491
+ var _a;
634
492
  if (d.holder_id !== accountId) {
635
- if (d._origin?.resources) {
636
- d._origin.resources.forEach(n => {
637
- // 如果是组合资源,还需要检查组合资源里子资源是否被占用过
493
+ if ((_a = d._origin) == null ? void 0 : _a.resources) {
494
+ d._origin.resources.forEach((n) => {
638
495
  if (n.metadata.combined_resource && n.metadata.combined_resource.status === 1) {
639
- // 如果组合资源里子资源被占用过,则这个资源不可以进待选列表了
640
- if (n.metadata.combined_resource.resource_ids.some(m => acc.includes(m))) {
496
+ if (n.metadata.combined_resource.resource_ids.some(
497
+ (m) => acc.includes(m)
498
+ )) {
641
499
  return acc;
642
500
  }
643
501
  acc.push(...n.metadata.combined_resource.resource_ids);
644
- // n.metadata.combined_resource.resource_ids.forEach((m: number) => {
645
- // if (resourcesMap[m]) resourcesMap[m].capacity -= d.num || 0;
646
- // });
647
502
  } else {
648
- // 如果当前选中的不是组合资源,但是是别的组合资源里的子资源,则还需要把别的组合资源也加进来
649
- // 去 resourcesMap 里找一下 n.id 是不是别的组合资源里的子资源,是的话把别的组合资源也加进来
650
- Object.values(resourcesMap).forEach(m => {
503
+ Object.values(resourcesMap).forEach((m) => {
651
504
  if (m.combined_resource && m.combined_resource.status === 1) {
652
505
  if (m.combined_resource.resource_ids.includes(n.id)) {
653
506
  acc.push(m.id);
654
- // if (resourcesMap[m.id]) resourcesMap[m.id].capacity -= d.num || 0;
655
507
  }
656
508
  }
657
509
  });
658
510
  }
659
511
  acc.push(n.id);
660
- // if (resourcesMap[n.id]) resourcesMap[n.id].capacity -= currentCapacity || 0;
661
512
  });
662
513
  }
663
514
  }
664
515
  return acc;
665
516
  }, []);
666
517
  };
667
-
668
- /**
669
- * @title: 获取其他购物车内商品的已选资源
670
- * @description:
671
- * @param {CartItem[]} cartItems
672
- * @param {number | string} accountId
673
- * @return {*}
674
- * @Author: jinglin.tan
675
- */
676
- exports.getOthersSelectedResources = getOthersSelectedResources;
677
- const getOthersCartSelectedResources = (cartItems, cartItemId, resourcesMap) => {
518
+ var getOthersCartSelectedResources = (cartItems, cartItemId, resourcesMap) => {
678
519
  return cartItems.reduce((acc, d) => {
520
+ var _a;
679
521
  if (d._id !== cartItemId) {
680
- if (d._origin?.resources) {
681
- d._origin.resources.forEach(n => {
682
- // 如果是组合资源,还需要检查组合资源里子资源是否被占用过
522
+ if ((_a = d._origin) == null ? void 0 : _a.resources) {
523
+ d._origin.resources.forEach((n) => {
683
524
  if (n.metadata.combined_resource && n.metadata.combined_resource.status === 1) {
684
- // 如果组合资源里子资源被占用过,则这个资源不可以进待选列表了
685
- if (n.metadata.combined_resource.resource_ids.some(m => acc.includes(m))) {
525
+ if (n.metadata.combined_resource.resource_ids.some(
526
+ (m) => acc.includes(m)
527
+ )) {
686
528
  return acc;
687
529
  }
688
530
  acc.push(...n.metadata.combined_resource.resource_ids);
689
- // n.metadata.combined_resource.resource_ids.forEach((m: number) => {
690
- // resourcesMap[m].capacity -= n.num;
691
- // });
692
531
  } else {
693
- // 如果当前选中的不是组合资源,但是是别的组合资源里的子资源,则还需要把别的组合资源也加进来
694
- // 去 resourcesMap 里找一下 n.id 是不是别的组合资源里的子资源,是的话把别的组合资源也加进来
695
- Object.values(resourcesMap).forEach(m => {
532
+ Object.values(resourcesMap).forEach((m) => {
696
533
  if (m.combined_resource && m.combined_resource.status === 1) {
697
534
  if (m.combined_resource.resource_ids.includes(n.id)) {
698
535
  acc.push(m.id);
699
- // resourcesMap[m.id].capacity -= n.num;
700
536
  }
701
537
  }
702
538
  });
703
539
  }
704
540
  acc.push(n.id);
705
- // push 完以后,把 resourceMap 的 capacity 减掉当前的商品数量
706
- // resourcesMap[n.id].capacity -= currentCapacity || 0;
707
541
  });
708
542
  }
709
543
  }
710
544
  return acc;
711
545
  }, []);
712
546
  };
713
- exports.getOthersCartSelectedResources = getOthersCartSelectedResources;
714
- /**
715
- * @title: 根据日期范围过滤日程
716
- *
717
- * @export
718
- * @param {any[]} schedule
719
- * @param {string} startDate
720
- * @param {string} endDate
721
- * @return {*}
722
- */
723
547
  function filterScheduleByDateRange(schedule, startDate, endDate) {
724
- if (!schedule?.length) return [];
548
+ if (!(schedule == null ? void 0 : schedule.length))
549
+ return [];
725
550
  const start = new Date(startDate);
726
551
  const end = new Date(endDate);
727
- return schedule.filter(item => {
552
+ return schedule.filter((item) => {
728
553
  const itemDate = new Date(item.date);
729
554
  return itemDate >= start && itemDate <= end;
730
555
  });
731
556
  }
732
-
733
- /**
734
- * 传入商品数据,返回基于商品配置的提前量的最早开始日期和最晚结束日期
735
- *
736
- * @export
737
- * @param {ProductData} product
738
- * @return {*}
739
- */
740
557
  function checkSessionProductLeadTime(product) {
741
- let latestStartDate = ''; // 最晚开始日期
742
- let earliestEndDate = ''; // 最早结束日期
743
- const {
744
- future_day,
745
- unit,
746
- unit_type
747
- } = product.cut_off_time;
748
- // 预定天数存在,则开始计算从当前时间开始往后推预定天数作为结束时间
558
+ let latestStartDate = "";
559
+ let earliestEndDate = "";
560
+ const { future_day, unit, unit_type } = product.cut_off_time;
749
561
  if (future_day) {
750
- const endDate = (0, _dayjs.default)().add(future_day, 'day');
751
- if (!earliestEndDate || endDate.isBefore((0, _dayjs.default)(earliestEndDate), 'day')) {
752
- earliestEndDate = endDate.format('YYYY-MM-DD');
562
+ const endDate = (0, import_dayjs.default)().add(future_day, "day");
563
+ if (!earliestEndDate || endDate.isBefore((0, import_dayjs.default)(earliestEndDate), "day")) {
564
+ earliestEndDate = endDate.format("YYYY-MM-DD");
753
565
  }
754
566
  } else if (future_day === 0) {
755
- const endDate = (0, _dayjs.default)();
756
- if (!earliestEndDate || endDate.isBefore((0, _dayjs.default)(earliestEndDate), 'day')) {
757
- earliestEndDate = endDate.format('YYYY-MM-DD');
567
+ const endDate = (0, import_dayjs.default)();
568
+ if (!earliestEndDate || endDate.isBefore((0, import_dayjs.default)(earliestEndDate), "day")) {
569
+ earliestEndDate = endDate.format("YYYY-MM-DD");
758
570
  }
759
571
  }
760
- // 如果存在提前预约时间,则开始计算从当前时间开始往后推提前预约时间作为开始时间
761
572
  if (unit && unit_type) {
762
- const startDate = (0, _dayjs.default)((0, _dayjs.default)().add(unit, unit_type).format('YYYY-MM-DD'));
763
- if (!latestStartDate || startDate.isAfter((0, _dayjs.default)(latestStartDate), 'day')) {
764
- latestStartDate = startDate.format('YYYY-MM-DD');
573
+ const startDate = (0, import_dayjs.default)(
574
+ (0, import_dayjs.default)().add(unit, unit_type).format("YYYY-MM-DD")
575
+ );
576
+ if (!latestStartDate || startDate.isAfter((0, import_dayjs.default)(latestStartDate), "day")) {
577
+ latestStartDate = startDate.format("YYYY-MM-DD");
765
578
  }
766
579
  }
767
580
  return {
@@ -769,75 +582,65 @@ function checkSessionProductLeadTime(product) {
769
582
  earliestEndDate
770
583
  };
771
584
  }
772
-
773
- /**
774
- * 基于商品的 resources 配置,返回可选择的资源的 id 列表
775
- *
776
- * @export
777
- * @param {ProductData} product
778
- * @return {*}
779
- */
780
585
  function getResourcesIdsByProduct(product) {
586
+ var _a, _b, _c;
781
587
  const tempResourceIds = [];
782
- product?.product_resource?.resources?.forEach?.(resource => {
783
- if (resource?.status == 1) {
784
- if (resource?.default_resource?.length) {
785
- tempResourceIds.push(...resource?.default_resource);
786
- } else if (resource?.optional_resource?.length) {
787
- tempResourceIds.push(...resource?.optional_resource);
588
+ (_c = (_b = (_a = product == null ? void 0 : product.product_resource) == null ? void 0 : _a.resources) == null ? void 0 : _b.forEach) == null ? void 0 : _c.call(_b, (resource) => {
589
+ var _a2, _b2;
590
+ if ((resource == null ? void 0 : resource.status) == 1) {
591
+ if ((_a2 = resource == null ? void 0 : resource.default_resource) == null ? void 0 : _a2.length) {
592
+ tempResourceIds.push(...resource == null ? void 0 : resource.default_resource);
593
+ } else if ((_b2 = resource == null ? void 0 : resource.optional_resource) == null ? void 0 : _b2.length) {
594
+ tempResourceIds.push(...resource == null ? void 0 : resource.optional_resource);
788
595
  }
789
596
  }
790
597
  });
791
598
  return tempResourceIds;
792
599
  }
793
-
794
- /**
795
- * 资源排序,把单个资源靠前,组合资源排在后面
796
- *
797
- * @export
798
- * @param {ResourceItem[]} resourcesList
799
- * @return {*}
800
- */
801
600
  function sortCombinedResources(resourcesList) {
802
601
  const newResourcesList = [...resourcesList];
803
602
  newResourcesList.sort((a, b) => {
804
- const aIsCombined = a.metadata?.combined_resource?.status === 1;
805
- const bIsCombined = b.metadata?.combined_resource?.status === 1;
603
+ var _a, _b, _c, _d;
604
+ const aIsCombined = ((_b = (_a = a.metadata) == null ? void 0 : _a.combined_resource) == null ? void 0 : _b.status) === 1;
605
+ const bIsCombined = ((_d = (_c = b.metadata) == null ? void 0 : _c.combined_resource) == null ? void 0 : _d.status) === 1;
806
606
  return aIsCombined === bIsCombined ? 0 : aIsCombined ? 1 : -1;
807
607
  });
808
608
  return newResourcesList;
809
609
  }
810
-
811
- /**
812
- * 传入一个资源组,根据 formid筛出相同类型的资源
813
- *
814
- * @export
815
- * @param {ResourceItem[]} resources
816
- * @param {string} form_id
817
- * @return {*}
818
- */
819
610
  function filterResourcesByFormItem(resources, form_id) {
820
- return resources.filter(n => n.form_id === form_id);
611
+ return resources.filter((n) => n.form_id === form_id);
821
612
  }
822
-
823
- /**
824
- * 传入两个资源,确认这两个资源是否有交集(包括组合资源)
825
- *
826
- * @export
827
- * @param {ResourceItem} resource1
828
- * @param {ResourceItem} resource2
829
- * @return {*}
830
- */
831
613
  function checkTwoResourcesIntersection(resource1, resource2) {
832
- // 检查主资源ID是否匹配
833
- if (resource1.id === resource2.id) return true;
834
- // 检查组合资源的情况
835
- if (resource1.metadata.combined_resource?.status === 1 && (
836
- // 如果现在选择的是组合资源,需要判断
614
+ var _a, _b;
615
+ if (resource1.id === resource2.id)
616
+ return true;
617
+ if (((_a = resource1.metadata.combined_resource) == null ? void 0 : _a.status) === 1 && // 如果现在选择的是组合资源,需要判断
837
618
  // 1、当前其他购物车里是否选了当前组合资源的子资源
838
619
  // 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
839
- resource1.metadata.combined_resource.resource_ids.includes(resource2.id) || resource1.metadata.combined_resource.resource_ids.some(n => {
620
+ (resource1.metadata.combined_resource.resource_ids.includes(resource2.id) || resource1.metadata.combined_resource.resource_ids.some((n) => {
840
621
  return resource2.metadata.combined_resource.resource_ids.includes(n);
841
- }))) return true;
842
- if (resource2.metadata.combined_resource?.status === 1 && resource2.metadata.combined_resource.resource_ids.includes(resource2.id)) return true;
843
- }
622
+ })))
623
+ return true;
624
+ if (((_b = resource2.metadata.combined_resource) == null ? void 0 : _b.status) === 1 && resource2.metadata.combined_resource.resource_ids.includes(resource2.id))
625
+ return true;
626
+ }
627
+ // Annotate the CommonJS export names for ESM import in node:
628
+ 0 && (module.exports = {
629
+ checkSessionProductLeadTime,
630
+ checkTwoResourcesIntersection,
631
+ filterResourcesByFormItem,
632
+ filterScheduleByDateRange,
633
+ formatResources,
634
+ getIsUsableByTimeItem,
635
+ getOthersCartSelectedResources,
636
+ getOthersSelectedResources,
637
+ getResourcesByIds,
638
+ getResourcesByProduct,
639
+ getResourcesIdsByProduct,
640
+ getTimeSlicesByResource,
641
+ getTimeSlicesByResources,
642
+ getTimesIntersection,
643
+ isConflict,
644
+ mergeSubResourcesTimeSlices,
645
+ sortCombinedResources
646
+ });