@pisell/pisellos 0.0.45 → 0.0.47
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.d.ts +1 -1
- package/dist/modules/Cart/index.js +13 -2
- package/dist/modules/Cart/types.d.ts +10 -3
- package/dist/modules/Cart/utils.d.ts +37 -12
- package/dist/modules/Cart/utils.js +78 -48
- package/dist/solution/BookingByStep/index.d.ts +12 -6
- 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.d.ts +1 -1
- package/lib/modules/Cart/index.js +11 -1
- package/lib/modules/Cart/types.d.ts +10 -3
- package/lib/modules/Cart/utils.d.ts +37 -12
- package/lib/modules/Cart/utils.js +50 -28
- package/lib/solution/BookingByStep/index.d.ts +12 -6
- package/lib/solution/BookingByStep/index.js +69 -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类型账户列表
|
|
@@ -58,7 +58,7 @@ export declare class CartModule extends BaseModule implements Module, CartModule
|
|
|
58
58
|
/**
|
|
59
59
|
* 清除购物车商品中的信息
|
|
60
60
|
*/
|
|
61
|
-
deleteCartItemInfo(types: 'resource' | 'time'): void;
|
|
61
|
+
deleteCartItemInfo(types: 'resource' | 'time' | 'relationForms'): void;
|
|
62
62
|
/**
|
|
63
63
|
* 清除购物车
|
|
64
64
|
*/
|
|
@@ -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,
|
|
@@ -123,7 +124,8 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
123
124
|
discounts,
|
|
124
125
|
resources,
|
|
125
126
|
note,
|
|
126
|
-
date
|
|
127
|
+
date,
|
|
128
|
+
relationForms
|
|
127
129
|
} = params;
|
|
128
130
|
let tempCartItem = this.store.list.find((i) => i._id === _id);
|
|
129
131
|
if (!tempCartItem) {
|
|
@@ -157,6 +159,12 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
157
159
|
resources
|
|
158
160
|
});
|
|
159
161
|
}
|
|
162
|
+
if (relationForms) {
|
|
163
|
+
tempCartItem = (0, import_utils.formatRelationFormsToCartItem)({
|
|
164
|
+
cartItem: tempCartItem,
|
|
165
|
+
relationForms
|
|
166
|
+
});
|
|
167
|
+
}
|
|
160
168
|
if (date) {
|
|
161
169
|
tempCartItem = (0, import_utils.formatDateToCartItem)({ cartItem: tempCartItem, date });
|
|
162
170
|
}
|
|
@@ -217,6 +225,8 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
217
225
|
item = (0, import_utils.deleteResourceFromCartItem)(item);
|
|
218
226
|
} else if (types === "time") {
|
|
219
227
|
item = (0, import_utils.deleteTimeFromCartItem)(item);
|
|
228
|
+
} else if (types === "relationForms") {
|
|
229
|
+
item = (0, import_utils.deleteRelationFormsFromCartItem)(item);
|
|
220
230
|
}
|
|
221
231
|
return item;
|
|
222
232
|
});
|
|
@@ -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
|
* 购物车状态接口
|
|
@@ -162,6 +162,13 @@ export interface IUpdateItemParams {
|
|
|
162
162
|
/** 结束时间 */
|
|
163
163
|
endTime: string;
|
|
164
164
|
};
|
|
165
|
+
/** 关联表单 */
|
|
166
|
+
relationForms?: {
|
|
167
|
+
/** 关联表单ID */
|
|
168
|
+
form_id: number[];
|
|
169
|
+
/** 关联表单记录ID */
|
|
170
|
+
form_record_ids: number[];
|
|
171
|
+
}[];
|
|
165
172
|
}
|
|
166
173
|
/**
|
|
167
174
|
* 折扣
|
|
@@ -90,6 +90,25 @@ export declare const formatResourceToCartItemOrigin: (params: {
|
|
|
90
90
|
cartItem: CartItem;
|
|
91
91
|
resources: Resource[];
|
|
92
92
|
}) => any;
|
|
93
|
+
/**
|
|
94
|
+
* 格式化关联表单到购物车
|
|
95
|
+
* @param params 参数
|
|
96
|
+
* @returns 格式化后的购物车
|
|
97
|
+
*/
|
|
98
|
+
export declare const formatRelationFormsToCartItem: (params: {
|
|
99
|
+
cartItem: CartItem;
|
|
100
|
+
relationForms: {
|
|
101
|
+
form_id: number[];
|
|
102
|
+
form_record_ids: number[];
|
|
103
|
+
}[];
|
|
104
|
+
}) => CartItem;
|
|
105
|
+
export declare const formatRelationFormsToCartItemOrigin: (params: {
|
|
106
|
+
cartItem: CartItem;
|
|
107
|
+
relationForms: {
|
|
108
|
+
form_id: number[];
|
|
109
|
+
form_record_ids: number[];
|
|
110
|
+
}[];
|
|
111
|
+
}) => any;
|
|
93
112
|
/**
|
|
94
113
|
* 格式化日期到购物车
|
|
95
114
|
* @param date 开始时间和结束时间
|
|
@@ -114,18 +133,6 @@ export declare const formatDateToCartItemOrigin: (params: {
|
|
|
114
133
|
endTime: string;
|
|
115
134
|
};
|
|
116
135
|
}) => any;
|
|
117
|
-
/**
|
|
118
|
-
* 从购物车中删除资源相关信息
|
|
119
|
-
* @param cartItem 购物车
|
|
120
|
-
* @returns 删除后的购物车
|
|
121
|
-
*/
|
|
122
|
-
export declare const deleteResourceFromCartItem: (cartItem: CartItem) => CartItem;
|
|
123
|
-
/**
|
|
124
|
-
* 从购物车中删除时间
|
|
125
|
-
* @param cartItem 购物车
|
|
126
|
-
* @returns 删除后的购物车
|
|
127
|
-
*/
|
|
128
|
-
export declare const deleteTimeFromCartItem: (cartItem: CartItem) => CartItem;
|
|
129
136
|
/**
|
|
130
137
|
* 格式化备注到购物车
|
|
131
138
|
* @param params 参数
|
|
@@ -226,3 +233,21 @@ export declare const handleProductDeposit: (params: {
|
|
|
226
233
|
depositTotal: Decimal;
|
|
227
234
|
result: boolean;
|
|
228
235
|
};
|
|
236
|
+
/**
|
|
237
|
+
* 从购物车中删除资源相关信息
|
|
238
|
+
* @param cartItem 购物车
|
|
239
|
+
* @returns 删除后的购物车
|
|
240
|
+
*/
|
|
241
|
+
export declare const deleteResourceFromCartItem: (cartItem: CartItem) => CartItem;
|
|
242
|
+
/**
|
|
243
|
+
* 从购物车中删除时间
|
|
244
|
+
* @param cartItem 购物车
|
|
245
|
+
* @returns 删除后的购物车
|
|
246
|
+
*/
|
|
247
|
+
export declare const deleteTimeFromCartItem: (cartItem: CartItem) => CartItem;
|
|
248
|
+
/**
|
|
249
|
+
* 从购物车中删除关联表单信息
|
|
250
|
+
* @param cartItem 购物车
|
|
251
|
+
* @returns 删除后的购物车
|
|
252
|
+
*/
|
|
253
|
+
export declare const deleteRelationFormsFromCartItem: (cartItem: CartItem) => CartItem;
|
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
var utils_exports = {};
|
|
31
31
|
__export(utils_exports, {
|
|
32
32
|
createCartItemOrigin: () => createCartItemOrigin,
|
|
33
|
+
deleteRelationFormsFromCartItem: () => deleteRelationFormsFromCartItem,
|
|
33
34
|
deleteResourceFromCartItem: () => deleteResourceFromCartItem,
|
|
34
35
|
deleteTimeFromCartItem: () => deleteTimeFromCartItem,
|
|
35
36
|
formatAccountToCartItem: () => formatAccountToCartItem,
|
|
@@ -46,6 +47,8 @@ __export(utils_exports, {
|
|
|
46
47
|
formatOptionsToOrigin: () => formatOptionsToOrigin,
|
|
47
48
|
formatProductToCartItem: () => formatProductToCartItem,
|
|
48
49
|
formatProductToCartItemOrigin: () => formatProductToCartItemOrigin,
|
|
50
|
+
formatRelationFormsToCartItem: () => formatRelationFormsToCartItem,
|
|
51
|
+
formatRelationFormsToCartItemOrigin: () => formatRelationFormsToCartItemOrigin,
|
|
49
52
|
formatResourceToCartItem: () => formatResourceToCartItem,
|
|
50
53
|
formatResourceToCartItemOrigin: () => formatResourceToCartItemOrigin,
|
|
51
54
|
getProductDeposit: () => getProductDeposit,
|
|
@@ -287,6 +290,18 @@ var formatResourceToCartItemOrigin = (params) => {
|
|
|
287
290
|
}
|
|
288
291
|
return origin;
|
|
289
292
|
};
|
|
293
|
+
var formatRelationFormsToCartItem = (params) => {
|
|
294
|
+
const { cartItem } = params;
|
|
295
|
+
const oringin = formatRelationFormsToCartItemOrigin(params);
|
|
296
|
+
cartItem._origin = oringin;
|
|
297
|
+
return cartItem;
|
|
298
|
+
};
|
|
299
|
+
var formatRelationFormsToCartItemOrigin = (params) => {
|
|
300
|
+
const { cartItem, relationForms } = params;
|
|
301
|
+
const origin = cartItem._origin;
|
|
302
|
+
origin.relation_forms = relationForms;
|
|
303
|
+
return origin;
|
|
304
|
+
};
|
|
290
305
|
var formatDateToCartItem = (params) => {
|
|
291
306
|
const { cartItem, date } = params;
|
|
292
307
|
cartItem.start_date = (0, import_dayjs.default)(date.startTime).format("YYYY-MM-DD");
|
|
@@ -307,34 +322,6 @@ var formatDateToCartItemOrigin = (params) => {
|
|
|
307
322
|
origin.end_time = (0, import_dayjs.default)(date.endTime).format("HH:mm");
|
|
308
323
|
return origin;
|
|
309
324
|
};
|
|
310
|
-
var deleteResourceFromCartItem = (cartItem) => {
|
|
311
|
-
cartItem.resource_id = void 0;
|
|
312
|
-
cartItem.relation_form_name = void 0;
|
|
313
|
-
cartItem.start_date = void 0;
|
|
314
|
-
cartItem.start_time = void 0;
|
|
315
|
-
cartItem.end_date = void 0;
|
|
316
|
-
cartItem.end_time = void 0;
|
|
317
|
-
delete cartItem._resourceOrigin;
|
|
318
|
-
cartItem._origin.resources = null;
|
|
319
|
-
cartItem._origin.select_date = null;
|
|
320
|
-
cartItem._origin.start_date = null;
|
|
321
|
-
cartItem._origin.start_time = null;
|
|
322
|
-
cartItem._origin.end_date = null;
|
|
323
|
-
cartItem._origin.end_time = null;
|
|
324
|
-
return cartItem;
|
|
325
|
-
};
|
|
326
|
-
var deleteTimeFromCartItem = (cartItem) => {
|
|
327
|
-
cartItem.start_date = void 0;
|
|
328
|
-
cartItem.start_time = void 0;
|
|
329
|
-
cartItem.end_date = void 0;
|
|
330
|
-
cartItem.end_time = void 0;
|
|
331
|
-
cartItem._origin.select_date = null;
|
|
332
|
-
cartItem._origin.start_date = null;
|
|
333
|
-
cartItem._origin.start_time = null;
|
|
334
|
-
cartItem._origin.end_date = null;
|
|
335
|
-
cartItem._origin.end_time = null;
|
|
336
|
-
return cartItem;
|
|
337
|
-
};
|
|
338
325
|
var formatNoteToCartItem = (params) => {
|
|
339
326
|
const { cartItem, note } = params;
|
|
340
327
|
cartItem.note = note;
|
|
@@ -497,9 +484,42 @@ var handleProductDeposit = (params) => {
|
|
|
497
484
|
}
|
|
498
485
|
return { result: false, depositTotal: new import_decimal.default(0) };
|
|
499
486
|
};
|
|
487
|
+
var deleteResourceFromCartItem = (cartItem) => {
|
|
488
|
+
cartItem.resource_id = void 0;
|
|
489
|
+
cartItem.relation_form_name = void 0;
|
|
490
|
+
cartItem.start_date = void 0;
|
|
491
|
+
cartItem.start_time = void 0;
|
|
492
|
+
cartItem.end_date = void 0;
|
|
493
|
+
cartItem.end_time = void 0;
|
|
494
|
+
delete cartItem._resourceOrigin;
|
|
495
|
+
cartItem._origin.resources = null;
|
|
496
|
+
cartItem._origin.select_date = null;
|
|
497
|
+
cartItem._origin.start_date = null;
|
|
498
|
+
cartItem._origin.start_time = null;
|
|
499
|
+
cartItem._origin.end_date = null;
|
|
500
|
+
cartItem._origin.end_time = null;
|
|
501
|
+
return cartItem;
|
|
502
|
+
};
|
|
503
|
+
var deleteTimeFromCartItem = (cartItem) => {
|
|
504
|
+
cartItem.start_date = void 0;
|
|
505
|
+
cartItem.start_time = void 0;
|
|
506
|
+
cartItem.end_date = void 0;
|
|
507
|
+
cartItem.end_time = void 0;
|
|
508
|
+
cartItem._origin.select_date = null;
|
|
509
|
+
cartItem._origin.start_date = null;
|
|
510
|
+
cartItem._origin.start_time = null;
|
|
511
|
+
cartItem._origin.end_date = null;
|
|
512
|
+
cartItem._origin.end_time = null;
|
|
513
|
+
return cartItem;
|
|
514
|
+
};
|
|
515
|
+
var deleteRelationFormsFromCartItem = (cartItem) => {
|
|
516
|
+
cartItem._origin.relation_forms = null;
|
|
517
|
+
return cartItem;
|
|
518
|
+
};
|
|
500
519
|
// Annotate the CommonJS export names for ESM import in node:
|
|
501
520
|
0 && (module.exports = {
|
|
502
521
|
createCartItemOrigin,
|
|
522
|
+
deleteRelationFormsFromCartItem,
|
|
503
523
|
deleteResourceFromCartItem,
|
|
504
524
|
deleteTimeFromCartItem,
|
|
505
525
|
formatAccountToCartItem,
|
|
@@ -516,6 +536,8 @@ var handleProductDeposit = (params) => {
|
|
|
516
536
|
formatOptionsToOrigin,
|
|
517
537
|
formatProductToCartItem,
|
|
518
538
|
formatProductToCartItemOrigin,
|
|
539
|
+
formatRelationFormsToCartItem,
|
|
540
|
+
formatRelationFormsToCartItemOrigin,
|
|
519
541
|
formatResourceToCartItem,
|
|
520
542
|
formatResourceToCartItemOrigin,
|
|
521
543
|
getProductDeposit,
|
|
@@ -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;
|
|
@@ -122,7 +127,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
122
127
|
/**
|
|
123
128
|
* 从购物车中按类别删除信息
|
|
124
129
|
*/
|
|
125
|
-
deleteCartItemInfo(types: 'resource' | 'time'): void;
|
|
130
|
+
deleteCartItemInfo(types: 'resource' | 'time' | 'relationForms'): void;
|
|
126
131
|
destroy(): void;
|
|
127
132
|
getResourcesList(): any[];
|
|
128
133
|
getResourcesListByCartItem(id: string | number): {
|
|
@@ -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,34 @@ 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(
|
|
257
|
+
account
|
|
258
|
+
);
|
|
259
|
+
return newAccount.getAccount();
|
|
246
260
|
}
|
|
247
261
|
// 添加账户或者 guest
|
|
248
|
-
async
|
|
262
|
+
async addAccounts(accounts, extra) {
|
|
249
263
|
if ((extra == null ? void 0 : extra.type) === "holder") {
|
|
250
264
|
this.store.accountList.addHolderAccounts(
|
|
251
265
|
accounts,
|
|
@@ -253,9 +267,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
253
267
|
);
|
|
254
268
|
return;
|
|
255
269
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
270
|
+
const res = [];
|
|
271
|
+
for (const account of accounts) {
|
|
272
|
+
const accountModule = await this.store.accountList.addAccount(
|
|
273
|
+
account
|
|
274
|
+
);
|
|
275
|
+
const accountData = accountModule.getAccount();
|
|
276
|
+
if (accountData) {
|
|
277
|
+
res.push(accountData);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return res;
|
|
259
281
|
}
|
|
260
282
|
// 获取所有账户
|
|
261
283
|
async getAccounts() {
|
|
@@ -330,6 +352,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
330
352
|
const { resourceIds, rules, resourcesMap } = (0, import_products.getAvailableProductResources)(tempProducts) || {};
|
|
331
353
|
this.otherParams.currentResourcesMap = resourcesMap;
|
|
332
354
|
const res = await this.store.date.getResourceDates({
|
|
355
|
+
url: params.url,
|
|
333
356
|
query: {
|
|
334
357
|
start_date: tempStartDate,
|
|
335
358
|
end_date: tempEndDate,
|
|
@@ -514,7 +537,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
514
537
|
if (n.resource)
|
|
515
538
|
resources.push(...n.resource);
|
|
516
539
|
});
|
|
517
|
-
}
|
|
540
|
+
}
|
|
541
|
+
if (!resources.length) {
|
|
518
542
|
const dateList = this.store.date.getDateList();
|
|
519
543
|
dateList.forEach((n) => {
|
|
520
544
|
if (n.resource)
|
|
@@ -992,8 +1016,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
992
1016
|
}
|
|
993
1017
|
getTimeslotBySchedule({
|
|
994
1018
|
date,
|
|
995
|
-
scheduleIds
|
|
1019
|
+
scheduleIds,
|
|
1020
|
+
resources
|
|
996
1021
|
}) {
|
|
1022
|
+
var _a, _b, _c;
|
|
997
1023
|
const targetProduct = this.store.currentProduct;
|
|
998
1024
|
const targetProductData = targetProduct == null ? void 0 : targetProduct.getData();
|
|
999
1025
|
let targetSchedules = [];
|
|
@@ -1006,32 +1032,46 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1006
1032
|
}
|
|
1007
1033
|
const resourcesDates = this.store.date.getDateList();
|
|
1008
1034
|
const targetResourceDate = resourcesDates.find((n) => n.date === date);
|
|
1035
|
+
const cartItems = this.store.cart.getItems();
|
|
1036
|
+
const resourcesMap = (0, import_utils.getResourcesMap)((targetResourceDate == null ? void 0 : targetResourceDate.resource) || []);
|
|
1037
|
+
const selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
1038
|
+
cartItems,
|
|
1039
|
+
"",
|
|
1040
|
+
resourcesMap
|
|
1041
|
+
);
|
|
1042
|
+
const productResources = (0, import_resources.getResourcesByProduct)(
|
|
1043
|
+
resourcesMap,
|
|
1044
|
+
resources || ((_c = (_b = (_a = this.store.currentProduct) == null ? void 0 : _a.getData()) == null ? void 0 : _b.product_resource) == null ? void 0 : _c.resources) || [],
|
|
1045
|
+
selectedResources,
|
|
1046
|
+
1
|
|
1047
|
+
);
|
|
1009
1048
|
const minTimeMaxTime = (0, import_utils2.calcMinTimeMaxTimeBySchedules)(
|
|
1010
1049
|
targetSchedules,
|
|
1011
1050
|
{},
|
|
1012
1051
|
date
|
|
1013
1052
|
);
|
|
1014
1053
|
const scheduleTimeSlots = (0, import_utils2.getAllSortedDateRanges)(minTimeMaxTime);
|
|
1015
|
-
console.log("scheduleTimeSlots:", scheduleTimeSlots,
|
|
1054
|
+
console.log("scheduleTimeSlots:", scheduleTimeSlots, productResources);
|
|
1055
|
+
const allProductResources = productResources.flatMap((n) => n.renderList);
|
|
1016
1056
|
const formatScheduleTimeSlots = scheduleTimeSlots.map((item) => {
|
|
1017
|
-
var _a;
|
|
1018
|
-
console.log(item);
|
|
1019
1057
|
let count = 0;
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1058
|
+
allProductResources == null ? void 0 : allProductResources.forEach((m) => {
|
|
1059
|
+
m.times.forEach((childTiem) => {
|
|
1060
|
+
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
1061
|
+
timeSlice: {
|
|
1062
|
+
start_time: item.start,
|
|
1063
|
+
end_time: item.end,
|
|
1064
|
+
start_at: (0, import_dayjs.default)(item.start),
|
|
1065
|
+
end_at: (0, import_dayjs.default)(item.end)
|
|
1066
|
+
},
|
|
1067
|
+
time: childTiem,
|
|
1068
|
+
resource: m,
|
|
1069
|
+
currentCount: 1
|
|
1070
|
+
});
|
|
1071
|
+
if (res.usable) {
|
|
1072
|
+
count += (res == null ? void 0 : res.remainingCapacity) || 0;
|
|
1073
|
+
}
|
|
1031
1074
|
});
|
|
1032
|
-
if (res.usable) {
|
|
1033
|
-
count += 1;
|
|
1034
|
-
}
|
|
1035
1075
|
});
|
|
1036
1076
|
const startDayJs = (0, import_dayjs.default)(item.start);
|
|
1037
1077
|
const endDayJs = (0, import_dayjs.default)(item.end);
|