@pisell/pisellos 0.0.60 → 0.0.61
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/index.d.ts +2 -1
- package/dist/modules/Cart/index.js +28 -1
- package/dist/modules/Cart/types.d.ts +15 -0
- package/dist/modules/Cart/types.js +11 -0
- package/dist/modules/Cart/utils.d.ts +1 -0
- package/dist/modules/Cart/utils.js +2 -4
- package/dist/modules/Date/index.js +1 -2
- package/dist/modules/Date/utils.js +9 -9
- package/dist/solution/BookingByStep/index.d.ts +2 -1
- package/dist/solution/BookingByStep/index.js +14 -6
- package/dist/solution/BookingByStep/utils/resources.js +1 -0
- package/lib/modules/Cart/index.d.ts +2 -1
- package/lib/modules/Cart/index.js +26 -0
- package/lib/modules/Cart/types.d.ts +15 -0
- package/lib/modules/Cart/types.js +9 -0
- package/lib/modules/Cart/utils.d.ts +1 -0
- package/lib/modules/Cart/utils.js +2 -3
- package/lib/modules/Date/index.js +7 -21
- package/lib/modules/Date/utils.js +12 -9
- package/lib/solution/BookingByStep/index.d.ts +2 -1
- package/lib/solution/BookingByStep/index.js +20 -17
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { CartItem, CartModuleAPI, ECartItemInfoType, IAddItemParams, IUpdateItemParams } from './types';
|
|
3
|
+
import { CartItem, CartModuleAPI, ECartItemCheckType, ECartItemInfoType, IAddItemParams, IUpdateItemParams } from './types';
|
|
4
4
|
export * from './types';
|
|
5
5
|
/**
|
|
6
6
|
* 购物车模块实现
|
|
@@ -66,4 +66,5 @@ export declare class CartModule extends BaseModule implements Module, CartModule
|
|
|
66
66
|
*/
|
|
67
67
|
clear(): void;
|
|
68
68
|
storeChange(): void;
|
|
69
|
+
checkCartItemByType(cartItem: CartItem, type: ECartItemCheckType): boolean;
|
|
69
70
|
}
|
|
@@ -22,7 +22,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
22
22
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
23
23
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
24
24
|
import { BaseModule } from "../BaseModule";
|
|
25
|
-
import { ECartItemInfoType } from "./types";
|
|
25
|
+
import { ECartItemCheckType, ECartItemInfoType } from "./types";
|
|
26
26
|
import { createCartItemOrigin, deleteHolderFromCartItem, deleteRelationFormsFromCartItem, deleteResourceFromCartItem, deleteTimeFromCartItem, formatAccountToCartItem, formatDateToCartItem, formatDiscountToCartItem, formatNoteToCartItem, formatProductToCartItem, formatRelationFormsToCartItem, formatResourceToCartItem, getUniqueId } from "./utils";
|
|
27
27
|
import { cloneDeep } from 'lodash-es';
|
|
28
28
|
export * from "./types";
|
|
@@ -443,6 +443,33 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
443
443
|
});
|
|
444
444
|
}
|
|
445
445
|
}
|
|
446
|
+
}, {
|
|
447
|
+
key: "checkCartItemByType",
|
|
448
|
+
value: function checkCartItemByType(cartItem, type) {
|
|
449
|
+
var result = false;
|
|
450
|
+
var _ref = cartItem._origin || {},
|
|
451
|
+
holder = _ref.holder,
|
|
452
|
+
metadata = _ref.metadata,
|
|
453
|
+
resources = _ref.resources,
|
|
454
|
+
start_date = _ref.start_date,
|
|
455
|
+
end_date = _ref.end_date,
|
|
456
|
+
relation_forms = _ref.relation_forms;
|
|
457
|
+
switch (type) {
|
|
458
|
+
case ECartItemCheckType.Account:
|
|
459
|
+
result = !!holder || !!(metadata !== null && metadata !== void 0 && metadata.account);
|
|
460
|
+
break;
|
|
461
|
+
case ECartItemCheckType.Resource:
|
|
462
|
+
result = !!(resources !== null && resources !== void 0 && resources.length);
|
|
463
|
+
break;
|
|
464
|
+
case ECartItemCheckType.Date:
|
|
465
|
+
result = !!start_date && !!end_date;
|
|
466
|
+
break;
|
|
467
|
+
case ECartItemCheckType.RelationForms:
|
|
468
|
+
result = !!(relation_forms !== null && relation_forms !== void 0 && relation_forms.length);
|
|
469
|
+
break;
|
|
470
|
+
}
|
|
471
|
+
return result;
|
|
472
|
+
}
|
|
446
473
|
}]);
|
|
447
474
|
return CartModule;
|
|
448
475
|
}(BaseModule);
|
|
@@ -20,6 +20,19 @@ export declare enum ECartItemInfoType {
|
|
|
20
20
|
/** 账户信息 */
|
|
21
21
|
Holder = "holder"
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* 购物车商品检查类型
|
|
25
|
+
*/
|
|
26
|
+
export declare enum ECartItemCheckType {
|
|
27
|
+
/** 账户信息 */
|
|
28
|
+
Account = "account",
|
|
29
|
+
/** 资源信息 */
|
|
30
|
+
Resource = "resource",
|
|
31
|
+
/** 时间信息 */
|
|
32
|
+
Date = "date",
|
|
33
|
+
/** 关联表单信息 */
|
|
34
|
+
RelationForms = "relationForms"
|
|
35
|
+
}
|
|
23
36
|
export interface CartModuleAPI {
|
|
24
37
|
/** 添加商品到购物车 */
|
|
25
38
|
addItem: (item: IAddItemParams) => Promise<void>;
|
|
@@ -41,6 +54,8 @@ export interface CartModuleAPI {
|
|
|
41
54
|
clear: () => void;
|
|
42
55
|
/** 清除购物车商品中的信息 */
|
|
43
56
|
deleteCartItemInfo: (type: ECartItemInfoType, _id?: string) => void;
|
|
57
|
+
/** 检查购物车商品 */
|
|
58
|
+
checkCartItemByType: (cartItem: CartItem, type: ECartItemCheckType) => boolean;
|
|
44
59
|
}
|
|
45
60
|
/**
|
|
46
61
|
* 购物车商品接口
|
|
@@ -17,6 +17,17 @@ export var ECartItemInfoType = /*#__PURE__*/function (ECartItemInfoType) {
|
|
|
17
17
|
return ECartItemInfoType;
|
|
18
18
|
}({});
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* 购物车商品检查类型
|
|
22
|
+
*/
|
|
23
|
+
export var ECartItemCheckType = /*#__PURE__*/function (ECartItemCheckType) {
|
|
24
|
+
ECartItemCheckType["Account"] = "account";
|
|
25
|
+
ECartItemCheckType["Resource"] = "resource";
|
|
26
|
+
ECartItemCheckType["Date"] = "date";
|
|
27
|
+
ECartItemCheckType["RelationForms"] = "relationForms";
|
|
28
|
+
return ECartItemCheckType;
|
|
29
|
+
}({});
|
|
30
|
+
|
|
20
31
|
/**
|
|
21
32
|
* 购物车商品接口
|
|
22
33
|
*/
|
|
@@ -63,10 +63,9 @@ export var createCartItemOrigin = function createCartItemOrigin() {
|
|
|
63
63
|
// 所选结束时间
|
|
64
64
|
end_date: null,
|
|
65
65
|
// 额外信息
|
|
66
|
-
metadata: {}
|
|
67
|
-
|
|
66
|
+
metadata: {},
|
|
68
67
|
// holder相关
|
|
69
|
-
|
|
68
|
+
holder: null
|
|
70
69
|
};
|
|
71
70
|
};
|
|
72
71
|
|
|
@@ -105,7 +104,6 @@ export var formatProductToCartItem = function formatProductToCartItem(params) {
|
|
|
105
104
|
cartItem.isNormalProduct = isNormalProduct(product);
|
|
106
105
|
cartItem.is_charge_tax = product === null || product === void 0 ? void 0 : product.is_charge_tax;
|
|
107
106
|
}
|
|
108
|
-
console.log('cartItem>>>>>>', cartItem);
|
|
109
107
|
if (bundle !== null && bundle !== void 0 && bundle.length) {
|
|
110
108
|
cartItem.bundle = formatBundle(bundle);
|
|
111
109
|
}
|
|
@@ -15,7 +15,6 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
15
15
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
16
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
17
17
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
18
|
-
import dayjs from 'dayjs';
|
|
19
18
|
import { BaseModule } from "../BaseModule";
|
|
20
19
|
import { disableAllDates, generateMonthDates, handleAvailableDateByResource, handleAvailableDatesByRules } from "./utils";
|
|
21
20
|
export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
@@ -132,7 +131,7 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
132
131
|
case 5:
|
|
133
132
|
// 1.生成当前月份的所有日期,默认都是可用的
|
|
134
133
|
dates = generateMonthDates(start_date, end_date, type); // 如果没有资源或者结束日期在今天之前,则所有日期均不可用
|
|
135
|
-
if (
|
|
134
|
+
if (resource_ids !== null && resource_ids !== void 0 && resource_ids.length) {
|
|
136
135
|
_context3.next = 8;
|
|
137
136
|
break;
|
|
138
137
|
}
|
|
@@ -28,7 +28,7 @@ export var generateMonthDates = function generateMonthDates(startDate, endDate,
|
|
|
28
28
|
var end = dayjs(endDate).format('YYYY-MM-DD');
|
|
29
29
|
var dates = [];
|
|
30
30
|
var currentDate = dayjs(start);
|
|
31
|
-
while (dayjs(currentDate).isBefore(dayjs(end)) || dayjs(currentDate).isSame(dayjs(end))) {
|
|
31
|
+
while (dayjs(currentDate).isBefore(dayjs(end), 'day') || dayjs(currentDate).isSame(dayjs(end), 'day')) {
|
|
32
32
|
dates.push({
|
|
33
33
|
date: dayjs(currentDate).format('YYYY-MM-DD'),
|
|
34
34
|
week: dayjs(currentDate).format('ddd'),
|
|
@@ -62,7 +62,7 @@ export var disableAllDates = function disableAllDates(dates) {
|
|
|
62
62
|
export var disableDatesBeforeOneDay = function disableDatesBeforeOneDay(dates, oneDay) {
|
|
63
63
|
var day = oneDay ? dayjs(oneDay).format('YYYY-MM-DD') : dayjs().format('YYYY-MM-DD');
|
|
64
64
|
return dates.map(function (date) {
|
|
65
|
-
if (dayjs(date.date).isBefore(day)) {
|
|
65
|
+
if (dayjs(date.date).isBefore(day, 'day')) {
|
|
66
66
|
return _objectSpread(_objectSpread({}, date), {}, {
|
|
67
67
|
status: 'unavailable'
|
|
68
68
|
});
|
|
@@ -153,11 +153,11 @@ export var handleAvailableDatesByRules = function handleAvailableDatesByRules(da
|
|
|
153
153
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
154
154
|
var item = _step.value;
|
|
155
155
|
// 判断item.date是否在dates的开始和结束日期范围内,如果不在则跳过
|
|
156
|
-
if (dayjs(item.date).isBefore(dayjs(newDates[0].date))) {
|
|
156
|
+
if (dayjs(item.date).isBefore(dayjs(newDates[0].date), 'day')) {
|
|
157
157
|
continue;
|
|
158
158
|
}
|
|
159
159
|
// 判断日程日期是否超过了dates中的最后一个日期,如果超过了则循环break
|
|
160
|
-
if (dayjs(item.date).isAfter(dayjs(newDates[newDates.length - 1].date))) {
|
|
160
|
+
if (dayjs(item.date).isAfter(dayjs(newDates[newDates.length - 1].date), 'day')) {
|
|
161
161
|
break;
|
|
162
162
|
}
|
|
163
163
|
// 在范围内的日程如果scheduleMap中不存在,则加入到scheduleMap
|
|
@@ -182,12 +182,12 @@ export var handleAvailableDatesByRules = function handleAvailableDatesByRules(da
|
|
|
182
182
|
// 预定天数存在,则开始计算从当前时间开始往后推预定天数作为结束时间
|
|
183
183
|
if (future_day) {
|
|
184
184
|
var endDate = dayjs().add(future_day, 'day');
|
|
185
|
-
if (!earliestEndDate || endDate.isBefore(dayjs(earliestEndDate))) {
|
|
185
|
+
if (!earliestEndDate || endDate.isBefore(dayjs(earliestEndDate), 'day')) {
|
|
186
186
|
earliestEndDate = endDate.format('YYYY-MM-DD');
|
|
187
187
|
}
|
|
188
188
|
} else if (future_day === 0) {
|
|
189
189
|
var _endDate = dayjs();
|
|
190
|
-
if (!earliestEndDate || _endDate.isBefore(dayjs(earliestEndDate))) {
|
|
190
|
+
if (!earliestEndDate || _endDate.isBefore(dayjs(earliestEndDate), 'day')) {
|
|
191
191
|
earliestEndDate = _endDate.format('YYYY-MM-DD');
|
|
192
192
|
}
|
|
193
193
|
}
|
|
@@ -195,7 +195,7 @@ export var handleAvailableDatesByRules = function handleAvailableDatesByRules(da
|
|
|
195
195
|
// 如果存在提前预约时间,则开始计算从当前时间开始往后推提前预约时间作为开始时间
|
|
196
196
|
if (unit && unit_type) {
|
|
197
197
|
var startDate = dayjs(dayjs().add(unit, unit_type).format('YYYY-MM-DD'));
|
|
198
|
-
if (!latestStartDate || startDate.isAfter(dayjs(latestStartDate))) {
|
|
198
|
+
if (!latestStartDate || startDate.isAfter(dayjs(latestStartDate), 'day')) {
|
|
199
199
|
latestStartDate = startDate.format('YYYY-MM-DD');
|
|
200
200
|
}
|
|
201
201
|
}
|
|
@@ -231,11 +231,11 @@ export var handleAvailableDatesByRules = function handleAvailableDatesByRules(da
|
|
|
231
231
|
}
|
|
232
232
|
if (latestStartDate || earliestEndDate) {
|
|
233
233
|
// 如果时间在最早开始时间之前,则设置为不可用
|
|
234
|
-
if (latestStartDate && dayjs(date.date).isBefore(latestStartDate)) {
|
|
234
|
+
if (latestStartDate && dayjs(date.date).isBefore(latestStartDate, 'day')) {
|
|
235
235
|
return disabledDate;
|
|
236
236
|
}
|
|
237
237
|
// 如果时间在最早结束时间之后,则设置为不可用
|
|
238
|
-
if (earliestEndDate && dayjs(date.date).isAfter(earliestEndDate)) {
|
|
238
|
+
if (earliestEndDate && dayjs(date.date).isAfter(earliestEndDate, 'day')) {
|
|
239
239
|
return disabledDate;
|
|
240
240
|
}
|
|
241
241
|
}
|
|
@@ -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, ProductResourceItem, ECartItemInfoType } from '../../modules';
|
|
5
|
+
import { CartItem, IUpdateItemParams, ProductData, ProductResourceItem, ECartItemInfoType, ECartItemCheckType } 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';
|
|
@@ -131,6 +131,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
131
131
|
* 从购物车中按类别删除信息
|
|
132
132
|
*/
|
|
133
133
|
deleteCartItemInfo(type: ECartItemInfoType, _id?: string): void;
|
|
134
|
+
checkCartItemByType(cartItem: CartItem, type: ECartItemCheckType): boolean;
|
|
134
135
|
destroy(): void;
|
|
135
136
|
getResourcesList(): any[];
|
|
136
137
|
getResourcesListByCartItem(id: string | number): {
|
|
@@ -319,14 +319,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
319
319
|
case 0:
|
|
320
320
|
startDate = _ref3.startDate, endDate = _ref3.endDate, custom_page_id = _ref3.custom_page_id;
|
|
321
321
|
// 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天,需要把 startDate 置为今天
|
|
322
|
-
if (dayjs(startDate).isBefore(dayjs())) {
|
|
322
|
+
if (dayjs(startDate).isBefore(dayjs(), 'day')) {
|
|
323
323
|
startDate = dayjs().format('YYYY-MM-DD');
|
|
324
324
|
}
|
|
325
325
|
// 1.生成当前月份的所有日期,默认都不可用
|
|
326
326
|
dates = generateMonthDates(startDate, endDate);
|
|
327
327
|
dates = disableAllDates(dates);
|
|
328
328
|
// 如果 endDate 在今天之前,则不用查接口,直接返回 dates
|
|
329
|
-
if (!dayjs(endDate).isBefore(dayjs())) {
|
|
329
|
+
if (!dayjs(endDate).isBefore(dayjs(), 'day')) {
|
|
330
330
|
_context5.next = 6;
|
|
331
331
|
break;
|
|
332
332
|
}
|
|
@@ -342,7 +342,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
342
342
|
res = _context5.sent;
|
|
343
343
|
this.store.schedule.setAvailabilityScheduleDateList(res.data.date_list);
|
|
344
344
|
// 如果没有schedule或者结束日期在今天之前,则所有日期均不可用
|
|
345
|
-
if (!(!((_res$data$date_list = res.data.date_list) !== null && _res$data$date_list !== void 0 && _res$data$date_list.length) || dayjs(endDate).isBefore(dayjs()))) {
|
|
345
|
+
if (!(!((_res$data$date_list = res.data.date_list) !== null && _res$data$date_list !== void 0 && _res$data$date_list.length) || dayjs(endDate).isBefore(dayjs(), 'day'))) {
|
|
346
346
|
_context5.next = 12;
|
|
347
347
|
break;
|
|
348
348
|
}
|
|
@@ -651,7 +651,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
651
651
|
params = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
|
|
652
652
|
// 开始日期如果小于今天,直接以今天当做开始日期
|
|
653
653
|
products = params.products, startDate = params.startDate, endDate = params.endDate, type = params.type; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
|
|
654
|
-
if (dayjs(startDate).isBefore(dayjs()) && (dayjs(endDate).isAfter(dayjs()) || dayjs(endDate).isSame(dayjs()))) {
|
|
654
|
+
if (dayjs(startDate).isBefore(dayjs(), 'day') && (dayjs(endDate).isAfter(dayjs(), 'day') || dayjs(endDate).isSame(dayjs(), 'day'))) {
|
|
655
655
|
startDate = dayjs().format('YYYY-MM-DD');
|
|
656
656
|
}
|
|
657
657
|
tempProducts = products || this.store.cart.getItems().map(function (p) {
|
|
@@ -888,7 +888,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
888
888
|
cartItems = this.store.cart.getItems();
|
|
889
889
|
newCartItems = cloneDeep(cartItems); // 先整个临时的逻辑,把购物车里所有商品的资源给他格式化一下
|
|
890
890
|
newCartItems.forEach(function (item) {
|
|
891
|
-
var _item$_productOrigin;
|
|
891
|
+
var _item$_productOrigin, _item$_origin;
|
|
892
892
|
item._origin.resources = item._origin.resources.map(function (n) {
|
|
893
893
|
var newResourcesItem = cloneDeep(n);
|
|
894
894
|
delete newResourcesItem.id;
|
|
@@ -903,6 +903,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
903
903
|
var currentCapacity = getSumCapacity({
|
|
904
904
|
capacity: formatCapacity
|
|
905
905
|
});
|
|
906
|
+
if (!((_item$_origin = item._origin) !== null && _item$_origin !== void 0 && _item$_origin.metadata)) {
|
|
907
|
+
item._origin.metadata = {};
|
|
908
|
+
}
|
|
906
909
|
item._origin.metadata.capacity = formatCapacity;
|
|
907
910
|
item._origin.number = currentCapacity;
|
|
908
911
|
});
|
|
@@ -1096,6 +1099,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1096
1099
|
value: function deleteCartItemInfo(type, _id) {
|
|
1097
1100
|
this.store.cart.deleteCartItemInfo(type, _id);
|
|
1098
1101
|
}
|
|
1102
|
+
}, {
|
|
1103
|
+
key: "checkCartItemByType",
|
|
1104
|
+
value: function checkCartItemByType(cartItem, type) {
|
|
1105
|
+
return this.store.cart.checkCartItemByType(cartItem, type);
|
|
1106
|
+
}
|
|
1099
1107
|
}, {
|
|
1100
1108
|
key: "destroy",
|
|
1101
1109
|
value: function destroy() {
|
|
@@ -1129,7 +1137,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1129
1137
|
});
|
|
1130
1138
|
}
|
|
1131
1139
|
var resourcesMap = getResourcesMap(cloneDeep(resources));
|
|
1132
|
-
var cartItems =
|
|
1140
|
+
var cartItems = this.store.cart.getItems();
|
|
1133
1141
|
var arr = [];
|
|
1134
1142
|
var capacityMap = {};
|
|
1135
1143
|
cartItems.forEach(function (cartItem) {
|
|
@@ -282,6 +282,7 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
|
|
|
282
282
|
var latestTime = d.times.reduce(function (latest, current) {
|
|
283
283
|
return dayjs(current.end_at).isAfter(dayjs(latest.end_at)) ? current : latest;
|
|
284
284
|
}, d.times[0]);
|
|
285
|
+
// TODO,在这拉时间切片出来,如果可用 timeSlots.length > 1 才可以被选择
|
|
285
286
|
return dayjs(latestTime.end_at).isAfter(dayjs());
|
|
286
287
|
});
|
|
287
288
|
item.form_id = form_id;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { CartItem, CartModuleAPI, ECartItemInfoType, IAddItemParams, IUpdateItemParams } from './types';
|
|
3
|
+
import { CartItem, CartModuleAPI, ECartItemCheckType, ECartItemInfoType, IAddItemParams, IUpdateItemParams } from './types';
|
|
4
4
|
export * from './types';
|
|
5
5
|
/**
|
|
6
6
|
* 购物车模块实现
|
|
@@ -66,4 +66,5 @@ export declare class CartModule extends BaseModule implements Module, CartModule
|
|
|
66
66
|
*/
|
|
67
67
|
clear(): void;
|
|
68
68
|
storeChange(): void;
|
|
69
|
+
checkCartItemByType(cartItem: CartItem, type: ECartItemCheckType): boolean;
|
|
69
70
|
}
|
|
@@ -274,6 +274,32 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
274
274
|
});
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
|
+
checkCartItemByType(cartItem, type) {
|
|
278
|
+
let result = false;
|
|
279
|
+
const {
|
|
280
|
+
holder,
|
|
281
|
+
metadata,
|
|
282
|
+
resources,
|
|
283
|
+
start_date,
|
|
284
|
+
end_date,
|
|
285
|
+
relation_forms
|
|
286
|
+
} = cartItem._origin || {};
|
|
287
|
+
switch (type) {
|
|
288
|
+
case import_types.ECartItemCheckType.Account:
|
|
289
|
+
result = !!holder || !!(metadata == null ? void 0 : metadata.account);
|
|
290
|
+
break;
|
|
291
|
+
case import_types.ECartItemCheckType.Resource:
|
|
292
|
+
result = !!(resources == null ? void 0 : resources.length);
|
|
293
|
+
break;
|
|
294
|
+
case import_types.ECartItemCheckType.Date:
|
|
295
|
+
result = !!start_date && !!end_date;
|
|
296
|
+
break;
|
|
297
|
+
case import_types.ECartItemCheckType.RelationForms:
|
|
298
|
+
result = !!(relation_forms == null ? void 0 : relation_forms.length);
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
return result;
|
|
302
|
+
}
|
|
277
303
|
};
|
|
278
304
|
// Annotate the CommonJS export names for ESM import in node:
|
|
279
305
|
0 && (module.exports = {
|
|
@@ -20,6 +20,19 @@ export declare enum ECartItemInfoType {
|
|
|
20
20
|
/** 账户信息 */
|
|
21
21
|
Holder = "holder"
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* 购物车商品检查类型
|
|
25
|
+
*/
|
|
26
|
+
export declare enum ECartItemCheckType {
|
|
27
|
+
/** 账户信息 */
|
|
28
|
+
Account = "account",
|
|
29
|
+
/** 资源信息 */
|
|
30
|
+
Resource = "resource",
|
|
31
|
+
/** 时间信息 */
|
|
32
|
+
Date = "date",
|
|
33
|
+
/** 关联表单信息 */
|
|
34
|
+
RelationForms = "relationForms"
|
|
35
|
+
}
|
|
23
36
|
export interface CartModuleAPI {
|
|
24
37
|
/** 添加商品到购物车 */
|
|
25
38
|
addItem: (item: IAddItemParams) => Promise<void>;
|
|
@@ -41,6 +54,8 @@ export interface CartModuleAPI {
|
|
|
41
54
|
clear: () => void;
|
|
42
55
|
/** 清除购物车商品中的信息 */
|
|
43
56
|
deleteCartItemInfo: (type: ECartItemInfoType, _id?: string) => void;
|
|
57
|
+
/** 检查购物车商品 */
|
|
58
|
+
checkCartItemByType: (cartItem: CartItem, type: ECartItemCheckType) => boolean;
|
|
44
59
|
}
|
|
45
60
|
/**
|
|
46
61
|
* 购物车商品接口
|
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
var types_exports = {};
|
|
21
21
|
__export(types_exports, {
|
|
22
22
|
CartHooks: () => CartHooks,
|
|
23
|
+
ECartItemCheckType: () => ECartItemCheckType,
|
|
23
24
|
ECartItemInfoType: () => ECartItemInfoType
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(types_exports);
|
|
@@ -37,8 +38,16 @@ var ECartItemInfoType = /* @__PURE__ */ ((ECartItemInfoType2) => {
|
|
|
37
38
|
ECartItemInfoType2["Holder"] = "holder";
|
|
38
39
|
return ECartItemInfoType2;
|
|
39
40
|
})(ECartItemInfoType || {});
|
|
41
|
+
var ECartItemCheckType = /* @__PURE__ */ ((ECartItemCheckType2) => {
|
|
42
|
+
ECartItemCheckType2["Account"] = "account";
|
|
43
|
+
ECartItemCheckType2["Resource"] = "resource";
|
|
44
|
+
ECartItemCheckType2["Date"] = "date";
|
|
45
|
+
ECartItemCheckType2["RelationForms"] = "relationForms";
|
|
46
|
+
return ECartItemCheckType2;
|
|
47
|
+
})(ECartItemCheckType || {});
|
|
40
48
|
// Annotate the CommonJS export names for ESM import in node:
|
|
41
49
|
0 && (module.exports = {
|
|
42
50
|
CartHooks,
|
|
51
|
+
ECartItemCheckType,
|
|
43
52
|
ECartItemInfoType
|
|
44
53
|
});
|
|
@@ -103,9 +103,9 @@ var createCartItemOrigin = () => {
|
|
|
103
103
|
// 所选结束时间
|
|
104
104
|
end_date: null,
|
|
105
105
|
// 额外信息
|
|
106
|
-
metadata: {}
|
|
106
|
+
metadata: {},
|
|
107
107
|
// holder相关
|
|
108
|
-
|
|
108
|
+
holder: null
|
|
109
109
|
};
|
|
110
110
|
};
|
|
111
111
|
var formatProductToCartItem = (params) => {
|
|
@@ -130,7 +130,6 @@ var formatProductToCartItem = (params) => {
|
|
|
130
130
|
cartItem.isNormalProduct = isNormalProduct(product);
|
|
131
131
|
cartItem.is_charge_tax = product == null ? void 0 : product.is_charge_tax;
|
|
132
132
|
}
|
|
133
|
-
console.log("cartItem>>>>>>", cartItem);
|
|
134
133
|
if (bundle == null ? void 0 : bundle.length) {
|
|
135
134
|
cartItem.bundle = formatBundle(bundle);
|
|
136
135
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all)
|
|
@@ -16,14 +14,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
14
|
}
|
|
17
15
|
return to;
|
|
18
16
|
};
|
|
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
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
18
|
|
|
29
19
|
// src/modules/Date/index.ts
|
|
@@ -32,7 +22,6 @@ __export(Date_exports, {
|
|
|
32
22
|
DateModule: () => DateModule
|
|
33
23
|
});
|
|
34
24
|
module.exports = __toCommonJS(Date_exports);
|
|
35
|
-
var import_dayjs = __toESM(require("dayjs"));
|
|
36
25
|
var import_BaseModule = require("../BaseModule");
|
|
37
26
|
var import_utils = require("./utils");
|
|
38
27
|
var DateModule = class extends import_BaseModule.BaseModule {
|
|
@@ -85,19 +74,16 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
85
74
|
return [];
|
|
86
75
|
}
|
|
87
76
|
let dates = (0, import_utils.generateMonthDates)(start_date, end_date, type);
|
|
88
|
-
if (!(resource_ids == null ? void 0 : resource_ids.length)
|
|
77
|
+
if (!(resource_ids == null ? void 0 : resource_ids.length)) {
|
|
89
78
|
return (0, import_utils.disableAllDates)(dates);
|
|
90
79
|
}
|
|
91
80
|
try {
|
|
92
|
-
const res = await this.request.get(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
front_end_cache_id: this.cacheId
|
|
99
|
-
}
|
|
100
|
-
);
|
|
81
|
+
const res = await this.request.get(fetchUrl, {
|
|
82
|
+
start_date,
|
|
83
|
+
end_date,
|
|
84
|
+
resource_ids,
|
|
85
|
+
front_end_cache_id: this.cacheId
|
|
86
|
+
});
|
|
101
87
|
if (!((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.length)) {
|
|
102
88
|
return (0, import_utils.disableAllDates)(dates);
|
|
103
89
|
}
|
|
@@ -42,7 +42,7 @@ var generateMonthDates = (startDate, endDate, type) => {
|
|
|
42
42
|
const end = (0, import_dayjs.default)(endDate).format("YYYY-MM-DD");
|
|
43
43
|
const dates = [];
|
|
44
44
|
let currentDate = (0, import_dayjs.default)(start);
|
|
45
|
-
while ((0, import_dayjs.default)(currentDate).isBefore((0, import_dayjs.default)(end)) || (0, import_dayjs.default)(currentDate).isSame((0, import_dayjs.default)(end))) {
|
|
45
|
+
while ((0, import_dayjs.default)(currentDate).isBefore((0, import_dayjs.default)(end), "day") || (0, import_dayjs.default)(currentDate).isSame((0, import_dayjs.default)(end), "day")) {
|
|
46
46
|
dates.push({
|
|
47
47
|
date: (0, import_dayjs.default)(currentDate).format("YYYY-MM-DD"),
|
|
48
48
|
week: (0, import_dayjs.default)(currentDate).format("ddd"),
|
|
@@ -59,7 +59,7 @@ var disableAllDates = (dates) => {
|
|
|
59
59
|
var disableDatesBeforeOneDay = (dates, oneDay) => {
|
|
60
60
|
const day = oneDay ? (0, import_dayjs.default)(oneDay).format("YYYY-MM-DD") : (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
61
61
|
return dates.map((date) => {
|
|
62
|
-
if ((0, import_dayjs.default)(date.date).isBefore(day)) {
|
|
62
|
+
if ((0, import_dayjs.default)(date.date).isBefore(day, "day")) {
|
|
63
63
|
return { ...date, status: "unavailable" };
|
|
64
64
|
} else {
|
|
65
65
|
return date;
|
|
@@ -108,10 +108,13 @@ var handleAvailableDatesByRules = (dates, rules) => {
|
|
|
108
108
|
var _a, _b;
|
|
109
109
|
if ((_a = rule == null ? void 0 : rule.schedule) == null ? void 0 : _a.length) {
|
|
110
110
|
for (const item of rule.schedule) {
|
|
111
|
-
if ((0, import_dayjs.default)(item.date).isBefore((0, import_dayjs.default)(newDates[0].date))) {
|
|
111
|
+
if ((0, import_dayjs.default)(item.date).isBefore((0, import_dayjs.default)(newDates[0].date), "day")) {
|
|
112
112
|
continue;
|
|
113
113
|
}
|
|
114
|
-
if ((0, import_dayjs.default)(item.date).isAfter(
|
|
114
|
+
if ((0, import_dayjs.default)(item.date).isAfter(
|
|
115
|
+
(0, import_dayjs.default)(newDates[newDates.length - 1].date),
|
|
116
|
+
"day"
|
|
117
|
+
)) {
|
|
115
118
|
break;
|
|
116
119
|
}
|
|
117
120
|
if (!scheduleMap[item.date]) {
|
|
@@ -126,12 +129,12 @@ var handleAvailableDatesByRules = (dates, rules) => {
|
|
|
126
129
|
const { future_day, unit, unit_type } = (rule == null ? void 0 : rule.cut_off_time) || {};
|
|
127
130
|
if (future_day) {
|
|
128
131
|
const endDate = (0, import_dayjs.default)().add(future_day, "day");
|
|
129
|
-
if (!earliestEndDate || endDate.isBefore((0, import_dayjs.default)(earliestEndDate))) {
|
|
132
|
+
if (!earliestEndDate || endDate.isBefore((0, import_dayjs.default)(earliestEndDate), "day")) {
|
|
130
133
|
earliestEndDate = endDate.format("YYYY-MM-DD");
|
|
131
134
|
}
|
|
132
135
|
} else if (future_day === 0) {
|
|
133
136
|
const endDate = (0, import_dayjs.default)();
|
|
134
|
-
if (!earliestEndDate || endDate.isBefore((0, import_dayjs.default)(earliestEndDate))) {
|
|
137
|
+
if (!earliestEndDate || endDate.isBefore((0, import_dayjs.default)(earliestEndDate), "day")) {
|
|
135
138
|
earliestEndDate = endDate.format("YYYY-MM-DD");
|
|
136
139
|
}
|
|
137
140
|
}
|
|
@@ -139,7 +142,7 @@ var handleAvailableDatesByRules = (dates, rules) => {
|
|
|
139
142
|
const startDate = (0, import_dayjs.default)(
|
|
140
143
|
(0, import_dayjs.default)().add(unit, unit_type).format("YYYY-MM-DD")
|
|
141
144
|
);
|
|
142
|
-
if (!latestStartDate || startDate.isAfter((0, import_dayjs.default)(latestStartDate))) {
|
|
145
|
+
if (!latestStartDate || startDate.isAfter((0, import_dayjs.default)(latestStartDate), "day")) {
|
|
143
146
|
latestStartDate = startDate.format("YYYY-MM-DD");
|
|
144
147
|
}
|
|
145
148
|
}
|
|
@@ -165,10 +168,10 @@ var handleAvailableDatesByRules = (dates, rules) => {
|
|
|
165
168
|
return disabledDate;
|
|
166
169
|
}
|
|
167
170
|
if (latestStartDate || earliestEndDate) {
|
|
168
|
-
if (latestStartDate && (0, import_dayjs.default)(date.date).isBefore(latestStartDate)) {
|
|
171
|
+
if (latestStartDate && (0, import_dayjs.default)(date.date).isBefore(latestStartDate, "day")) {
|
|
169
172
|
return disabledDate;
|
|
170
173
|
}
|
|
171
|
-
if (earliestEndDate && (0, import_dayjs.default)(date.date).isAfter(earliestEndDate)) {
|
|
174
|
+
if (earliestEndDate && (0, import_dayjs.default)(date.date).isAfter(earliestEndDate, "day")) {
|
|
172
175
|
return disabledDate;
|
|
173
176
|
}
|
|
174
177
|
}
|
|
@@ -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, ProductResourceItem, ECartItemInfoType } from '../../modules';
|
|
5
|
+
import { CartItem, IUpdateItemParams, ProductData, ProductResourceItem, ECartItemInfoType, ECartItemCheckType } 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';
|
|
@@ -131,6 +131,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
131
131
|
* 从购物车中按类别删除信息
|
|
132
132
|
*/
|
|
133
133
|
deleteCartItemInfo(type: ECartItemInfoType, _id?: string): void;
|
|
134
|
+
checkCartItemByType(cartItem: CartItem, type: ECartItemCheckType): boolean;
|
|
134
135
|
destroy(): void;
|
|
135
136
|
getResourcesList(): any[];
|
|
136
137
|
getResourcesListByCartItem(id: string | number): {
|
|
@@ -210,12 +210,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
210
210
|
custom_page_id
|
|
211
211
|
}) {
|
|
212
212
|
var _a;
|
|
213
|
-
if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)())) {
|
|
213
|
+
if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)(), "day")) {
|
|
214
214
|
startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
215
215
|
}
|
|
216
216
|
let dates = (0, import_utils3.generateMonthDates)(startDate, endDate);
|
|
217
217
|
dates = (0, import_utils3.disableAllDates)(dates);
|
|
218
|
-
if ((0, import_dayjs.default)(endDate).isBefore((0, import_dayjs.default)())) {
|
|
218
|
+
if ((0, import_dayjs.default)(endDate).isBefore((0, import_dayjs.default)(), "day")) {
|
|
219
219
|
return dates;
|
|
220
220
|
}
|
|
221
221
|
const res = await this.request.get(
|
|
@@ -227,7 +227,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
227
227
|
}
|
|
228
228
|
);
|
|
229
229
|
this.store.schedule.setAvailabilityScheduleDateList(res.data.date_list);
|
|
230
|
-
if (!((_a = res.data.date_list) == null ? void 0 : _a.length) || (0, import_dayjs.default)(endDate).isBefore((0, import_dayjs.default)())) {
|
|
230
|
+
if (!((_a = res.data.date_list) == null ? void 0 : _a.length) || (0, import_dayjs.default)(endDate).isBefore((0, import_dayjs.default)(), "day")) {
|
|
231
231
|
return dates;
|
|
232
232
|
}
|
|
233
233
|
res.data.date_list.forEach((n) => {
|
|
@@ -334,7 +334,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
334
334
|
// 获取商品/服务的可用日期
|
|
335
335
|
async getAvailableDate(params = {}) {
|
|
336
336
|
let { products, startDate, endDate, type } = params;
|
|
337
|
-
if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)()) && ((0, import_dayjs.default)(endDate).isAfter((0, import_dayjs.default)()) || (0, import_dayjs.default)(endDate).isSame((0, import_dayjs.default)()))) {
|
|
337
|
+
if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)(), "day") && ((0, import_dayjs.default)(endDate).isAfter((0, import_dayjs.default)(), "day") || (0, import_dayjs.default)(endDate).isSame((0, import_dayjs.default)(), "day"))) {
|
|
338
338
|
startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
339
339
|
}
|
|
340
340
|
let tempProducts = products || this.store.cart.getItems().map((p) => p._productOrigin);
|
|
@@ -436,7 +436,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
436
436
|
const cartItems = this.store.cart.getItems();
|
|
437
437
|
const newCartItems = (0, import_lodash_es.cloneDeep)(cartItems);
|
|
438
438
|
newCartItems.forEach((item) => {
|
|
439
|
-
var _a;
|
|
439
|
+
var _a, _b;
|
|
440
440
|
item._origin.resources = item._origin.resources.map((n) => {
|
|
441
441
|
const newResourcesItem = (0, import_lodash_es.cloneDeep)(n);
|
|
442
442
|
delete newResourcesItem.id;
|
|
@@ -449,6 +449,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
449
449
|
product_bundle: item._origin.product.product_bundle
|
|
450
450
|
});
|
|
451
451
|
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
452
|
+
if (!((_b = item._origin) == null ? void 0 : _b.metadata)) {
|
|
453
|
+
item._origin.metadata = {};
|
|
454
|
+
}
|
|
452
455
|
item._origin.metadata.capacity = formatCapacity;
|
|
453
456
|
item._origin.number = currentCapacity;
|
|
454
457
|
});
|
|
@@ -542,6 +545,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
542
545
|
deleteCartItemInfo(type, _id) {
|
|
543
546
|
this.store.cart.deleteCartItemInfo(type, _id);
|
|
544
547
|
}
|
|
548
|
+
checkCartItemByType(cartItem, type) {
|
|
549
|
+
return this.store.cart.checkCartItemByType(cartItem, type);
|
|
550
|
+
}
|
|
545
551
|
destroy() {
|
|
546
552
|
var _a, _b, _c, _d, _e, _f;
|
|
547
553
|
(_a = this.store.cart) == null ? void 0 : _a.destroy();
|
|
@@ -571,7 +577,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
571
577
|
});
|
|
572
578
|
}
|
|
573
579
|
const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
|
|
574
|
-
const cartItems =
|
|
580
|
+
const cartItems = this.store.cart.getItems();
|
|
575
581
|
const arr = [];
|
|
576
582
|
const capacityMap = {};
|
|
577
583
|
cartItems.forEach((cartItem) => {
|
|
@@ -1019,17 +1025,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1019
1025
|
// 提交时间切片,绑定到对应购物车的商品上,更新购物车
|
|
1020
1026
|
submitTimeSlot(timeSlots) {
|
|
1021
1027
|
const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
1022
|
-
const itemsByAccount = cartItems.reduce(
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
},
|
|
1031
|
-
{}
|
|
1032
|
-
);
|
|
1028
|
+
const itemsByAccount = cartItems.reduce((acc, item) => {
|
|
1029
|
+
const holderId = item.holder_id;
|
|
1030
|
+
if (!acc[holderId]) {
|
|
1031
|
+
acc[holderId] = [];
|
|
1032
|
+
}
|
|
1033
|
+
acc[holderId].push(item);
|
|
1034
|
+
return acc;
|
|
1035
|
+
}, {});
|
|
1033
1036
|
Object.values(itemsByAccount).forEach((accountItems) => {
|
|
1034
1037
|
let currentStartTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
1035
1038
|
accountItems.forEach((item, index) => {
|