@pisell/pisellos 3.0.38 → 3.0.40
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/Cart/types.d.ts +3 -1
- package/dist/modules/Cart/utils/cartProduct.js +3 -2
- package/dist/modules/Date/index.d.ts +1 -0
- package/dist/modules/Date/index.js +10 -0
- package/dist/modules/Summary/utils.js +2 -2
- package/dist/solution/BookingByStep/index.d.ts +2 -1
- package/dist/solution/BookingByStep/index.js +163 -104
- package/dist/solution/BookingByStep/utils/resources.d.ts +12 -2
- package/dist/solution/BookingByStep/utils/resources.js +15 -4
- package/lib/modules/Cart/types.d.ts +3 -1
- package/lib/modules/Cart/utils/cartProduct.js +2 -2
- package/lib/modules/Date/index.d.ts +1 -0
- package/lib/modules/Date/index.js +6 -0
- package/lib/modules/Summary/utils.js +2 -2
- package/lib/solution/BookingByStep/index.d.ts +2 -1
- package/lib/solution/BookingByStep/index.js +92 -45
- package/lib/solution/BookingByStep/utils/resources.d.ts +12 -2
- package/lib/solution/BookingByStep/utils/resources.js +13 -4
- package/package.json +1 -1
|
@@ -79,7 +79,7 @@ export declare const formatResources: ({ booking, resources, }: {
|
|
|
79
79
|
* @return {*}
|
|
80
80
|
* @Author: zhiwei.Wang
|
|
81
81
|
*/
|
|
82
|
-
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, cut_off_time, }: {
|
|
82
|
+
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary }: {
|
|
83
83
|
resource: ResourceItem;
|
|
84
84
|
duration: number;
|
|
85
85
|
split: number;
|
|
@@ -96,6 +96,11 @@ export declare const getTimeSlicesByResource: ({ resource, duration, split, curr
|
|
|
96
96
|
unit: number;
|
|
97
97
|
} | undefined;
|
|
98
98
|
} | undefined;
|
|
99
|
+
hasFlexibleDuration?: boolean | undefined;
|
|
100
|
+
operating_day_boundary?: {
|
|
101
|
+
type: string;
|
|
102
|
+
time: string;
|
|
103
|
+
} | undefined;
|
|
99
104
|
}) => TimeSliceItem[];
|
|
100
105
|
/**
|
|
101
106
|
* @title: 获取时间切片列表的交集
|
|
@@ -133,7 +138,7 @@ export declare const mergeSubResourcesTimeSlices: (resources: ResourceItem[], re
|
|
|
133
138
|
* @return {*}
|
|
134
139
|
* @Author: zhiwei.Wang
|
|
135
140
|
*/
|
|
136
|
-
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time, }: {
|
|
141
|
+
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary }: {
|
|
137
142
|
resourceIds: number[];
|
|
138
143
|
resourcesMap: any;
|
|
139
144
|
duration: number;
|
|
@@ -151,6 +156,11 @@ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, dur
|
|
|
151
156
|
unit: number;
|
|
152
157
|
} | undefined;
|
|
153
158
|
} | undefined;
|
|
159
|
+
hasFlexibleDuration?: boolean | undefined;
|
|
160
|
+
operating_day_boundary?: {
|
|
161
|
+
type: string;
|
|
162
|
+
time: string;
|
|
163
|
+
} | undefined;
|
|
154
164
|
}) => any[];
|
|
155
165
|
/**
|
|
156
166
|
* @title: 获取其他人的已选资源
|
|
@@ -415,7 +415,9 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
|
|
|
415
415
|
capacity = _ref5.capacity,
|
|
416
416
|
_ref5$resourcesUseabl = _ref5.resourcesUseableMap,
|
|
417
417
|
resourcesUseableMap = _ref5$resourcesUseabl === void 0 ? {} : _ref5$resourcesUseabl,
|
|
418
|
-
cut_off_time = _ref5.cut_off_time
|
|
418
|
+
cut_off_time = _ref5.cut_off_time,
|
|
419
|
+
hasFlexibleDuration = _ref5.hasFlexibleDuration,
|
|
420
|
+
operating_day_boundary = _ref5.operating_day_boundary;
|
|
419
421
|
var times = resource.times;
|
|
420
422
|
|
|
421
423
|
// 存储所有时间切片
|
|
@@ -424,7 +426,7 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
|
|
|
424
426
|
// 处理每个时间范围
|
|
425
427
|
times.forEach(function (time) {
|
|
426
428
|
// 创建今天的日期字符串,用于构建完整的日期时间
|
|
427
|
-
|
|
429
|
+
// const today = dayjs(currentDate).format('YYYY-MM-DD');
|
|
428
430
|
|
|
429
431
|
// 解析开始和结束时间
|
|
430
432
|
var startTime = dayjs("".concat(time.start_at));
|
|
@@ -460,6 +462,11 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
|
|
|
460
462
|
resourcesUseableMap[resource.id] = _status.usable;
|
|
461
463
|
}
|
|
462
464
|
if (_status.usable) {
|
|
465
|
+
// 如果有hasFlexibleDuration,且timeSlice.start_at 大于等于operating_day_boundary,则不添加时间切片
|
|
466
|
+
var operatingBoundaryDateTime = (operating_day_boundary === null || operating_day_boundary === void 0 ? void 0 : operating_day_boundary.type) === 'start_time' ? "23:59" : operating_day_boundary === null || operating_day_boundary === void 0 ? void 0 : operating_day_boundary.time;
|
|
467
|
+
if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= (operatingBoundaryDateTime || "23:59")) {
|
|
468
|
+
break;
|
|
469
|
+
}
|
|
463
470
|
// 添加时间切片 09:00 ~ 10:00 09:20 ~ 10:20 09:00 ~ 10:00 09:20 ~ 10:20 11:00 ~ 12:00 11:20 ~ 12:20
|
|
464
471
|
timeSlices.push(_objectSpread(_objectSpread({}, timeSlice), {}, {
|
|
465
472
|
// 这里需要补充这个时间段内是否可预约
|
|
@@ -565,7 +572,9 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref6) {
|
|
|
565
572
|
split = _ref6.split,
|
|
566
573
|
capacity = _ref6.capacity,
|
|
567
574
|
resourcesUseableMap = _ref6.resourcesUseableMap,
|
|
568
|
-
cut_off_time = _ref6.cut_off_time
|
|
575
|
+
cut_off_time = _ref6.cut_off_time,
|
|
576
|
+
hasFlexibleDuration = _ref6.hasFlexibleDuration,
|
|
577
|
+
operating_day_boundary = _ref6.operating_day_boundary;
|
|
569
578
|
// 获取资源列表
|
|
570
579
|
var resources = getResourcesByIds(resourcesMap, resourceIds);
|
|
571
580
|
mergeSubResourcesTimeSlices(resources, resourcesMap);
|
|
@@ -588,7 +597,9 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref6) {
|
|
|
588
597
|
currentDate: currentDate,
|
|
589
598
|
capacity: capacity,
|
|
590
599
|
resourcesUseableMap: resourcesUseableMap,
|
|
591
|
-
cut_off_time: cut_off_time
|
|
600
|
+
cut_off_time: cut_off_time,
|
|
601
|
+
hasFlexibleDuration: hasFlexibleDuration,
|
|
602
|
+
operating_day_boundary: operating_day_boundary
|
|
592
603
|
}));
|
|
593
604
|
}, []);
|
|
594
605
|
|
|
@@ -69,8 +69,10 @@ export interface CartItem {
|
|
|
69
69
|
name?: string;
|
|
70
70
|
/** 商品价格 */
|
|
71
71
|
price?: number | string;
|
|
72
|
-
/**
|
|
72
|
+
/** 单个商品包括商品本身价格+套餐价格+规格等价格得出来的 */
|
|
73
73
|
total?: number | string;
|
|
74
|
+
/** 基于 total 乘以 商品数量的价格 */
|
|
75
|
+
summaryTotal?: number | string;
|
|
74
76
|
/** 商品原价总价,排除原始价格为0的场景 */
|
|
75
77
|
origin_total?: number | string;
|
|
76
78
|
/** 商品数量 */
|
|
@@ -74,6 +74,7 @@ var formatProductToCartItem = (params) => {
|
|
|
74
74
|
cartItem.price = product == null ? void 0 : product.price;
|
|
75
75
|
cartItem.num = num;
|
|
76
76
|
cartItem.total = getProductTotalPrice({ product, bundle, options, num });
|
|
77
|
+
cartItem.summaryTotal = cartItem.total * (num || 1);
|
|
77
78
|
cartItem.origin_total = getProductOriginTotalPrice({
|
|
78
79
|
product,
|
|
79
80
|
bundle,
|
|
@@ -163,7 +164,6 @@ var formatProductToCartItemOrigin = (params) => {
|
|
|
163
164
|
};
|
|
164
165
|
var getProductTotalPrice = (params) => {
|
|
165
166
|
const { product, bundle, options } = params;
|
|
166
|
-
const num = params.num || 1;
|
|
167
167
|
let price = Number(product.price);
|
|
168
168
|
if (bundle == null ? void 0 : bundle.length) {
|
|
169
169
|
price = bundle.reduce((accumulator, currentValue) => {
|
|
@@ -175,7 +175,7 @@ var getProductTotalPrice = (params) => {
|
|
|
175
175
|
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
176
176
|
}, price);
|
|
177
177
|
}
|
|
178
|
-
return price
|
|
178
|
+
return price;
|
|
179
179
|
};
|
|
180
180
|
var getProductOriginTotalPrice = (params) => {
|
|
181
181
|
const { product, bundle, options } = params;
|
|
@@ -20,4 +20,5 @@ export declare class DateModule extends BaseModule implements Module, DateModule
|
|
|
20
20
|
getResourceAvailableTimeList(params: IGetAvailableTimeListParams): Promise<ITime[]>;
|
|
21
21
|
clearDateRange(): void;
|
|
22
22
|
storeChange(): void;
|
|
23
|
+
getResourcesListByDate(date: string): any[] | undefined;
|
|
23
24
|
}
|
|
@@ -125,6 +125,12 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
+
getResourcesListByDate(date) {
|
|
129
|
+
var _a;
|
|
130
|
+
const dateList = this.store.dateList;
|
|
131
|
+
const resourcesList = (_a = dateList.find((item) => item.date === date)) == null ? void 0 : _a.resource;
|
|
132
|
+
return resourcesList;
|
|
133
|
+
}
|
|
128
134
|
};
|
|
129
135
|
// Annotate the CommonJS export names for ESM import in node:
|
|
130
136
|
0 && (module.exports = {
|
|
@@ -55,7 +55,7 @@ var calculateSubtotal = (items) => {
|
|
|
55
55
|
return "0.00";
|
|
56
56
|
}
|
|
57
57
|
const subtotal = items.reduce((sum, item) => {
|
|
58
|
-
const cartItemTotalPrice = new import_decimal.default(item.
|
|
58
|
+
const cartItemTotalPrice = new import_decimal.default(item.summaryTotal || 0);
|
|
59
59
|
return sum.plus(cartItemTotalPrice);
|
|
60
60
|
}, new import_decimal.default(0));
|
|
61
61
|
return subtotal.toFixed(2);
|
|
@@ -66,7 +66,7 @@ var calculateTaxFee = (shopInfo, items) => {
|
|
|
66
66
|
}
|
|
67
67
|
const { is_price_include_tax, tax_rate } = shopInfo || {};
|
|
68
68
|
const totalTaxFee = items.reduce((sum, item) => {
|
|
69
|
-
const cartItemTotalPrice = new import_decimal.default(item.
|
|
69
|
+
const cartItemTotalPrice = new import_decimal.default(item.summaryTotal || 0);
|
|
70
70
|
const taxRate = new import_decimal.default(tax_rate || 0).div(100);
|
|
71
71
|
const productTaxRate = cartItemTotalPrice.times(taxRate).times((item == null ? void 0 : item.is_charge_tax) || 0).div(taxRate.times(is_price_include_tax || 0).plus(1));
|
|
72
72
|
return sum.plus(productTaxRate);
|
|
@@ -42,10 +42,11 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
42
42
|
* 更新step
|
|
43
43
|
*/
|
|
44
44
|
updateStep(key: string, step: IStep): void;
|
|
45
|
-
loadProducts({ category_ids, product_ids, collection, }: {
|
|
45
|
+
loadProducts({ category_ids, product_ids, collection, schedule_date, }: {
|
|
46
46
|
category_ids?: number[];
|
|
47
47
|
product_ids?: number[];
|
|
48
48
|
collection?: number | string[];
|
|
49
|
+
schedule_date?: string;
|
|
49
50
|
}): Promise<any>;
|
|
50
51
|
loadProductByScheduleDate({ date, product_ids, category_ids, }: {
|
|
51
52
|
date: string;
|
|
@@ -69,6 +69,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
69
69
|
if (!this.request) {
|
|
70
70
|
throw new Error("bookingByStep解决方案需要 request 插件支持");
|
|
71
71
|
}
|
|
72
|
+
if (!this.shopStore) {
|
|
73
|
+
throw new Error("SummaryModule 需要 shopStore 插件支持");
|
|
74
|
+
}
|
|
72
75
|
let targetCacheData = {};
|
|
73
76
|
this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
|
|
74
77
|
if ((_b = this.otherParams) == null ? void 0 : _b.cacheId) {
|
|
@@ -163,9 +166,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
163
166
|
async loadProducts({
|
|
164
167
|
category_ids = [],
|
|
165
168
|
product_ids = [],
|
|
166
|
-
collection = []
|
|
169
|
+
collection = [],
|
|
167
170
|
// schedule_ids = [],
|
|
168
|
-
|
|
171
|
+
schedule_date
|
|
169
172
|
}) {
|
|
170
173
|
var _a;
|
|
171
174
|
let userPlugin = this.core.getPlugin("user");
|
|
@@ -196,9 +199,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
196
199
|
category_ids,
|
|
197
200
|
ids: product_ids,
|
|
198
201
|
collection,
|
|
199
|
-
front_end_cache_id: this.cacheId
|
|
202
|
+
front_end_cache_id: this.cacheId,
|
|
200
203
|
// client_schedule_ids: schedule_ids,
|
|
201
|
-
|
|
204
|
+
schedule_date
|
|
202
205
|
},
|
|
203
206
|
{ useCache: true }
|
|
204
207
|
);
|
|
@@ -227,8 +230,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
227
230
|
return await this.loadProducts({
|
|
228
231
|
// schedule_ids: scheduleIds,
|
|
229
232
|
product_ids: allProductIds,
|
|
230
|
-
category_ids
|
|
231
|
-
|
|
233
|
+
category_ids,
|
|
234
|
+
schedule_date: date
|
|
232
235
|
});
|
|
233
236
|
}
|
|
234
237
|
async updateQuotationPriceAndCart(date) {
|
|
@@ -821,7 +824,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
821
824
|
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
822
825
|
const arr = [];
|
|
823
826
|
cartItems.forEach((cartItem) => {
|
|
824
|
-
var _a, _b, _c;
|
|
827
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
825
828
|
let selectedResources = [];
|
|
826
829
|
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
827
830
|
capacity: (_a = cartItem._productOrigin) == null ? void 0 : _a.capacity,
|
|
@@ -858,9 +861,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
858
861
|
const resourcesUseableMap = {};
|
|
859
862
|
productResources.forEach((n) => {
|
|
860
863
|
n.renderList = n.renderList.sort((a, b) => {
|
|
861
|
-
var _a2, _b2, _c2,
|
|
864
|
+
var _a2, _b2, _c2, _d2;
|
|
862
865
|
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
863
|
-
const bIsCombined = ((
|
|
866
|
+
const bIsCombined = ((_d2 = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d2.status) === 1;
|
|
864
867
|
if (aIsCombined && !bIsCombined)
|
|
865
868
|
return 1;
|
|
866
869
|
if (!aIsCombined && bIsCombined)
|
|
@@ -900,17 +903,22 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
900
903
|
});
|
|
901
904
|
});
|
|
902
905
|
} else {
|
|
906
|
+
const hasFlexibleDuration = ((_e = (_d = cartItem._productOrigin) == null ? void 0 : _d.duration) == null ? void 0 : _e.type) === "flexible";
|
|
907
|
+
const operating_day_boundary = (_g = (_f = this.shopStore.get("core")) == null ? void 0 : _f.core) == null ? void 0 : _g.operating_day_boundary;
|
|
903
908
|
productResources.forEach((item) => {
|
|
904
909
|
item.renderList = item.renderList.filter((n) => {
|
|
905
|
-
var _a2, _b2;
|
|
910
|
+
var _a2, _b2, _c2;
|
|
906
911
|
const recordCount = n.capacity || 0;
|
|
907
912
|
if (n.onlyComputed)
|
|
908
913
|
return false;
|
|
909
914
|
const timeSlots = (0, import_resources.getTimeSlicesByResource)({
|
|
910
915
|
resource: n,
|
|
911
|
-
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) ||
|
|
916
|
+
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10,
|
|
912
917
|
split: 10,
|
|
913
|
-
currentDate: dateRange[0].date
|
|
918
|
+
currentDate: dateRange[0].date,
|
|
919
|
+
hasFlexibleDuration,
|
|
920
|
+
cut_off_time: (_c2 = cartItem._productOrigin) == null ? void 0 : _c2.cut_off_time,
|
|
921
|
+
operating_day_boundary
|
|
914
922
|
});
|
|
915
923
|
return recordCount >= currentCapacity && timeSlots.length > 0;
|
|
916
924
|
});
|
|
@@ -1037,7 +1045,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1037
1045
|
return false;
|
|
1038
1046
|
const timeSlots = (0, import_resources.getTimeSlicesByResource)({
|
|
1039
1047
|
resource: n,
|
|
1040
|
-
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) ||
|
|
1048
|
+
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10,
|
|
1041
1049
|
split: 10,
|
|
1042
1050
|
currentDate: dateRange[0].date
|
|
1043
1051
|
});
|
|
@@ -1155,7 +1163,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1155
1163
|
}
|
|
1156
1164
|
let duration = accountCartItems.reduce((acc, n) => {
|
|
1157
1165
|
var _a2, _b2;
|
|
1158
|
-
return acc + (((_b2 = (_a2 = n._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value)
|
|
1166
|
+
return acc + (((_b2 = (_a2 = n._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10);
|
|
1159
1167
|
}, 0);
|
|
1160
1168
|
let AllResources = [];
|
|
1161
1169
|
if (dateRange == null ? void 0 : dateRange.length) {
|
|
@@ -1219,6 +1227,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1219
1227
|
},
|
|
1220
1228
|
0
|
|
1221
1229
|
);
|
|
1230
|
+
if (n.resourceType === "single" && totalCapacity > 0) {
|
|
1231
|
+
continue;
|
|
1232
|
+
}
|
|
1222
1233
|
const canUseTime = mTimes.find((item) => {
|
|
1223
1234
|
var _a2;
|
|
1224
1235
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
@@ -1286,8 +1297,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1286
1297
|
const accountList = this.store.accountList.getAccounts();
|
|
1287
1298
|
const selectForCartResources = (cartItems2) => {
|
|
1288
1299
|
let recordTimeSlots = (0, import_lodash_es.cloneDeep)(timeSlots);
|
|
1300
|
+
const hasFlexibleProduct = cartItems2.some((item) => {
|
|
1301
|
+
var _a2, _b;
|
|
1302
|
+
return ((_b = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b.type) === "flexible";
|
|
1303
|
+
});
|
|
1289
1304
|
cartItems2.forEach((item, index) => {
|
|
1290
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m
|
|
1305
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
1291
1306
|
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
1292
1307
|
capacity: (_a2 = item._productOrigin) == null ? void 0 : _a2.capacity,
|
|
1293
1308
|
product_bundle: item._origin.product.product_bundle
|
|
@@ -1305,14 +1320,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1305
1320
|
const currentResourceConfig = (_d = (_c = (_b = item._productOrigin) == null ? void 0 : _b.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.find(
|
|
1306
1321
|
(n) => n.code === resources_code
|
|
1307
1322
|
);
|
|
1308
|
-
if (index !== 0 && recordTimeSlots && (currentResourceConfig == null ? void 0 : currentResourceConfig.type) === "single" && ((_e = item._productOrigin) == null ? void 0 : _e.duration)) {
|
|
1323
|
+
if (index !== 0 && recordTimeSlots && (currentResourceConfig == null ? void 0 : currentResourceConfig.type) === "single" && ((_e = item._productOrigin) == null ? void 0 : _e.duration) && !hasFlexibleProduct) {
|
|
1309
1324
|
let start_at = (0, import_dayjs.default)(recordTimeSlots.end_time).add(
|
|
1310
|
-
((_g = (_f = item._productOrigin) == null ? void 0 : _f.duration) == null ? void 0 : _g.value)
|
|
1311
|
-
|
|
1325
|
+
((_g = (_f = item._productOrigin) == null ? void 0 : _f.duration) == null ? void 0 : _g.value) || 10,
|
|
1326
|
+
"minutes"
|
|
1312
1327
|
);
|
|
1313
1328
|
let end_at = start_at.add(
|
|
1314
|
-
((
|
|
1315
|
-
|
|
1329
|
+
((_i = (_h = item._productOrigin) == null ? void 0 : _h.duration) == null ? void 0 : _i.value) || 10,
|
|
1330
|
+
"minutes"
|
|
1316
1331
|
);
|
|
1317
1332
|
recordTimeSlots = {
|
|
1318
1333
|
start_time: start_at.format("HH:mm"),
|
|
@@ -1365,7 +1380,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1365
1380
|
const allCartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
1366
1381
|
let selectedResources = [];
|
|
1367
1382
|
const resources2 = (0, import_lodash_es.cloneDeep)(
|
|
1368
|
-
((
|
|
1383
|
+
((_k = (_j = item._productOrigin) == null ? void 0 : _j.product_resource) == null ? void 0 : _k.resources) || []
|
|
1369
1384
|
);
|
|
1370
1385
|
const currentResourcesRenderList = [];
|
|
1371
1386
|
resources2.forEach((n) => {
|
|
@@ -1376,7 +1391,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1376
1391
|
const recordCount = (m.capacity || 0) - (selectResourcesMap[m.id] || 0);
|
|
1377
1392
|
const timeSlots2 = (0, import_resources.getTimeSlicesByResource)({
|
|
1378
1393
|
resource: m,
|
|
1379
|
-
duration: ((_a4 = item == null ? void 0 : item.duration) == null ? void 0 : _a4.value) ||
|
|
1394
|
+
duration: ((_a4 = item == null ? void 0 : item.duration) == null ? void 0 : _a4.value) || 10,
|
|
1380
1395
|
split: 10,
|
|
1381
1396
|
currentDate: dateRange[0].date
|
|
1382
1397
|
});
|
|
@@ -1413,11 +1428,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1413
1428
|
return recordCount >= currentCapacity;
|
|
1414
1429
|
});
|
|
1415
1430
|
});
|
|
1416
|
-
const targetRenderList = (
|
|
1431
|
+
const targetRenderList = (_l = productResources.find(
|
|
1417
1432
|
(n) => n.code === resources_code
|
|
1418
|
-
)) == null ? void 0 :
|
|
1433
|
+
)) == null ? void 0 : _l.renderList;
|
|
1419
1434
|
if (targetRenderList && targetRenderList.length > 0) {
|
|
1420
|
-
if ((
|
|
1435
|
+
if ((_m = item._origin.resources) == null ? void 0 : _m.some(
|
|
1421
1436
|
(n) => n.form_id === targetRenderList[0].form_id
|
|
1422
1437
|
)) {
|
|
1423
1438
|
return;
|
|
@@ -1463,7 +1478,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1463
1478
|
}
|
|
1464
1479
|
// 从购物车中获取已经分配好第一步资源的所有时间片
|
|
1465
1480
|
getTimeSlotByAllResources(resources_code) {
|
|
1466
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1481
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1467
1482
|
let dateRange = this.store.date.getDateRange();
|
|
1468
1483
|
const resources = [];
|
|
1469
1484
|
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
@@ -1473,7 +1488,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1473
1488
|
let maxCutOffTime = void 0;
|
|
1474
1489
|
let maxCutOffTimeValue = (0, import_dayjs.default)();
|
|
1475
1490
|
cartItems.forEach((item) => {
|
|
1476
|
-
var _a2, _b2, _c2, _d2, _e2, _f2,
|
|
1491
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i;
|
|
1477
1492
|
(_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
|
|
1478
1493
|
if (n.code === resources_code) {
|
|
1479
1494
|
resources.push(...n.renderList || []);
|
|
@@ -1483,10 +1498,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1483
1498
|
if (item.resource_id) {
|
|
1484
1499
|
resourceIds.push(item.resource_id);
|
|
1485
1500
|
}
|
|
1486
|
-
resourcesTypeId = (
|
|
1501
|
+
resourcesTypeId = (_g2 = (_f2 = (_e2 = (_d2 = item == null ? void 0 : item._productOrigin) == null ? void 0 : _d2.product_resource) == null ? void 0 : _e2.resources) == null ? void 0 : _f2.find(
|
|
1487
1502
|
(n) => n.code === resources_code
|
|
1488
|
-
)) == null ? void 0 :
|
|
1489
|
-
if (((
|
|
1503
|
+
)) == null ? void 0 : _g2.id;
|
|
1504
|
+
if (((_h2 = item._productOrigin) == null ? void 0 : _h2.cut_off_time) && ((_i = item._productOrigin) == null ? void 0 : _i.cut_off_time.type) === "advance") {
|
|
1490
1505
|
const currentCutOffTime = (0, import_dayjs.default)().add(
|
|
1491
1506
|
item._productOrigin.cut_off_time.unit,
|
|
1492
1507
|
item._productOrigin.cut_off_time.unit_type
|
|
@@ -1512,10 +1527,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1512
1527
|
cartItems2.forEach((item) => {
|
|
1513
1528
|
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
1514
1529
|
if (isSingleResource) {
|
|
1515
|
-
accountDuration += ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value)
|
|
1530
|
+
accountDuration += ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10;
|
|
1516
1531
|
} else {
|
|
1517
|
-
if (accountDuration < (((_d2 = (_c2 = item._productOrigin) == null ? void 0 : _c2.duration) == null ? void 0 : _d2.value)
|
|
1518
|
-
accountDuration = ((_f2 = (_e2 = item._productOrigin) == null ? void 0 : _e2.duration) == null ? void 0 : _f2.value)
|
|
1532
|
+
if (accountDuration < (((_d2 = (_c2 = item._productOrigin) == null ? void 0 : _c2.duration) == null ? void 0 : _d2.value) || 10)) {
|
|
1533
|
+
accountDuration = ((_f2 = (_e2 = item._productOrigin) == null ? void 0 : _e2.duration) == null ? void 0 : _f2.value) || 10;
|
|
1519
1534
|
}
|
|
1520
1535
|
}
|
|
1521
1536
|
});
|
|
@@ -1551,6 +1566,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1551
1566
|
];
|
|
1552
1567
|
}
|
|
1553
1568
|
const resourcesUseableMap = {};
|
|
1569
|
+
const hasFlexibleDuration = cartItems.some((item) => {
|
|
1570
|
+
var _a2, _b2;
|
|
1571
|
+
return ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.type) === "flexible";
|
|
1572
|
+
});
|
|
1573
|
+
const operating_day_boundary = (_h = (_g = this.shopStore.get("core")) == null ? void 0 : _g.core) == null ? void 0 : _h.operating_day_boundary;
|
|
1554
1574
|
const timeSlots = (0, import_resources.getTimeSlicesByResources)({
|
|
1555
1575
|
resourceIds,
|
|
1556
1576
|
resourcesMap,
|
|
@@ -1558,13 +1578,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1558
1578
|
currentDate: dateRange[0].date,
|
|
1559
1579
|
split: 10,
|
|
1560
1580
|
resourcesUseableMap,
|
|
1561
|
-
cut_off_time: maxCutOffTime
|
|
1581
|
+
cut_off_time: maxCutOffTime,
|
|
1582
|
+
hasFlexibleDuration,
|
|
1583
|
+
operating_day_boundary
|
|
1562
1584
|
});
|
|
1563
1585
|
return timeSlots;
|
|
1564
1586
|
}
|
|
1565
|
-
//
|
|
1587
|
+
// 提交时间切片,绑定到对应购物车的商品上,更新购物车---只有 duration 商品
|
|
1566
1588
|
submitTimeSlot(timeSlots) {
|
|
1589
|
+
var _a, _b;
|
|
1567
1590
|
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
1591
|
+
const allResources = this.store.date.getResourcesListByDate(timeSlots.start_at.format("YYYY-MM-DD"));
|
|
1568
1592
|
const itemsByAccount = cartItems.reduce(
|
|
1569
1593
|
(acc, item) => {
|
|
1570
1594
|
const holderId = item.holder_id;
|
|
@@ -1576,25 +1600,48 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1576
1600
|
},
|
|
1577
1601
|
{}
|
|
1578
1602
|
);
|
|
1603
|
+
const operating_day_boundary = (_b = (_a = this.shopStore.get("core")) == null ? void 0 : _a.core) == null ? void 0 : _b.operating_day_boundary;
|
|
1579
1604
|
Object.values(itemsByAccount).forEach((accountItems) => {
|
|
1580
1605
|
let currentStartTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
1581
1606
|
accountItems.forEach((item, index) => {
|
|
1582
|
-
var
|
|
1607
|
+
var _a2;
|
|
1583
1608
|
const newResources = (0, import_lodash_es.cloneDeep)(item._origin.resources);
|
|
1584
1609
|
newResources.forEach((resource) => {
|
|
1585
|
-
var
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1610
|
+
var _a3, _b2, _c, _d, _e;
|
|
1611
|
+
if (((_b2 = (_a3 = item._productOrigin) == null ? void 0 : _a3.duration) == null ? void 0 : _b2.type) === "flexible") {
|
|
1612
|
+
item.duration = {
|
|
1613
|
+
type: "minutes",
|
|
1614
|
+
value: 10
|
|
1615
|
+
};
|
|
1616
|
+
resource.startTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
1617
|
+
const targetResourceTimes = (_c = allResources == null ? void 0 : allResources.find((n) => n.id === resource.id)) == null ? void 0 : _c.times;
|
|
1618
|
+
const resourcesEndTime = targetResourceTimes.reduce((acc, curr) => {
|
|
1619
|
+
return (0, import_dayjs.default)(curr.end_at).isBefore((0, import_dayjs.default)(acc.end_at)) ? curr : acc;
|
|
1620
|
+
}, targetResourceTimes[0]);
|
|
1621
|
+
const resourceDate = (0, import_dayjs.default)(resourcesEndTime.end_at).format("YYYY-MM-DD");
|
|
1622
|
+
const operatingBoundaryDateTime = `${resourceDate} ${operating_day_boundary.type === "start_time" ? "23:59" : operating_day_boundary.time}`;
|
|
1623
|
+
const endTime = (0, import_dayjs.default)(resourcesEndTime.end_at).isBefore((0, import_dayjs.default)(operatingBoundaryDateTime)) ? resourcesEndTime.end_at : operatingBoundaryDateTime;
|
|
1624
|
+
let formattedEndTime;
|
|
1625
|
+
if (typeof endTime === "string" && endTime.includes(":") && !endTime.includes(" ") && !endTime.includes("T")) {
|
|
1626
|
+
const currentDate = timeSlots.start_at.format("YYYY-MM-DD");
|
|
1627
|
+
formattedEndTime = (0, import_dayjs.default)(`${currentDate} ${endTime}`);
|
|
1628
|
+
} else {
|
|
1629
|
+
formattedEndTime = (0, import_dayjs.default)(endTime);
|
|
1630
|
+
}
|
|
1631
|
+
resource.endTime = formattedEndTime.format("YYYY-MM-DD HH:mm");
|
|
1632
|
+
} else {
|
|
1633
|
+
resource.startTime = currentStartTime;
|
|
1634
|
+
resource.endTime = (0, import_dayjs.default)(currentStartTime).add(
|
|
1635
|
+
((_e = (_d = item._productOrigin) == null ? void 0 : _d.duration) == null ? void 0 : _e.value) || 10,
|
|
1636
|
+
"minutes"
|
|
1637
|
+
).format("YYYY-MM-DD HH:mm");
|
|
1638
|
+
}
|
|
1592
1639
|
});
|
|
1593
1640
|
this.store.cart.updateItem({
|
|
1594
1641
|
_id: item._id,
|
|
1595
1642
|
resources: newResources
|
|
1596
1643
|
});
|
|
1597
|
-
if (index < accountItems.length - 1 && ((
|
|
1644
|
+
if (index < accountItems.length - 1 && ((_a2 = newResources == null ? void 0 : newResources[0]) == null ? void 0 : _a2.resourceType) === "single") {
|
|
1598
1645
|
currentStartTime = newResources[0].endTime;
|
|
1599
1646
|
}
|
|
1600
1647
|
});
|
|
@@ -1939,7 +1986,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1939
1986
|
return false;
|
|
1940
1987
|
const timeSlots = (0, import_resources.getTimeSlicesByResource)({
|
|
1941
1988
|
resource: n,
|
|
1942
|
-
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) ||
|
|
1989
|
+
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10,
|
|
1943
1990
|
split: 10,
|
|
1944
1991
|
currentDate: dateRange[0].date
|
|
1945
1992
|
});
|
|
@@ -79,7 +79,7 @@ export declare const formatResources: ({ booking, resources, }: {
|
|
|
79
79
|
* @return {*}
|
|
80
80
|
* @Author: zhiwei.Wang
|
|
81
81
|
*/
|
|
82
|
-
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, cut_off_time, }: {
|
|
82
|
+
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary }: {
|
|
83
83
|
resource: ResourceItem;
|
|
84
84
|
duration: number;
|
|
85
85
|
split: number;
|
|
@@ -96,6 +96,11 @@ export declare const getTimeSlicesByResource: ({ resource, duration, split, curr
|
|
|
96
96
|
unit: number;
|
|
97
97
|
} | undefined;
|
|
98
98
|
} | undefined;
|
|
99
|
+
hasFlexibleDuration?: boolean | undefined;
|
|
100
|
+
operating_day_boundary?: {
|
|
101
|
+
type: string;
|
|
102
|
+
time: string;
|
|
103
|
+
} | undefined;
|
|
99
104
|
}) => TimeSliceItem[];
|
|
100
105
|
/**
|
|
101
106
|
* @title: 获取时间切片列表的交集
|
|
@@ -133,7 +138,7 @@ export declare const mergeSubResourcesTimeSlices: (resources: ResourceItem[], re
|
|
|
133
138
|
* @return {*}
|
|
134
139
|
* @Author: zhiwei.Wang
|
|
135
140
|
*/
|
|
136
|
-
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time, }: {
|
|
141
|
+
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary }: {
|
|
137
142
|
resourceIds: number[];
|
|
138
143
|
resourcesMap: any;
|
|
139
144
|
duration: number;
|
|
@@ -151,6 +156,11 @@ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, dur
|
|
|
151
156
|
unit: number;
|
|
152
157
|
} | undefined;
|
|
153
158
|
} | undefined;
|
|
159
|
+
hasFlexibleDuration?: boolean | undefined;
|
|
160
|
+
operating_day_boundary?: {
|
|
161
|
+
type: string;
|
|
162
|
+
time: string;
|
|
163
|
+
} | undefined;
|
|
154
164
|
}) => any[];
|
|
155
165
|
/**
|
|
156
166
|
* @title: 获取其他人的已选资源
|
|
@@ -333,12 +333,13 @@ var getTimeSlicesByResource = ({
|
|
|
333
333
|
currentDate = (0, import_dayjs.default)(),
|
|
334
334
|
capacity,
|
|
335
335
|
resourcesUseableMap = {},
|
|
336
|
-
cut_off_time
|
|
336
|
+
cut_off_time,
|
|
337
|
+
hasFlexibleDuration,
|
|
338
|
+
operating_day_boundary
|
|
337
339
|
}) => {
|
|
338
340
|
const { times } = resource;
|
|
339
341
|
const timeSlices = [];
|
|
340
342
|
times.forEach((time) => {
|
|
341
|
-
const today = (0, import_dayjs.default)(currentDate).format("YYYY-MM-DD");
|
|
342
343
|
const startTime = (0, import_dayjs.default)(`${time.start_at}`);
|
|
343
344
|
const endTime = (0, import_dayjs.default)(`${time.end_at}`);
|
|
344
345
|
let currentStart = startTime;
|
|
@@ -365,6 +366,10 @@ var getTimeSlicesByResource = ({
|
|
|
365
366
|
resourcesUseableMap[resource.id] = _status.usable;
|
|
366
367
|
}
|
|
367
368
|
if (_status.usable) {
|
|
369
|
+
const operatingBoundaryDateTime = (operating_day_boundary == null ? void 0 : operating_day_boundary.type) === "start_time" ? "23:59" : operating_day_boundary == null ? void 0 : operating_day_boundary.time;
|
|
370
|
+
if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= (operatingBoundaryDateTime || "23:59")) {
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
368
373
|
timeSlices.push({
|
|
369
374
|
...timeSlice,
|
|
370
375
|
// 这里需要补充这个时间段内是否可预约
|
|
@@ -422,7 +427,9 @@ var getTimeSlicesByResources = ({
|
|
|
422
427
|
split,
|
|
423
428
|
capacity,
|
|
424
429
|
resourcesUseableMap,
|
|
425
|
-
cut_off_time
|
|
430
|
+
cut_off_time,
|
|
431
|
+
hasFlexibleDuration,
|
|
432
|
+
operating_day_boundary
|
|
426
433
|
}) => {
|
|
427
434
|
let resources = getResourcesByIds(resourcesMap, resourceIds);
|
|
428
435
|
mergeSubResourcesTimeSlices(resources, resourcesMap);
|
|
@@ -446,7 +453,9 @@ var getTimeSlicesByResources = ({
|
|
|
446
453
|
currentDate,
|
|
447
454
|
capacity,
|
|
448
455
|
resourcesUseableMap,
|
|
449
|
-
cut_off_time
|
|
456
|
+
cut_off_time,
|
|
457
|
+
hasFlexibleDuration,
|
|
458
|
+
operating_day_boundary
|
|
450
459
|
})
|
|
451
460
|
);
|
|
452
461
|
},
|