@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.
- package/dist/core/index.js +10 -6
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -3
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +7 -5
- package/dist/model/strategy/adapter/walletPass/example.js +26 -3
- package/dist/model/strategy/adapter/walletPass/index.js +5 -5
- package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -3
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -26
- package/dist/model/strategy/adapter/walletPass/utils.js +17 -92
- package/dist/model/strategy/strategy-example.js +19 -5
- package/dist/modules/BaseModule.d.ts +1 -1
- package/dist/modules/BaseModule.js +8 -10
- package/dist/modules/Cart/index.js +3 -0
- package/dist/modules/Cart/utils/cartProduct.js +1 -0
- package/dist/modules/Cart/utils/cartResource.js +0 -2
- package/dist/modules/Cart/utils/changePrice.js +9 -16
- package/dist/modules/Date/index.js +5 -1
- package/dist/modules/Discount/index.d.ts +0 -1
- package/dist/modules/Discount/index.js +7 -22
- package/dist/modules/Discount/types.d.ts +0 -1
- package/dist/modules/OpenData/index.js +2 -0
- package/dist/modules/Order/index.js +70 -40
- package/dist/modules/Payment/index.js +162 -97
- package/dist/modules/Payment/types.d.ts +4 -8
- package/dist/modules/Payment/walletpass.d.ts +0 -2
- package/dist/modules/Payment/walletpass.js +5 -4
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +3 -12
- package/dist/modules/ProductList/types.d.ts +0 -1
- package/dist/modules/Rules/index.js +126 -427
- package/dist/modules/SalesSummary/utils.js +1 -2
- package/dist/modules/Schedule/getDateIsInSchedule.js +0 -5
- package/dist/modules/Schedule/index.js +1 -0
- package/dist/modules/Schedule/utils.js +1 -0
- package/dist/modules/Step/index.js +1 -0
- package/dist/modules/Summary/utils.js +22 -43
- package/dist/plugins/request.js +4 -1
- package/dist/plugins/window.js +6 -2
- package/dist/server/index.js +129 -97
- package/dist/server/modules/menu/index.js +41 -32
- package/dist/server/modules/order/index.js +4 -2
- package/dist/server/modules/products/index.js +42 -24
- package/dist/server/modules/quotation/index.js +38 -29
- package/dist/server/modules/resource/index.js +4 -3
- package/dist/server/modules/schedule/index.js +35 -27
- package/dist/server/utils/product.js +1 -0
- package/dist/solution/BaseSales/index.js +41 -38
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +60 -11
- package/dist/solution/BookingByStep/utils/capacity.js +11 -1
- package/dist/solution/BookingByStep/utils/resources.js +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +43 -2
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +2 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +7 -6
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +31 -25
- package/dist/solution/BookingTicket/utils/scan/index.js +10 -6
- package/dist/solution/BuyTickets/index.js +12 -9
- package/dist/solution/Checkout/index.js +252 -177
- package/dist/solution/Checkout/utils/index.js +16 -4
- package/dist/solution/RegisterAndLogin/index.js +76 -30
- package/dist/solution/ScanOrder/index.js +60 -50
- package/dist/solution/ShopDiscount/index.js +14 -15
- package/dist/solution/ShopDiscount/types.d.ts +4 -5
- package/dist/solution/ShopDiscount/utils.d.ts +0 -9
- package/dist/solution/ShopDiscount/utils.js +0 -9
- package/dist/solution/VenueBooking/index.d.ts +3 -31
- package/dist/solution/VenueBooking/index.js +496 -651
- package/dist/solution/VenueBooking/types.d.ts +1 -3
- package/dist/solution/VenueBooking/types.js +0 -1
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/dist/solution/VenueBooking/utils/dateSummary.js +25 -12
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/dist/solution/VenueBooking/utils/timeSlot.js +4 -9
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/task.js +18 -15
- package/dist/utils/watch.js +1 -0
- package/lib/apis/picoding.js +0 -2
- package/lib/core/index.js +132 -130
- package/lib/effects/index.js +57 -46
- package/lib/index.d.ts +0 -1
- package/lib/index.js +50 -92
- package/lib/model/index.js +21 -14
- package/lib/model/strategy/adapter/dataVariant/adapter.js +50 -38
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +236 -162
- package/lib/model/strategy/adapter/dataVariant/examples.js +237 -229
- package/lib/model/strategy/adapter/dataVariant/index.js +34 -39
- package/lib/model/strategy/adapter/dataVariant/type.js +28 -57
- package/lib/model/strategy/adapter/index.js +64 -100
- package/lib/model/strategy/adapter/itemRule/adapter.js +144 -156
- package/lib/model/strategy/adapter/itemRule/evaluator.js +48 -36
- package/lib/model/strategy/adapter/itemRule/examples.js +225 -295
- package/lib/model/strategy/adapter/itemRule/index.js +57 -83
- package/lib/model/strategy/adapter/itemRule/type.js +36 -97
- package/lib/model/strategy/adapter/promotion/adapter.js +63 -84
- package/lib/model/strategy/adapter/promotion/evaluator.js +231 -381
- package/lib/model/strategy/adapter/promotion/examples.js +159 -139
- package/lib/model/strategy/adapter/promotion/index.js +49 -1
- package/lib/model/strategy/adapter/promotion/type.js +35 -199
- package/lib/model/strategy/adapter/type.js +16 -4
- package/lib/model/strategy/adapter/walletPass/evaluator.js +152 -180
- package/lib/model/strategy/adapter/walletPass/example.js +190 -217
- package/lib/model/strategy/adapter/walletPass/index.js +51 -75
- package/lib/model/strategy/adapter/walletPass/locales.js +58 -36
- package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -3
- package/lib/model/strategy/adapter/walletPass/type.js +16 -4
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -26
- package/lib/model/strategy/adapter/walletPass/utils.js +383 -678
- package/lib/model/strategy/engine.js +168 -270
- package/lib/model/strategy/index.js +34 -49
- package/lib/model/strategy/strategy-example.js +239 -243
- package/lib/model/strategy/type.js +40 -100
- package/lib/modules/Account/index.js +53 -39
- package/lib/modules/Account/types.js +33 -20
- package/lib/modules/AccountList/index.js +154 -116
- package/lib/modules/AccountList/types.js +31 -30
- package/lib/modules/AccountList/utils.js +30 -18
- package/lib/modules/BaseModule.d.ts +1 -1
- package/lib/modules/BaseModule.js +46 -25
- package/lib/modules/BookingContext/index.js +136 -158
- package/lib/modules/BookingContext/types.js +32 -46
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +143 -131
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +82 -75
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +150 -170
- package/lib/modules/BookingContext/utils/flexible.js +55 -38
- package/lib/modules/BookingContext/utils/formatResourceList.js +34 -19
- package/lib/modules/BookingContext/utils/index.js +41 -124
- package/lib/modules/BookingContext/utils/noResource.js +70 -58
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +41 -14
- package/lib/modules/BookingContext/utils/productExtend.js +155 -202
- package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
- package/lib/modules/BookingContext/utils/resourceSelection.js +41 -19
- package/lib/modules/BookingContext/utils/resources.js +167 -209
- package/lib/modules/BookingContext/utils/serviceTimes.js +116 -115
- package/lib/modules/BookingContext/utils/timeSlices.js +80 -70
- package/lib/modules/Cart/index.js +124 -170
- package/lib/modules/Cart/types.js +51 -46
- package/lib/modules/Cart/utils/cartAccount.js +39 -40
- package/lib/modules/Cart/utils/cartDate.js +61 -56
- package/lib/modules/Cart/utils/cartDiscount.js +33 -28
- package/lib/modules/Cart/utils/cartNote.js +32 -27
- package/lib/modules/Cart/utils/cartProduct.js +251 -321
- package/lib/modules/Cart/utils/cartRelationForms.js +35 -29
- package/lib/modules/Cart/utils/cartResource.js +78 -72
- package/lib/modules/Cart/utils/changePrice.js +50 -28
- package/lib/modules/Cart/utils/index.js +48 -106
- package/lib/modules/Customer/constants.js +34 -13
- package/lib/modules/Customer/index.js +169 -232
- package/lib/modules/Customer/types.js +35 -38
- package/lib/modules/Date/index.js +115 -116
- package/lib/modules/Date/types.js +28 -16
- package/lib/modules/Date/utils.js +123 -174
- package/lib/modules/Discount/index.d.ts +0 -1
- package/lib/modules/Discount/index.js +128 -130
- package/lib/modules/Discount/types.d.ts +0 -1
- package/lib/modules/Discount/types.js +31 -9
- package/lib/modules/Guests/index.js +56 -30
- package/lib/modules/Guests/types.js +33 -23
- package/lib/modules/Holder/index.js +189 -209
- package/lib/modules/Holder/types.js +16 -4
- package/lib/modules/Holder/utils.js +49 -20
- package/lib/modules/OpenData/index.js +76 -69
- package/lib/modules/OpenData/types.js +16 -4
- package/lib/modules/OpenData/utils.js +78 -44
- package/lib/modules/Order/index.js +1909 -1572
- package/lib/modules/Order/types.js +35 -78
- package/lib/modules/Order/utils/bundleDiscountHydration.js +74 -41
- package/lib/modules/Order/utils/manualProductDiscount.js +123 -124
- package/lib/modules/Order/utils/orderCollectionIdentity.js +210 -148
- package/lib/modules/Order/utils.js +634 -799
- package/lib/modules/Payment/cash.js +33 -20
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +76 -145
- package/lib/modules/Payment/eftpos.js +30 -16
- package/lib/modules/Payment/index.js +378 -518
- package/lib/modules/Payment/mx51.js +0 -1
- package/lib/modules/Payment/types.d.ts +4 -8
- package/lib/modules/Payment/types.js +107 -216
- package/lib/modules/Payment/utils.js +48 -51
- package/lib/modules/Payment/walletpass.d.ts +0 -2
- package/lib/modules/Payment/walletpass.js +211 -226
- package/lib/modules/Product/index.js +46 -51
- package/lib/modules/Product/types.js +16 -4
- package/lib/modules/Product/utils.js +33 -32
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +117 -117
- package/lib/modules/ProductList/types.d.ts +0 -1
- package/lib/modules/ProductList/types.js +31 -9
- package/lib/modules/Quotation/index.js +100 -66
- package/lib/modules/Quotation/types.js +16 -4
- package/lib/modules/Resource/index.js +59 -27
- package/lib/modules/Resource/types.js +32 -22
- package/lib/modules/Resource/utils.js +38 -30
- package/lib/modules/ResourcePlanner/index.js +61 -60
- package/lib/modules/ResourcePlanner/planner.js +384 -346
- package/lib/modules/ResourcePlanner/types.js +16 -4
- package/lib/modules/Rules/index.js +903 -1475
- package/lib/modules/Rules/types.js +40 -17
- package/lib/modules/SalesSummary/index.js +90 -85
- package/lib/modules/SalesSummary/types.js +16 -4
- package/lib/modules/SalesSummary/utils.js +427 -351
- package/lib/modules/ScanOrderLogger/index.js +79 -59
- package/lib/modules/ScanOrderLogger/providers/feishu.js +78 -54
- package/lib/modules/ScanOrderLogger/providers/grafana.js +36 -13
- package/lib/modules/ScanOrderLogger/types.js +16 -4
- package/lib/modules/Schedule/getDateIsInSchedule.js +163 -339
- package/lib/modules/Schedule/index.js +114 -100
- package/lib/modules/Schedule/type.js +16 -4
- package/lib/modules/Schedule/types.js +16 -4
- package/lib/modules/Schedule/utils.js +291 -433
- package/lib/modules/Step/index.js +52 -40
- package/lib/modules/Step/tyeps.js +16 -4
- package/lib/modules/Summary/index.js +71 -66
- package/lib/modules/Summary/types.js +16 -4
- package/lib/modules/Summary/utils.js +418 -791
- package/lib/modules/SurchargeList/index.js +60 -46
- package/lib/modules/SurchargeList/types.js +16 -4
- package/lib/modules/index.js +63 -245
- package/lib/plugins/app.js +16 -4
- package/lib/plugins/index.js +25 -36
- package/lib/plugins/request.js +126 -137
- package/lib/plugins/shopStore.js +16 -4
- package/lib/plugins/user.js +16 -4
- package/lib/plugins/window.js +179 -171
- package/lib/server/index.js +2337 -2675
- package/lib/server/modules/floor-plan/index.js +123 -102
- package/lib/server/modules/floor-plan/types.js +30 -15
- package/lib/server/modules/index.js +68 -106
- package/lib/server/modules/menu/index.js +122 -146
- package/lib/server/modules/menu/types.js +31 -18
- package/lib/server/modules/order/index.js +642 -567
- package/lib/server/modules/order/types.js +32 -117
- package/lib/server/modules/order/utils/filterBookings.js +194 -219
- package/lib/server/modules/order/utils/filterOrders.js +92 -118
- package/lib/server/modules/payment/index.js +83 -59
- package/lib/server/modules/payment/types.js +16 -4
- package/lib/server/modules/products/index.js +459 -575
- package/lib/server/modules/products/types.js +34 -44
- package/lib/server/modules/quotation/index.js +172 -137
- package/lib/server/modules/quotation/types.js +31 -21
- package/lib/server/modules/resource/index.js +184 -213
- package/lib/server/modules/resource/types.js +33 -42
- package/lib/server/modules/schedule/index.js +123 -135
- package/lib/server/modules/schedule/types.js +21 -14
- package/lib/server/modules/schedule/utils.js +163 -334
- package/lib/server/types.js +16 -4
- package/lib/server/utils/index.js +23 -25
- package/lib/server/utils/product.js +139 -196
- package/lib/server/utils/schedule.js +41 -34
- package/lib/server/utils/small-ticket.js +456 -478
- package/lib/server/utils/time.js +49 -40
- package/lib/solution/BaseSales/index.js +1016 -850
- package/lib/solution/BaseSales/types.js +37 -41
- package/lib/solution/BaseSales/utils/cartPromotion.js +460 -611
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +105 -85
- package/lib/solution/BaseSales/utils/quotationPrice.js +114 -56
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +143 -102
- package/lib/solution/BaseSales/utils.js +140 -155
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +1340 -1530
- package/lib/solution/BookingByStep/types.js +99 -40
- package/lib/solution/BookingByStep/utils/capacity.js +160 -192
- package/lib/solution/BookingByStep/utils/products.js +52 -42
- package/lib/solution/BookingByStep/utils/resources.js +330 -527
- package/lib/solution/BookingByStep/utils/stock.js +44 -65
- package/lib/solution/BookingByStep/utils/timeslots.js +131 -129
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +459 -543
- package/lib/solution/BookingTicket/types.js +77 -99
- package/lib/solution/BookingTicket/utils/addProductDecision.js +184 -219
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +89 -58
- package/lib/solution/BookingTicket/utils/bookingStatus.js +78 -107
- package/lib/solution/BookingTicket/utils/cartView.js +94 -110
- package/lib/solution/BookingTicket/utils/exampleData.js +0 -185
- package/lib/solution/BookingTicket/utils/orderCustomer.js +41 -18
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +86 -219
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +93 -144
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +91 -79
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +41 -54
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +81 -84
- package/lib/solution/BookingTicket/utils/scan/index.js +104 -98
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +43 -90
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +64 -52
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +58 -56
- package/lib/solution/BuyTickets/index.js +70 -67
- package/lib/solution/BuyTickets/types.js +38 -22
- package/lib/solution/Checkout/index.js +1158 -1451
- package/lib/solution/Checkout/types.js +61 -91
- package/lib/solution/Checkout/utils/index.js +156 -228
- package/lib/solution/PlaceOrder/index.js +0 -55
- package/lib/solution/RegisterAndLogin/config.js +460 -493
- package/lib/solution/RegisterAndLogin/index.js +630 -633
- package/lib/solution/RegisterAndLogin/types.js +76 -189
- package/lib/solution/RegisterAndLogin/utils.js +125 -183
- package/lib/solution/Sales/index.js +320 -317
- package/lib/solution/Sales/types.js +33 -27
- package/lib/solution/ScanOrder/index.js +862 -831
- package/lib/solution/ScanOrder/types.js +34 -33
- package/lib/solution/ScanOrder/utils.js +371 -406
- package/lib/solution/ShopDiscount/index.js +233 -235
- package/lib/solution/ShopDiscount/types.d.ts +4 -5
- package/lib/solution/ShopDiscount/types.js +37 -15
- package/lib/solution/ShopDiscount/utils.d.ts +0 -9
- package/lib/solution/ShopDiscount/utils.js +172 -309
- package/lib/solution/UnifiedBookingSales/index.js +405 -379
- package/lib/solution/UnifiedBookingSales/types.js +31 -12
- package/lib/solution/VenueBooking/index.d.ts +3 -31
- package/lib/solution/VenueBooking/index.js +916 -967
- package/lib/solution/VenueBooking/types.d.ts +1 -3
- package/lib/solution/VenueBooking/types.js +39 -20
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/lib/solution/VenueBooking/utils/dateSummary.js +62 -25
- package/lib/solution/VenueBooking/utils/resource.js +54 -31
- package/lib/solution/VenueBooking/utils/slotMerge.js +107 -94
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/lib/solution/VenueBooking/utils/timeSlot.js +133 -138
- package/lib/solution/VenueBooking/utils.js +67 -130
- package/lib/solution/index.js +41 -124
- package/lib/store/createStore.js +29 -32
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.js +16 -4
- package/lib/utils/task.js +36 -36
- package/lib/utils/watch.js +47 -81
- package/package.json +2 -4
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/lib/solution/VenueBooking/utils/smartPricing.js +0 -192
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
4
|
-
|
|
19
|
+
// src/solution/BookingByStep/utils/stock.ts
|
|
20
|
+
var stock_exports = {};
|
|
21
|
+
__export(stock_exports, {
|
|
22
|
+
checkProductStock: () => checkProductStock
|
|
5
23
|
});
|
|
6
|
-
exports
|
|
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
|
-
|
|
48
|
-
const isSameProduct = cartItem._productOrigin
|
|
49
|
-
const isSameVariant = !product_variant_id && !cartItem._productOrigin
|
|
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 (
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
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
|
|
7
|
-
|
|
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
|
-
|
|
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)
|
|
28
|
-
|
|
29
|
-
// 计算所有时间段与目标时间槽的重叠部分
|
|
46
|
+
if (matchingTimes.length === 0)
|
|
47
|
+
return 0;
|
|
30
48
|
const overlaps = [];
|
|
31
49
|
for (const time of matchingTimes) {
|
|
32
|
-
|
|
33
|
-
const
|
|
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,
|
|
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
|
-
|
|
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,
|
|
93
|
-
const isTargetDayToday = targetDay.isSame(currentTime,
|
|
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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (!isTargetDayToday)
|
|
103
|
-
|
|
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,
|
|
110
|
-
const workEndTime = (0,
|
|
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
|
-
|
|
116
|
-
|
|
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
|
-
|
|
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,
|
|
127
|
-
const eventEnd = (0,
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
182
|
-
const
|
|
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)
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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,
|
|
201
|
-
const eventEnd = (0,
|
|
202
|
-
const eventDuration = eventEnd.diff(eventStart,
|
|
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,
|
|
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, "
|
|
325
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
326
326
|
/**
|
|
327
327
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
328
328
|
* @returns 客户状态
|