@pisell/pisellos 3.0.32 → 3.0.33
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/Date/index.d.ts +2 -0
- package/dist/modules/Date/index.js +70 -34
- package/dist/modules/Rules/index.js +1 -1
- package/dist/modules/Schedule/types.d.ts +1 -0
- package/dist/solution/BookingByStep/index.d.ts +26 -5
- package/dist/solution/BookingByStep/index.js +358 -27
- package/dist/solution/BookingByStep/utils/resources.d.ts +40 -3
- package/dist/solution/BookingByStep/utils/resources.js +100 -1
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +25 -0
- package/dist/solution/BookingByStep/utils/timeslots.js +209 -0
- package/lib/modules/Date/index.d.ts +2 -0
- package/lib/modules/Date/index.js +23 -10
- package/lib/modules/Rules/index.js +2 -2
- package/lib/modules/Schedule/types.d.ts +1 -0
- package/lib/solution/BookingByStep/index.d.ts +26 -5
- package/lib/solution/BookingByStep/index.js +280 -34
- package/lib/solution/BookingByStep/utils/resources.d.ts +40 -3
- package/lib/solution/BookingByStep/utils/resources.js +73 -2
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +25 -0
- package/lib/solution/BookingByStep/utils/timeslots.js +159 -0
- package/package.json +1 -1
|
@@ -15,6 +15,8 @@ export declare class DateModule extends BaseModule implements Module, DateModule
|
|
|
15
15
|
getDateRange(): ITime[];
|
|
16
16
|
getResourceDates(params: IGetAvailableTimeListParams): Promise<ITime[]>;
|
|
17
17
|
getDateList(): ITime[];
|
|
18
|
+
setDateList(dateList: ITime[]): void;
|
|
19
|
+
fetchResourceDates(params: IGetAvailableTimeListParams): Promise<any>;
|
|
18
20
|
getResourceAvailableTimeList(params: IGetAvailableTimeListParams): Promise<ITime[]>;
|
|
19
21
|
clearDateRange(): void;
|
|
20
22
|
storeChange(): void;
|
|
@@ -113,32 +113,23 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
113
113
|
return this.store.dateList;
|
|
114
114
|
}
|
|
115
115
|
}, {
|
|
116
|
-
key: "
|
|
116
|
+
key: "setDateList",
|
|
117
|
+
value: function setDateList(dateList) {
|
|
118
|
+
this.store.dateList = dateList;
|
|
119
|
+
}
|
|
120
|
+
}, {
|
|
121
|
+
key: "fetchResourceDates",
|
|
117
122
|
value: function () {
|
|
118
|
-
var
|
|
119
|
-
var url, query,
|
|
123
|
+
var _fetchResourceDates = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
124
|
+
var url, query, fetchUrl, _ref, start_date, end_date, resource_ids, res;
|
|
120
125
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
121
126
|
while (1) switch (_context3.prev = _context3.next) {
|
|
122
127
|
case 0:
|
|
123
|
-
url = params.url, query = params.query
|
|
128
|
+
url = params.url, query = params.query;
|
|
124
129
|
fetchUrl = url || '/schedule/resource/list';
|
|
125
130
|
_ref = query || {}, start_date = _ref.start_date, end_date = _ref.end_date, resource_ids = _ref.resource_ids;
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
break;
|
|
129
|
-
}
|
|
130
|
-
return _context3.abrupt("return", []);
|
|
131
|
-
case 5:
|
|
132
|
-
// 1.生成当前月份的所有日期,默认都是可用的
|
|
133
|
-
dates = generateMonthDates(start_date, end_date, type); // 如果没有资源或者结束日期在今天之前,则所有日期均不可用
|
|
134
|
-
if (resource_ids !== null && resource_ids !== void 0 && resource_ids.length) {
|
|
135
|
-
_context3.next = 8;
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
return _context3.abrupt("return", disableAllDates(dates));
|
|
139
|
-
case 8:
|
|
140
|
-
_context3.prev = 8;
|
|
141
|
-
_context3.next = 11;
|
|
131
|
+
_context3.prev = 3;
|
|
132
|
+
_context3.next = 6;
|
|
142
133
|
return this.request.get(fetchUrl, {
|
|
143
134
|
start_date: start_date,
|
|
144
135
|
end_date: end_date,
|
|
@@ -147,14 +138,59 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
147
138
|
}, {
|
|
148
139
|
useCache: true
|
|
149
140
|
});
|
|
150
|
-
case
|
|
141
|
+
case 6:
|
|
151
142
|
res = _context3.sent;
|
|
143
|
+
return _context3.abrupt("return", res);
|
|
144
|
+
case 10:
|
|
145
|
+
_context3.prev = 10;
|
|
146
|
+
_context3.t0 = _context3["catch"](3);
|
|
147
|
+
console.error(_context3.t0);
|
|
148
|
+
case 13:
|
|
149
|
+
case "end":
|
|
150
|
+
return _context3.stop();
|
|
151
|
+
}
|
|
152
|
+
}, _callee3, this, [[3, 10]]);
|
|
153
|
+
}));
|
|
154
|
+
function fetchResourceDates(_x4) {
|
|
155
|
+
return _fetchResourceDates.apply(this, arguments);
|
|
156
|
+
}
|
|
157
|
+
return fetchResourceDates;
|
|
158
|
+
}()
|
|
159
|
+
}, {
|
|
160
|
+
key: "getResourceAvailableTimeList",
|
|
161
|
+
value: function () {
|
|
162
|
+
var _getResourceAvailableTimeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
|
|
163
|
+
var query, rules, type, _ref2, start_date, end_date, resource_ids, dates, _res$data, res;
|
|
164
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
165
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
166
|
+
case 0:
|
|
167
|
+
query = params.query, rules = params.rules, type = params.type;
|
|
168
|
+
_ref2 = query || {}, start_date = _ref2.start_date, end_date = _ref2.end_date, resource_ids = _ref2.resource_ids;
|
|
169
|
+
if (!(!start_date || !end_date)) {
|
|
170
|
+
_context4.next = 4;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
return _context4.abrupt("return", []);
|
|
174
|
+
case 4:
|
|
175
|
+
// 1.生成当前月份的所有日期,默认都是可用的
|
|
176
|
+
dates = generateMonthDates(start_date, end_date, type); // 如果没有资源或者结束日期在今天之前,则所有日期均不可用
|
|
177
|
+
if (resource_ids !== null && resource_ids !== void 0 && resource_ids.length) {
|
|
178
|
+
_context4.next = 7;
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
return _context4.abrupt("return", disableAllDates(dates));
|
|
182
|
+
case 7:
|
|
183
|
+
_context4.prev = 7;
|
|
184
|
+
_context4.next = 10;
|
|
185
|
+
return this.fetchResourceDates(params);
|
|
186
|
+
case 10:
|
|
187
|
+
res = _context4.sent;
|
|
152
188
|
if (res !== null && res !== void 0 && (_res$data = res.data) !== null && _res$data !== void 0 && _res$data.length) {
|
|
153
|
-
|
|
189
|
+
_context4.next = 13;
|
|
154
190
|
break;
|
|
155
191
|
}
|
|
156
|
-
return
|
|
157
|
-
case
|
|
192
|
+
return _context4.abrupt("return", disableAllDates(dates));
|
|
193
|
+
case 13:
|
|
158
194
|
// 2.根据资源times判定哪些日期内存在可用资源
|
|
159
195
|
dates = handleAvailableDateByResource(res.data, dates);
|
|
160
196
|
|
|
@@ -162,19 +198,19 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
162
198
|
if (rules !== null && rules !== void 0 && rules.length) {
|
|
163
199
|
dates = handleAvailableDatesByRules(dates, rules);
|
|
164
200
|
}
|
|
165
|
-
return
|
|
166
|
-
case
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
console.log('getAvailableTimeList_error',
|
|
170
|
-
return
|
|
171
|
-
case
|
|
201
|
+
return _context4.abrupt("return", dates);
|
|
202
|
+
case 18:
|
|
203
|
+
_context4.prev = 18;
|
|
204
|
+
_context4.t0 = _context4["catch"](7);
|
|
205
|
+
console.log('getAvailableTimeList_error', _context4.t0);
|
|
206
|
+
return _context4.abrupt("return", disableAllDates(dates));
|
|
207
|
+
case 22:
|
|
172
208
|
case "end":
|
|
173
|
-
return
|
|
209
|
+
return _context4.stop();
|
|
174
210
|
}
|
|
175
|
-
},
|
|
211
|
+
}, _callee4, this, [[7, 18]]);
|
|
176
212
|
}));
|
|
177
|
-
function getResourceAvailableTimeList(
|
|
213
|
+
function getResourceAvailableTimeList(_x5) {
|
|
178
214
|
return _getResourceAvailableTimeList.apply(this, arguments);
|
|
179
215
|
}
|
|
180
216
|
return getResourceAvailableTimeList;
|
|
@@ -107,7 +107,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
// 合并新旧折扣列表,并计算折扣结果
|
|
110
|
-
var mergedDiscountList = uniqueById([].concat(_toConsumableArray(oldDiscountList), _toConsumableArray(newDiscountList)));
|
|
110
|
+
var mergedDiscountList = uniqueById(uniqueById([].concat(_toConsumableArray(oldDiscountList), _toConsumableArray(newDiscountList))), 'product_id');
|
|
111
111
|
var result = this.calcDiscount({
|
|
112
112
|
discountList: mergedDiscountList,
|
|
113
113
|
productList: _toConsumableArray(productList)
|
|
@@ -5,7 +5,7 @@ import { BookingByStepState } from './types';
|
|
|
5
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
|
-
import { TimeSliceItem } from './utils/resources';
|
|
8
|
+
import { TimeSliceItem, ResourceItem } from './utils/resources';
|
|
9
9
|
import { ITime } from '../../modules/Date/types';
|
|
10
10
|
import dayjs from 'dayjs';
|
|
11
11
|
import { IHolder, IFetchHolderAccountsParams } from '../../modules/AccountList/types';
|
|
@@ -153,7 +153,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
153
153
|
id: number | undefined;
|
|
154
154
|
_id: string;
|
|
155
155
|
product: ProductData | undefined;
|
|
156
|
-
resources:
|
|
156
|
+
resources: ResourceItem[];
|
|
157
157
|
holder_id: string | number | undefined;
|
|
158
158
|
holder_name: string | undefined;
|
|
159
159
|
} | undefined;
|
|
@@ -189,7 +189,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
189
189
|
private getScheduleDataByIds;
|
|
190
190
|
openProductDetail(productId: number): Promise<void>;
|
|
191
191
|
closeProductDetail(): void;
|
|
192
|
-
getTimeslotBySchedule({ date, scheduleIds, resources, product }: {
|
|
192
|
+
getTimeslotBySchedule({ date, scheduleIds, resources, product, }: {
|
|
193
193
|
date: string;
|
|
194
194
|
scheduleIds?: number[];
|
|
195
195
|
resources?: ProductResourceItem[];
|
|
@@ -211,7 +211,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
211
211
|
}): void;
|
|
212
212
|
setOtherData(key: string, value: any): void;
|
|
213
213
|
getOtherData(key: string): any;
|
|
214
|
-
getProductTypeById(id: number): Promise<"
|
|
214
|
+
getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
|
|
215
215
|
/**
|
|
216
216
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
217
217
|
*
|
|
@@ -221,9 +221,30 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
221
221
|
* @memberof BookingByStepImpl
|
|
222
222
|
*/
|
|
223
223
|
getResourcesByCartItemAndCode(cartItemId: string, resourceCode: string): any;
|
|
224
|
+
/**
|
|
225
|
+
* 根据日期范围批量获取时间槽
|
|
226
|
+
* @param params 参数对象
|
|
227
|
+
* @returns Promise<Record<string, TimeSliceItem[]>> 返回日期到时间槽的映射
|
|
228
|
+
*/
|
|
229
|
+
getTimeslotsScheduleByDateRange({ startDate, endDate, scheduleIds, resources, }: {
|
|
230
|
+
startDate: string;
|
|
231
|
+
endDate: string;
|
|
232
|
+
scheduleIds?: number[];
|
|
233
|
+
resources?: ProductResourceItem[];
|
|
234
|
+
}): Promise<Record<string, TimeSliceItem[]>>;
|
|
224
235
|
getAvailableDateForSession(params?: {
|
|
225
236
|
startDate?: string;
|
|
226
237
|
endDate?: string;
|
|
227
238
|
type?: 'month';
|
|
228
|
-
}): Promise<
|
|
239
|
+
}): Promise<{
|
|
240
|
+
dateList: ITime[];
|
|
241
|
+
firstAvailableDate: ITime | undefined;
|
|
242
|
+
}>;
|
|
243
|
+
getAvailableDateForSessionOptimize(params?: {
|
|
244
|
+
startDate?: string;
|
|
245
|
+
endDate?: string;
|
|
246
|
+
}): Promise<{
|
|
247
|
+
dateList: any;
|
|
248
|
+
firstAvailableDate: any;
|
|
249
|
+
}>;
|
|
229
250
|
}
|