@pisell/pisellos 0.0.43 → 0.0.45
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/Account/index.d.ts +2 -6
- package/dist/modules/Account/index.js +21 -103
- package/dist/modules/Account/types.d.ts +12 -1
- package/dist/modules/AccountList/index.d.ts +19 -0
- package/dist/modules/AccountList/index.js +224 -70
- package/dist/modules/AccountList/types.d.ts +33 -1
- package/dist/modules/AccountList/types.js +8 -0
- package/dist/modules/AccountList/utils.d.ts +9 -0
- package/dist/modules/AccountList/utils.js +25 -0
- package/dist/modules/BaseModule.d.ts +2 -2
- package/dist/modules/BaseModule.js +1 -1
- package/dist/modules/Cart/index.d.ts +5 -5
- package/dist/modules/Cart/index.js +32 -19
- package/dist/modules/Cart/types.d.ts +18 -4
- package/dist/modules/Cart/utils.d.ts +29 -5
- package/dist/modules/Cart/utils.js +72 -26
- package/dist/modules/Date/index.d.ts +6 -6
- package/dist/modules/Date/index.js +41 -55
- package/dist/modules/Date/types.d.ts +22 -6
- package/dist/modules/Date/utils.d.ts +4 -3
- package/dist/modules/Date/utils.js +74 -23
- package/dist/modules/Discount/index.d.ts +4 -4
- package/dist/modules/Discount/index.js +11 -11
- package/dist/modules/Order/index.d.ts +11 -5
- package/dist/modules/Order/index.js +39 -18
- package/dist/modules/Order/types.d.ts +10 -3
- package/dist/modules/Product/index.d.ts +4 -1
- package/dist/modules/Product/index.js +22 -0
- package/dist/modules/Product/types.d.ts +7 -3
- package/dist/modules/ProductList/index.js +11 -5
- package/dist/modules/Resource/utils.js +1 -1
- package/dist/modules/Rules/index.d.ts +4 -4
- package/dist/modules/Rules/index.js +11 -11
- package/dist/modules/Rules/types.d.ts +1 -1
- package/dist/modules/Schedule/index.d.ts +8 -3
- package/dist/modules/Schedule/index.js +45 -5
- package/dist/modules/Schedule/type.d.ts +7 -7
- package/dist/modules/Schedule/types.d.ts +8 -8
- package/dist/modules/Schedule/utils.d.ts +9 -3
- package/dist/modules/Schedule/utils.js +77 -48
- package/dist/modules/Step/index.d.ts +14 -3
- package/dist/modules/Step/index.js +54 -2
- package/dist/modules/Summary/index.d.ts +5 -5
- package/dist/modules/Summary/index.js +7 -7
- package/dist/modules/Summary/types.d.ts +2 -2
- package/dist/modules/Summary/utils.d.ts +4 -4
- package/dist/modules/Summary/utils.js +3 -3
- package/dist/plugins/index.d.ts +3 -3
- package/dist/plugins/request.d.ts +3 -3
- package/dist/plugins/request.js +30 -30
- package/dist/plugins/shopStore.d.ts +1 -1
- package/dist/solution/BookingByStep/index.d.ts +65 -16
- package/dist/solution/BookingByStep/index.js +553 -216
- package/dist/solution/BookingByStep/types.d.ts +2 -2
- package/dist/solution/BookingByStep/types.js +9 -9
- package/dist/solution/BookingByStep/utils/products.d.ts +1 -1
- package/dist/solution/BookingByStep/utils/products.js +3 -0
- package/dist/solution/BookingByStep/utils/resources.d.ts +5 -5
- package/dist/solution/BookingByStep/utils/resources.js +11 -11
- package/dist/solution/ShopDiscount/index.d.ts +4 -4
- package/dist/solution/ShopDiscount/index.js +16 -16
- package/dist/solution/ShopDiscount/types.d.ts +2 -2
- package/dist/solution/ShopDiscount/utils.js +1 -1
- package/lib/core/index.js +7 -2
- package/lib/modules/Account/index.d.ts +2 -6
- package/lib/modules/Account/index.js +15 -30
- package/lib/modules/Account/types.d.ts +12 -1
- package/lib/modules/AccountList/index.d.ts +19 -0
- package/lib/modules/AccountList/index.js +109 -12
- package/lib/modules/AccountList/types.d.ts +33 -1
- package/lib/modules/AccountList/utils.d.ts +9 -0
- package/lib/modules/AccountList/utils.js +39 -0
- package/lib/modules/BaseModule.d.ts +2 -2
- package/lib/modules/BaseModule.js +14 -3
- package/lib/modules/Cart/index.d.ts +5 -5
- package/lib/modules/Cart/index.js +27 -6
- package/lib/modules/Cart/types.d.ts +18 -4
- package/lib/modules/Cart/utils.d.ts +29 -5
- package/lib/modules/Cart/utils.js +47 -3
- package/lib/modules/Date/index.d.ts +6 -6
- package/lib/modules/Date/index.js +6 -6
- package/lib/modules/Date/types.d.ts +22 -6
- package/lib/modules/Date/utils.d.ts +4 -3
- package/lib/modules/Date/utils.js +37 -6
- package/lib/modules/Discount/index.d.ts +4 -4
- package/lib/modules/Discount/index.js +9 -2
- package/lib/modules/Guests/index.js +4 -1
- package/lib/modules/Order/index.d.ts +11 -5
- package/lib/modules/Order/index.js +18 -3
- package/lib/modules/Order/types.d.ts +10 -3
- package/lib/modules/Payment/index.js +1 -6
- package/lib/modules/Product/index.d.ts +4 -1
- package/lib/modules/Product/index.js +16 -0
- package/lib/modules/Product/types.d.ts +7 -3
- package/lib/modules/ProductList/index.js +21 -7
- package/lib/modules/Resource/index.js +4 -1
- package/lib/modules/Resource/utils.js +7 -4
- package/lib/modules/Rules/index.d.ts +4 -4
- package/lib/modules/Rules/types.d.ts +1 -1
- package/lib/modules/Schedule/index.d.ts +8 -3
- package/lib/modules/Schedule/index.js +33 -2
- package/lib/modules/Schedule/type.d.ts +7 -7
- package/lib/modules/Schedule/types.d.ts +8 -8
- package/lib/modules/Schedule/utils.d.ts +9 -3
- package/lib/modules/Schedule/utils.js +32 -4
- package/lib/modules/Step/index.d.ts +14 -3
- package/lib/modules/Step/index.js +38 -1
- package/lib/modules/Summary/index.d.ts +5 -5
- package/lib/modules/Summary/types.d.ts +2 -2
- package/lib/modules/Summary/utils.d.ts +4 -4
- package/lib/plugins/index.d.ts +3 -3
- package/lib/plugins/request.d.ts +3 -3
- package/lib/plugins/request.js +48 -11
- package/lib/plugins/shopStore.d.ts +1 -1
- package/lib/solution/BookingByStep/index.d.ts +65 -16
- package/lib/solution/BookingByStep/index.js +351 -39
- package/lib/solution/BookingByStep/types.d.ts +2 -2
- package/lib/solution/BookingByStep/types.js +36 -9
- package/lib/solution/BookingByStep/utils/products.d.ts +1 -1
- package/lib/solution/BookingByStep/utils/products.js +3 -0
- package/lib/solution/BookingByStep/utils/resources.d.ts +5 -5
- package/lib/solution/BookingByStep/utils/resources.js +103 -52
- package/lib/solution/BuyTickets/index.js +34 -20
- package/lib/solution/ShopDiscount/index.d.ts +4 -4
- package/lib/solution/ShopDiscount/index.js +10 -2
- package/lib/solution/ShopDiscount/types.d.ts +2 -2
- package/package.json +4 -2
|
@@ -28,9 +28,11 @@ import { BaseModule } from "../../modules/BaseModule";
|
|
|
28
28
|
import { BookingByStepHooks, createModule } from "./types";
|
|
29
29
|
import { getAvailableProductResources } from "./utils/products";
|
|
30
30
|
import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem, getOthersSelectedResources, formatDefaultCapacitys, getSumCapacity, checkSubResourcesCapacity } from "./utils/resources";
|
|
31
|
-
import dayjs from
|
|
31
|
+
import dayjs from 'dayjs';
|
|
32
32
|
import { getResourcesMap } from "../../modules/Resource/utils";
|
|
33
|
-
import { cloneDeep } from
|
|
33
|
+
import { cloneDeep } from 'lodash-es';
|
|
34
|
+
import { calcCalendarDataByScheduleResult, calcMinTimeMaxTimeBySchedules, getAllSortedDateRanges } from "../../modules/Schedule/utils";
|
|
35
|
+
import { disableAllDates, disableDatesBeforeOneDay, generateMonthDates } from "../../modules/Date/utils";
|
|
34
36
|
export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
35
37
|
_inherits(BookingByStepImpl, _BaseModule);
|
|
36
38
|
var _super = _createSuper(BookingByStepImpl);
|
|
@@ -41,8 +43,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
41
43
|
args[_key] = arguments[_key];
|
|
42
44
|
}
|
|
43
45
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
44
|
-
_defineProperty(_assertThisInitialized(_this), "defaultName",
|
|
45
|
-
_defineProperty(_assertThisInitialized(_this), "defaultVersion",
|
|
46
|
+
_defineProperty(_assertThisInitialized(_this), "defaultName", 'bookingByStep');
|
|
47
|
+
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
46
48
|
_defineProperty(_assertThisInitialized(_this), "isSolution", true);
|
|
47
49
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
48
50
|
_defineProperty(_assertThisInitialized(_this), "window", void 0);
|
|
@@ -50,32 +52,34 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
50
52
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
51
53
|
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
52
54
|
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
55
|
+
_defineProperty(_assertThisInitialized(_this), "otherData", {});
|
|
53
56
|
return _this;
|
|
54
57
|
}
|
|
55
58
|
_createClass(BookingByStepImpl, [{
|
|
56
59
|
key: "initialize",
|
|
57
|
-
value:
|
|
60
|
+
value: // 提供给 UI 层的临时数据存储,会进缓存
|
|
61
|
+
function () {
|
|
58
62
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
59
63
|
var _this$otherParams,
|
|
60
64
|
_this$otherParams2,
|
|
61
65
|
_this2 = this;
|
|
62
|
-
var targetCacheData, sessionData, data, moduleArr;
|
|
66
|
+
var targetCacheData, sessionData, _data$this$otherParam, data, moduleArr;
|
|
63
67
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
64
68
|
while (1) switch (_context.prev = _context.next) {
|
|
65
69
|
case 0:
|
|
66
70
|
this.core = core;
|
|
67
71
|
this.store = options.store || {};
|
|
68
72
|
this.otherParams = options.otherParams || {};
|
|
69
|
-
console.log(
|
|
73
|
+
console.log('[BookingByStep] 初始化完成');
|
|
70
74
|
// 获取依赖的插件
|
|
71
|
-
this.request = core.getPlugin(
|
|
72
|
-
this.window = core.getPlugin(
|
|
73
|
-
this.shopStore = core.getPlugin(
|
|
75
|
+
this.request = core.getPlugin('request');
|
|
76
|
+
this.window = core.getPlugin('window');
|
|
77
|
+
this.shopStore = core.getPlugin('shopStore');
|
|
74
78
|
if (this.request) {
|
|
75
79
|
_context.next = 9;
|
|
76
80
|
break;
|
|
77
81
|
}
|
|
78
|
-
throw new Error(
|
|
82
|
+
throw new Error('bookingByStep解决方案需要 request 插件支持');
|
|
79
83
|
case 9:
|
|
80
84
|
// 如果有传 cacheid,默认需要收集上面这些模块里用户操作选中的数据
|
|
81
85
|
// 并且在上面 registerModule 的时候,读取 sessionStroage 里的数据,塞进默认值
|
|
@@ -87,9 +91,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
87
91
|
data = JSON.parse(sessionData); // 匹配 cacheid,如果匹配不到,直接把 sessionData 清掉即可
|
|
88
92
|
// 如果匹配到了,则把 sessionData 里的数据按模块塞到 store 里去
|
|
89
93
|
targetCacheData = data[this.otherParams.cacheId];
|
|
94
|
+
this.otherData = ((_data$this$otherParam = data[this.otherParams.cacheId]) === null || _data$this$otherParam === void 0 || (_data$this$otherParam = _data$this$otherParam[this.name]) === null || _data$this$otherParam === void 0 ? void 0 : _data$this$otherParam['otherData']) || {};
|
|
90
95
|
}
|
|
91
96
|
}
|
|
92
|
-
moduleArr = [
|
|
97
|
+
moduleArr = ['accountList', 'cart', 'schedule', 'summary', 'step', 'products', 'date', 'order', 'payment'];
|
|
93
98
|
moduleArr.forEach(function (step) {
|
|
94
99
|
var targetModule = createModule(step, _this2.name);
|
|
95
100
|
if (targetModule) {
|
|
@@ -161,6 +166,23 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
161
166
|
return this.store.step.getStepList();
|
|
162
167
|
}
|
|
163
168
|
|
|
169
|
+
/**
|
|
170
|
+
* 添加step
|
|
171
|
+
*/
|
|
172
|
+
}, {
|
|
173
|
+
key: "addStep",
|
|
174
|
+
value: function addStep(step, key) {
|
|
175
|
+
this.store.step.addStep(step, key);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* 删除step
|
|
180
|
+
*/
|
|
181
|
+
}, {
|
|
182
|
+
key: "removeStep",
|
|
183
|
+
value: function removeStep(key) {
|
|
184
|
+
this.store.step.removeStep(key);
|
|
185
|
+
}
|
|
164
186
|
// 获取购物车里 temp.xxx的方法
|
|
165
187
|
// async getStoreCart(key?: string) {
|
|
166
188
|
// return this.store.cart.getTemp(key);
|
|
@@ -180,9 +202,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
180
202
|
return this.request.post("/product/query", {
|
|
181
203
|
open_quotation: 1,
|
|
182
204
|
open_bundle: 1,
|
|
183
|
-
extension_type: [
|
|
184
|
-
with: [
|
|
185
|
-
status:
|
|
205
|
+
extension_type: ['product_appointment', 'appointment_ticket', 'session_product', 'session_ticket'],
|
|
206
|
+
with: ['category', 'collection', 'resourceRelation'],
|
|
207
|
+
status: 'published',
|
|
186
208
|
num: 500,
|
|
187
209
|
skip: 1,
|
|
188
210
|
category_ids: category_ids,
|
|
@@ -210,37 +232,55 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
210
232
|
}()
|
|
211
233
|
}, {
|
|
212
234
|
key: "loadProductByScheduleDate",
|
|
213
|
-
value: function
|
|
214
|
-
var
|
|
215
|
-
|
|
216
|
-
return
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
235
|
+
value: function () {
|
|
236
|
+
var _loadProductByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(date) {
|
|
237
|
+
var scheduleList, scheduleIds;
|
|
238
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
239
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
240
|
+
case 0:
|
|
241
|
+
scheduleList = this.store.schedule.getAvailabilityScheduleDateList();
|
|
242
|
+
scheduleIds = scheduleList.filter(function (n) {
|
|
243
|
+
return n.date === date;
|
|
244
|
+
}).flatMap(function (n) {
|
|
245
|
+
return n.schedule_id;
|
|
246
|
+
}); // 换了日期就清空购物车,不能购物车里的商品不在同一天
|
|
247
|
+
this.store.cart.clear();
|
|
248
|
+
_context3.next = 5;
|
|
249
|
+
return this.loadProducts({
|
|
250
|
+
schedule_ids: scheduleIds
|
|
251
|
+
});
|
|
252
|
+
case 5:
|
|
253
|
+
return _context3.abrupt("return", _context3.sent);
|
|
254
|
+
case 6:
|
|
255
|
+
case "end":
|
|
256
|
+
return _context3.stop();
|
|
257
|
+
}
|
|
258
|
+
}, _callee3, this);
|
|
259
|
+
}));
|
|
260
|
+
function loadProductByScheduleDate(_x4) {
|
|
261
|
+
return _loadProductByScheduleDate.apply(this, arguments);
|
|
262
|
+
}
|
|
263
|
+
return loadProductByScheduleDate;
|
|
264
|
+
}() // 加载当前店铺下所有 schedule
|
|
226
265
|
}, {
|
|
227
266
|
key: "loadAllSchedule",
|
|
228
267
|
value: function () {
|
|
229
|
-
var _loadAllSchedule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
268
|
+
var _loadAllSchedule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
269
|
+
var _scheduleList$data;
|
|
230
270
|
var scheduleList;
|
|
231
|
-
return _regeneratorRuntime().wrap(function
|
|
232
|
-
while (1) switch (
|
|
271
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
272
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
233
273
|
case 0:
|
|
234
|
-
|
|
274
|
+
_context4.next = 2;
|
|
235
275
|
return this.request.get("/schedule");
|
|
236
276
|
case 2:
|
|
237
|
-
scheduleList =
|
|
238
|
-
this.store.schedule.setScheduleList(scheduleList.data);
|
|
277
|
+
scheduleList = _context4.sent;
|
|
278
|
+
this.store.schedule.setScheduleList(((_scheduleList$data = scheduleList.data) === null || _scheduleList$data === void 0 ? void 0 : _scheduleList$data.list) || []);
|
|
239
279
|
case 4:
|
|
240
280
|
case "end":
|
|
241
|
-
return
|
|
281
|
+
return _context4.stop();
|
|
242
282
|
}
|
|
243
|
-
},
|
|
283
|
+
}, _callee4, this);
|
|
244
284
|
}));
|
|
245
285
|
function loadAllSchedule() {
|
|
246
286
|
return _loadAllSchedule.apply(this, arguments);
|
|
@@ -248,49 +288,83 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
248
288
|
return loadAllSchedule;
|
|
249
289
|
}() // ui 层提供日期的起始范围,返回一个起始范围内日期的可用情况
|
|
250
290
|
}, {
|
|
251
|
-
key: "
|
|
291
|
+
key: "loadScheduleAvailableDate",
|
|
252
292
|
value: function () {
|
|
253
|
-
var
|
|
254
|
-
var
|
|
255
|
-
|
|
256
|
-
|
|
293
|
+
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref2) {
|
|
294
|
+
var _res$data$date_list;
|
|
295
|
+
var startDate, endDate, custom_page_id, dates, res;
|
|
296
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
297
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
257
298
|
case 0:
|
|
258
299
|
startDate = _ref2.startDate, endDate = _ref2.endDate, custom_page_id = _ref2.custom_page_id;
|
|
259
|
-
|
|
300
|
+
// 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天,需要把 startDate 置为今天
|
|
301
|
+
if (dayjs(startDate).isBefore(dayjs())) {
|
|
302
|
+
startDate = dayjs().format('YYYY-MM-DD');
|
|
303
|
+
}
|
|
304
|
+
// 1.生成当前月份的所有日期,默认都不可用
|
|
305
|
+
dates = generateMonthDates(startDate, endDate);
|
|
306
|
+
dates = disableAllDates(dates);
|
|
307
|
+
// 如果 endDate 在今天之前,则不用查接口,直接返回 dates
|
|
308
|
+
if (!dayjs(endDate).isBefore(dayjs())) {
|
|
309
|
+
_context5.next = 6;
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
return _context5.abrupt("return", dates);
|
|
313
|
+
case 6:
|
|
314
|
+
_context5.next = 8;
|
|
260
315
|
return this.request.get("/schedule/product/availability", {
|
|
261
316
|
start_date: startDate,
|
|
262
317
|
end_date: endDate,
|
|
263
318
|
custom_page_id: custom_page_id
|
|
264
319
|
});
|
|
265
|
-
case
|
|
266
|
-
res =
|
|
267
|
-
this.store.schedule.
|
|
268
|
-
|
|
320
|
+
case 8:
|
|
321
|
+
res = _context5.sent;
|
|
322
|
+
this.store.schedule.setAvailabilityScheduleDateList(res.data.date_list);
|
|
323
|
+
// 如果没有schedule或者结束日期在今天之前,则所有日期均不可用
|
|
324
|
+
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()))) {
|
|
325
|
+
_context5.next = 12;
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
return _context5.abrupt("return", dates);
|
|
329
|
+
case 12:
|
|
330
|
+
res.data.date_list.forEach(function (n) {
|
|
331
|
+
if (n.schedule_id && n.schedule_id.length) {
|
|
332
|
+
var index = dates.findIndex(function (m) {
|
|
333
|
+
return m.date === n.date;
|
|
334
|
+
});
|
|
335
|
+
if (index !== -1) {
|
|
336
|
+
dates[index].status = 'available';
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
dates = disableDatesBeforeOneDay(dates);
|
|
341
|
+
return _context5.abrupt("return", dates);
|
|
342
|
+
case 15:
|
|
269
343
|
case "end":
|
|
270
|
-
return
|
|
344
|
+
return _context5.stop();
|
|
271
345
|
}
|
|
272
|
-
},
|
|
346
|
+
}, _callee5, this);
|
|
273
347
|
}));
|
|
274
|
-
function
|
|
275
|
-
return
|
|
348
|
+
function loadScheduleAvailableDate(_x5) {
|
|
349
|
+
return _loadScheduleAvailableDate.apply(this, arguments);
|
|
276
350
|
}
|
|
277
|
-
return
|
|
351
|
+
return loadScheduleAvailableDate;
|
|
278
352
|
}()
|
|
279
353
|
}, {
|
|
280
354
|
key: "storeProduct",
|
|
281
355
|
value: function () {
|
|
282
|
-
var _storeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
356
|
+
var _storeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(productData) {
|
|
283
357
|
var activeAccount, _ref3, bundle, options, origin, product_variant_id, product;
|
|
284
|
-
return _regeneratorRuntime().wrap(function
|
|
285
|
-
while (1) switch (
|
|
358
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
359
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
286
360
|
case 0:
|
|
287
361
|
// 往购物车加商品数据的时候,默认用当前 activeAccount 填充到 product 的 account 里面
|
|
288
362
|
activeAccount = this.getActiveAccount();
|
|
289
363
|
if (activeAccount) {
|
|
290
|
-
|
|
364
|
+
_context6.next = 3;
|
|
291
365
|
break;
|
|
292
366
|
}
|
|
293
|
-
throw new Error(
|
|
367
|
+
throw new Error('没有找到当前账户');
|
|
294
368
|
case 3:
|
|
295
369
|
_ref3 = productData || {}, bundle = _ref3.bundle, options = _ref3.options, origin = _ref3.origin, product_variant_id = _ref3.product_variant_id;
|
|
296
370
|
product = _objectSpread(_objectSpread({}, origin), {}, {
|
|
@@ -304,11 +378,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
304
378
|
});
|
|
305
379
|
case 6:
|
|
306
380
|
case "end":
|
|
307
|
-
return
|
|
381
|
+
return _context6.stop();
|
|
308
382
|
}
|
|
309
|
-
},
|
|
383
|
+
}, _callee6, this);
|
|
310
384
|
}));
|
|
311
|
-
function storeProduct(
|
|
385
|
+
function storeProduct(_x6) {
|
|
312
386
|
return _storeProduct.apply(this, arguments);
|
|
313
387
|
}
|
|
314
388
|
return storeProduct;
|
|
@@ -316,21 +390,28 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
316
390
|
}, {
|
|
317
391
|
key: "addAccount",
|
|
318
392
|
value: function () {
|
|
319
|
-
var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
393
|
+
var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(accounts, extra) {
|
|
320
394
|
var _this3 = this;
|
|
321
|
-
return _regeneratorRuntime().wrap(function
|
|
322
|
-
while (1) switch (
|
|
395
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
396
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
323
397
|
case 0:
|
|
398
|
+
if (!((extra === null || extra === void 0 ? void 0 : extra.type) === 'holder')) {
|
|
399
|
+
_context7.next = 3;
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
402
|
+
this.store.accountList.addHolderAccounts(accounts, extra.customerId);
|
|
403
|
+
return _context7.abrupt("return");
|
|
404
|
+
case 3:
|
|
324
405
|
accounts.forEach(function (account) {
|
|
325
406
|
_this3.store.accountList.addAccount(account);
|
|
326
407
|
});
|
|
327
|
-
case
|
|
408
|
+
case 4:
|
|
328
409
|
case "end":
|
|
329
|
-
return
|
|
410
|
+
return _context7.stop();
|
|
330
411
|
}
|
|
331
|
-
},
|
|
412
|
+
}, _callee7, this);
|
|
332
413
|
}));
|
|
333
|
-
function addAccount(
|
|
414
|
+
function addAccount(_x7, _x8) {
|
|
334
415
|
return _addAccount.apply(this, arguments);
|
|
335
416
|
}
|
|
336
417
|
return addAccount;
|
|
@@ -338,20 +419,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
338
419
|
}, {
|
|
339
420
|
key: "getAccounts",
|
|
340
421
|
value: function () {
|
|
341
|
-
var _getAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
422
|
+
var _getAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
342
423
|
var accounts;
|
|
343
|
-
return _regeneratorRuntime().wrap(function
|
|
344
|
-
while (1) switch (
|
|
424
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
425
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
345
426
|
case 0:
|
|
346
427
|
accounts = this.store.accountList.getAccounts();
|
|
347
|
-
return
|
|
428
|
+
return _context8.abrupt("return", accounts.map(function (account) {
|
|
348
429
|
return account.getAccount();
|
|
349
430
|
}));
|
|
350
431
|
case 2:
|
|
351
432
|
case "end":
|
|
352
|
-
return
|
|
433
|
+
return _context8.stop();
|
|
353
434
|
}
|
|
354
|
-
},
|
|
435
|
+
}, _callee8, this);
|
|
355
436
|
}));
|
|
356
437
|
function getAccounts() {
|
|
357
438
|
return _getAccounts.apply(this, arguments);
|
|
@@ -385,22 +466,45 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
385
466
|
this.clearCartByAccount(id);
|
|
386
467
|
}
|
|
387
468
|
|
|
388
|
-
|
|
469
|
+
/**
|
|
470
|
+
* 获取holder类型账户列表
|
|
471
|
+
* @param params
|
|
472
|
+
*/
|
|
473
|
+
}, {
|
|
474
|
+
key: "fetchHolderAccountsAsync",
|
|
475
|
+
value: (function () {
|
|
476
|
+
var _fetchHolderAccountsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
|
|
477
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
478
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
479
|
+
case 0:
|
|
480
|
+
return _context9.abrupt("return", this.store.accountList.fetchHolderAccounts(params));
|
|
481
|
+
case 1:
|
|
482
|
+
case "end":
|
|
483
|
+
return _context9.stop();
|
|
484
|
+
}
|
|
485
|
+
}, _callee9, this);
|
|
486
|
+
}));
|
|
487
|
+
function fetchHolderAccountsAsync(_x9) {
|
|
488
|
+
return _fetchHolderAccountsAsync.apply(this, arguments);
|
|
489
|
+
}
|
|
490
|
+
return fetchHolderAccountsAsync;
|
|
491
|
+
}() // 设置日期范围,注入到日期模块中
|
|
492
|
+
)
|
|
389
493
|
}, {
|
|
390
494
|
key: "setDateRange",
|
|
391
495
|
value: function () {
|
|
392
|
-
var _setDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
393
|
-
return _regeneratorRuntime().wrap(function
|
|
394
|
-
while (1) switch (
|
|
496
|
+
var _setDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(dateRange) {
|
|
497
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
498
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
395
499
|
case 0:
|
|
396
500
|
this.store.date.setDateRange(dateRange);
|
|
397
501
|
case 1:
|
|
398
502
|
case "end":
|
|
399
|
-
return
|
|
503
|
+
return _context10.stop();
|
|
400
504
|
}
|
|
401
|
-
},
|
|
505
|
+
}, _callee10, this);
|
|
402
506
|
}));
|
|
403
|
-
function setDateRange(
|
|
507
|
+
function setDateRange(_x10) {
|
|
404
508
|
return _setDateRange.apply(this, arguments);
|
|
405
509
|
}
|
|
406
510
|
return setDateRange;
|
|
@@ -415,16 +519,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
415
519
|
}, {
|
|
416
520
|
key: "getDateRange",
|
|
417
521
|
value: function () {
|
|
418
|
-
var _getDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
419
|
-
return _regeneratorRuntime().wrap(function
|
|
420
|
-
while (1) switch (
|
|
522
|
+
var _getDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
523
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
524
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
421
525
|
case 0:
|
|
422
|
-
return
|
|
526
|
+
return _context11.abrupt("return", this.store.date.getDateRange());
|
|
423
527
|
case 1:
|
|
424
528
|
case "end":
|
|
425
|
-
return
|
|
529
|
+
return _context11.stop();
|
|
426
530
|
}
|
|
427
|
-
},
|
|
531
|
+
}, _callee11, this);
|
|
428
532
|
}));
|
|
429
533
|
function getDateRange() {
|
|
430
534
|
return _getDateRange.apply(this, arguments);
|
|
@@ -441,12 +545,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
441
545
|
}, {
|
|
442
546
|
key: "getAvailableDate",
|
|
443
547
|
value: function () {
|
|
444
|
-
var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
445
|
-
var
|
|
548
|
+
var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
549
|
+
var _this4 = this,
|
|
550
|
+
_this$otherParams3,
|
|
551
|
+
_this$otherParams4;
|
|
446
552
|
var params,
|
|
447
553
|
products,
|
|
448
554
|
startDate,
|
|
449
555
|
endDate,
|
|
556
|
+
type,
|
|
450
557
|
tempProducts,
|
|
451
558
|
tempStartDate,
|
|
452
559
|
tempEndDate,
|
|
@@ -455,45 +562,62 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
455
562
|
rules,
|
|
456
563
|
resourcesMap,
|
|
457
564
|
res,
|
|
458
|
-
|
|
459
|
-
return _regeneratorRuntime().wrap(function
|
|
460
|
-
while (1) switch (
|
|
565
|
+
_args12 = arguments;
|
|
566
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
567
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
461
568
|
case 0:
|
|
462
|
-
params =
|
|
569
|
+
params = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
|
|
463
570
|
// 开始日期如果小于今天,直接以今天当做开始日期
|
|
464
|
-
products = params.products, startDate = params.startDate, endDate = params.endDate;
|
|
571
|
+
products = params.products, startDate = params.startDate, endDate = params.endDate, type = params.type; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
|
|
572
|
+
if (dayjs(startDate).isBefore(dayjs()) && (dayjs(endDate).isAfter(dayjs()) || dayjs(endDate).isSame(dayjs()))) {
|
|
573
|
+
startDate = dayjs().format('YYYY-MM-DD');
|
|
574
|
+
}
|
|
465
575
|
tempProducts = products || this.store.cart.getItems().map(function (p) {
|
|
466
576
|
return p._productOrigin;
|
|
467
577
|
});
|
|
578
|
+
if (tempProducts.length) {
|
|
579
|
+
tempProducts.forEach(function (p) {
|
|
580
|
+
if (p !== null && p !== void 0 && p['schedule.ids']) {
|
|
581
|
+
var scheduleData = _this4.getScheduleDataByIds(p['schedule.ids']);
|
|
582
|
+
p['_schedule'] = scheduleData;
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
// 如果当前打开了某个的商品详情弹窗,则应该默认用这个商品
|
|
587
|
+
if (this.store.currentProduct) {
|
|
588
|
+
tempProducts = [_objectSpread(_objectSpread({}, this.store.currentProduct.getData()), {}, {
|
|
589
|
+
_schedule: this.store.currentProduct.getOtherParams()['schedule']
|
|
590
|
+
})];
|
|
591
|
+
}
|
|
468
592
|
tempStartDate = startDate || ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 || (_this$otherParams3 = _this$otherParams3.dateRange) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3[0]);
|
|
469
593
|
tempEndDate = endDate || ((_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 || (_this$otherParams4 = _this$otherParams4.dateRange) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4[1]);
|
|
470
594
|
if (tempProducts.length) {
|
|
471
|
-
|
|
595
|
+
_context12.next = 10;
|
|
472
596
|
break;
|
|
473
597
|
}
|
|
474
|
-
return
|
|
475
|
-
case
|
|
598
|
+
return _context12.abrupt("return", []);
|
|
599
|
+
case 10:
|
|
476
600
|
// 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
|
|
477
601
|
_ref4 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref4.resourceIds, rules = _ref4.rules, resourcesMap = _ref4.resourcesMap;
|
|
478
|
-
console.log("resourceIds", tempProducts);
|
|
479
602
|
this.otherParams.currentResourcesMap = resourcesMap;
|
|
480
|
-
|
|
481
|
-
return this.store.date.
|
|
603
|
+
_context12.next = 14;
|
|
604
|
+
return this.store.date.getResourceDates({
|
|
482
605
|
query: {
|
|
483
606
|
start_date: tempStartDate,
|
|
484
607
|
end_date: tempEndDate,
|
|
485
608
|
resource_ids: resourceIds
|
|
486
609
|
},
|
|
487
|
-
rules: rules
|
|
610
|
+
rules: rules,
|
|
611
|
+
type: type
|
|
488
612
|
});
|
|
489
|
-
case 12:
|
|
490
|
-
res = _context10.sent;
|
|
491
|
-
return _context10.abrupt("return", res);
|
|
492
613
|
case 14:
|
|
614
|
+
res = _context12.sent;
|
|
615
|
+
return _context12.abrupt("return", res);
|
|
616
|
+
case 16:
|
|
493
617
|
case "end":
|
|
494
|
-
return
|
|
618
|
+
return _context12.stop();
|
|
495
619
|
}
|
|
496
|
-
},
|
|
620
|
+
}, _callee12, this);
|
|
497
621
|
}));
|
|
498
622
|
function getAvailableDate() {
|
|
499
623
|
return _getAvailableDate.apply(this, arguments);
|
|
@@ -506,22 +630,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
506
630
|
}, {
|
|
507
631
|
key: "getSummary",
|
|
508
632
|
value: (function () {
|
|
509
|
-
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
633
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
510
634
|
var cartItems, summary;
|
|
511
|
-
return _regeneratorRuntime().wrap(function
|
|
512
|
-
while (1) switch (
|
|
635
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
636
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
513
637
|
case 0:
|
|
514
638
|
cartItems = this.store.cart.getItems();
|
|
515
|
-
|
|
639
|
+
_context13.next = 3;
|
|
516
640
|
return this.store.summary.getSummary(cartItems);
|
|
517
641
|
case 3:
|
|
518
|
-
summary =
|
|
519
|
-
return
|
|
642
|
+
summary = _context13.sent;
|
|
643
|
+
return _context13.abrupt("return", summary);
|
|
520
644
|
case 5:
|
|
521
645
|
case "end":
|
|
522
|
-
return
|
|
646
|
+
return _context13.stop();
|
|
523
647
|
}
|
|
524
|
-
},
|
|
648
|
+
}, _callee13, this);
|
|
525
649
|
}));
|
|
526
650
|
function getSummary() {
|
|
527
651
|
return _getSummary.apply(this, arguments);
|
|
@@ -535,18 +659,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
535
659
|
}, {
|
|
536
660
|
key: "getProtocol",
|
|
537
661
|
value: (function () {
|
|
538
|
-
var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
539
|
-
return _regeneratorRuntime().wrap(function
|
|
540
|
-
while (1) switch (
|
|
662
|
+
var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(protocolId) {
|
|
663
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
664
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
541
665
|
case 0:
|
|
542
|
-
return
|
|
666
|
+
return _context14.abrupt("return", this.store.summary.getProtocol(protocolId));
|
|
543
667
|
case 1:
|
|
544
668
|
case "end":
|
|
545
|
-
return
|
|
669
|
+
return _context14.stop();
|
|
546
670
|
}
|
|
547
|
-
},
|
|
671
|
+
}, _callee14, this);
|
|
548
672
|
}));
|
|
549
|
-
function getProtocol(
|
|
673
|
+
function getProtocol(_x11) {
|
|
550
674
|
return _getProtocol.apply(this, arguments);
|
|
551
675
|
}
|
|
552
676
|
return getProtocol;
|
|
@@ -555,16 +679,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
555
679
|
}, {
|
|
556
680
|
key: "getProducts",
|
|
557
681
|
value: function () {
|
|
558
|
-
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
559
|
-
return _regeneratorRuntime().wrap(function
|
|
560
|
-
while (1) switch (
|
|
682
|
+
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
683
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
684
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
561
685
|
case 0:
|
|
562
|
-
return
|
|
686
|
+
return _context15.abrupt("return", this.store.products.getProducts());
|
|
563
687
|
case 1:
|
|
564
688
|
case "end":
|
|
565
|
-
return
|
|
689
|
+
return _context15.stop();
|
|
566
690
|
}
|
|
567
|
-
},
|
|
691
|
+
}, _callee15, this);
|
|
568
692
|
}));
|
|
569
693
|
function getProducts() {
|
|
570
694
|
return _getProducts.apply(this, arguments);
|
|
@@ -574,15 +698,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
574
698
|
}, {
|
|
575
699
|
key: "setLoginAccount",
|
|
576
700
|
value: function () {
|
|
577
|
-
var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
578
|
-
var
|
|
701
|
+
var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(accountId, accountInfo) {
|
|
702
|
+
var _this5 = this;
|
|
579
703
|
var account, stateAccountId, cartItems;
|
|
580
|
-
return _regeneratorRuntime().wrap(function
|
|
581
|
-
while (1) switch (
|
|
704
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
705
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
582
706
|
case 0:
|
|
583
707
|
account = this.store.accountList.getAccount(accountId);
|
|
584
708
|
if (!account) {
|
|
585
|
-
|
|
709
|
+
_context16.next = 9;
|
|
586
710
|
break;
|
|
587
711
|
}
|
|
588
712
|
stateAccountId = account.getId();
|
|
@@ -591,24 +715,24 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
591
715
|
cartItems = this.store.cart.getItems();
|
|
592
716
|
cartItems.forEach(function (item) {
|
|
593
717
|
if (item.holder_id === accountId) {
|
|
594
|
-
|
|
718
|
+
_this5.store.cart.updateItem({
|
|
595
719
|
_id: item._id,
|
|
596
720
|
account: accountInfo
|
|
597
721
|
});
|
|
598
722
|
}
|
|
599
723
|
});
|
|
600
724
|
this.store.accountList.updateAccountListById(stateAccountId, accountInfo);
|
|
601
|
-
|
|
725
|
+
_context16.next = 10;
|
|
602
726
|
break;
|
|
603
727
|
case 9:
|
|
604
728
|
throw new Error("\u6CA1\u6709\u627E\u5230".concat(accountId, "\u8D26\u6237"));
|
|
605
729
|
case 10:
|
|
606
730
|
case "end":
|
|
607
|
-
return
|
|
731
|
+
return _context16.stop();
|
|
608
732
|
}
|
|
609
|
-
},
|
|
733
|
+
}, _callee16, this);
|
|
610
734
|
}));
|
|
611
|
-
function setLoginAccount(
|
|
735
|
+
function setLoginAccount(_x12, _x13) {
|
|
612
736
|
return _setLoginAccount.apply(this, arguments);
|
|
613
737
|
}
|
|
614
738
|
return setLoginAccount;
|
|
@@ -616,14 +740,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
616
740
|
}, {
|
|
617
741
|
key: "generateCartData",
|
|
618
742
|
value: function () {
|
|
619
|
-
var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
620
|
-
return _regeneratorRuntime().wrap(function
|
|
621
|
-
while (1) switch (
|
|
743
|
+
var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
744
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
745
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
622
746
|
case 0:
|
|
623
747
|
case "end":
|
|
624
|
-
return
|
|
748
|
+
return _context17.stop();
|
|
625
749
|
}
|
|
626
|
-
},
|
|
750
|
+
}, _callee17);
|
|
627
751
|
}));
|
|
628
752
|
function generateCartData() {
|
|
629
753
|
return _generateCartData.apply(this, arguments);
|
|
@@ -633,34 +757,49 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
633
757
|
}, {
|
|
634
758
|
key: "getFreeProduct",
|
|
635
759
|
value: function () {
|
|
636
|
-
var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
760
|
+
var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(id) {
|
|
637
761
|
var res;
|
|
638
|
-
return _regeneratorRuntime().wrap(function
|
|
639
|
-
while (1) switch (
|
|
762
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
763
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
640
764
|
case 0:
|
|
641
|
-
|
|
765
|
+
_context18.next = 2;
|
|
642
766
|
return this.request.post("/pay/order/free-pay/".concat(id));
|
|
643
767
|
case 2:
|
|
644
|
-
res =
|
|
645
|
-
return
|
|
768
|
+
res = _context18.sent;
|
|
769
|
+
return _context18.abrupt("return", res);
|
|
646
770
|
case 4:
|
|
647
771
|
case "end":
|
|
648
|
-
return
|
|
772
|
+
return _context18.stop();
|
|
649
773
|
}
|
|
650
|
-
},
|
|
774
|
+
}, _callee18, this);
|
|
651
775
|
}));
|
|
652
|
-
function getFreeProduct(
|
|
776
|
+
function getFreeProduct(_x14) {
|
|
653
777
|
return _getFreeProduct.apply(this, arguments);
|
|
654
778
|
}
|
|
655
779
|
return getFreeProduct;
|
|
656
|
-
}()
|
|
780
|
+
}()
|
|
781
|
+
/**
|
|
782
|
+
* 检查购物车提交订单前是否符合条件
|
|
783
|
+
* @param type 类型 "holder" | "account"
|
|
784
|
+
* @returns boolean
|
|
785
|
+
*/
|
|
786
|
+
}, {
|
|
787
|
+
key: "checkBeforeSubmitOrder",
|
|
788
|
+
value: function checkBeforeSubmitOrder(type) {
|
|
789
|
+
return this.store.order.checkBeforeSubmitOrder({
|
|
790
|
+
type: type,
|
|
791
|
+
cartItems: this.store.cart.getItems()
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
// 购物车提交订单
|
|
657
796
|
}, {
|
|
658
797
|
key: "submitOrder",
|
|
659
798
|
value: function () {
|
|
660
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
799
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
661
800
|
var cartItems, newCartItems;
|
|
662
|
-
return _regeneratorRuntime().wrap(function
|
|
663
|
-
while (1) switch (
|
|
801
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
802
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
664
803
|
case 0:
|
|
665
804
|
cartItems = this.store.cart.getItems();
|
|
666
805
|
newCartItems = cloneDeep(cartItems); // 先整个临时的逻辑,把购物车里所有商品的资源给他格式化一下
|
|
@@ -673,16 +812,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
673
812
|
return _objectSpread({}, newResourcesItem);
|
|
674
813
|
});
|
|
675
814
|
});
|
|
676
|
-
return
|
|
815
|
+
return _context19.abrupt("return", this.store.order.submitOrder({
|
|
677
816
|
query: {
|
|
678
817
|
cartItems: newCartItems
|
|
679
818
|
}
|
|
680
819
|
}));
|
|
681
820
|
case 4:
|
|
682
821
|
case "end":
|
|
683
|
-
return
|
|
822
|
+
return _context19.stop();
|
|
684
823
|
}
|
|
685
|
-
},
|
|
824
|
+
}, _callee19, this);
|
|
686
825
|
}));
|
|
687
826
|
function submitOrder() {
|
|
688
827
|
return _submitOrder.apply(this, arguments);
|
|
@@ -692,14 +831,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
692
831
|
}, {
|
|
693
832
|
key: "pay",
|
|
694
833
|
value: function () {
|
|
695
|
-
var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
696
|
-
return _regeneratorRuntime().wrap(function
|
|
697
|
-
while (1) switch (
|
|
834
|
+
var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
835
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
836
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
698
837
|
case 0:
|
|
699
838
|
case "end":
|
|
700
|
-
return
|
|
839
|
+
return _context20.stop();
|
|
701
840
|
}
|
|
702
|
-
},
|
|
841
|
+
}, _callee20);
|
|
703
842
|
}));
|
|
704
843
|
function pay() {
|
|
705
844
|
return _pay.apply(this, arguments);
|
|
@@ -709,14 +848,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
709
848
|
}, {
|
|
710
849
|
key: "getPayInfo",
|
|
711
850
|
value: function () {
|
|
712
|
-
var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
713
|
-
return _regeneratorRuntime().wrap(function
|
|
714
|
-
while (1) switch (
|
|
851
|
+
var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
852
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
853
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
715
854
|
case 0:
|
|
716
855
|
case "end":
|
|
717
|
-
return
|
|
856
|
+
return _context21.stop();
|
|
718
857
|
}
|
|
719
|
-
},
|
|
858
|
+
}, _callee21);
|
|
720
859
|
}));
|
|
721
860
|
function getPayInfo() {
|
|
722
861
|
return _getPayInfo.apply(this, arguments);
|
|
@@ -726,15 +865,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
726
865
|
}, {
|
|
727
866
|
key: "setOtherParams",
|
|
728
867
|
value: function () {
|
|
729
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
868
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
|
|
730
869
|
var _ref5,
|
|
731
870
|
_ref5$cover,
|
|
732
871
|
cover,
|
|
733
|
-
|
|
734
|
-
return _regeneratorRuntime().wrap(function
|
|
735
|
-
while (1) switch (
|
|
872
|
+
_args22 = arguments;
|
|
873
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
874
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
736
875
|
case 0:
|
|
737
|
-
_ref5 =
|
|
876
|
+
_ref5 = _args22.length > 1 && _args22[1] !== undefined ? _args22[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
|
|
738
877
|
if (cover) {
|
|
739
878
|
this.otherParams = params;
|
|
740
879
|
} else {
|
|
@@ -742,11 +881,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
742
881
|
}
|
|
743
882
|
case 2:
|
|
744
883
|
case "end":
|
|
745
|
-
return
|
|
884
|
+
return _context22.stop();
|
|
746
885
|
}
|
|
747
|
-
},
|
|
886
|
+
}, _callee22, this);
|
|
748
887
|
}));
|
|
749
|
-
function setOtherParams(
|
|
888
|
+
function setOtherParams(_x15) {
|
|
750
889
|
return _setOtherParams.apply(this, arguments);
|
|
751
890
|
}
|
|
752
891
|
return setOtherParams;
|
|
@@ -754,16 +893,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
754
893
|
}, {
|
|
755
894
|
key: "getOtherParams",
|
|
756
895
|
value: function () {
|
|
757
|
-
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
758
|
-
return _regeneratorRuntime().wrap(function
|
|
759
|
-
while (1) switch (
|
|
896
|
+
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
897
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
898
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
760
899
|
case 0:
|
|
761
|
-
return
|
|
900
|
+
return _context23.abrupt("return", this.otherParams);
|
|
762
901
|
case 1:
|
|
763
902
|
case "end":
|
|
764
|
-
return
|
|
903
|
+
return _context23.stop();
|
|
765
904
|
}
|
|
766
|
-
},
|
|
905
|
+
}, _callee23, this);
|
|
767
906
|
}));
|
|
768
907
|
function getOtherParams() {
|
|
769
908
|
return _getOtherParams.apply(this, arguments);
|
|
@@ -773,12 +912,19 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
773
912
|
}, {
|
|
774
913
|
key: "updateCart",
|
|
775
914
|
value: function updateCart(params) {
|
|
776
|
-
var
|
|
777
|
-
this.store.cart.updateItem(params);
|
|
915
|
+
var _this6 = this;
|
|
778
916
|
var targetCartItem = this.store.cart.getItem(params._id);
|
|
779
917
|
if (!targetCartItem) {
|
|
780
918
|
throw new Error("\u6CA1\u6709\u627E\u5230".concat(params._id, "\u8D2D\u7269\u8F66\u5546\u54C1"));
|
|
781
919
|
}
|
|
920
|
+
if (params.resources) {
|
|
921
|
+
params.resources = params.resources.map(function (n) {
|
|
922
|
+
n.capacity = targetCartItem.num || 1;
|
|
923
|
+
checkSubResourcesCapacity(n);
|
|
924
|
+
return n;
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
this.store.cart.updateItem(params);
|
|
782
928
|
// 更新购物车后,需要判定购物车里是否存在多个账号选择了相同资源的情况,如果是,则要把选择了相同资源的 product._origin.resources 给去除
|
|
783
929
|
var cartItems = this.store.cart.getItems();
|
|
784
930
|
cartItems.forEach(function (item) {
|
|
@@ -796,7 +942,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
796
942
|
return false;
|
|
797
943
|
});
|
|
798
944
|
});
|
|
799
|
-
|
|
945
|
+
_this6.store.cart.updateItem({
|
|
800
946
|
_id: item._id,
|
|
801
947
|
resources: resources
|
|
802
948
|
});
|
|
@@ -831,10 +977,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
831
977
|
}, {
|
|
832
978
|
key: "batchUpdateCart",
|
|
833
979
|
value: function batchUpdateCart(paramsList) {
|
|
834
|
-
var
|
|
980
|
+
var _this7 = this;
|
|
835
981
|
var cartItems = [];
|
|
836
982
|
paramsList.forEach(function (params) {
|
|
837
|
-
var cartItem =
|
|
983
|
+
var cartItem = _this7.store.cart.formatCartItem(params);
|
|
838
984
|
cartItems.push(cartItem);
|
|
839
985
|
});
|
|
840
986
|
this.store.cart.batchSetItems(cartItems);
|
|
@@ -868,17 +1014,27 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
868
1014
|
value: function getResourcesList() {
|
|
869
1015
|
var dateRange = this.store.date.getDateRange();
|
|
870
1016
|
var resources = [];
|
|
871
|
-
dateRange.
|
|
872
|
-
|
|
873
|
-
|
|
1017
|
+
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
1018
|
+
dateRange.forEach(function (n) {
|
|
1019
|
+
if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
|
|
1020
|
+
});
|
|
1021
|
+
} else {
|
|
1022
|
+
// 如果没有 dateRange,视作购物车里已经有了 dateRange 数据,此时 dateList 里明确就是那一天的数据
|
|
1023
|
+
var dateList = this.store.date.getDateList();
|
|
1024
|
+
dateList.forEach(function (n) {
|
|
1025
|
+
if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
874
1028
|
var resourcesMap = getResourcesMap(resources);
|
|
875
1029
|
var cartItems = this.store.cart.getItems();
|
|
876
1030
|
var arr = [];
|
|
1031
|
+
var capacityMap = {};
|
|
877
1032
|
cartItems.forEach(function (cartItem) {
|
|
878
1033
|
var _cartItem$_productOri, _cartItem$_productOri2;
|
|
879
|
-
|
|
880
|
-
if (
|
|
881
|
-
|
|
1034
|
+
var selectedResources = [];
|
|
1035
|
+
if (cartItem.holder_id) {
|
|
1036
|
+
selectedResources = getOthersSelectedResources(cartItems, cartItem.holder_id, resourcesMap);
|
|
1037
|
+
}
|
|
882
1038
|
var formatCapacity = formatDefaultCapacitys({
|
|
883
1039
|
capacity: (_cartItem$_productOri = cartItem._productOrigin) === null || _cartItem$_productOri === void 0 ? void 0 : _cartItem$_productOri.capacity,
|
|
884
1040
|
product_bundle: cartItem._origin.product.product_bundle
|
|
@@ -887,6 +1043,31 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
887
1043
|
capacity: formatCapacity
|
|
888
1044
|
});
|
|
889
1045
|
var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri2 = cartItem._productOrigin) === null || _cartItem$_productOri2 === void 0 || (_cartItem$_productOri2 = _cartItem$_productOri2.product_resource) === null || _cartItem$_productOri2 === void 0 ? void 0 : _cartItem$_productOri2.resources) || [], selectedResources, currentCapacity);
|
|
1046
|
+
// 如果购物车里已经有了时间片,则需要按照时间片过滤
|
|
1047
|
+
if (cartItem._origin.start_time) {
|
|
1048
|
+
var startTime = dayjs("".concat(cartItem._origin.start_date, " ").concat(cartItem._origin.start_time));
|
|
1049
|
+
var endTime = dayjs("".concat(cartItem._origin.end_date, " ").concat(cartItem._origin.end_time));
|
|
1050
|
+
productResources.forEach(function (n) {
|
|
1051
|
+
n.renderList = n.renderList.filter(function (m) {
|
|
1052
|
+
var recordCount = capacityMap[m.id] || 0;
|
|
1053
|
+
var canUseTime = m.times.find(function (item) {
|
|
1054
|
+
var res = getIsUsableByTimeItem({
|
|
1055
|
+
timeSlice: {
|
|
1056
|
+
start_time: startTime.format('HH:mm'),
|
|
1057
|
+
end_time: endTime.format('HH:mm'),
|
|
1058
|
+
start_at: startTime,
|
|
1059
|
+
end_at: endTime
|
|
1060
|
+
},
|
|
1061
|
+
time: item,
|
|
1062
|
+
resource: m,
|
|
1063
|
+
currentCount: recordCount + (currentCapacity || 0)
|
|
1064
|
+
});
|
|
1065
|
+
return res.usable;
|
|
1066
|
+
});
|
|
1067
|
+
return canUseTime;
|
|
1068
|
+
});
|
|
1069
|
+
});
|
|
1070
|
+
}
|
|
890
1071
|
arr.push({
|
|
891
1072
|
id: cartItem.id,
|
|
892
1073
|
// 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
|
|
@@ -1141,7 +1322,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1141
1322
|
}, {
|
|
1142
1323
|
key: "autoSelectAllProductResources",
|
|
1143
1324
|
value: function autoSelectAllProductResources(resources_code, timeSlots) {
|
|
1144
|
-
var
|
|
1325
|
+
var _this8 = this;
|
|
1145
1326
|
var dateRange = this.store.date.getDateRange();
|
|
1146
1327
|
var resources = [];
|
|
1147
1328
|
dateRange.forEach(function (n) {
|
|
@@ -1152,7 +1333,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1152
1333
|
var errorList = [];
|
|
1153
1334
|
var selectResourcesMap = {};
|
|
1154
1335
|
this.store.accountList.getAccounts().forEach(function (account) {
|
|
1155
|
-
var cartItems =
|
|
1336
|
+
var cartItems = _this8.store.cart.getCartByAccount(account.getId());
|
|
1156
1337
|
var recordTimeSlots = cloneDeep(timeSlots);
|
|
1157
1338
|
// timeSlots 传进来的只是用户选中的时间片,但是实际上需要根据多个商品时间进行累加
|
|
1158
1339
|
// 假设 timeSlots.start_time 是15:40 duration 是 30min
|
|
@@ -1170,17 +1351,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1170
1351
|
if (timeSlots) {
|
|
1171
1352
|
if (index !== 0 && recordTimeSlots) {
|
|
1172
1353
|
var _item$_productOrigin$, _item$_productOrigin3, _ref9, _item$_productOrigin4, _item$_productOrigin$2, _item$_productOrigin5, _ref10, _item$_productOrigin6;
|
|
1173
|
-
var start_at = dayjs(recordTimeSlots.end_time).add((_item$_productOrigin$ = (_item$_productOrigin3 = item._productOrigin) === null || _item$_productOrigin3 === void 0 || (_item$_productOrigin3 = _item$_productOrigin3.duration) === null || _item$_productOrigin3 === void 0 ? void 0 : _item$_productOrigin3.value) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : 0, (_ref9 = (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.duration) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.type) !== null && _ref9 !== void 0 ? _ref9 :
|
|
1174
|
-
var end_at = start_at.add((_item$_productOrigin$2 = (_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.duration) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.value) !== null && _item$_productOrigin$2 !== void 0 ? _item$_productOrigin$2 : 0, (_ref10 = (_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.duration) === null || _item$_productOrigin6 === void 0 ? void 0 : _item$_productOrigin6.type) !== null && _ref10 !== void 0 ? _ref10 :
|
|
1354
|
+
var start_at = dayjs(recordTimeSlots.end_time).add((_item$_productOrigin$ = (_item$_productOrigin3 = item._productOrigin) === null || _item$_productOrigin3 === void 0 || (_item$_productOrigin3 = _item$_productOrigin3.duration) === null || _item$_productOrigin3 === void 0 ? void 0 : _item$_productOrigin3.value) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : 0, (_ref9 = (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.duration) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.type) !== null && _ref9 !== void 0 ? _ref9 : 'minutes');
|
|
1355
|
+
var end_at = start_at.add((_item$_productOrigin$2 = (_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.duration) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.value) !== null && _item$_productOrigin$2 !== void 0 ? _item$_productOrigin$2 : 0, (_ref10 = (_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.duration) === null || _item$_productOrigin6 === void 0 ? void 0 : _item$_productOrigin6.type) !== null && _ref10 !== void 0 ? _ref10 : 'minutes');
|
|
1175
1356
|
recordTimeSlots = {
|
|
1176
|
-
start_time: start_at.format(
|
|
1177
|
-
end_time: end_at.format(
|
|
1357
|
+
start_time: start_at.format('HH:mm'),
|
|
1358
|
+
end_time: end_at.format('HH:mm'),
|
|
1178
1359
|
start_at: start_at,
|
|
1179
1360
|
end_at: end_at
|
|
1180
1361
|
};
|
|
1181
1362
|
}
|
|
1182
1363
|
// 如果传递了 timeSlots,代表是第二种资源,则直接拿 timeSlots 去匹配
|
|
1183
|
-
var res =
|
|
1364
|
+
var res = _this8.autoSelectAccountResources({
|
|
1184
1365
|
holder_id: item.holder_id,
|
|
1185
1366
|
resources_code: resources_code,
|
|
1186
1367
|
timeSlots: recordTimeSlots,
|
|
@@ -1199,7 +1380,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1199
1380
|
}
|
|
1200
1381
|
res.selectedResource.capacity = currentCapacity;
|
|
1201
1382
|
checkSubResourcesCapacity(res.selectedResource);
|
|
1202
|
-
|
|
1383
|
+
_this8.store.cart.updateItem({
|
|
1203
1384
|
_id: item._id,
|
|
1204
1385
|
// 这里要做去重,避免出现同样类型的资源被塞进同一个商品
|
|
1205
1386
|
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
@@ -1213,7 +1394,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1213
1394
|
} else {
|
|
1214
1395
|
var _item$_productOrigin7, _productResources$fin;
|
|
1215
1396
|
// 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
|
|
1216
|
-
var allCartItems =
|
|
1397
|
+
var allCartItems = _this8.store.cart.getItems();
|
|
1217
1398
|
// 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
|
|
1218
1399
|
if (!item.holder_id) return;
|
|
1219
1400
|
var selectedResources = getOthersSelectedResources(allCartItems, item.holder_id, resourcesMap);
|
|
@@ -1234,7 +1415,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1234
1415
|
targetResource.capacity = currentCapacity;
|
|
1235
1416
|
// 在这里处理 children 的数据
|
|
1236
1417
|
checkSubResourcesCapacity(targetResource);
|
|
1237
|
-
|
|
1418
|
+
_this8.store.cart.updateItem({
|
|
1238
1419
|
_id: item._id,
|
|
1239
1420
|
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
1240
1421
|
return existingRes.resourceType !== targetRenderList[0].resourceType;
|
|
@@ -1256,7 +1437,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1256
1437
|
}, {
|
|
1257
1438
|
key: "getTimeSlotByAllResources",
|
|
1258
1439
|
value: function getTimeSlotByAllResources(resources_code) {
|
|
1259
|
-
var
|
|
1440
|
+
var _this9 = this;
|
|
1260
1441
|
var dateRange = this.store.date.getDateRange();
|
|
1261
1442
|
// 取出购物车中所有一已选择的第一步资源
|
|
1262
1443
|
var resources = [];
|
|
@@ -1281,7 +1462,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1281
1462
|
// duration = 不同账号的最长时间
|
|
1282
1463
|
this.store.accountList.getAccounts().forEach(function (account) {
|
|
1283
1464
|
var accountDuration = 0;
|
|
1284
|
-
var cartItems =
|
|
1465
|
+
var cartItems = _this9.store.cart.getCartByAccount(account.getId());
|
|
1285
1466
|
cartItems.forEach(function (item) {
|
|
1286
1467
|
var _item$_productOrigin$3, _item$_productOrigin9;
|
|
1287
1468
|
accountDuration += (_item$_productOrigin$3 = (_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.duration) === null || _item$_productOrigin9 === void 0 ? void 0 : _item$_productOrigin9.value) !== null && _item$_productOrigin$3 !== void 0 ? _item$_productOrigin$3 : 0;
|
|
@@ -1304,7 +1485,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1304
1485
|
}, {
|
|
1305
1486
|
key: "submitTimeSlot",
|
|
1306
1487
|
value: function submitTimeSlot(timeSlots) {
|
|
1307
|
-
var
|
|
1488
|
+
var _this10 = this;
|
|
1308
1489
|
// 以账号为维度处理数据。购物车里每一项的 startTime应该是前一个商品的 endTime,如果是第一个商品则用 timeSlots.start_at
|
|
1309
1490
|
var cartItems = this.store.cart.getItems();
|
|
1310
1491
|
|
|
@@ -1320,16 +1501,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1320
1501
|
|
|
1321
1502
|
// 处理每个账号的商品
|
|
1322
1503
|
Object.values(itemsByAccount).forEach(function (accountItems) {
|
|
1323
|
-
var currentStartTime = timeSlots.start_at.format(
|
|
1504
|
+
var currentStartTime = timeSlots.start_at.format('YYYY-MM-DD HH:mm');
|
|
1324
1505
|
accountItems.forEach(function (item, index) {
|
|
1325
1506
|
var newResources = cloneDeep(item._origin.resources);
|
|
1326
1507
|
newResources.forEach(function (resource) {
|
|
1327
1508
|
var _item$_productOrigin$4, _item$_productOrigin10, _ref11, _item$_productOrigin11;
|
|
1328
1509
|
resource.startTime = currentStartTime;
|
|
1329
|
-
resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.duration) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.value) !== null && _item$_productOrigin$4 !== void 0 ? _item$_productOrigin$4 : 0, (_ref11 = (_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.duration) === null || _item$_productOrigin11 === void 0 ? void 0 : _item$_productOrigin11.type) !== null && _ref11 !== void 0 ? _ref11 :
|
|
1510
|
+
resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.duration) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.value) !== null && _item$_productOrigin$4 !== void 0 ? _item$_productOrigin$4 : 0, (_ref11 = (_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.duration) === null || _item$_productOrigin11 === void 0 ? void 0 : _item$_productOrigin11.type) !== null && _ref11 !== void 0 ? _ref11 : 'minutes').format('YYYY-MM-DD HH:mm');
|
|
1330
1511
|
delete resource.times;
|
|
1331
1512
|
});
|
|
1332
|
-
|
|
1513
|
+
_this10.store.cart.updateItem({
|
|
1333
1514
|
_id: item._id,
|
|
1334
1515
|
resources: newResources
|
|
1335
1516
|
});
|
|
@@ -1347,32 +1528,188 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1347
1528
|
}, {
|
|
1348
1529
|
key: "clearCacheByModule",
|
|
1349
1530
|
value: function clearCacheByModule(module) {}
|
|
1531
|
+
}, {
|
|
1532
|
+
key: "getScheduleDataByIds",
|
|
1533
|
+
value: function getScheduleDataByIds(scheduleIds) {
|
|
1534
|
+
var targetSchedules = this.store.schedule.getScheduleListByIds(scheduleIds);
|
|
1535
|
+
var targetSchedulesData = targetSchedules.map(function (item) {
|
|
1536
|
+
return calcCalendarDataByScheduleResult(item);
|
|
1537
|
+
});
|
|
1538
|
+
var newSchedule = {};
|
|
1539
|
+
targetSchedulesData.forEach(function (item) {
|
|
1540
|
+
item.forEach(function (n) {
|
|
1541
|
+
if (!newSchedule[n.date]) {
|
|
1542
|
+
newSchedule[n.date] = n;
|
|
1543
|
+
} else {
|
|
1544
|
+
if (!n.isExcluded) {
|
|
1545
|
+
newSchedule[n.date].isExcluded = false;
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
});
|
|
1549
|
+
});
|
|
1550
|
+
var newScheduleArr = Object.values(newSchedule);
|
|
1551
|
+
return newScheduleArr;
|
|
1552
|
+
}
|
|
1553
|
+
// 打开某个商品详情的弹窗,OS 层这边会记录当前选中的商品,适用于 session 类商品预约
|
|
1350
1554
|
}, {
|
|
1351
1555
|
key: "openProductDetail",
|
|
1352
1556
|
value: function () {
|
|
1353
|
-
var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1354
|
-
var targetProduct;
|
|
1355
|
-
return _regeneratorRuntime().wrap(function
|
|
1356
|
-
while (1) switch (
|
|
1557
|
+
var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(productId) {
|
|
1558
|
+
var targetProduct, targetProductData, newScheduleArr;
|
|
1559
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1560
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1357
1561
|
case 0:
|
|
1358
|
-
|
|
1562
|
+
_context24.next = 2;
|
|
1359
1563
|
return this.store.products.getProduct(productId);
|
|
1360
1564
|
case 2:
|
|
1361
|
-
targetProduct =
|
|
1565
|
+
targetProduct = _context24.sent;
|
|
1362
1566
|
if (targetProduct) {
|
|
1567
|
+
targetProductData = targetProduct.getData();
|
|
1363
1568
|
this.store.currentProduct = targetProduct;
|
|
1569
|
+
newScheduleArr = this.getScheduleDataByIds(targetProductData['schedule.ids']);
|
|
1570
|
+
targetProduct.setOtherParams('schedule', newScheduleArr);
|
|
1364
1571
|
}
|
|
1365
1572
|
case 4:
|
|
1366
1573
|
case "end":
|
|
1367
|
-
return
|
|
1574
|
+
return _context24.stop();
|
|
1368
1575
|
}
|
|
1369
|
-
},
|
|
1576
|
+
}, _callee24, this);
|
|
1370
1577
|
}));
|
|
1371
|
-
function openProductDetail(
|
|
1578
|
+
function openProductDetail(_x16) {
|
|
1372
1579
|
return _openProductDetail.apply(this, arguments);
|
|
1373
1580
|
}
|
|
1374
1581
|
return openProductDetail;
|
|
1375
1582
|
}()
|
|
1583
|
+
}, {
|
|
1584
|
+
key: "closeProductDetail",
|
|
1585
|
+
value: function closeProductDetail() {
|
|
1586
|
+
var _this$store$currentPr;
|
|
1587
|
+
(_this$store$currentPr = this.store.currentProduct) === null || _this$store$currentPr === void 0 || _this$store$currentPr.setOtherParams('schedule', []);
|
|
1588
|
+
this.store.currentProduct = undefined;
|
|
1589
|
+
}
|
|
1590
|
+
}, {
|
|
1591
|
+
key: "getTimeslotBySchedule",
|
|
1592
|
+
value: function getTimeslotBySchedule(_ref12) {
|
|
1593
|
+
var date = _ref12.date,
|
|
1594
|
+
scheduleIds = _ref12.scheduleIds;
|
|
1595
|
+
var targetProduct = this.store.currentProduct;
|
|
1596
|
+
var targetProductData = targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.getData();
|
|
1597
|
+
var targetSchedules = [];
|
|
1598
|
+
// 如果外面传递了 scheduleIds,优先取入参
|
|
1599
|
+
if (scheduleIds !== null && scheduleIds !== void 0 && scheduleIds.length) {
|
|
1600
|
+
targetSchedules = this.store.schedule.getScheduleListByIds(scheduleIds);
|
|
1601
|
+
} else {
|
|
1602
|
+
targetSchedules = this.store.schedule.getScheduleListByIds(targetProductData['schedule.ids']);
|
|
1603
|
+
}
|
|
1604
|
+
var resourcesDates = this.store.date.getDateList();
|
|
1605
|
+
var targetResourceDate = resourcesDates.find(function (n) {
|
|
1606
|
+
return n.date === date;
|
|
1607
|
+
});
|
|
1608
|
+
var minTimeMaxTime = calcMinTimeMaxTimeBySchedules(targetSchedules, {}, date);
|
|
1609
|
+
var scheduleTimeSlots = getAllSortedDateRanges(minTimeMaxTime);
|
|
1610
|
+
console.log('scheduleTimeSlots:', scheduleTimeSlots, targetResourceDate);
|
|
1611
|
+
var formatScheduleTimeSlots = scheduleTimeSlots.map(function (item) {
|
|
1612
|
+
var _targetResourceDate$r;
|
|
1613
|
+
console.log(item);
|
|
1614
|
+
var count = 0;
|
|
1615
|
+
targetResourceDate === null || targetResourceDate === void 0 || (_targetResourceDate$r = targetResourceDate.resource) === null || _targetResourceDate$r === void 0 || _targetResourceDate$r.forEach(function (n) {
|
|
1616
|
+
var res = getIsUsableByTimeItem({
|
|
1617
|
+
timeSlice: {
|
|
1618
|
+
start_time: item.start,
|
|
1619
|
+
end_time: item.end,
|
|
1620
|
+
start_at: dayjs(item.start),
|
|
1621
|
+
end_at: dayjs(item.end)
|
|
1622
|
+
},
|
|
1623
|
+
time: item,
|
|
1624
|
+
resource: n,
|
|
1625
|
+
currentCount: 1
|
|
1626
|
+
});
|
|
1627
|
+
if (res.usable) {
|
|
1628
|
+
count += 1;
|
|
1629
|
+
}
|
|
1630
|
+
});
|
|
1631
|
+
var startDayJs = dayjs(item.start);
|
|
1632
|
+
var endDayJs = dayjs(item.end);
|
|
1633
|
+
return {
|
|
1634
|
+
start_time: startDayJs.format('HH:mm'),
|
|
1635
|
+
end_time: endDayJs.format('HH:mm'),
|
|
1636
|
+
start_at: startDayJs,
|
|
1637
|
+
end_at: endDayJs,
|
|
1638
|
+
count: count
|
|
1639
|
+
};
|
|
1640
|
+
});
|
|
1641
|
+
return formatScheduleTimeSlots;
|
|
1642
|
+
}
|
|
1643
|
+
}, {
|
|
1644
|
+
key: "addProductToCart",
|
|
1645
|
+
value: function addProductToCart(_ref13) {
|
|
1646
|
+
var product = _ref13.product,
|
|
1647
|
+
date = _ref13.date,
|
|
1648
|
+
account = _ref13.account;
|
|
1649
|
+
var _ref14 = product || {},
|
|
1650
|
+
bundle = _ref14.bundle,
|
|
1651
|
+
options = _ref14.options,
|
|
1652
|
+
origin = _ref14.origin,
|
|
1653
|
+
product_variant_id = _ref14.product_variant_id;
|
|
1654
|
+
var productData = _objectSpread(_objectSpread({}, origin), {}, {
|
|
1655
|
+
product_variant_id: product_variant_id
|
|
1656
|
+
});
|
|
1657
|
+
this.store.cart.addItem({
|
|
1658
|
+
product: productData,
|
|
1659
|
+
date: date,
|
|
1660
|
+
account: account,
|
|
1661
|
+
bundle: bundle,
|
|
1662
|
+
options: options
|
|
1663
|
+
});
|
|
1664
|
+
}
|
|
1665
|
+
}, {
|
|
1666
|
+
key: "setOtherData",
|
|
1667
|
+
value: function setOtherData(key, value) {
|
|
1668
|
+
this.otherData[key] = value;
|
|
1669
|
+
this.checkSaveCache({
|
|
1670
|
+
cacheId: this.cacheId,
|
|
1671
|
+
fatherModule: this.name,
|
|
1672
|
+
store: {
|
|
1673
|
+
otherData: this.otherData
|
|
1674
|
+
},
|
|
1675
|
+
cacheKey: ['otherData']
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1678
|
+
}, {
|
|
1679
|
+
key: "getOtherData",
|
|
1680
|
+
value: function getOtherData(key) {
|
|
1681
|
+
return this.otherData[key];
|
|
1682
|
+
}
|
|
1683
|
+
}, {
|
|
1684
|
+
key: "getProductTypeById",
|
|
1685
|
+
value: function () {
|
|
1686
|
+
var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(id) {
|
|
1687
|
+
var product;
|
|
1688
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1689
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1690
|
+
case 0:
|
|
1691
|
+
_context25.next = 2;
|
|
1692
|
+
return this.store.products.getProduct(id);
|
|
1693
|
+
case 2:
|
|
1694
|
+
product = _context25.sent;
|
|
1695
|
+
if (!product) {
|
|
1696
|
+
_context25.next = 5;
|
|
1697
|
+
break;
|
|
1698
|
+
}
|
|
1699
|
+
return _context25.abrupt("return", product.getProductType());
|
|
1700
|
+
case 5:
|
|
1701
|
+
return _context25.abrupt("return", 'normal');
|
|
1702
|
+
case 6:
|
|
1703
|
+
case "end":
|
|
1704
|
+
return _context25.stop();
|
|
1705
|
+
}
|
|
1706
|
+
}, _callee25, this);
|
|
1707
|
+
}));
|
|
1708
|
+
function getProductTypeById(_x17) {
|
|
1709
|
+
return _getProductTypeById.apply(this, arguments);
|
|
1710
|
+
}
|
|
1711
|
+
return getProductTypeById;
|
|
1712
|
+
}()
|
|
1376
1713
|
}]);
|
|
1377
1714
|
return BookingByStepImpl;
|
|
1378
1715
|
}(BaseModule);
|