@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,22 +1,47 @@
|
|
|
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/server/modules/schedule/utils.ts
|
|
30
|
+
var utils_exports = {};
|
|
31
|
+
__export(utils_exports, {
|
|
32
|
+
getDateIsInSchedule: () => getDateIsInSchedule,
|
|
33
|
+
getScheduleStartEndTimePoints: () => getScheduleStartEndTimePoints
|
|
5
34
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
// 获取时间是否在日程范围内
|
|
10
|
-
const getDateIsInSchedule = (dateTime, scheduleList) => {
|
|
35
|
+
module.exports = __toCommonJS(utils_exports);
|
|
36
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
37
|
+
var getDateIsInSchedule = (dateTime, scheduleList) => {
|
|
11
38
|
if (!dateTime || !scheduleList || scheduleList.length === 0) {
|
|
12
39
|
return false;
|
|
13
40
|
}
|
|
14
|
-
const targetDate = (0,
|
|
41
|
+
const targetDate = (0, import_dayjs.default)(dateTime);
|
|
15
42
|
if (!targetDate.isValid()) {
|
|
16
43
|
return false;
|
|
17
44
|
}
|
|
18
|
-
|
|
19
|
-
// 遍历所有日程项
|
|
20
45
|
for (const schedule of scheduleList) {
|
|
21
46
|
if (isTimeInScheduleItem(dateTime, schedule)) {
|
|
22
47
|
return true;
|
|
@@ -24,270 +49,175 @@ const getDateIsInSchedule = (dateTime, scheduleList) => {
|
|
|
24
49
|
}
|
|
25
50
|
return false;
|
|
26
51
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
const targetDate = (0, _dayjs.default)(dateTime);
|
|
32
|
-
const targetDateString = dateTime.split(' ')[0]; // YYYY-MM-DD
|
|
33
|
-
const targetTimeString = dateTime.split(' ')[1] || '00:00:00'; // HH:mm:ss
|
|
34
|
-
|
|
52
|
+
var isTimeInScheduleItem = (dateTime, schedule) => {
|
|
53
|
+
const targetDate = (0, import_dayjs.default)(dateTime);
|
|
54
|
+
const targetDateString = dateTime.split(" ")[0];
|
|
55
|
+
const targetTimeString = dateTime.split(" ")[1] || "00:00:00";
|
|
35
56
|
switch (schedule.type) {
|
|
36
|
-
case
|
|
57
|
+
case "standard":
|
|
37
58
|
return isInStandardSchedule(targetDate, targetDateString, targetTimeString, schedule);
|
|
38
|
-
case
|
|
59
|
+
case "time-slots":
|
|
39
60
|
return isInTimeSlotsSchedule(targetDate, targetDateString, targetTimeString, schedule);
|
|
40
|
-
case
|
|
61
|
+
case "designation":
|
|
41
62
|
return isInDesignationSchedule(targetDate, targetDateString, targetTimeString, schedule);
|
|
42
63
|
default:
|
|
43
64
|
return false;
|
|
44
65
|
}
|
|
45
66
|
};
|
|
46
|
-
|
|
47
|
-
// 处理标准类型日程
|
|
48
|
-
const isInStandardSchedule = (targetDate, targetDateString, targetTimeString, schedule) => {
|
|
67
|
+
var isInStandardSchedule = (targetDate, targetDateString, targetTimeString, schedule) => {
|
|
49
68
|
if (!schedule.start_time || !schedule.end_time) {
|
|
50
69
|
return false;
|
|
51
70
|
}
|
|
52
|
-
const startDate = (0,
|
|
53
|
-
const endDate = (0,
|
|
54
|
-
|
|
55
|
-
// 先检查是否在基础时间范围内(不考虑重复)
|
|
71
|
+
const startDate = (0, import_dayjs.default)(schedule.start_time);
|
|
72
|
+
const endDate = (0, import_dayjs.default)(schedule.end_time);
|
|
56
73
|
const isInBasicRange = targetDate.isSameOrAfter(startDate) && targetDate.isSameOrBefore(endDate);
|
|
57
|
-
if (schedule.repeat_type ===
|
|
74
|
+
if (schedule.repeat_type === "none") {
|
|
58
75
|
return isInBasicRange;
|
|
59
76
|
}
|
|
60
|
-
|
|
61
|
-
// 处理重复日程
|
|
62
77
|
return isInRepeatingSchedule(targetDate, targetDateString, targetTimeString, schedule, startDate, endDate);
|
|
63
78
|
};
|
|
64
|
-
|
|
65
|
-
// 处理时间段类型日程
|
|
66
|
-
const isInTimeSlotsSchedule = (targetDate, targetDateString, targetTimeString, schedule) => {
|
|
79
|
+
var isInTimeSlotsSchedule = (targetDate, targetDateString, targetTimeString, schedule) => {
|
|
67
80
|
if (!schedule.start_time) {
|
|
68
81
|
return false;
|
|
69
82
|
}
|
|
70
|
-
const scheduleDate = schedule.start_time.split(
|
|
71
|
-
|
|
72
|
-
// 检查日期是否匹配
|
|
83
|
+
const scheduleDate = schedule.start_time.split(" ")[0];
|
|
73
84
|
if (targetDateString !== scheduleDate) {
|
|
74
85
|
return false;
|
|
75
86
|
}
|
|
76
|
-
|
|
77
|
-
// 检查是否在任一时间段内
|
|
78
87
|
for (const timeSlot of schedule.time_slot) {
|
|
79
88
|
const slotStart = `${scheduleDate} ${timeSlot.start_time}:00`;
|
|
80
89
|
const slotEnd = `${scheduleDate} ${timeSlot.end_time}:00`;
|
|
81
|
-
const slotStartDate = (0,
|
|
82
|
-
const slotEndDate = (0,
|
|
90
|
+
const slotStartDate = (0, import_dayjs.default)(slotStart);
|
|
91
|
+
const slotEndDate = (0, import_dayjs.default)(slotEnd);
|
|
83
92
|
if (targetDate.isSameOrAfter(slotStartDate) && targetDate.isSameOrBefore(slotEndDate)) {
|
|
84
93
|
return true;
|
|
85
94
|
}
|
|
86
95
|
}
|
|
87
96
|
return false;
|
|
88
97
|
};
|
|
89
|
-
|
|
90
|
-
// 处理指定类型日程
|
|
91
|
-
const isInDesignationSchedule = (targetDate, targetDateString, targetTimeString, schedule) => {
|
|
98
|
+
var isInDesignationSchedule = (targetDate, targetDateString, targetTimeString, schedule) => {
|
|
92
99
|
if (!schedule.designation) {
|
|
93
100
|
return false;
|
|
94
101
|
}
|
|
95
|
-
|
|
96
|
-
// @ts-ignore
|
|
97
102
|
for (const designation of schedule.designation) {
|
|
98
103
|
const startDateTime = `${designation.start_date} ${designation.start_time}:00`;
|
|
99
104
|
const endDateTime = `${designation.end_date} ${designation.end_time}:00`;
|
|
100
|
-
const startDate = (0,
|
|
101
|
-
const endDate = (0,
|
|
105
|
+
const startDate = (0, import_dayjs.default)(startDateTime);
|
|
106
|
+
const endDate = (0, import_dayjs.default)(endDateTime);
|
|
102
107
|
if (targetDate.isSameOrAfter(startDate) && targetDate.isSameOrBefore(endDate)) {
|
|
103
108
|
return true;
|
|
104
109
|
}
|
|
105
110
|
}
|
|
106
111
|
return false;
|
|
107
112
|
};
|
|
108
|
-
|
|
109
|
-
// 处理重复日程逻辑
|
|
110
|
-
const isInRepeatingSchedule = (targetDate, targetDateString, targetTimeString, schedule, startDate, endDate) => {
|
|
113
|
+
var isInRepeatingSchedule = (targetDate, targetDateString, targetTimeString, schedule, startDate, endDate) => {
|
|
111
114
|
if (!schedule.repeat_rule) {
|
|
112
115
|
return false;
|
|
113
116
|
}
|
|
114
|
-
const {
|
|
115
|
-
|
|
116
|
-
repeat_type
|
|
117
|
-
} = schedule;
|
|
118
|
-
const targetDateOnly = (0, _dayjs.default)(targetDateString); // 只取日期部分
|
|
119
|
-
|
|
120
|
-
// 首先检查是否在包含日期中(包含日期是额外增加的有效日期)
|
|
117
|
+
const { repeat_rule, repeat_type } = schedule;
|
|
118
|
+
const targetDateOnly = (0, import_dayjs.default)(targetDateString);
|
|
121
119
|
if (repeat_rule.included_date && repeat_rule.included_date.length > 0) {
|
|
122
120
|
for (const includedDate of repeat_rule.included_date) {
|
|
123
|
-
const includeStartDate = (0,
|
|
124
|
-
const includeEndDate = (0,
|
|
125
|
-
if (targetDateOnly.isSameOrAfter(includeStartDate,
|
|
126
|
-
// 在包含日期中,直接返回true,无需检查其他条件
|
|
121
|
+
const includeStartDate = (0, import_dayjs.default)(includedDate.start);
|
|
122
|
+
const includeEndDate = (0, import_dayjs.default)(includedDate.end);
|
|
123
|
+
if (targetDateOnly.isSameOrAfter(includeStartDate, "day") && targetDateOnly.isSameOrBefore(includeEndDate, "day")) {
|
|
127
124
|
return true;
|
|
128
125
|
}
|
|
129
126
|
}
|
|
130
127
|
}
|
|
131
|
-
|
|
132
|
-
// 检查是否在排除日期中
|
|
133
128
|
for (const excludedDate of repeat_rule.excluded_date) {
|
|
134
|
-
const excludeStartDate = (0,
|
|
135
|
-
const excludeEndDate = (0,
|
|
136
|
-
|
|
137
|
-
if (targetDateOnly.isSameOrAfter(excludeStartDate, 'day') && targetDateOnly.isSameOrBefore(excludeEndDate, 'day')) {
|
|
129
|
+
const excludeStartDate = (0, import_dayjs.default)(excludedDate.start);
|
|
130
|
+
const excludeEndDate = (0, import_dayjs.default)(excludedDate.end);
|
|
131
|
+
if (targetDateOnly.isSameOrAfter(excludeStartDate, "day") && targetDateOnly.isSameOrBefore(excludeEndDate, "day")) {
|
|
138
132
|
return false;
|
|
139
133
|
}
|
|
140
134
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (repeat_rule.end.type === 'date' && repeat_rule.end.end_date) {
|
|
144
|
-
const ruleEndDate = (0, _dayjs.default)(repeat_rule.end.end_date);
|
|
135
|
+
if (repeat_rule.end.type === "date" && repeat_rule.end.end_date) {
|
|
136
|
+
const ruleEndDate = (0, import_dayjs.default)(repeat_rule.end.end_date);
|
|
145
137
|
if (targetDate.isAfter(ruleEndDate)) {
|
|
146
138
|
return false;
|
|
147
139
|
}
|
|
148
140
|
}
|
|
149
|
-
|
|
150
|
-
// 根据重复类型检查
|
|
151
141
|
switch (repeat_type) {
|
|
152
|
-
case
|
|
142
|
+
case "daily":
|
|
153
143
|
return isInDailyRepeat(targetDate, startDate, endDate, repeat_rule);
|
|
154
|
-
case
|
|
144
|
+
case "weekly":
|
|
155
145
|
return isInWeeklyRepeat(targetDate, startDate, endDate, repeat_rule);
|
|
156
146
|
default:
|
|
157
147
|
return false;
|
|
158
|
-
// 不支持月和年重复
|
|
159
148
|
}
|
|
160
149
|
};
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const isInDailyRepeat = (targetDate, startDate, endDate, repeatRule) => {
|
|
164
|
-
const daysDiff = targetDate.diff(startDate, 'day');
|
|
150
|
+
var isInDailyRepeat = (targetDate, startDate, endDate, repeatRule) => {
|
|
151
|
+
const daysDiff = targetDate.diff(startDate, "day");
|
|
165
152
|
if (daysDiff < 0) {
|
|
166
153
|
return false;
|
|
167
154
|
}
|
|
168
|
-
|
|
169
|
-
// 检查频率
|
|
170
155
|
if (daysDiff % repeatRule.frequency !== 0) {
|
|
171
156
|
return false;
|
|
172
157
|
}
|
|
173
|
-
|
|
174
|
-
// 检查时间是否在日程的时间范围内
|
|
175
158
|
const targetTimeOfDay = targetDate.hour() * 3600 + targetDate.minute() * 60 + targetDate.second();
|
|
176
159
|
const startTimeOfDay = startDate.hour() * 3600 + startDate.minute() * 60 + startDate.second();
|
|
177
160
|
const endTimeOfDay = endDate.hour() * 3600 + endDate.minute() * 60 + endDate.second();
|
|
178
|
-
|
|
179
|
-
// 每日重复:每天都在相同的时间段内有效
|
|
180
|
-
// 例如:01:00:00 - 16:00:00,每天都是这个时间段
|
|
181
161
|
return targetTimeOfDay >= startTimeOfDay && targetTimeOfDay <= endTimeOfDay;
|
|
182
162
|
};
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
const isInWeeklyRepeat = (targetDate, startDate, endDate, repeatRule) => {
|
|
186
|
-
const targetDayOfWeek = targetDate.day(); // 0=周日, 1=周一, ..., 6=周六
|
|
187
|
-
|
|
188
|
-
// 检查是否在指定的星期几内
|
|
163
|
+
var isInWeeklyRepeat = (targetDate, startDate, endDate, repeatRule) => {
|
|
164
|
+
const targetDayOfWeek = targetDate.day();
|
|
189
165
|
if (!repeatRule.frequency_date.includes(targetDayOfWeek)) {
|
|
190
166
|
return false;
|
|
191
167
|
}
|
|
192
|
-
|
|
193
|
-
// 计算周差
|
|
194
|
-
const weeksDiff = targetDate.diff(startDate, 'week');
|
|
168
|
+
const weeksDiff = targetDate.diff(startDate, "week");
|
|
195
169
|
if (weeksDiff < 0) {
|
|
196
170
|
return false;
|
|
197
171
|
}
|
|
198
|
-
|
|
199
|
-
// 检查频率
|
|
200
172
|
if (weeksDiff % repeatRule.frequency !== 0) {
|
|
201
173
|
return false;
|
|
202
174
|
}
|
|
203
|
-
|
|
204
|
-
// 检查时间是否在日程的时间范围内
|
|
205
175
|
const targetTimeOfDay = targetDate.hour() * 3600 + targetDate.minute() * 60 + targetDate.second();
|
|
206
176
|
const startTimeOfDay = startDate.hour() * 3600 + startDate.minute() * 60 + startDate.second();
|
|
207
177
|
const endTimeOfDay = endDate.hour() * 3600 + endDate.minute() * 60 + endDate.second();
|
|
208
178
|
return targetTimeOfDay >= startTimeOfDay && targetTimeOfDay <= endTimeOfDay;
|
|
209
179
|
};
|
|
210
|
-
|
|
211
|
-
// 日程时间段类型
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* 获取当前日期日程时间点
|
|
215
|
-
* @param date 日期 YYYY-MM-DD
|
|
216
|
-
* @param scheduleList 日程列表
|
|
217
|
-
* @returns 当前日期日程时间点 结构,数组 [{
|
|
218
|
-
*
|
|
219
|
-
* // HH:mm
|
|
220
|
-
* end_time: string,
|
|
221
|
-
* // HH:mm
|
|
222
|
-
* start_time: string,
|
|
223
|
-
* // 日期时间
|
|
224
|
-
* // YYYY-MM-DD HH:mm:ss
|
|
225
|
-
* end_at: Dayjs,
|
|
226
|
-
* // YYYY-MM-DD HH:mm:ss
|
|
227
|
-
* start_at: Dayjs,
|
|
228
|
-
*
|
|
229
|
-
* }]
|
|
230
|
-
*/
|
|
231
|
-
const getScheduleStartEndTimePoints = (date, scheduleList) => {
|
|
180
|
+
var getScheduleStartEndTimePoints = (date, scheduleList) => {
|
|
232
181
|
if (!date || !scheduleList || scheduleList.length === 0) {
|
|
233
182
|
return [];
|
|
234
183
|
}
|
|
235
|
-
const targetDate = (0,
|
|
184
|
+
const targetDate = (0, import_dayjs.default)(date);
|
|
236
185
|
if (!targetDate.isValid()) {
|
|
237
186
|
return [];
|
|
238
187
|
}
|
|
239
188
|
const timeSlots = [];
|
|
240
|
-
|
|
241
|
-
// 遍历所有日程
|
|
242
189
|
for (const schedule of scheduleList) {
|
|
243
190
|
const slots = extractTimeSlotsFromSchedule(date, schedule);
|
|
244
191
|
timeSlots.push(...slots);
|
|
245
192
|
}
|
|
246
|
-
|
|
247
|
-
// 去重并排序时间段
|
|
248
193
|
return mergeAndSortTimeSlots(timeSlots);
|
|
249
194
|
};
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* 从单个日程中提取指定日期的时间段
|
|
253
|
-
*/
|
|
254
|
-
exports.getScheduleStartEndTimePoints = getScheduleStartEndTimePoints;
|
|
255
|
-
const extractTimeSlotsFromSchedule = (date, schedule) => {
|
|
195
|
+
var extractTimeSlotsFromSchedule = (date, schedule) => {
|
|
256
196
|
switch (schedule.type) {
|
|
257
|
-
case
|
|
197
|
+
case "standard":
|
|
258
198
|
return extractStandardScheduleTimeSlots(date, schedule);
|
|
259
|
-
case
|
|
199
|
+
case "time-slots":
|
|
260
200
|
return extractTimeSlotsScheduleTimeSlots(date, schedule);
|
|
261
|
-
case
|
|
201
|
+
case "designation":
|
|
262
202
|
return extractDesignationScheduleTimeSlots(date, schedule);
|
|
263
203
|
default:
|
|
264
204
|
return [];
|
|
265
205
|
}
|
|
266
206
|
};
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* 提取标准类型日程的时间段
|
|
270
|
-
*/
|
|
271
|
-
const extractStandardScheduleTimeSlots = (date, schedule) => {
|
|
207
|
+
var extractStandardScheduleTimeSlots = (date, schedule) => {
|
|
272
208
|
if (!schedule.start_time || !schedule.end_time) {
|
|
273
209
|
return [];
|
|
274
210
|
}
|
|
275
|
-
const targetDate = (0,
|
|
276
|
-
const startDate = (0,
|
|
277
|
-
const endDate = (0,
|
|
278
|
-
|
|
279
|
-
// 检查日期是否在日程范围内
|
|
211
|
+
const targetDate = (0, import_dayjs.default)(date);
|
|
212
|
+
const startDate = (0, import_dayjs.default)(schedule.start_time);
|
|
213
|
+
const endDate = (0, import_dayjs.default)(schedule.end_time);
|
|
280
214
|
if (!isDateInStandardSchedule(targetDate, schedule, startDate, endDate)) {
|
|
281
215
|
return [];
|
|
282
216
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
const
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
// 构造完整的日期时间
|
|
289
|
-
const startAt = (0, _dayjs.default)(`${date} ${startTime}:00`);
|
|
290
|
-
const endAt = (0, _dayjs.default)(`${date} ${endTime}:00`);
|
|
217
|
+
const startTime = startDate.format("HH:mm");
|
|
218
|
+
const endTime = endDate.format("HH:mm");
|
|
219
|
+
const startAt = (0, import_dayjs.default)(`${date} ${startTime}:00`);
|
|
220
|
+
const endAt = (0, import_dayjs.default)(`${date} ${endTime}:00`);
|
|
291
221
|
return [{
|
|
292
222
|
start_time: startTime,
|
|
293
223
|
end_time: endTime,
|
|
@@ -295,30 +225,22 @@ const extractStandardScheduleTimeSlots = (date, schedule) => {
|
|
|
295
225
|
end_at: endAt
|
|
296
226
|
}];
|
|
297
227
|
};
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* 提取时间段类型日程的时间段
|
|
301
|
-
*/
|
|
302
|
-
const extractTimeSlotsScheduleTimeSlots = (date, schedule) => {
|
|
228
|
+
var extractTimeSlotsScheduleTimeSlots = (date, schedule) => {
|
|
303
229
|
if (!schedule.start_time || !schedule.time_slot || schedule.time_slot.length === 0) {
|
|
304
230
|
return [];
|
|
305
231
|
}
|
|
306
|
-
const targetDate = (0,
|
|
307
|
-
const scheduleStartDate = (0,
|
|
308
|
-
|
|
309
|
-
// 检查日期是否在日程的有效范围内(考虑重复规则)
|
|
232
|
+
const targetDate = (0, import_dayjs.default)(date);
|
|
233
|
+
const scheduleStartDate = (0, import_dayjs.default)(schedule.start_time.split(" ")[0]);
|
|
310
234
|
if (!isDateInTimeSlotsSchedule(targetDate, schedule, scheduleStartDate)) {
|
|
311
235
|
return [];
|
|
312
236
|
}
|
|
313
237
|
const slots = [];
|
|
314
|
-
|
|
315
|
-
// 提取所有时间段
|
|
316
238
|
for (const timeSlot of schedule.time_slot) {
|
|
317
239
|
if (!timeSlot.start_time || !timeSlot.end_time) {
|
|
318
240
|
continue;
|
|
319
241
|
}
|
|
320
|
-
const startAt = (0,
|
|
321
|
-
const endAt = (0,
|
|
242
|
+
const startAt = (0, import_dayjs.default)(`${date} ${timeSlot.start_time}:00`);
|
|
243
|
+
const endAt = (0, import_dayjs.default)(`${date} ${timeSlot.end_time}:00`);
|
|
322
244
|
slots.push({
|
|
323
245
|
start_time: timeSlot.start_time,
|
|
324
246
|
end_time: timeSlot.end_time,
|
|
@@ -328,90 +250,63 @@ const extractTimeSlotsScheduleTimeSlots = (date, schedule) => {
|
|
|
328
250
|
}
|
|
329
251
|
return slots;
|
|
330
252
|
};
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
*/
|
|
335
|
-
const isDateInTimeSlotsSchedule = (targetDate, schedule, scheduleStartDate) => {
|
|
336
|
-
// 不重复的日程
|
|
337
|
-
if (schedule.repeat_type === 'none') {
|
|
338
|
-
// 只在 start_time 的日期有效
|
|
339
|
-
return targetDate.isSame(scheduleStartDate, 'day');
|
|
253
|
+
var isDateInTimeSlotsSchedule = (targetDate, schedule, scheduleStartDate) => {
|
|
254
|
+
if (schedule.repeat_type === "none") {
|
|
255
|
+
return targetDate.isSame(scheduleStartDate, "day");
|
|
340
256
|
}
|
|
341
|
-
|
|
342
|
-
// 重复的日程,需要检查重复规则
|
|
343
257
|
if (!schedule.repeat_rule) {
|
|
344
258
|
return false;
|
|
345
259
|
}
|
|
346
|
-
const {
|
|
347
|
-
repeat_rule,
|
|
348
|
-
repeat_type
|
|
349
|
-
} = schedule;
|
|
350
|
-
|
|
351
|
-
// 检查是否在包含日期中(优先级最高)
|
|
260
|
+
const { repeat_rule, repeat_type } = schedule;
|
|
352
261
|
if (repeat_rule.included_date && repeat_rule.included_date.length > 0) {
|
|
353
262
|
for (const includedDate of repeat_rule.included_date) {
|
|
354
|
-
const includeStartDate = (0,
|
|
355
|
-
const includeEndDate = (0,
|
|
356
|
-
if (targetDate.isSameOrAfter(includeStartDate,
|
|
263
|
+
const includeStartDate = (0, import_dayjs.default)(includedDate.start);
|
|
264
|
+
const includeEndDate = (0, import_dayjs.default)(includedDate.end);
|
|
265
|
+
if (targetDate.isSameOrAfter(includeStartDate, "day") && targetDate.isSameOrBefore(includeEndDate, "day")) {
|
|
357
266
|
return true;
|
|
358
267
|
}
|
|
359
268
|
}
|
|
360
269
|
}
|
|
361
|
-
|
|
362
|
-
// 检查是否在排除日期中
|
|
363
270
|
if (repeat_rule.excluded_date && repeat_rule.excluded_date.length > 0) {
|
|
364
271
|
for (const excludedDate of repeat_rule.excluded_date) {
|
|
365
|
-
const excludeStartDate = (0,
|
|
366
|
-
const excludeEndDate = (0,
|
|
367
|
-
if (targetDate.isSameOrAfter(excludeStartDate,
|
|
272
|
+
const excludeStartDate = (0, import_dayjs.default)(excludedDate.start);
|
|
273
|
+
const excludeEndDate = (0, import_dayjs.default)(excludedDate.end);
|
|
274
|
+
if (targetDate.isSameOrAfter(excludeStartDate, "day") && targetDate.isSameOrBefore(excludeEndDate, "day")) {
|
|
368
275
|
return false;
|
|
369
276
|
}
|
|
370
277
|
}
|
|
371
278
|
}
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
const ruleEndDate = (0, _dayjs.default)(repeat_rule.end.end_date);
|
|
376
|
-
if (targetDate.isAfter(ruleEndDate, 'day')) {
|
|
279
|
+
if (repeat_rule.end.type === "date" && repeat_rule.end.end_date) {
|
|
280
|
+
const ruleEndDate = (0, import_dayjs.default)(repeat_rule.end.end_date);
|
|
281
|
+
if (targetDate.isAfter(ruleEndDate, "day")) {
|
|
377
282
|
return false;
|
|
378
283
|
}
|
|
379
284
|
}
|
|
380
|
-
|
|
381
|
-
// 检查是否在开始日期之前
|
|
382
|
-
if (targetDate.isBefore(scheduleStartDate, 'day')) {
|
|
285
|
+
if (targetDate.isBefore(scheduleStartDate, "day")) {
|
|
383
286
|
return false;
|
|
384
287
|
}
|
|
385
|
-
|
|
386
|
-
// 根据重复类型检查
|
|
387
288
|
switch (repeat_type) {
|
|
388
|
-
case
|
|
289
|
+
case "daily":
|
|
389
290
|
return isDateInDailyRepeat(targetDate, scheduleStartDate, repeat_rule);
|
|
390
|
-
case
|
|
291
|
+
case "weekly":
|
|
391
292
|
return isDateInWeeklyRepeat(targetDate, scheduleStartDate, repeat_rule);
|
|
392
293
|
default:
|
|
393
294
|
return false;
|
|
394
295
|
}
|
|
395
296
|
};
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* 提取指定日期类型日程的时间段
|
|
399
|
-
*/
|
|
400
|
-
const extractDesignationScheduleTimeSlots = (date, schedule) => {
|
|
297
|
+
var extractDesignationScheduleTimeSlots = (date, schedule) => {
|
|
401
298
|
if (!schedule.designation) {
|
|
402
299
|
return [];
|
|
403
300
|
}
|
|
404
|
-
const targetDate = (0,
|
|
301
|
+
const targetDate = (0, import_dayjs.default)(date);
|
|
405
302
|
const designations = Array.isArray(schedule.designation) ? schedule.designation : [schedule.designation];
|
|
406
303
|
const slots = [];
|
|
407
304
|
for (const designation of designations) {
|
|
408
|
-
const startDate = (0,
|
|
409
|
-
const endDate = (0,
|
|
410
|
-
|
|
411
|
-
// 检查日期是否在指定范围内(考虑重复规则)
|
|
305
|
+
const startDate = (0, import_dayjs.default)(designation.start_date);
|
|
306
|
+
const endDate = (0, import_dayjs.default)(designation.end_date);
|
|
412
307
|
if (isDateInDesignationSchedule(targetDate, schedule, designation, startDate, endDate)) {
|
|
413
|
-
const startAt = (0,
|
|
414
|
-
const endAt = (0,
|
|
308
|
+
const startAt = (0, import_dayjs.default)(`${date} ${designation.start_time}:00`);
|
|
309
|
+
const endAt = (0, import_dayjs.default)(`${date} ${designation.end_time}:00`);
|
|
415
310
|
slots.push({
|
|
416
311
|
start_time: designation.start_time,
|
|
417
312
|
end_time: designation.end_time,
|
|
@@ -422,196 +317,125 @@ const extractDesignationScheduleTimeSlots = (date, schedule) => {
|
|
|
422
317
|
}
|
|
423
318
|
return slots;
|
|
424
319
|
};
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
*/
|
|
429
|
-
const isDateInDesignationSchedule = (targetDate, schedule, designation, startDate, endDate) => {
|
|
430
|
-
// 不重复的日程
|
|
431
|
-
if (schedule.repeat_type === 'none') {
|
|
432
|
-
// 检查日期是否在指定的日期范围内
|
|
433
|
-
return targetDate.isSameOrAfter(startDate, 'day') && targetDate.isSameOrBefore(endDate, 'day');
|
|
320
|
+
var isDateInDesignationSchedule = (targetDate, schedule, designation, startDate, endDate) => {
|
|
321
|
+
if (schedule.repeat_type === "none") {
|
|
322
|
+
return targetDate.isSameOrAfter(startDate, "day") && targetDate.isSameOrBefore(endDate, "day");
|
|
434
323
|
}
|
|
435
|
-
|
|
436
|
-
// 重复的日程,需要检查重复规则
|
|
437
324
|
if (!schedule.repeat_rule) {
|
|
438
325
|
return false;
|
|
439
326
|
}
|
|
440
|
-
const {
|
|
441
|
-
repeat_rule,
|
|
442
|
-
repeat_type
|
|
443
|
-
} = schedule;
|
|
444
|
-
|
|
445
|
-
// 检查是否在包含日期中(优先级最高)
|
|
327
|
+
const { repeat_rule, repeat_type } = schedule;
|
|
446
328
|
if (repeat_rule.included_date && repeat_rule.included_date.length > 0) {
|
|
447
329
|
for (const includedDate of repeat_rule.included_date) {
|
|
448
|
-
const includeStartDate = (0,
|
|
449
|
-
const includeEndDate = (0,
|
|
450
|
-
if (targetDate.isSameOrAfter(includeStartDate,
|
|
330
|
+
const includeStartDate = (0, import_dayjs.default)(includedDate.start);
|
|
331
|
+
const includeEndDate = (0, import_dayjs.default)(includedDate.end);
|
|
332
|
+
if (targetDate.isSameOrAfter(includeStartDate, "day") && targetDate.isSameOrBefore(includeEndDate, "day")) {
|
|
451
333
|
return true;
|
|
452
334
|
}
|
|
453
335
|
}
|
|
454
336
|
}
|
|
455
|
-
|
|
456
|
-
// 检查是否在排除日期中
|
|
457
337
|
if (repeat_rule.excluded_date && repeat_rule.excluded_date.length > 0) {
|
|
458
338
|
for (const excludedDate of repeat_rule.excluded_date) {
|
|
459
|
-
const excludeStartDate = (0,
|
|
460
|
-
const excludeEndDate = (0,
|
|
461
|
-
if (targetDate.isSameOrAfter(excludeStartDate,
|
|
339
|
+
const excludeStartDate = (0, import_dayjs.default)(excludedDate.start);
|
|
340
|
+
const excludeEndDate = (0, import_dayjs.default)(excludedDate.end);
|
|
341
|
+
if (targetDate.isSameOrAfter(excludeStartDate, "day") && targetDate.isSameOrBefore(excludeEndDate, "day")) {
|
|
462
342
|
return false;
|
|
463
343
|
}
|
|
464
344
|
}
|
|
465
345
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
const ruleEndDate = (0, _dayjs.default)(repeat_rule.end.end_date);
|
|
470
|
-
if (targetDate.isAfter(ruleEndDate, 'day')) {
|
|
346
|
+
if (repeat_rule.end.type === "date" && repeat_rule.end.end_date) {
|
|
347
|
+
const ruleEndDate = (0, import_dayjs.default)(repeat_rule.end.end_date);
|
|
348
|
+
if (targetDate.isAfter(ruleEndDate, "day")) {
|
|
471
349
|
return false;
|
|
472
350
|
}
|
|
473
351
|
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
if (!targetDate.isSameOrAfter(startDate, 'day') || !targetDate.isSameOrBefore(endDate, 'day')) {
|
|
477
|
-
// 对于重复日程,如果不在基本范围内,还需要检查是否符合重复规则
|
|
478
|
-
// 只要在 startDate 之后,并且符合重复规则即可
|
|
479
|
-
if (targetDate.isBefore(startDate, 'day')) {
|
|
352
|
+
if (!targetDate.isSameOrAfter(startDate, "day") || !targetDate.isSameOrBefore(endDate, "day")) {
|
|
353
|
+
if (targetDate.isBefore(startDate, "day")) {
|
|
480
354
|
return false;
|
|
481
355
|
}
|
|
482
356
|
}
|
|
483
|
-
|
|
484
|
-
// 根据重复类型检查
|
|
485
357
|
switch (repeat_type) {
|
|
486
|
-
case
|
|
358
|
+
case "daily":
|
|
487
359
|
return isDateInDailyRepeat(targetDate, startDate, repeat_rule);
|
|
488
|
-
case
|
|
360
|
+
case "weekly":
|
|
489
361
|
return isDateInWeeklyRepeat(targetDate, startDate, repeat_rule);
|
|
490
362
|
default:
|
|
491
363
|
return false;
|
|
492
364
|
}
|
|
493
365
|
};
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
const
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
// 不重复的日程
|
|
502
|
-
if (schedule.repeat_type === 'none') {
|
|
503
|
-
// 检查日期是否在范围内
|
|
504
|
-
const scheduleStartDate = startDate.format('YYYY-MM-DD');
|
|
505
|
-
const scheduleEndDate = endDate.format('YYYY-MM-DD');
|
|
506
|
-
return targetDate.isSameOrAfter(scheduleStartDate, 'day') && targetDate.isSameOrBefore(scheduleEndDate, 'day');
|
|
366
|
+
var isDateInStandardSchedule = (targetDate, schedule, startDate, endDate) => {
|
|
367
|
+
const targetDateString = targetDate.format("YYYY-MM-DD");
|
|
368
|
+
if (schedule.repeat_type === "none") {
|
|
369
|
+
const scheduleStartDate = startDate.format("YYYY-MM-DD");
|
|
370
|
+
const scheduleEndDate = endDate.format("YYYY-MM-DD");
|
|
371
|
+
return targetDate.isSameOrAfter(scheduleStartDate, "day") && targetDate.isSameOrBefore(scheduleEndDate, "day");
|
|
507
372
|
}
|
|
508
|
-
|
|
509
|
-
// 重复的日程,需要检查重复规则
|
|
510
373
|
if (!schedule.repeat_rule) {
|
|
511
374
|
return false;
|
|
512
375
|
}
|
|
513
|
-
const {
|
|
514
|
-
repeat_rule,
|
|
515
|
-
repeat_type
|
|
516
|
-
} = schedule;
|
|
517
|
-
|
|
518
|
-
// 检查是否在包含日期中
|
|
376
|
+
const { repeat_rule, repeat_type } = schedule;
|
|
519
377
|
if (repeat_rule.included_date && repeat_rule.included_date.length > 0) {
|
|
520
378
|
for (const includedDate of repeat_rule.included_date) {
|
|
521
|
-
const includeStartDate = (0,
|
|
522
|
-
const includeEndDate = (0,
|
|
523
|
-
if (targetDate.isSameOrAfter(includeStartDate,
|
|
379
|
+
const includeStartDate = (0, import_dayjs.default)(includedDate.start);
|
|
380
|
+
const includeEndDate = (0, import_dayjs.default)(includedDate.end);
|
|
381
|
+
if (targetDate.isSameOrAfter(includeStartDate, "day") && targetDate.isSameOrBefore(includeEndDate, "day")) {
|
|
524
382
|
return true;
|
|
525
383
|
}
|
|
526
384
|
}
|
|
527
385
|
}
|
|
528
|
-
|
|
529
|
-
// 检查是否在排除日期中
|
|
530
386
|
for (const excludedDate of repeat_rule.excluded_date) {
|
|
531
|
-
const excludeStartDate = (0,
|
|
532
|
-
const excludeEndDate = (0,
|
|
533
|
-
if (targetDate.isSameOrAfter(excludeStartDate,
|
|
387
|
+
const excludeStartDate = (0, import_dayjs.default)(excludedDate.start);
|
|
388
|
+
const excludeEndDate = (0, import_dayjs.default)(excludedDate.end);
|
|
389
|
+
if (targetDate.isSameOrAfter(excludeStartDate, "day") && targetDate.isSameOrBefore(excludeEndDate, "day")) {
|
|
534
390
|
return false;
|
|
535
391
|
}
|
|
536
392
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
const ruleEndDate = (0, _dayjs.default)(repeat_rule.end.end_date);
|
|
541
|
-
if (targetDate.isAfter(ruleEndDate, 'day')) {
|
|
393
|
+
if (repeat_rule.end.type === "date" && repeat_rule.end.end_date) {
|
|
394
|
+
const ruleEndDate = (0, import_dayjs.default)(repeat_rule.end.end_date);
|
|
395
|
+
if (targetDate.isAfter(ruleEndDate, "day")) {
|
|
542
396
|
return false;
|
|
543
397
|
}
|
|
544
398
|
}
|
|
545
|
-
|
|
546
|
-
// 检查是否在开始日期之前
|
|
547
|
-
if (targetDate.isBefore(startDate, 'day')) {
|
|
399
|
+
if (targetDate.isBefore(startDate, "day")) {
|
|
548
400
|
return false;
|
|
549
401
|
}
|
|
550
|
-
|
|
551
|
-
// 根据重复类型检查
|
|
552
402
|
switch (repeat_type) {
|
|
553
|
-
case
|
|
403
|
+
case "daily":
|
|
554
404
|
return isDateInDailyRepeat(targetDate, startDate, repeat_rule);
|
|
555
|
-
case
|
|
405
|
+
case "weekly":
|
|
556
406
|
return isDateInWeeklyRepeat(targetDate, startDate, repeat_rule);
|
|
557
407
|
default:
|
|
558
408
|
return false;
|
|
559
409
|
}
|
|
560
410
|
};
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
* 检查日期是否符合每日重复规则
|
|
564
|
-
*/
|
|
565
|
-
const isDateInDailyRepeat = (targetDate, startDate, repeatRule) => {
|
|
566
|
-
const daysDiff = targetDate.diff(startDate, 'day');
|
|
411
|
+
var isDateInDailyRepeat = (targetDate, startDate, repeatRule) => {
|
|
412
|
+
const daysDiff = targetDate.diff(startDate, "day");
|
|
567
413
|
if (daysDiff < 0) {
|
|
568
414
|
return false;
|
|
569
415
|
}
|
|
570
|
-
|
|
571
|
-
// 检查频率
|
|
572
416
|
return daysDiff % repeatRule.frequency === 0;
|
|
573
417
|
};
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
* 检查日期是否符合每周重复规则
|
|
577
|
-
*/
|
|
578
|
-
const isDateInWeeklyRepeat = (targetDate, startDate, repeatRule) => {
|
|
579
|
-
const targetDayOfWeek = targetDate.day(); // 0=周日, 1=周一, ..., 6=周六
|
|
580
|
-
|
|
581
|
-
// 检查是否在指定的星期几内
|
|
418
|
+
var isDateInWeeklyRepeat = (targetDate, startDate, repeatRule) => {
|
|
419
|
+
const targetDayOfWeek = targetDate.day();
|
|
582
420
|
if (!repeatRule.frequency_date.includes(targetDayOfWeek)) {
|
|
583
421
|
return false;
|
|
584
422
|
}
|
|
585
|
-
|
|
586
|
-
// 计算周差
|
|
587
|
-
const weeksDiff = targetDate.diff(startDate, 'week');
|
|
423
|
+
const weeksDiff = targetDate.diff(startDate, "week");
|
|
588
424
|
if (weeksDiff < 0) {
|
|
589
425
|
return false;
|
|
590
426
|
}
|
|
591
|
-
|
|
592
|
-
// 检查频率
|
|
593
427
|
return weeksDiff % repeatRule.frequency === 0;
|
|
594
428
|
};
|
|
595
|
-
|
|
596
|
-
/**
|
|
597
|
-
* 对时间段去重并排序
|
|
598
|
-
* 只移除开始时间和结束时间完全相同的重复时间段
|
|
599
|
-
*/
|
|
600
|
-
const mergeAndSortTimeSlots = slots => {
|
|
429
|
+
var mergeAndSortTimeSlots = (slots) => {
|
|
601
430
|
if (slots.length === 0) {
|
|
602
431
|
return [];
|
|
603
432
|
}
|
|
604
|
-
|
|
605
|
-
// 按开始时间排序
|
|
606
433
|
const sorted = [...slots].sort((a, b) => {
|
|
607
434
|
return a.start_at.valueOf() - b.start_at.valueOf();
|
|
608
435
|
});
|
|
609
|
-
|
|
610
|
-
// 去重:移除开始和结束时间完全相同的时间段
|
|
611
436
|
const unique = [];
|
|
612
|
-
const seenKeys = new Set();
|
|
437
|
+
const seenKeys = /* @__PURE__ */ new Set();
|
|
613
438
|
for (const slot of sorted) {
|
|
614
|
-
// 使用开始时间和结束时间作为唯一键
|
|
615
439
|
const key = `${slot.start_time}-${slot.end_time}`;
|
|
616
440
|
if (!seenKeys.has(key)) {
|
|
617
441
|
seenKeys.add(key);
|
|
@@ -619,4 +443,9 @@ const mergeAndSortTimeSlots = slots => {
|
|
|
619
443
|
}
|
|
620
444
|
}
|
|
621
445
|
return unique;
|
|
622
|
-
};
|
|
446
|
+
};
|
|
447
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
448
|
+
0 && (module.exports = {
|
|
449
|
+
getDateIsInSchedule,
|
|
450
|
+
getScheduleStartEndTimePoints
|
|
451
|
+
});
|