@pisell/pisellos 0.0.569 → 0.10.1

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 (329) 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/walletPass/evaluator.js +7 -5
  5. package/dist/model/strategy/adapter/walletPass/example.js +26 -3
  6. package/dist/model/strategy/adapter/walletPass/index.js +5 -5
  7. package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -3
  8. package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -26
  9. package/dist/model/strategy/adapter/walletPass/utils.js +17 -92
  10. package/dist/model/strategy/strategy-example.js +19 -5
  11. package/dist/modules/BaseModule.d.ts +1 -1
  12. package/dist/modules/BaseModule.js +8 -10
  13. package/dist/modules/Cart/index.js +3 -0
  14. package/dist/modules/Cart/utils/cartProduct.js +1 -0
  15. package/dist/modules/Cart/utils/cartResource.js +0 -2
  16. package/dist/modules/Cart/utils/changePrice.js +9 -16
  17. package/dist/modules/Date/index.js +5 -1
  18. package/dist/modules/Discount/index.d.ts +0 -1
  19. package/dist/modules/Discount/index.js +7 -22
  20. package/dist/modules/Discount/types.d.ts +0 -1
  21. package/dist/modules/OpenData/index.js +2 -0
  22. package/dist/modules/Order/index.d.ts +1 -1
  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 +0 -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.d.ts +1 -1
  167. package/lib/modules/Order/index.js +1909 -1572
  168. package/lib/modules/Order/types.js +35 -78
  169. package/lib/modules/Order/utils/bundleDiscountHydration.js +74 -41
  170. package/lib/modules/Order/utils/manualProductDiscount.js +123 -124
  171. package/lib/modules/Order/utils/orderCollectionIdentity.js +210 -148
  172. package/lib/modules/Order/utils.js +634 -799
  173. package/lib/modules/Payment/cash.js +33 -20
  174. package/lib/modules/Payment/cashRecommendationAlgorithm.js +76 -145
  175. package/lib/modules/Payment/eftpos.js +30 -16
  176. package/lib/modules/Payment/index.js +378 -518
  177. package/lib/modules/Payment/mx51.js +0 -1
  178. package/lib/modules/Payment/types.d.ts +4 -8
  179. package/lib/modules/Payment/types.js +107 -216
  180. package/lib/modules/Payment/utils.js +48 -51
  181. package/lib/modules/Payment/walletpass.d.ts +0 -2
  182. package/lib/modules/Payment/walletpass.js +211 -226
  183. package/lib/modules/Product/index.js +46 -51
  184. package/lib/modules/Product/types.js +16 -4
  185. package/lib/modules/Product/utils.js +33 -32
  186. package/lib/modules/ProductList/index.d.ts +1 -1
  187. package/lib/modules/ProductList/index.js +117 -117
  188. package/lib/modules/ProductList/types.d.ts +0 -1
  189. package/lib/modules/ProductList/types.js +31 -9
  190. package/lib/modules/Quotation/index.js +100 -66
  191. package/lib/modules/Quotation/types.js +16 -4
  192. package/lib/modules/Resource/index.js +59 -27
  193. package/lib/modules/Resource/types.js +32 -22
  194. package/lib/modules/Resource/utils.js +38 -30
  195. package/lib/modules/ResourcePlanner/index.js +61 -60
  196. package/lib/modules/ResourcePlanner/planner.js +384 -346
  197. package/lib/modules/ResourcePlanner/types.js +16 -4
  198. package/lib/modules/Rules/index.js +903 -1475
  199. package/lib/modules/Rules/types.js +40 -17
  200. package/lib/modules/SalesSummary/index.js +90 -85
  201. package/lib/modules/SalesSummary/types.js +16 -4
  202. package/lib/modules/SalesSummary/utils.js +427 -351
  203. package/lib/modules/ScanOrderLogger/index.js +79 -59
  204. package/lib/modules/ScanOrderLogger/providers/feishu.js +78 -54
  205. package/lib/modules/ScanOrderLogger/providers/grafana.js +36 -13
  206. package/lib/modules/ScanOrderLogger/types.js +16 -4
  207. package/lib/modules/Schedule/getDateIsInSchedule.js +163 -339
  208. package/lib/modules/Schedule/index.js +114 -100
  209. package/lib/modules/Schedule/type.js +16 -4
  210. package/lib/modules/Schedule/types.js +16 -4
  211. package/lib/modules/Schedule/utils.js +291 -433
  212. package/lib/modules/Step/index.js +52 -40
  213. package/lib/modules/Step/tyeps.js +16 -4
  214. package/lib/modules/Summary/index.js +71 -66
  215. package/lib/modules/Summary/types.js +16 -4
  216. package/lib/modules/Summary/utils.js +418 -791
  217. package/lib/modules/SurchargeList/index.js +60 -46
  218. package/lib/modules/SurchargeList/types.js +16 -4
  219. package/lib/modules/index.js +63 -245
  220. package/lib/plugins/app.js +16 -4
  221. package/lib/plugins/index.js +25 -36
  222. package/lib/plugins/request.js +126 -137
  223. package/lib/plugins/shopStore.js +16 -4
  224. package/lib/plugins/user.js +16 -4
  225. package/lib/plugins/window.js +179 -171
  226. package/lib/server/index.js +2337 -2675
  227. package/lib/server/modules/floor-plan/index.js +123 -102
  228. package/lib/server/modules/floor-plan/types.js +30 -15
  229. package/lib/server/modules/index.js +68 -106
  230. package/lib/server/modules/menu/index.js +122 -146
  231. package/lib/server/modules/menu/types.js +31 -18
  232. package/lib/server/modules/order/index.js +642 -567
  233. package/lib/server/modules/order/types.js +32 -117
  234. package/lib/server/modules/order/utils/filterBookings.js +194 -219
  235. package/lib/server/modules/order/utils/filterOrders.js +92 -118
  236. package/lib/server/modules/payment/index.js +83 -59
  237. package/lib/server/modules/payment/types.js +16 -4
  238. package/lib/server/modules/products/index.js +459 -575
  239. package/lib/server/modules/products/types.js +34 -44
  240. package/lib/server/modules/quotation/index.js +172 -137
  241. package/lib/server/modules/quotation/types.js +31 -21
  242. package/lib/server/modules/resource/index.js +184 -213
  243. package/lib/server/modules/resource/types.js +33 -42
  244. package/lib/server/modules/schedule/index.js +123 -135
  245. package/lib/server/modules/schedule/types.js +21 -14
  246. package/lib/server/modules/schedule/utils.js +163 -334
  247. package/lib/server/types.js +16 -4
  248. package/lib/server/utils/index.js +23 -25
  249. package/lib/server/utils/product.js +139 -196
  250. package/lib/server/utils/schedule.js +41 -34
  251. package/lib/server/utils/small-ticket.js +456 -478
  252. package/lib/server/utils/time.js +49 -40
  253. package/lib/solution/BaseSales/index.js +1016 -850
  254. package/lib/solution/BaseSales/types.js +37 -41
  255. package/lib/solution/BaseSales/utils/cartPromotion.js +460 -611
  256. package/lib/solution/BaseSales/utils/parseSalesResponse.js +105 -85
  257. package/lib/solution/BaseSales/utils/quotationPrice.js +114 -56
  258. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +143 -102
  259. package/lib/solution/BaseSales/utils.js +140 -155
  260. package/lib/solution/BookingByStep/index.d.ts +1 -1
  261. package/lib/solution/BookingByStep/index.js +1340 -1530
  262. package/lib/solution/BookingByStep/types.js +99 -40
  263. package/lib/solution/BookingByStep/utils/capacity.js +160 -192
  264. package/lib/solution/BookingByStep/utils/products.js +52 -42
  265. package/lib/solution/BookingByStep/utils/resources.js +330 -527
  266. package/lib/solution/BookingByStep/utils/stock.js +44 -65
  267. package/lib/solution/BookingByStep/utils/timeslots.js +131 -129
  268. package/lib/solution/BookingTicket/index.d.ts +1 -1
  269. package/lib/solution/BookingTicket/index.js +459 -543
  270. package/lib/solution/BookingTicket/types.js +77 -99
  271. package/lib/solution/BookingTicket/utils/addProductDecision.js +184 -219
  272. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +89 -58
  273. package/lib/solution/BookingTicket/utils/bookingStatus.js +78 -107
  274. package/lib/solution/BookingTicket/utils/cartView.js +94 -110
  275. package/lib/solution/BookingTicket/utils/exampleData.js +0 -185
  276. package/lib/solution/BookingTicket/utils/orderCustomer.js +41 -18
  277. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +86 -219
  278. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +93 -144
  279. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +91 -79
  280. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +41 -54
  281. package/lib/solution/BookingTicket/utils/scan/handleScan.js +81 -84
  282. package/lib/solution/BookingTicket/utils/scan/index.js +104 -98
  283. package/lib/solution/BookingTicket/utils/scan/scanCache.js +43 -90
  284. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +64 -52
  285. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +58 -56
  286. package/lib/solution/BuyTickets/index.js +70 -67
  287. package/lib/solution/BuyTickets/types.js +38 -22
  288. package/lib/solution/Checkout/index.js +1158 -1451
  289. package/lib/solution/Checkout/types.js +61 -91
  290. package/lib/solution/Checkout/utils/index.js +156 -228
  291. package/lib/solution/PlaceOrder/index.js +0 -55
  292. package/lib/solution/RegisterAndLogin/config.js +460 -493
  293. package/lib/solution/RegisterAndLogin/index.js +630 -633
  294. package/lib/solution/RegisterAndLogin/types.js +76 -189
  295. package/lib/solution/RegisterAndLogin/utils.js +125 -183
  296. package/lib/solution/Sales/index.js +320 -317
  297. package/lib/solution/Sales/types.js +33 -27
  298. package/lib/solution/ScanOrder/index.js +862 -831
  299. package/lib/solution/ScanOrder/types.js +34 -33
  300. package/lib/solution/ScanOrder/utils.js +371 -406
  301. package/lib/solution/ShopDiscount/index.js +233 -235
  302. package/lib/solution/ShopDiscount/types.d.ts +4 -5
  303. package/lib/solution/ShopDiscount/types.js +37 -15
  304. package/lib/solution/ShopDiscount/utils.d.ts +0 -9
  305. package/lib/solution/ShopDiscount/utils.js +172 -309
  306. package/lib/solution/UnifiedBookingSales/index.js +405 -379
  307. package/lib/solution/UnifiedBookingSales/types.js +31 -12
  308. package/lib/solution/VenueBooking/index.d.ts +3 -31
  309. package/lib/solution/VenueBooking/index.js +916 -967
  310. package/lib/solution/VenueBooking/types.d.ts +1 -3
  311. package/lib/solution/VenueBooking/types.js +39 -20
  312. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  313. package/lib/solution/VenueBooking/utils/dateSummary.js +62 -25
  314. package/lib/solution/VenueBooking/utils/resource.js +54 -31
  315. package/lib/solution/VenueBooking/utils/slotMerge.js +107 -94
  316. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
  317. package/lib/solution/VenueBooking/utils/timeSlot.js +133 -138
  318. package/lib/solution/VenueBooking/utils.js +67 -130
  319. package/lib/solution/index.js +41 -124
  320. package/lib/store/createStore.js +29 -32
  321. package/lib/types/index.d.ts +1 -1
  322. package/lib/types/index.js +16 -4
  323. package/lib/utils/task.js +36 -36
  324. package/lib/utils/watch.js +47 -81
  325. package/package.json +2 -4
  326. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  327. package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
  328. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  329. package/lib/solution/VenueBooking/utils/smartPricing.js +0 -192
@@ -1,27 +1,27 @@
1
- "use strict";
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
2
18
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
19
+ // src/solution/BookingByStep/utils/stock.ts
20
+ var stock_exports = {};
21
+ __export(stock_exports, {
22
+ checkProductStock: () => checkProductStock
5
23
  });
6
- exports.checkProductStock = checkProductStock;
7
- /**
8
- * 检测商品库存是否足够
9
- *
10
- * 只有同时满足以下条件时才会进行库存检测:
11
- * - is_track 开启(值为 1 或 true)
12
- * - over_sold 为 0(不允许超卖)
13
- *
14
- * 对于多规格商品:
15
- * - 如果有 product_variant_id,则从 productData.variant 数组中查找对应规格
16
- * - 使用规格的 is_track, over_sold, stock_quantity 而不是主商品的
17
- *
18
- * @param productData 商品数据(需包含 is_track, over_sold, stock_quantity 字段,多规格商品需包含 variant 数组)
19
- * @param product_variant_id 商品变体ID,如果存在则为多规格商品
20
- * @param quantity 需要添加的数量
21
- * @param bundle 套餐配置(子商品需包含 is_track, over_sold, stock_quantity 字段)
22
- * @param currentCartItems 当前购物车商品列表
23
- * @returns 库存检测结果
24
- */
24
+ module.exports = __toCommonJS(stock_exports);
25
25
  function checkProductStock({
26
26
  productData,
27
27
  product_variant_id,
@@ -29,24 +29,20 @@ function checkProductStock({
29
29
  bundle,
30
30
  currentCartItems
31
31
  }) {
32
- // 1. 检测主商品库存
33
- // 处理多规格商品:如果有product_variant_id,则从variant数组中查找对应的规格配置
34
32
  let mainProductConfig = productData;
35
33
  if (product_variant_id && productData.variant && Array.isArray(productData.variant)) {
36
- const variant = productData.variant.find(v => v.id === product_variant_id);
34
+ const variant = productData.variant.find((v) => v.id === product_variant_id);
37
35
  if (variant) {
38
- mainProductConfig = variant; // 使用规格的配置替换主商品配置
36
+ mainProductConfig = variant;
39
37
  }
40
38
  }
41
-
42
- // 只有开启库存控制且不允许超卖时才需要检测主商品库存
43
39
  const isMainProductTrackingEnabled = mainProductConfig.is_track === 1 || mainProductConfig.is_track === true;
44
40
  const isMainProductOverSoldDisabled = mainProductConfig.over_sold === 0;
45
41
  if (isMainProductTrackingEnabled && isMainProductOverSoldDisabled) {
46
42
  const existingQuantity = currentCartItems.reduce((total, cartItem) => {
47
- // 检查是否为相同商品(比较商品ID和变体ID)
48
- const isSameProduct = cartItem._productOrigin?.id === productData.id;
49
- const isSameVariant = !product_variant_id && !cartItem._productOrigin?.product_variant_id || cartItem._productOrigin?.product_variant_id === product_variant_id;
43
+ var _a, _b, _c;
44
+ const isSameProduct = ((_a = cartItem._productOrigin) == null ? void 0 : _a.id) === productData.id;
45
+ const isSameVariant = !product_variant_id && !((_b = cartItem._productOrigin) == null ? void 0 : _b.product_variant_id) || ((_c = cartItem._productOrigin) == null ? void 0 : _c.product_variant_id) === product_variant_id;
50
46
  if (isSameProduct && isSameVariant) {
51
47
  return total + (cartItem.num || 0);
52
48
  }
@@ -54,39 +50,25 @@ function checkProductStock({
54
50
  }, 0);
55
51
  const totalQuantity = existingQuantity + quantity;
56
52
  const stockQuantity = mainProductConfig.stock_quantity;
57
-
58
- // 检查主商品库存是否足够
59
- if (stockQuantity !== undefined && stockQuantity !== null && totalQuantity > stockQuantity) {
60
- return {
61
- success: false,
62
- errorCode: 'not_enough_stock'
63
- };
53
+ if (stockQuantity !== void 0 && stockQuantity !== null && totalQuantity > stockQuantity) {
54
+ return { success: false, errorCode: "not_enough_stock" };
64
55
  }
65
56
  }
66
-
67
- // 2. 检测套餐商品库存
68
57
  if (bundle && Array.isArray(bundle)) {
69
- // 直接遍历套餐商品数组
70
58
  for (const bundleItem of bundle) {
71
59
  const bundleProductId = bundleItem.bundle_product_id;
72
60
  const bundleStockQuantity = bundleItem.stock_quantity;
73
- const bundleRequiredQuantity = (bundleItem.num || 1) * quantity; // 子商品需求数量 = 子商品配置数量 * 主商品购买数量
74
-
75
- // 检查套餐子商品是否需要进行库存控制
61
+ const bundleRequiredQuantity = (bundleItem.num || 1) * quantity;
76
62
  const isBundleTrackingEnabled = bundleItem.is_track === 1 || bundleItem.is_track === true;
77
63
  const isBundleOverSoldDisabled = bundleItem.over_sold === 0;
78
-
79
- // 跳过没有开启库存控制或允许超卖的子商品
80
- if (!isBundleTrackingEnabled || !isBundleOverSoldDisabled) continue;
81
-
82
- // 跳过没有库存配置的子商品
83
- if (bundleStockQuantity === undefined || bundleStockQuantity === null) continue;
84
-
85
- // 计算购物车中已有的相同子商品数量
64
+ if (!isBundleTrackingEnabled || !isBundleOverSoldDisabled)
65
+ continue;
66
+ if (bundleStockQuantity === void 0 || bundleStockQuantity === null)
67
+ continue;
86
68
  const existingBundleQuantity = currentCartItems.reduce((total, cartItem) => {
87
- // 检查购物车中商品的套餐配置
88
- if (!cartItem._bundleOrigin || !Array.isArray(cartItem._bundleOrigin)) return total;
89
- cartItem._bundleOrigin.forEach(cartBundleItem => {
69
+ if (!cartItem._bundleOrigin || !Array.isArray(cartItem._bundleOrigin))
70
+ return total;
71
+ cartItem._bundleOrigin.forEach((cartBundleItem) => {
90
72
  if (cartBundleItem.bundle_product_id === bundleProductId) {
91
73
  total += (cartBundleItem.num || 1) * (cartItem.num || 1);
92
74
  }
@@ -94,17 +76,14 @@ function checkProductStock({
94
76
  return total;
95
77
  }, 0);
96
78
  const totalBundleQuantity = existingBundleQuantity + bundleRequiredQuantity;
97
-
98
- // 检查子商品库存是否足够
99
79
  if (totalBundleQuantity > bundleStockQuantity) {
100
- return {
101
- success: false,
102
- errorCode: 'not_enough_stock'
103
- };
80
+ return { success: false, errorCode: "not_enough_stock" };
104
81
  }
105
82
  }
106
83
  }
107
- return {
108
- success: true
109
- };
110
- }
84
+ return { success: true };
85
+ }
86
+ // Annotate the CommonJS export names for ESM import in node:
87
+ 0 && (module.exports = {
88
+ checkProductStock
89
+ });
@@ -1,85 +1,79 @@
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/timeslots.ts
30
+ var timeslots_exports = {};
31
+ __export(timeslots_exports, {
32
+ calculateResourceAvailableTime: () => calculateResourceAvailableTime,
33
+ filterConditionTimeSlots: () => filterConditionTimeSlots,
34
+ findFastestAvailableResource: () => findFastestAvailableResource
5
35
  });
6
- exports.calculateResourceAvailableTime = calculateResourceAvailableTime;
7
- exports.filterConditionTimeSlots = filterConditionTimeSlots;
8
- exports.findFastestAvailableResource = findFastestAvailableResource;
9
- var _dayjs = _interopRequireDefault(require("dayjs"));
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- /**
12
- * 计算资源在指定时间段内的总可用时间(以分钟为单位)
13
- * @param resource 需要计算可用时间的资源
14
- * @param timeSlots 要检查可用性的时间段
15
- * @param currentCapacity 当前预约所需的容量
16
- * @returns 总可用时间(分钟)
17
- */
36
+ module.exports = __toCommonJS(timeslots_exports);
37
+ var import_dayjs = __toESM(require("dayjs"));
18
38
  function calculateResourceAvailableTime({
19
39
  resource,
20
40
  timeSlots,
21
41
  currentCapacity = 1
22
42
  }) {
23
- // 过滤出与给定日期相同的资源时间
24
- const matchingTimes = resource.times.filter(time => {
25
- return (0, _dayjs.default)(time.start_at).isSame((0, _dayjs.default)(timeSlots.start_at), 'day');
43
+ const matchingTimes = resource.times.filter((time) => {
44
+ return (0, import_dayjs.default)(time.start_at).isSame((0, import_dayjs.default)(timeSlots.start_at), "day");
26
45
  });
27
- if (matchingTimes.length === 0) return 0;
28
-
29
- // 计算所有时间段与目标时间槽的重叠部分
46
+ if (matchingTimes.length === 0)
47
+ return 0;
30
48
  const overlaps = [];
31
49
  for (const time of matchingTimes) {
32
- // 计算实际重叠的时间段
33
- const overlapStart = (0, _dayjs.default)(time.start_at).isAfter((0, _dayjs.default)(timeSlots.start_at)) ? (0, _dayjs.default)(time.start_at) : (0, _dayjs.default)(timeSlots.start_at);
34
- const overlapEnd = (0, _dayjs.default)(time.end_at).isBefore((0, _dayjs.default)(timeSlots.end_at)) ? (0, _dayjs.default)(time.end_at) : (0, _dayjs.default)(timeSlots.end_at);
35
-
36
- // 只有当重叠时间段有效时才添加
50
+ const overlapStart = (0, import_dayjs.default)(time.start_at).isAfter((0, import_dayjs.default)(timeSlots.start_at)) ? (0, import_dayjs.default)(time.start_at) : (0, import_dayjs.default)(timeSlots.start_at);
51
+ const overlapEnd = (0, import_dayjs.default)(time.end_at).isBefore((0, import_dayjs.default)(timeSlots.end_at)) ? (0, import_dayjs.default)(time.end_at) : (0, import_dayjs.default)(timeSlots.end_at);
37
52
  if (overlapStart.isBefore(overlapEnd)) {
38
- overlaps.push({
39
- start: overlapStart,
40
- end: overlapEnd
41
- });
53
+ overlaps.push({ start: overlapStart, end: overlapEnd });
42
54
  }
43
55
  }
44
-
45
- // 合并重叠的时间段,计算并集
46
- if (overlaps.length === 0) return 0;
47
-
48
- // 按开始时间排序
56
+ if (overlaps.length === 0)
57
+ return 0;
49
58
  overlaps.sort((a, b) => a.start.diff(b.start));
50
-
51
- // 合并重叠的时间段
52
59
  const merged = [];
53
60
  let current = overlaps[0];
54
61
  for (let i = 1; i < overlaps.length; i++) {
55
62
  const next = overlaps[i];
56
-
57
- // 如果当前时间段与下一个时间段重叠或相邻,则合并
58
63
  if (current.end.isSameOrAfter(next.start)) {
59
64
  current.end = current.end.isAfter(next.end) ? current.end : next.end;
60
65
  } else {
61
- // 不重叠,添加当前时间段到结果中,开始处理下一个
62
66
  merged.push(current);
63
67
  current = next;
64
68
  }
65
69
  }
66
70
  merged.push(current);
67
-
68
- // 计算所有合并后时间段的总时长
69
71
  let totalAvailableMinutes = 0;
70
72
  for (const segment of merged) {
71
- totalAvailableMinutes += segment.end.diff(segment.start, 'minute');
73
+ totalAvailableMinutes += segment.end.diff(segment.start, "minute");
72
74
  }
73
75
  return totalAvailableMinutes;
74
76
  }
75
-
76
- /**
77
- * 查找最快可用的资源,如果有多个资源在相同时间点可用,则选择空闲时间最长的资源
78
- * @param resources 资源列表
79
- * @param currentCapacity 当前预约所需的容量
80
- * @param countMap 已预约数量映射
81
- * @returns 最快可用的资源
82
- */
83
77
  function findFastestAvailableResource({
84
78
  resources,
85
79
  currentCapacity = 1,
@@ -87,140 +81,148 @@ function findFastestAvailableResource({
87
81
  targetDate,
88
82
  durationMinutes = 30
89
83
  }) {
90
- const currentTime = (0, _dayjs.default)();
84
+ var _a, _b, _c;
85
+ const currentTime = (0, import_dayjs.default)();
91
86
  const resolvedDuration = durationMinutes > 0 ? durationMinutes : 30;
92
- const targetDay = targetDate ? (0, _dayjs.default)(targetDate) : currentTime;
93
- const isTargetDayToday = targetDay.isSame(currentTime, 'day');
87
+ const targetDay = targetDate ? (0, import_dayjs.default)(targetDate) : currentTime;
88
+ const isTargetDayToday = targetDay.isSame(currentTime, "day");
94
89
  let fastestTime = null;
95
90
  let fastestResources = [];
96
- // 遍历所有资源,找到最快可用的时间点
91
+ console.log("[TimeslotUtils] 查找最快可用资源:", {
92
+ currentTime: currentTime.format("YYYY-MM-DD HH:mm:ss"),
93
+ resourceCount: resources.length,
94
+ currentCapacity,
95
+ countMap
96
+ });
97
97
  for (const resource of resources) {
98
- // 获取资源在目标日期且还在工作时间内的时间段
99
- const targetDayTimes = resource.times.filter(time => {
100
- const isSameTargetDay = (0, _dayjs.default)(time.start_at).isSame(targetDay, 'day');
101
- if (!isSameTargetDay) return false;
102
- if (!isTargetDayToday) return true;
103
- return (0, _dayjs.default)(time.end_at).isAfter(currentTime);
98
+ const targetDayTimes = resource.times.filter((time) => {
99
+ const isSameTargetDay = (0, import_dayjs.default)(time.start_at).isSame(targetDay, "day");
100
+ if (!isSameTargetDay)
101
+ return false;
102
+ if (!isTargetDayToday)
103
+ return true;
104
+ return (0, import_dayjs.default)(time.end_at).isAfter(currentTime);
104
105
  });
105
106
  if (targetDayTimes.length === 0) {
107
+ console.log(`[TimeslotUtils] 资源 ${resource.id}(${resource.main_field}) 今日无可用时间段`);
106
108
  continue;
107
109
  }
108
110
  for (const time of targetDayTimes) {
109
- const workStartTime = (0, _dayjs.default)(time.start_at);
110
- const workEndTime = (0, _dayjs.default)(time.end_at);
111
-
112
- // 确定检查的起始时间(当前时间 vs 工作开始时间)
111
+ const workStartTime = (0, import_dayjs.default)(time.start_at);
112
+ const workEndTime = (0, import_dayjs.default)(time.end_at);
113
113
  let nextAvailableTime = isTargetDayToday && currentTime.isAfter(workStartTime) ? currentTime : workStartTime;
114
- // 获取所有影响的预约事件(当前时间之后的)
115
- const relevantEvents = time.event_list?.filter(event => {
116
- const eventEnd = (0, _dayjs.default)(event.end_at);
114
+ console.log(`[TimeslotUtils] 检查资源 ${resource.id}(${resource.main_field}):`, {
115
+ workTime: `${workStartTime.format("HH:mm")}-${workEndTime.format("HH:mm")}`,
116
+ checkStartTime: nextAvailableTime.format("HH:mm:ss"),
117
+ eventCount: ((_a = time.event_list) == null ? void 0 : _a.length) || 0
118
+ });
119
+ const relevantEvents = ((_b = time.event_list) == null ? void 0 : _b.filter((event) => {
120
+ const eventEnd = (0, import_dayjs.default)(event.end_at);
117
121
  return eventEnd.isAfter(nextAvailableTime);
118
- }) || [];
119
-
120
- // 按开始时间排序
121
- relevantEvents.sort((a, b) => (0, _dayjs.default)(a.start_at).diff((0, _dayjs.default)(b.start_at)));
122
-
123
- // 检查从 nextAvailableTime 开始的可用性
122
+ })) || [];
123
+ relevantEvents.sort(
124
+ (a, b) => (0, import_dayjs.default)(a.start_at).diff((0, import_dayjs.default)(b.start_at))
125
+ );
124
126
  let finalAvailableTime = nextAvailableTime;
125
127
  for (const event of relevantEvents) {
126
- const eventStart = (0, _dayjs.default)(event.start_at);
127
- const eventEnd = (0, _dayjs.default)(event.end_at);
128
- // 检查资源类型和容量
129
- if (resource.resourceType === 'single' || (resource.capacity || 1) === 1) {
130
- // 单人预约资源:检查时间冲突
131
- if (finalAvailableTime.isBefore(eventEnd) && eventStart.isBefore(finalAvailableTime.add(resolvedDuration, 'minute'))) {
132
- // 有冲突,使用事件结束时间
128
+ const eventStart = (0, import_dayjs.default)(event.start_at);
129
+ const eventEnd = (0, import_dayjs.default)(event.end_at);
130
+ console.log(`[TimeslotUtils] 检查事件冲突:`, {
131
+ resourceId: resource.id,
132
+ eventTime: `${eventStart.format("HH:mm")}-${eventEnd.format("HH:mm")}`,
133
+ checkTime: finalAvailableTime.format("HH:mm:ss"),
134
+ pax: event.pax || 1
135
+ });
136
+ if (resource.resourceType === "single" || (resource.capacity || 1) === 1) {
137
+ if (finalAvailableTime.isBefore(eventEnd) && eventStart.isBefore(finalAvailableTime.add(resolvedDuration, "minute"))) {
133
138
  finalAvailableTime = eventEnd;
139
+ console.log(`[TimeslotUtils] 发现时间冲突,调整到: ${finalAvailableTime.format("HH:mm:ss")}`);
134
140
  }
135
141
  } else {
136
- // 多人预约资源:检查容量
137
142
  const totalCapacity = resource.capacity || 0;
138
143
  const currentUsedCapacity = countMap[resource.id] || 0;
139
144
  const eventUsedCapacity = event.pax || 1;
140
-
141
- // 如果在事件时间范围内,检查容量是否足够
142
- if (finalAvailableTime.isBefore(eventEnd) && eventStart.isBefore(finalAvailableTime.add(resolvedDuration, 'minute'))) {
145
+ if (finalAvailableTime.isBefore(eventEnd) && eventStart.isBefore(finalAvailableTime.add(resolvedDuration, "minute"))) {
143
146
  const totalRequiredCapacity = currentUsedCapacity + currentCapacity + eventUsedCapacity;
144
147
  if (totalRequiredCapacity > totalCapacity) {
145
- // 容量不足,使用事件结束时间
146
148
  finalAvailableTime = eventEnd;
149
+ console.log(`[TimeslotUtils] 容量不足,调整到: ${finalAvailableTime.format("HH:mm:ss")}`);
147
150
  }
148
151
  }
149
152
  }
150
153
  }
151
-
152
- // 确保可用时间在工作时间内
153
- if (finalAvailableTime.add(resolvedDuration, 'minute').isAfter(workEndTime)) {
154
+ if (finalAvailableTime.add(resolvedDuration, "minute").isAfter(workEndTime)) {
155
+ console.log(`[TimeslotUtils] 资源 ${resource.id} 可用时间超出工作时间,跳过`);
154
156
  continue;
155
157
  }
156
- // 更新最快可用时间和资源
158
+ console.log(`[TimeslotUtils] 资源 ${resource.id}(${resource.main_field}) 最快可用时间: ${finalAvailableTime.format("HH:mm:ss")}`);
157
159
  if (!fastestTime || finalAvailableTime.isBefore(fastestTime)) {
158
160
  fastestTime = finalAvailableTime;
159
161
  fastestResources = [resource];
162
+ console.log(`[TimeslotUtils] 更新最快时间: ${fastestTime.format("HH:mm:ss")}, 资源: ${resource.main_field}`);
160
163
  } else if (finalAvailableTime.isSame(fastestTime)) {
161
164
  fastestResources.push(resource);
165
+ console.log(`[TimeslotUtils] 添加相同时间资源: ${resource.main_field}`);
162
166
  }
163
- break; // 每个资源只需要计算一次
167
+ break;
164
168
  }
165
169
  }
166
-
167
- // 如果没有找到可用资源,返回null
168
170
  if (!fastestTime || fastestResources.length === 0) {
171
+ console.log("[TimeslotUtils] 未找到可用资源");
169
172
  return null;
170
173
  }
171
- // 如果只有一个最快可用的资源,直接返回
174
+ console.log(`[TimeslotUtils] 找到 ${fastestResources.length} 个最快可用资源,时间: ${fastestTime.format("HH:mm:ss")}`);
172
175
  if (fastestResources.length === 1) {
176
+ console.log(`[TimeslotUtils] 返回唯一最快资源: ${fastestResources[0].main_field}`);
173
177
  return fastestResources[0];
174
178
  }
175
-
176
- // 如果有多个最快可用的资源,选择空闲时间最长的资源
177
179
  let selectedResource = fastestResources[0];
178
180
  let maxIdleTime = 0;
181
+ console.log(`[TimeslotUtils] 比较 ${fastestResources.length} 个资源的空闲时间:`);
179
182
  for (const resource of fastestResources) {
180
- // 找到该资源当天且还在工作的时间段
181
- const workingTime = resource.times.find(time => {
182
- const isToday = (0, _dayjs.default)(time.start_at).isSame(fastestTime, 'day');
183
- const isStillWorking = (0, _dayjs.default)(time.end_at).isAfter(fastestTime);
183
+ const workingTime = resource.times.find((time) => {
184
+ const isToday = (0, import_dayjs.default)(time.start_at).isSame(fastestTime, "day");
185
+ const isStillWorking = (0, import_dayjs.default)(time.end_at).isAfter(fastestTime);
184
186
  return isToday && isStillWorking;
185
187
  });
186
- if (!workingTime) continue;
187
- const workEndTime = (0, _dayjs.default)(workingTime.end_at);
188
-
189
- // 计算从最快可用时间到工作结束时间的空闲时长(分钟)
190
- let totalIdleTime = workEndTime.diff(fastestTime, 'minute');
191
-
192
- // 减去已有预约占用的时间
193
- const relevantEvents = workingTime.event_list?.filter(event => {
194
- const eventStart = (0, _dayjs.default)(event.start_at);
195
- const eventEnd = (0, _dayjs.default)(event.end_at);
196
- // 只计算在最快可用时间之后的预约
188
+ if (!workingTime)
189
+ continue;
190
+ const workEndTime = (0, import_dayjs.default)(workingTime.end_at);
191
+ let totalIdleTime = workEndTime.diff(fastestTime, "minute");
192
+ const relevantEvents = ((_c = workingTime.event_list) == null ? void 0 : _c.filter((event) => {
193
+ const eventStart = (0, import_dayjs.default)(event.start_at);
194
+ const eventEnd = (0, import_dayjs.default)(event.end_at);
197
195
  return eventEnd.isAfter(fastestTime) && eventStart.isAfter(fastestTime);
198
- }) || [];
196
+ })) || [];
199
197
  for (const event of relevantEvents) {
200
- const eventStart = (0, _dayjs.default)(event.start_at);
201
- const eventEnd = (0, _dayjs.default)(event.end_at);
202
- const eventDuration = eventEnd.diff(eventStart, 'minute');
198
+ const eventStart = (0, import_dayjs.default)(event.start_at);
199
+ const eventEnd = (0, import_dayjs.default)(event.end_at);
200
+ const eventDuration = eventEnd.diff(eventStart, "minute");
203
201
  totalIdleTime -= eventDuration;
204
202
  }
203
+ console.log(`[TimeslotUtils] 资源 ${resource.id}(${resource.main_field}):`, {
204
+ 工作结束时间: workEndTime.format("HH:mm"),
205
+ 总工作时长: workEndTime.diff(fastestTime, "minute") + "分钟",
206
+ 预约占用时长: workEndTime.diff(fastestTime, "minute") - totalIdleTime + "分钟",
207
+ 实际空闲时长: totalIdleTime + "分钟"
208
+ });
205
209
  if (totalIdleTime > maxIdleTime) {
206
210
  maxIdleTime = totalIdleTime;
207
211
  selectedResource = resource;
212
+ console.log(`[TimeslotUtils] 更新最佳选择: ${resource.main_field} (空闲${totalIdleTime}分钟)`);
208
213
  }
209
214
  }
215
+ console.log(`[TimeslotUtils] 最终选择资源: ${selectedResource.main_field} (最长空闲${maxIdleTime}分钟)`);
210
216
  return selectedResource;
211
217
  }
212
-
213
- /**
214
- * 给定一个时间列表,通过开始和结束时间过滤出符合条件的时间段
215
- *
216
- * @export
217
- * @param {TimeSliceItem[]} times
218
- * @param {Dayjs} startTime
219
- * @param {Dayjs} endTime
220
- * @return {*}
221
- */
222
218
  function filterConditionTimeSlots(times, startTime, endTime) {
223
- return times.filter(n => {
224
- return !(0, _dayjs.default)(n.start_at).isAfter((0, _dayjs.default)(startTime)) && !(0, _dayjs.default)(n.end_at).isBefore((0, _dayjs.default)(endTime));
219
+ return times.filter((n) => {
220
+ return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(startTime)) && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(endTime));
225
221
  });
226
- }
222
+ }
223
+ // Annotate the CommonJS export names for ESM import in node:
224
+ 0 && (module.exports = {
225
+ calculateResourceAvailableTime,
226
+ filterConditionTimeSlots,
227
+ findFastestAvailableResource
228
+ });
@@ -322,7 +322,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
322
322
  * 获取当前的客户搜索条件
323
323
  * @returns 当前搜索条件
324
324
  */
325
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
325
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
326
326
  /**
327
327
  * 获取客户列表状态(包含滚动加载相关状态)
328
328
  * @returns 客户状态