@pisell/pisellos 0.0.45 → 0.0.46
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/modules/AccountList/index.d.ts +2 -2
- package/dist/modules/AccountList/index.js +52 -38
- package/dist/modules/Cart/index.js +1 -0
- package/dist/modules/Cart/types.d.ts +3 -3
- package/dist/solution/BookingByStep/index.d.ts +11 -5
- package/dist/solution/BookingByStep/index.js +280 -201
- package/dist/solution/BookingByStep/utils/resources.d.ts +1 -0
- package/dist/solution/BookingByStep/utils/resources.js +26 -8
- package/lib/modules/AccountList/index.d.ts +2 -2
- package/lib/modules/AccountList/index.js +16 -4
- package/lib/modules/Cart/index.js +1 -0
- package/lib/modules/Cart/types.d.ts +3 -3
- package/lib/solution/BookingByStep/index.d.ts +11 -5
- package/lib/solution/BookingByStep/index.js +65 -29
- package/lib/solution/BookingByStep/utils/resources.d.ts +1 -0
- package/lib/solution/BookingByStep/utils/resources.js +27 -8
- package/package.json +1 -1
|
@@ -111,7 +111,10 @@ var checkCapacity = function checkCapacity(_ref) {
|
|
|
111
111
|
_ref$currentCount = _ref.currentCount,
|
|
112
112
|
currentCount = _ref$currentCount === void 0 ? 1 : _ref$currentCount;
|
|
113
113
|
if (currentCount > resource.capacity) {
|
|
114
|
-
return
|
|
114
|
+
return {
|
|
115
|
+
status: false,
|
|
116
|
+
capacity: resource.capacity
|
|
117
|
+
};
|
|
115
118
|
}
|
|
116
119
|
var conflict = (event_list || []).filter(function (d) {
|
|
117
120
|
return isConflict({
|
|
@@ -127,9 +130,15 @@ var checkCapacity = function checkCapacity(_ref) {
|
|
|
127
130
|
if (resource.resourceType === 'single') {
|
|
128
131
|
// 0代表着不重叠,则满足条件
|
|
129
132
|
if (conflict.length === 0) {
|
|
130
|
-
return
|
|
133
|
+
return {
|
|
134
|
+
status: true,
|
|
135
|
+
capacity: 1
|
|
136
|
+
};
|
|
131
137
|
} else {
|
|
132
|
-
return
|
|
138
|
+
return {
|
|
139
|
+
status: false,
|
|
140
|
+
capacity: 1
|
|
141
|
+
};
|
|
133
142
|
}
|
|
134
143
|
} else {
|
|
135
144
|
// 减去重叠的总量
|
|
@@ -137,9 +146,15 @@ var checkCapacity = function checkCapacity(_ref) {
|
|
|
137
146
|
|
|
138
147
|
// 当前预约量 <= 总剩余容量
|
|
139
148
|
if (currentCount <= conflictCount) {
|
|
140
|
-
return
|
|
149
|
+
return {
|
|
150
|
+
status: true,
|
|
151
|
+
capacity: conflictCount
|
|
152
|
+
};
|
|
141
153
|
} else {
|
|
142
|
-
return
|
|
154
|
+
return {
|
|
155
|
+
status: false,
|
|
156
|
+
capacity: conflictCount
|
|
157
|
+
};
|
|
143
158
|
}
|
|
144
159
|
}
|
|
145
160
|
};
|
|
@@ -160,7 +175,8 @@ export var getIsUsableByTimeItem = function getIsUsableByTimeItem(_ref2) {
|
|
|
160
175
|
var status = {
|
|
161
176
|
afterToDay: false,
|
|
162
177
|
capacity: false,
|
|
163
|
-
usable: false
|
|
178
|
+
usable: false,
|
|
179
|
+
remainingCapacity: 0 // 剩余容量
|
|
164
180
|
};
|
|
165
181
|
// 最早可预约时间为 当前日期之后并且提前量之后
|
|
166
182
|
var earliest = dayjs();
|
|
@@ -170,14 +186,16 @@ export var getIsUsableByTimeItem = function getIsUsableByTimeItem(_ref2) {
|
|
|
170
186
|
return status;
|
|
171
187
|
}
|
|
172
188
|
status.afterToDay = true;
|
|
173
|
-
|
|
189
|
+
var checkCapacityResult = checkCapacity({
|
|
174
190
|
event_list: time === null || time === void 0 ? void 0 : time.event_list,
|
|
175
191
|
timeSlice: timeSlice,
|
|
176
192
|
resource: resource,
|
|
177
193
|
currentCount: currentCount
|
|
178
|
-
})
|
|
194
|
+
});
|
|
195
|
+
if (!checkCapacityResult.status) {
|
|
179
196
|
return status;
|
|
180
197
|
}
|
|
198
|
+
status.remainingCapacity = checkCapacityResult.capacity;
|
|
181
199
|
status.capacity = true;
|
|
182
200
|
status.usable = true;
|
|
183
201
|
return status;
|
|
@@ -18,7 +18,7 @@ export declare class AccountListModule extends BaseModule implements Module {
|
|
|
18
18
|
* @param needEmit 是否需要触发事件
|
|
19
19
|
*/
|
|
20
20
|
private createAccountAndAdd;
|
|
21
|
-
addAccount(account: Account): Promise<
|
|
21
|
+
addAccount(account: Account): Promise<AccountModule>;
|
|
22
22
|
updateAccount(id: string, updates: Account): Promise<void>;
|
|
23
23
|
updateAccountListById(id: string | number, updates: Account): Promise<void>;
|
|
24
24
|
removeAccount(id: string): Promise<void>;
|
|
@@ -33,7 +33,7 @@ export declare class AccountListModule extends BaseModule implements Module {
|
|
|
33
33
|
* @param holders 账号信息列表
|
|
34
34
|
* @param customerId 账户id
|
|
35
35
|
*/
|
|
36
|
-
addHolderAccounts(holders: IHolder[], customerId: number): Promise<
|
|
36
|
+
addHolderAccounts(holders: IHolder[], customerId: number): Promise<AccountModule[]>;
|
|
37
37
|
/**
|
|
38
38
|
* 获取holder类型账户列表
|
|
39
39
|
* @param params
|
|
@@ -71,8 +71,11 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
71
71
|
* @param needEmit 是否需要触发事件
|
|
72
72
|
*/
|
|
73
73
|
async createAccountAndAdd(account, needEmit = true) {
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
const tempAccountModule = this.store.accounts.find(
|
|
75
|
+
(a) => a.getId() === account.id
|
|
76
|
+
);
|
|
77
|
+
if (tempAccountModule) {
|
|
78
|
+
return tempAccountModule;
|
|
76
79
|
}
|
|
77
80
|
this.store.accountList.push(account);
|
|
78
81
|
const accountModule = new import_Account.AccountModule(`account_${account.id}`);
|
|
@@ -85,14 +88,18 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
85
88
|
this.store
|
|
86
89
|
);
|
|
87
90
|
}
|
|
91
|
+
return accountModule;
|
|
88
92
|
}
|
|
89
93
|
async addAccount(account) {
|
|
94
|
+
let currentAccountModule;
|
|
90
95
|
try {
|
|
91
96
|
this.store.isLoading = true;
|
|
92
97
|
this.store.error = null;
|
|
93
98
|
if (this.store.accounts.some((a) => a.getId() === account.id)) {
|
|
99
|
+
currentAccountModule = this.store.accounts.find(
|
|
100
|
+
(n) => n.getId() === account.id
|
|
101
|
+
);
|
|
94
102
|
throw new Error(`Account with id ${account.id} already exists`);
|
|
95
|
-
return;
|
|
96
103
|
}
|
|
97
104
|
this.store.accountList.push(account);
|
|
98
105
|
const accountModule = new import_Account.AccountModule(`account_${account.id}`);
|
|
@@ -102,6 +109,7 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
102
109
|
if (this.store.accounts.length === 1) {
|
|
103
110
|
this.setActiveAccount(accountModule.getId());
|
|
104
111
|
}
|
|
112
|
+
currentAccountModule = accountModule;
|
|
105
113
|
await this.core.effects.emit(
|
|
106
114
|
import_types.AccountListHooks.OnAccountListUpdate,
|
|
107
115
|
this.store
|
|
@@ -115,6 +123,7 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
115
123
|
);
|
|
116
124
|
} finally {
|
|
117
125
|
this.store.isLoading = false;
|
|
126
|
+
return currentAccountModule;
|
|
118
127
|
}
|
|
119
128
|
}
|
|
120
129
|
async updateAccount(id, updates) {
|
|
@@ -245,14 +254,17 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
245
254
|
* @param customerId 账户id
|
|
246
255
|
*/
|
|
247
256
|
async addHolderAccounts(holders, customerId) {
|
|
257
|
+
const accountModules = [];
|
|
248
258
|
for (const holder of holders) {
|
|
249
259
|
const account = (0, import_utils.createHolderAccount)(holder, customerId);
|
|
250
|
-
await this.createAccountAndAdd(account, false);
|
|
260
|
+
const accountModule = await this.createAccountAndAdd(account, false);
|
|
261
|
+
accountModules.push(accountModule);
|
|
251
262
|
}
|
|
252
263
|
await this.core.effects.emit(
|
|
253
264
|
import_types.AccountListHooks.OnAccountListUpdate,
|
|
254
265
|
this.store
|
|
255
266
|
);
|
|
267
|
+
return accountModules;
|
|
256
268
|
}
|
|
257
269
|
/**
|
|
258
270
|
* 获取holder类型账户列表
|
|
@@ -76,6 +76,7 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
76
76
|
};
|
|
77
77
|
if (product) {
|
|
78
78
|
cartItem._productOrigin = (0, import_lodash_es.cloneDeep)(product);
|
|
79
|
+
cartItem._productInit = (0, import_lodash_es.cloneDeep)(product);
|
|
79
80
|
cartItem = (0, import_utils.formatProductToCartItem)({
|
|
80
81
|
cartItem,
|
|
81
82
|
product,
|
|
@@ -96,16 +96,16 @@ export interface CartItem {
|
|
|
96
96
|
title: string;
|
|
97
97
|
}[];
|
|
98
98
|
} | null;
|
|
99
|
-
/**
|
|
99
|
+
/** 接口原始数据 */
|
|
100
100
|
_origin: any;
|
|
101
|
+
/** 商品加入购物车时初始数据 */
|
|
102
|
+
_productInit?: ProductData;
|
|
101
103
|
/** 商品原始数据 */
|
|
102
104
|
_productOrigin?: ProductData;
|
|
103
105
|
/** 资源原始数据 */
|
|
104
106
|
_resourceOrigin?: Resource[];
|
|
105
107
|
/** 容量 */
|
|
106
108
|
capacity?: any;
|
|
107
|
-
/** 商品套餐 */
|
|
108
|
-
product_bundle?: any;
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
111
|
* 购物车状态接口
|
|
@@ -2,7 +2,7 @@ import { Module, PisellCore } from '../../types';
|
|
|
2
2
|
import { BaseModule } from '../../modules/BaseModule';
|
|
3
3
|
import { Response } from '../../plugins';
|
|
4
4
|
import { BookingByStepState } from './types';
|
|
5
|
-
import { CartItem, IUpdateItemParams, ProductData } from '../../modules';
|
|
5
|
+
import { CartItem, IUpdateItemParams, ProductData, ProductResourceItem } from '../../modules';
|
|
6
6
|
import { Account } from '../../modules/Account/types';
|
|
7
7
|
import { IStep } from '../../modules/Step/tyeps';
|
|
8
8
|
import { TimeSliceItem } from './utils/resources';
|
|
@@ -52,10 +52,14 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
52
52
|
custom_page_id?: number;
|
|
53
53
|
}): Promise<ITime[]>;
|
|
54
54
|
storeProduct(productData: ProductData): Promise<void>;
|
|
55
|
-
addAccount(
|
|
55
|
+
addAccount(account: Account | IHolder, extra?: {
|
|
56
56
|
type: 'account' | 'holder';
|
|
57
57
|
customerId: number;
|
|
58
|
-
}): Promise<
|
|
58
|
+
}): Promise<Account | null>;
|
|
59
|
+
addAccounts(accounts: Account[] | IHolder[], extra?: {
|
|
60
|
+
type: 'account' | 'holder';
|
|
61
|
+
customerId: number;
|
|
62
|
+
}): Promise<Account[] | undefined>;
|
|
59
63
|
getAccounts(): Promise<(Account | null)[]>;
|
|
60
64
|
checkHasLoginAccount(): boolean;
|
|
61
65
|
setActiveAccount(id: string): void;
|
|
@@ -71,6 +75,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
71
75
|
getDateRange(): Promise<ITime[]>;
|
|
72
76
|
getCart(): CartItem[];
|
|
73
77
|
getAvailableDate(params?: {
|
|
78
|
+
url?: string;
|
|
74
79
|
products?: ProductData[];
|
|
75
80
|
startDate?: string;
|
|
76
81
|
endDate?: string;
|
|
@@ -172,9 +177,10 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
172
177
|
private getScheduleDataByIds;
|
|
173
178
|
openProductDetail(productId: number): Promise<void>;
|
|
174
179
|
closeProductDetail(): void;
|
|
175
|
-
getTimeslotBySchedule({ date, scheduleIds, }: {
|
|
180
|
+
getTimeslotBySchedule({ date, scheduleIds, resources, }: {
|
|
176
181
|
date: string;
|
|
177
|
-
scheduleIds
|
|
182
|
+
scheduleIds?: number[];
|
|
183
|
+
resources?: ProductResourceItem[];
|
|
178
184
|
}): {
|
|
179
185
|
start_time: string;
|
|
180
186
|
end_time: string;
|
|
@@ -232,20 +232,32 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
232
232
|
}
|
|
233
233
|
async storeProduct(productData) {
|
|
234
234
|
const activeAccount = this.getActiveAccount();
|
|
235
|
-
if (!activeAccount) {
|
|
236
|
-
throw new Error("没有找到当前账户");
|
|
237
|
-
}
|
|
238
235
|
const { bundle, options, origin, product_variant_id } = productData || {};
|
|
239
236
|
const product = { ...origin, product_variant_id };
|
|
240
|
-
|
|
241
|
-
account: activeAccount,
|
|
237
|
+
const addCartItem = {
|
|
242
238
|
product,
|
|
243
239
|
bundle,
|
|
244
240
|
options
|
|
245
|
-
}
|
|
241
|
+
};
|
|
242
|
+
if (activeAccount) {
|
|
243
|
+
addCartItem.account = activeAccount;
|
|
244
|
+
}
|
|
245
|
+
this.store.cart.addItem(addCartItem);
|
|
246
|
+
}
|
|
247
|
+
// 添加单个账户或者 guest
|
|
248
|
+
async addAccount(account, extra) {
|
|
249
|
+
if ((extra == null ? void 0 : extra.type) === "holder") {
|
|
250
|
+
const accountModules = await this.store.accountList.addHolderAccounts(
|
|
251
|
+
[account],
|
|
252
|
+
extra.customerId
|
|
253
|
+
);
|
|
254
|
+
return accountModules[0].getAccount();
|
|
255
|
+
}
|
|
256
|
+
const newAccount = await this.store.accountList.addAccount(account);
|
|
257
|
+
return newAccount.getAccount();
|
|
246
258
|
}
|
|
247
259
|
// 添加账户或者 guest
|
|
248
|
-
async
|
|
260
|
+
async addAccounts(accounts, extra) {
|
|
249
261
|
if ((extra == null ? void 0 : extra.type) === "holder") {
|
|
250
262
|
this.store.accountList.addHolderAccounts(
|
|
251
263
|
accounts,
|
|
@@ -253,9 +265,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
253
265
|
);
|
|
254
266
|
return;
|
|
255
267
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
268
|
+
const res = [];
|
|
269
|
+
for (const account of accounts) {
|
|
270
|
+
const accountModule = await this.store.accountList.addAccount(account);
|
|
271
|
+
const accountData = accountModule.getAccount();
|
|
272
|
+
if (accountData) {
|
|
273
|
+
res.push(accountData);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return res;
|
|
259
277
|
}
|
|
260
278
|
// 获取所有账户
|
|
261
279
|
async getAccounts() {
|
|
@@ -330,6 +348,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
330
348
|
const { resourceIds, rules, resourcesMap } = (0, import_products.getAvailableProductResources)(tempProducts) || {};
|
|
331
349
|
this.otherParams.currentResourcesMap = resourcesMap;
|
|
332
350
|
const res = await this.store.date.getResourceDates({
|
|
351
|
+
url: params.url,
|
|
333
352
|
query: {
|
|
334
353
|
start_date: tempStartDate,
|
|
335
354
|
end_date: tempEndDate,
|
|
@@ -514,7 +533,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
514
533
|
if (n.resource)
|
|
515
534
|
resources.push(...n.resource);
|
|
516
535
|
});
|
|
517
|
-
}
|
|
536
|
+
}
|
|
537
|
+
if (!resources.length) {
|
|
518
538
|
const dateList = this.store.date.getDateList();
|
|
519
539
|
dateList.forEach((n) => {
|
|
520
540
|
if (n.resource)
|
|
@@ -992,8 +1012,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
992
1012
|
}
|
|
993
1013
|
getTimeslotBySchedule({
|
|
994
1014
|
date,
|
|
995
|
-
scheduleIds
|
|
1015
|
+
scheduleIds,
|
|
1016
|
+
resources
|
|
996
1017
|
}) {
|
|
1018
|
+
var _a, _b, _c;
|
|
997
1019
|
const targetProduct = this.store.currentProduct;
|
|
998
1020
|
const targetProductData = targetProduct == null ? void 0 : targetProduct.getData();
|
|
999
1021
|
let targetSchedules = [];
|
|
@@ -1006,32 +1028,46 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1006
1028
|
}
|
|
1007
1029
|
const resourcesDates = this.store.date.getDateList();
|
|
1008
1030
|
const targetResourceDate = resourcesDates.find((n) => n.date === date);
|
|
1031
|
+
const cartItems = this.store.cart.getItems();
|
|
1032
|
+
const resourcesMap = (0, import_utils.getResourcesMap)((targetResourceDate == null ? void 0 : targetResourceDate.resource) || []);
|
|
1033
|
+
const selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
1034
|
+
cartItems,
|
|
1035
|
+
"",
|
|
1036
|
+
resourcesMap
|
|
1037
|
+
);
|
|
1038
|
+
const productResources = (0, import_resources.getResourcesByProduct)(
|
|
1039
|
+
resourcesMap,
|
|
1040
|
+
resources || ((_c = (_b = (_a = this.store.currentProduct) == null ? void 0 : _a.getData()) == null ? void 0 : _b.product_resource) == null ? void 0 : _c.resources) || [],
|
|
1041
|
+
selectedResources,
|
|
1042
|
+
1
|
|
1043
|
+
);
|
|
1009
1044
|
const minTimeMaxTime = (0, import_utils2.calcMinTimeMaxTimeBySchedules)(
|
|
1010
1045
|
targetSchedules,
|
|
1011
1046
|
{},
|
|
1012
1047
|
date
|
|
1013
1048
|
);
|
|
1014
1049
|
const scheduleTimeSlots = (0, import_utils2.getAllSortedDateRanges)(minTimeMaxTime);
|
|
1015
|
-
console.log("scheduleTimeSlots:", scheduleTimeSlots,
|
|
1050
|
+
console.log("scheduleTimeSlots:", scheduleTimeSlots, productResources);
|
|
1051
|
+
const allProductResources = productResources.flatMap((n) => n.renderList);
|
|
1016
1052
|
const formatScheduleTimeSlots = scheduleTimeSlots.map((item) => {
|
|
1017
|
-
var _a;
|
|
1018
|
-
console.log(item);
|
|
1019
1053
|
let count = 0;
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1054
|
+
allProductResources == null ? void 0 : allProductResources.forEach((m) => {
|
|
1055
|
+
m.times.forEach((childTiem) => {
|
|
1056
|
+
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
1057
|
+
timeSlice: {
|
|
1058
|
+
start_time: item.start,
|
|
1059
|
+
end_time: item.end,
|
|
1060
|
+
start_at: (0, import_dayjs.default)(item.start),
|
|
1061
|
+
end_at: (0, import_dayjs.default)(item.end)
|
|
1062
|
+
},
|
|
1063
|
+
time: childTiem,
|
|
1064
|
+
resource: m,
|
|
1065
|
+
currentCount: 1
|
|
1066
|
+
});
|
|
1067
|
+
if (res.usable) {
|
|
1068
|
+
count += (res == null ? void 0 : res.remainingCapacity) || 0;
|
|
1069
|
+
}
|
|
1031
1070
|
});
|
|
1032
|
-
if (res.usable) {
|
|
1033
|
-
count += 1;
|
|
1034
|
-
}
|
|
1035
1071
|
});
|
|
1036
1072
|
const startDayJs = (0, import_dayjs.default)(item.start);
|
|
1037
1073
|
const endDayJs = (0, import_dayjs.default)(item.end);
|
|
@@ -81,7 +81,10 @@ var checkCapacity = ({
|
|
|
81
81
|
currentCount = 1
|
|
82
82
|
}) => {
|
|
83
83
|
if (currentCount > resource.capacity) {
|
|
84
|
-
return
|
|
84
|
+
return {
|
|
85
|
+
status: false,
|
|
86
|
+
capacity: resource.capacity
|
|
87
|
+
};
|
|
85
88
|
}
|
|
86
89
|
let conflict = (event_list || []).filter((d) => {
|
|
87
90
|
return isConflict(
|
|
@@ -91,16 +94,28 @@ var checkCapacity = ({
|
|
|
91
94
|
});
|
|
92
95
|
if (resource.resourceType === "single") {
|
|
93
96
|
if (conflict.length === 0) {
|
|
94
|
-
return
|
|
97
|
+
return {
|
|
98
|
+
status: true,
|
|
99
|
+
capacity: 1
|
|
100
|
+
};
|
|
95
101
|
} else {
|
|
96
|
-
return
|
|
102
|
+
return {
|
|
103
|
+
status: false,
|
|
104
|
+
capacity: 1
|
|
105
|
+
};
|
|
97
106
|
}
|
|
98
107
|
} else {
|
|
99
108
|
let conflictCount = getUseableEventCount(conflict, resource.capacity);
|
|
100
109
|
if (currentCount <= conflictCount) {
|
|
101
|
-
return
|
|
110
|
+
return {
|
|
111
|
+
status: true,
|
|
112
|
+
capacity: conflictCount
|
|
113
|
+
};
|
|
102
114
|
} else {
|
|
103
|
-
return
|
|
115
|
+
return {
|
|
116
|
+
status: false,
|
|
117
|
+
capacity: conflictCount
|
|
118
|
+
};
|
|
104
119
|
}
|
|
105
120
|
}
|
|
106
121
|
};
|
|
@@ -113,21 +128,25 @@ var getIsUsableByTimeItem = ({
|
|
|
113
128
|
let status = {
|
|
114
129
|
afterToDay: false,
|
|
115
130
|
capacity: false,
|
|
116
|
-
usable: false
|
|
131
|
+
usable: false,
|
|
132
|
+
remainingCapacity: 0
|
|
133
|
+
// 剩余容量
|
|
117
134
|
};
|
|
118
135
|
let earliest = (0, import_dayjs.default)();
|
|
119
136
|
if (!checkAfterToDay(timeSlice.start_at, earliest)) {
|
|
120
137
|
return status;
|
|
121
138
|
}
|
|
122
139
|
status.afterToDay = true;
|
|
123
|
-
|
|
140
|
+
const checkCapacityResult = checkCapacity({
|
|
124
141
|
event_list: time == null ? void 0 : time.event_list,
|
|
125
142
|
timeSlice,
|
|
126
143
|
resource,
|
|
127
144
|
currentCount
|
|
128
|
-
})
|
|
145
|
+
});
|
|
146
|
+
if (!checkCapacityResult.status) {
|
|
129
147
|
return status;
|
|
130
148
|
}
|
|
149
|
+
status.remainingCapacity = checkCapacityResult.capacity;
|
|
131
150
|
status.capacity = true;
|
|
132
151
|
status.usable = true;
|
|
133
152
|
return status;
|