@pisell/pisellos 0.0.50 → 0.0.52
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/utils.d.ts +1 -1
- package/dist/modules/Cart/utils.js +9 -2
- package/dist/solution/BookingByStep/index.d.ts +4 -1
- package/dist/solution/BookingByStep/index.js +110 -70
- package/lib/modules/Cart/utils.d.ts +1 -1
- package/lib/modules/Cart/utils.js +4 -1
- package/lib/solution/BookingByStep/index.d.ts +4 -1
- package/lib/solution/BookingByStep/index.js +56 -25
- package/package.json +1 -1
|
@@ -598,8 +598,15 @@ export var handleProductDeposit = function handleProductDeposit(params) {
|
|
|
598
598
|
var depositData = params.depositData,
|
|
599
599
|
total = params.total,
|
|
600
600
|
num = params.num;
|
|
601
|
-
|
|
602
|
-
|
|
601
|
+
if (!depositData) {
|
|
602
|
+
return {
|
|
603
|
+
result: false,
|
|
604
|
+
depositTotal: new Decimal(0)
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
var _ref3 = depositData || {},
|
|
608
|
+
deposit_fixed = _ref3.deposit_fixed,
|
|
609
|
+
deposit_percentage = _ref3.deposit_percentage;
|
|
603
610
|
if (typeof deposit_fixed === 'string' && typeof deposit_percentage === 'string') {
|
|
604
611
|
var depositFixed = Decimal(deposit_fixed || 0);
|
|
605
612
|
var depositPercent = Decimal(deposit_percentage || 0);
|
|
@@ -44,7 +44,10 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
44
44
|
collection?: number | string[];
|
|
45
45
|
schedule_ids?: number[];
|
|
46
46
|
}): Promise<any>;
|
|
47
|
-
loadProductByScheduleDate(date
|
|
47
|
+
loadProductByScheduleDate({ date, product_ids, }: {
|
|
48
|
+
date: string;
|
|
49
|
+
product_ids?: number[];
|
|
50
|
+
}): Promise<any>;
|
|
48
51
|
loadAllSchedule(): Promise<void>;
|
|
49
52
|
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, }: {
|
|
50
53
|
startDate: string;
|
|
@@ -113,8 +113,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
115
|
this.core.effects.emit(BookingByStepHooks.onInited, {});
|
|
116
|
-
|
|
117
|
-
case 16:
|
|
116
|
+
case 15:
|
|
118
117
|
case "end":
|
|
119
118
|
return _context.stop();
|
|
120
119
|
}
|
|
@@ -211,7 +210,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
211
210
|
ids: product_ids,
|
|
212
211
|
collection: collection,
|
|
213
212
|
front_end_cache_id: this.cacheId,
|
|
214
|
-
|
|
213
|
+
client_schedule_ids: schedule_ids
|
|
215
214
|
}, {
|
|
216
215
|
useCache: true
|
|
217
216
|
});
|
|
@@ -233,24 +232,32 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
233
232
|
}, {
|
|
234
233
|
key: "loadProductByScheduleDate",
|
|
235
234
|
value: function () {
|
|
236
|
-
var _loadProductByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(
|
|
237
|
-
var scheduleList, scheduleIds;
|
|
235
|
+
var _loadProductByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref2) {
|
|
236
|
+
var date, product_ids, scheduleList, scheduleIds;
|
|
238
237
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
239
238
|
while (1) switch (_context3.prev = _context3.next) {
|
|
240
239
|
case 0:
|
|
241
|
-
|
|
240
|
+
date = _ref2.date, product_ids = _ref2.product_ids;
|
|
241
|
+
scheduleList = this.store.schedule.getAvailabilityScheduleDateList(); // 缓存下这次选择的结果,如果是先选日期再选 duration 类商品,后面用得到
|
|
242
|
+
this.setDateRange([{
|
|
243
|
+
date: date,
|
|
244
|
+
status: 'available',
|
|
245
|
+
week: '',
|
|
246
|
+
weekNum: 0
|
|
247
|
+
}]);
|
|
242
248
|
scheduleIds = scheduleList.filter(function (n) {
|
|
243
249
|
return n.date === date;
|
|
244
250
|
}).flatMap(function (n) {
|
|
245
251
|
return n.schedule_id;
|
|
246
252
|
});
|
|
247
|
-
_context3.next =
|
|
253
|
+
_context3.next = 6;
|
|
248
254
|
return this.loadProducts({
|
|
249
|
-
schedule_ids: scheduleIds
|
|
255
|
+
schedule_ids: scheduleIds,
|
|
256
|
+
product_ids: product_ids
|
|
250
257
|
});
|
|
251
|
-
case
|
|
258
|
+
case 6:
|
|
252
259
|
return _context3.abrupt("return", _context3.sent);
|
|
253
|
-
case
|
|
260
|
+
case 7:
|
|
254
261
|
case "end":
|
|
255
262
|
return _context3.stop();
|
|
256
263
|
}
|
|
@@ -289,13 +296,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
289
296
|
}, {
|
|
290
297
|
key: "loadScheduleAvailableDate",
|
|
291
298
|
value: function () {
|
|
292
|
-
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(
|
|
299
|
+
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref3) {
|
|
293
300
|
var _res$data$date_list;
|
|
294
301
|
var startDate, endDate, custom_page_id, dates, res;
|
|
295
302
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
296
303
|
while (1) switch (_context5.prev = _context5.next) {
|
|
297
304
|
case 0:
|
|
298
|
-
startDate =
|
|
305
|
+
startDate = _ref3.startDate, endDate = _ref3.endDate, custom_page_id = _ref3.custom_page_id;
|
|
299
306
|
// 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天,需要把 startDate 置为今天
|
|
300
307
|
if (dayjs(startDate).isBefore(dayjs())) {
|
|
301
308
|
startDate = dayjs().format('YYYY-MM-DD');
|
|
@@ -353,13 +360,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
353
360
|
key: "storeProduct",
|
|
354
361
|
value: function () {
|
|
355
362
|
var _storeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(productData) {
|
|
356
|
-
var activeAccount,
|
|
363
|
+
var activeAccount, _ref4, bundle, options, origin, product_variant_id, product, addCartItem;
|
|
357
364
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
358
365
|
while (1) switch (_context6.prev = _context6.next) {
|
|
359
366
|
case 0:
|
|
360
367
|
// 往购物车加商品数据的时候,默认用当前 activeAccount 填充到 product 的 account 里面
|
|
361
368
|
activeAccount = this.getActiveAccount();
|
|
362
|
-
|
|
369
|
+
_ref4 = productData || {}, bundle = _ref4.bundle, options = _ref4.options, origin = _ref4.origin, product_variant_id = _ref4.product_variant_id;
|
|
363
370
|
product = _objectSpread(_objectSpread({}, origin), {}, {
|
|
364
371
|
product_variant_id: product_variant_id
|
|
365
372
|
});
|
|
@@ -607,18 +614,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
607
614
|
key: "getAvailableDate",
|
|
608
615
|
value: function () {
|
|
609
616
|
var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
610
|
-
var _this3 = this
|
|
611
|
-
_this$otherParams3,
|
|
612
|
-
_this$otherParams4;
|
|
617
|
+
var _this3 = this;
|
|
613
618
|
var params,
|
|
614
619
|
products,
|
|
615
620
|
startDate,
|
|
616
621
|
endDate,
|
|
617
622
|
type,
|
|
618
623
|
tempProducts,
|
|
624
|
+
dateRange,
|
|
619
625
|
tempStartDate,
|
|
620
626
|
tempEndDate,
|
|
621
|
-
|
|
627
|
+
_ref5,
|
|
622
628
|
resourceIds,
|
|
623
629
|
rules,
|
|
624
630
|
resourcesMap,
|
|
@@ -650,18 +656,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
650
656
|
_schedule: this.store.currentProduct.getOtherParams()['schedule']
|
|
651
657
|
})];
|
|
652
658
|
}
|
|
653
|
-
|
|
654
|
-
|
|
659
|
+
_context13.next = 8;
|
|
660
|
+
return this.getDateRange();
|
|
661
|
+
case 8:
|
|
662
|
+
dateRange = _context13.sent;
|
|
663
|
+
tempStartDate = startDate || (dateRange === null || dateRange === void 0 ? void 0 : dateRange[0].date);
|
|
664
|
+
tempEndDate = endDate || (dateRange === null || dateRange === void 0 ? void 0 : dateRange[0].date);
|
|
655
665
|
if (tempProducts.length) {
|
|
656
|
-
_context13.next =
|
|
666
|
+
_context13.next = 13;
|
|
657
667
|
break;
|
|
658
668
|
}
|
|
659
669
|
return _context13.abrupt("return", []);
|
|
660
|
-
case
|
|
670
|
+
case 13:
|
|
661
671
|
// 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
|
|
662
|
-
|
|
672
|
+
_ref5 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref5.resourceIds, rules = _ref5.rules, resourcesMap = _ref5.resourcesMap;
|
|
663
673
|
this.otherParams.currentResourcesMap = resourcesMap;
|
|
664
|
-
_context13.next =
|
|
674
|
+
_context13.next = 17;
|
|
665
675
|
return this.store.date.getResourceDates({
|
|
666
676
|
url: params.url,
|
|
667
677
|
query: {
|
|
@@ -672,10 +682,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
672
682
|
rules: rules,
|
|
673
683
|
type: type
|
|
674
684
|
});
|
|
675
|
-
case
|
|
685
|
+
case 17:
|
|
676
686
|
res = _context13.sent;
|
|
677
687
|
return _context13.abrupt("return", res);
|
|
678
|
-
case
|
|
688
|
+
case 19:
|
|
679
689
|
case "end":
|
|
680
690
|
return _context13.stop();
|
|
681
691
|
}
|
|
@@ -928,14 +938,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
928
938
|
key: "setOtherParams",
|
|
929
939
|
value: function () {
|
|
930
940
|
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
931
|
-
var
|
|
932
|
-
|
|
941
|
+
var _ref6,
|
|
942
|
+
_ref6$cover,
|
|
933
943
|
cover,
|
|
934
944
|
_args23 = arguments;
|
|
935
945
|
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
936
946
|
while (1) switch (_context23.prev = _context23.next) {
|
|
937
947
|
case 0:
|
|
938
|
-
|
|
948
|
+
_ref6 = _args23.length > 1 && _args23[1] !== undefined ? _args23[1] : {}, _ref6$cover = _ref6.cover, cover = _ref6$cover === void 0 ? false : _ref6$cover;
|
|
939
949
|
if (cover) {
|
|
940
950
|
this.otherParams = params;
|
|
941
951
|
} else {
|
|
@@ -1198,10 +1208,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1198
1208
|
// 通过资源列表和指定的资源 id,获取指定资源的时间切片
|
|
1199
1209
|
}, {
|
|
1200
1210
|
key: "getResourceTimeSlot",
|
|
1201
|
-
value: function getResourceTimeSlot(
|
|
1202
|
-
var product =
|
|
1203
|
-
resources =
|
|
1204
|
-
currentResourceId =
|
|
1211
|
+
value: function getResourceTimeSlot(_ref7) {
|
|
1212
|
+
var product = _ref7.product,
|
|
1213
|
+
resources = _ref7.resources,
|
|
1214
|
+
currentResourceId = _ref7.currentResourceId;
|
|
1205
1215
|
var dateRange = this.store.date.getDateRange();
|
|
1206
1216
|
var timeSlots = getTimeSlicesByResource({
|
|
1207
1217
|
resource: resources.find(function (n) {
|
|
@@ -1217,10 +1227,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1217
1227
|
// 自动分派可用的资源-单种资源类型——此方法目前未使用,未经验证
|
|
1218
1228
|
}, {
|
|
1219
1229
|
key: "autoSelectResource",
|
|
1220
|
-
value: function autoSelectResource(
|
|
1221
|
-
var resourceProductData =
|
|
1222
|
-
resources =
|
|
1223
|
-
timeSlots =
|
|
1230
|
+
value: function autoSelectResource(_ref8) {
|
|
1231
|
+
var resourceProductData = _ref8.resourceProductData,
|
|
1232
|
+
resources = _ref8.resources,
|
|
1233
|
+
timeSlots = _ref8.timeSlots;
|
|
1224
1234
|
var dateRange = this.store.date.getDateRange();
|
|
1225
1235
|
if (timeSlots) {
|
|
1226
1236
|
// 如果 start_time 存在,则直接根据 start_time 算出商品总共需要的时长,然后根据时长去匹配资源
|
|
@@ -1289,23 +1299,21 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1289
1299
|
// 自动分派可用资源-pro 版,ui 传递某个账号,自动给某个账号下所有商品分配第一种资源
|
|
1290
1300
|
}, {
|
|
1291
1301
|
key: "autoSelectAccountResources",
|
|
1292
|
-
value: function autoSelectAccountResources(
|
|
1293
|
-
var holder_id =
|
|
1294
|
-
resources_code =
|
|
1295
|
-
timeSlots =
|
|
1296
|
-
countMap =
|
|
1297
|
-
capacity =
|
|
1302
|
+
value: function autoSelectAccountResources(_ref9) {
|
|
1303
|
+
var holder_id = _ref9.holder_id,
|
|
1304
|
+
resources_code = _ref9.resources_code,
|
|
1305
|
+
timeSlots = _ref9.timeSlots,
|
|
1306
|
+
countMap = _ref9.countMap,
|
|
1307
|
+
capacity = _ref9.capacity;
|
|
1298
1308
|
var dateRange = this.store.date.getDateRange();
|
|
1299
1309
|
var cartItems = this.store.cart.getItems();
|
|
1300
1310
|
// 取到账号下所有的商品,然后根据商品的 duration 和资源列表,获取所有可用的资源
|
|
1301
1311
|
var accountCartItems = cartItems.filter(function (n) {
|
|
1302
1312
|
return n.holder_id === holder_id;
|
|
1303
1313
|
}) || [];
|
|
1304
|
-
//
|
|
1314
|
+
// 账号下没商品则处理所有购物车
|
|
1305
1315
|
if (!accountCartItems.length) {
|
|
1306
|
-
|
|
1307
|
-
selectedResource: null
|
|
1308
|
-
};
|
|
1316
|
+
accountCartItems = cartItems;
|
|
1309
1317
|
}
|
|
1310
1318
|
// duration=所有商品时间的集合
|
|
1311
1319
|
var duration = accountCartItems.reduce(function (acc, n) {
|
|
@@ -1403,8 +1411,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1403
1411
|
// 一个账号一个账号处理
|
|
1404
1412
|
var errorList = [];
|
|
1405
1413
|
var selectResourcesMap = {};
|
|
1406
|
-
this.store.accountList.getAccounts()
|
|
1407
|
-
|
|
1414
|
+
var accountList = this.store.accountList.getAccounts();
|
|
1415
|
+
var selectForCartResources = function selectForCartResources(cartItems) {
|
|
1408
1416
|
var recordTimeSlots = cloneDeep(timeSlots);
|
|
1409
1417
|
// timeSlots 传进来的只是用户选中的时间片,但是实际上需要根据多个商品时间进行累加
|
|
1410
1418
|
// 假设 timeSlots.start_time 是15:40 duration 是 30min
|
|
@@ -1419,11 +1427,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1419
1427
|
var currentCapacity = getSumCapacity({
|
|
1420
1428
|
capacity: formatCapacity
|
|
1421
1429
|
});
|
|
1422
|
-
|
|
1430
|
+
// 如果商品已经有时间数据了,意味着是通过先选日期再选商品流程进来的,相当于时间切片已经选中了
|
|
1431
|
+
if (item._origin.start_time && !(timeSlots !== null && timeSlots !== void 0 && timeSlots.start_time)) {
|
|
1432
|
+
recordTimeSlots = {
|
|
1433
|
+
start_time: item._origin.start_time,
|
|
1434
|
+
end_time: item._origin.end_time,
|
|
1435
|
+
start_at: dayjs("".concat(item.start_date, " ").concat(item._origin.start_time)),
|
|
1436
|
+
end_at: dayjs("".concat(item.end_date, " ").concat(item._origin.end_time))
|
|
1437
|
+
};
|
|
1438
|
+
}
|
|
1439
|
+
if (recordTimeSlots) {
|
|
1423
1440
|
if (index !== 0 && recordTimeSlots) {
|
|
1424
|
-
var _item$_productOrigin$, _item$_productOrigin3,
|
|
1425
|
-
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, (
|
|
1426
|
-
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, (
|
|
1441
|
+
var _item$_productOrigin$, _item$_productOrigin3, _ref10, _item$_productOrigin4, _item$_productOrigin$2, _item$_productOrigin5, _ref11, _item$_productOrigin6;
|
|
1442
|
+
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, (_ref10 = (_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 && _ref10 !== void 0 ? _ref10 : 'minutes');
|
|
1443
|
+
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, (_ref11 = (_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 && _ref11 !== void 0 ? _ref11 : 'minutes');
|
|
1427
1444
|
recordTimeSlots = {
|
|
1428
1445
|
start_time: start_at.format('HH:mm'),
|
|
1429
1446
|
end_time: end_at.format('HH:mm'),
|
|
@@ -1496,14 +1513,24 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1496
1513
|
return existingRes.resourceType !== targetRenderList[0].resourceType;
|
|
1497
1514
|
})), [targetResource])
|
|
1498
1515
|
});
|
|
1499
|
-
console.log(account, '已分配');
|
|
1500
1516
|
} else {
|
|
1501
1517
|
// 如果没有可用的技师了,推到错误列表里让 UI 去提示
|
|
1502
1518
|
errorList.push(item._id);
|
|
1503
1519
|
}
|
|
1504
1520
|
}
|
|
1505
1521
|
});
|
|
1506
|
-
}
|
|
1522
|
+
};
|
|
1523
|
+
var cartItems = this.store.cart.getItems();
|
|
1524
|
+
|
|
1525
|
+
// 如果购物车里没有 holderid数据,证明不按 holder 类流程预约走,给所有购物车一次性分派即可,不做账号下资源互斥逻辑
|
|
1526
|
+
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
1527
|
+
accountList.forEach(function (account) {
|
|
1528
|
+
var cartItems = _this7.store.cart.getCartByAccount(account.getId());
|
|
1529
|
+
selectForCartResources(cartItems);
|
|
1530
|
+
});
|
|
1531
|
+
} else {
|
|
1532
|
+
selectForCartResources(cartItems);
|
|
1533
|
+
}
|
|
1507
1534
|
return {
|
|
1508
1535
|
errorList: errorList
|
|
1509
1536
|
};
|
|
@@ -1580,9 +1607,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1580
1607
|
accountItems.forEach(function (item, index) {
|
|
1581
1608
|
var newResources = cloneDeep(item._origin.resources);
|
|
1582
1609
|
newResources.forEach(function (resource) {
|
|
1583
|
-
var _item$_productOrigin$4, _item$_productOrigin10,
|
|
1610
|
+
var _item$_productOrigin$4, _item$_productOrigin10, _ref12, _item$_productOrigin11;
|
|
1584
1611
|
resource.startTime = currentStartTime;
|
|
1585
|
-
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, (
|
|
1612
|
+
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, (_ref12 = (_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 && _ref12 !== void 0 ? _ref12 : 'minutes').format('YYYY-MM-DD HH:mm');
|
|
1586
1613
|
delete resource.times;
|
|
1587
1614
|
});
|
|
1588
1615
|
_this9.store.cart.updateItem({
|
|
@@ -1664,11 +1691,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1664
1691
|
}
|
|
1665
1692
|
}, {
|
|
1666
1693
|
key: "getTimeslotBySchedule",
|
|
1667
|
-
value: function getTimeslotBySchedule(
|
|
1694
|
+
value: function getTimeslotBySchedule(_ref13) {
|
|
1668
1695
|
var _this$store$currentPr2;
|
|
1669
|
-
var date =
|
|
1670
|
-
scheduleIds =
|
|
1671
|
-
resources =
|
|
1696
|
+
var date = _ref13.date,
|
|
1697
|
+
scheduleIds = _ref13.scheduleIds,
|
|
1698
|
+
resources = _ref13.resources;
|
|
1672
1699
|
var targetProduct = this.store.currentProduct;
|
|
1673
1700
|
var targetProductData = targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.getData();
|
|
1674
1701
|
var targetSchedules = [];
|
|
@@ -1732,15 +1759,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1732
1759
|
}
|
|
1733
1760
|
}, {
|
|
1734
1761
|
key: "addProductToCart",
|
|
1735
|
-
value: function addProductToCart(
|
|
1736
|
-
var
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1762
|
+
value: function addProductToCart(_ref14) {
|
|
1763
|
+
var _this10 = this;
|
|
1764
|
+
var product = _ref14.product,
|
|
1765
|
+
date = _ref14.date,
|
|
1766
|
+
account = _ref14.account;
|
|
1767
|
+
var _ref15 = product || {},
|
|
1768
|
+
bundle = _ref15.bundle,
|
|
1769
|
+
options = _ref15.options,
|
|
1770
|
+
origin = _ref15.origin,
|
|
1771
|
+
product_variant_id = _ref15.product_variant_id;
|
|
1744
1772
|
var productData = _objectSpread(_objectSpread({}, origin), {}, {
|
|
1745
1773
|
product_variant_id: product_variant_id
|
|
1746
1774
|
});
|
|
@@ -1751,6 +1779,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1751
1779
|
bundle: bundle,
|
|
1752
1780
|
options: options
|
|
1753
1781
|
});
|
|
1782
|
+
// 检测,有传递 date,检查购物车里其他商品的 date 是否在同一天,如果不在,清空那些不在同一天的商品
|
|
1783
|
+
if (date) {
|
|
1784
|
+
var cartItems = this.store.cart.getItems();
|
|
1785
|
+
var cartItemsByDate = cartItems.filter(function (n) {
|
|
1786
|
+
return !dayjs(n.start_date).isSame(dayjs(date.startTime), 'day');
|
|
1787
|
+
});
|
|
1788
|
+
if (cartItemsByDate.length) {
|
|
1789
|
+
cartItemsByDate.forEach(function (n) {
|
|
1790
|
+
_this10.store.cart.removeItem(n._id);
|
|
1791
|
+
});
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1754
1794
|
}
|
|
1755
1795
|
}, {
|
|
1756
1796
|
key: "setOtherData",
|
|
@@ -475,7 +475,10 @@ var getProductDeposit = (params) => {
|
|
|
475
475
|
};
|
|
476
476
|
var handleProductDeposit = (params) => {
|
|
477
477
|
const { depositData, total, num } = params;
|
|
478
|
-
|
|
478
|
+
if (!depositData) {
|
|
479
|
+
return { result: false, depositTotal: new import_decimal.default(0) };
|
|
480
|
+
}
|
|
481
|
+
const { deposit_fixed, deposit_percentage } = depositData || {};
|
|
479
482
|
if (typeof deposit_fixed === "string" && typeof deposit_percentage === "string") {
|
|
480
483
|
const depositFixed = (0, import_decimal.default)(deposit_fixed || 0);
|
|
481
484
|
const depositPercent = (0, import_decimal.default)(deposit_percentage || 0);
|
|
@@ -44,7 +44,10 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
44
44
|
collection?: number | string[];
|
|
45
45
|
schedule_ids?: number[];
|
|
46
46
|
}): Promise<any>;
|
|
47
|
-
loadProductByScheduleDate(date
|
|
47
|
+
loadProductByScheduleDate({ date, product_ids, }: {
|
|
48
|
+
date: string;
|
|
49
|
+
product_ids?: number[];
|
|
50
|
+
}): Promise<any>;
|
|
48
51
|
loadAllSchedule(): Promise<void>;
|
|
49
52
|
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, }: {
|
|
50
53
|
startDate: string;
|
|
@@ -103,7 +103,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
105
|
this.core.effects.emit(import_types.BookingByStepHooks.onInited, {});
|
|
106
|
-
this.loadAllSchedule();
|
|
107
106
|
}
|
|
108
107
|
// 初始化step
|
|
109
108
|
initStep(stepList) {
|
|
@@ -173,17 +172,21 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
173
172
|
ids: product_ids,
|
|
174
173
|
collection,
|
|
175
174
|
front_end_cache_id: this.cacheId,
|
|
176
|
-
schedule_ids
|
|
175
|
+
client_schedule_ids: schedule_ids
|
|
177
176
|
},
|
|
178
177
|
{ useCache: true }
|
|
179
178
|
);
|
|
180
179
|
this.store.products.addProduct(productsData.data.list);
|
|
181
180
|
return productsData.data.list;
|
|
182
181
|
}
|
|
183
|
-
async loadProductByScheduleDate(
|
|
182
|
+
async loadProductByScheduleDate({
|
|
183
|
+
date,
|
|
184
|
+
product_ids
|
|
185
|
+
}) {
|
|
184
186
|
const scheduleList = this.store.schedule.getAvailabilityScheduleDateList();
|
|
187
|
+
this.setDateRange([{ date, status: "available", week: "", weekNum: 0 }]);
|
|
185
188
|
const scheduleIds = scheduleList.filter((n) => n.date === date).flatMap((n) => n.schedule_id);
|
|
186
|
-
return await this.loadProducts({ schedule_ids: scheduleIds });
|
|
189
|
+
return await this.loadProducts({ schedule_ids: scheduleIds, product_ids });
|
|
187
190
|
}
|
|
188
191
|
// 加载当前店铺下所有 schedule
|
|
189
192
|
async loadAllSchedule() {
|
|
@@ -321,7 +324,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
321
324
|
}
|
|
322
325
|
// 获取商品/服务的可用日期
|
|
323
326
|
async getAvailableDate(params = {}) {
|
|
324
|
-
var _a, _b, _c, _d;
|
|
325
327
|
let { products, startDate, endDate, type } = params;
|
|
326
328
|
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)()))) {
|
|
327
329
|
startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
@@ -343,8 +345,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
343
345
|
}
|
|
344
346
|
];
|
|
345
347
|
}
|
|
346
|
-
const
|
|
347
|
-
const
|
|
348
|
+
const dateRange = await this.getDateRange();
|
|
349
|
+
const tempStartDate = startDate || (dateRange == null ? void 0 : dateRange[0].date);
|
|
350
|
+
const tempEndDate = endDate || (dateRange == null ? void 0 : dateRange[0].date);
|
|
348
351
|
if (!tempProducts.length) {
|
|
349
352
|
return [];
|
|
350
353
|
}
|
|
@@ -741,11 +744,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
741
744
|
}) {
|
|
742
745
|
const dateRange = this.store.date.getDateRange();
|
|
743
746
|
const cartItems = this.store.cart.getItems();
|
|
744
|
-
|
|
747
|
+
let accountCartItems = cartItems.filter((n) => n.holder_id === holder_id) || [];
|
|
745
748
|
if (!accountCartItems.length) {
|
|
746
|
-
|
|
747
|
-
selectedResource: null
|
|
748
|
-
};
|
|
749
|
+
accountCartItems = cartItems;
|
|
749
750
|
}
|
|
750
751
|
let duration = accountCartItems.reduce((acc, n) => {
|
|
751
752
|
var _a, _b;
|
|
@@ -812,17 +813,25 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
812
813
|
const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
|
|
813
814
|
const errorList = [];
|
|
814
815
|
const selectResourcesMap = {};
|
|
815
|
-
this.store.accountList.getAccounts()
|
|
816
|
-
|
|
816
|
+
const accountList = this.store.accountList.getAccounts();
|
|
817
|
+
const selectForCartResources = (cartItems2) => {
|
|
817
818
|
let recordTimeSlots = (0, import_lodash_es.cloneDeep)(timeSlots);
|
|
818
|
-
|
|
819
|
+
cartItems2.forEach((item, index) => {
|
|
819
820
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
820
821
|
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
821
822
|
capacity: (_a = item._productOrigin) == null ? void 0 : _a.capacity,
|
|
822
823
|
product_bundle: item._origin.product.product_bundle
|
|
823
824
|
});
|
|
824
825
|
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
825
|
-
if (timeSlots) {
|
|
826
|
+
if (item._origin.start_time && !(timeSlots == null ? void 0 : timeSlots.start_time)) {
|
|
827
|
+
recordTimeSlots = {
|
|
828
|
+
start_time: item._origin.start_time,
|
|
829
|
+
end_time: item._origin.end_time,
|
|
830
|
+
start_at: (0, import_dayjs.default)(`${item.start_date} ${item._origin.start_time}`),
|
|
831
|
+
end_at: (0, import_dayjs.default)(`${item.end_date} ${item._origin.end_time}`)
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
if (recordTimeSlots) {
|
|
826
835
|
if (index !== 0 && recordTimeSlots) {
|
|
827
836
|
let start_at = (0, import_dayjs.default)(recordTimeSlots.end_time).add(
|
|
828
837
|
((_c = (_b = item._productOrigin) == null ? void 0 : _b.duration) == null ? void 0 : _c.value) ?? 0,
|
|
@@ -910,13 +919,21 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
910
919
|
targetResource
|
|
911
920
|
]
|
|
912
921
|
});
|
|
913
|
-
console.log(account, "已分配");
|
|
914
922
|
} else {
|
|
915
923
|
errorList.push(item._id);
|
|
916
924
|
}
|
|
917
925
|
}
|
|
918
926
|
});
|
|
919
|
-
}
|
|
927
|
+
};
|
|
928
|
+
const cartItems = this.store.cart.getItems();
|
|
929
|
+
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
930
|
+
accountList.forEach((account) => {
|
|
931
|
+
const cartItems2 = this.store.cart.getCartByAccount(account.getId());
|
|
932
|
+
selectForCartResources(cartItems2);
|
|
933
|
+
});
|
|
934
|
+
} else {
|
|
935
|
+
selectForCartResources(cartItems);
|
|
936
|
+
}
|
|
920
937
|
return { errorList };
|
|
921
938
|
}
|
|
922
939
|
// 从购物车中获取已经分配好第一步资源的所有时间片
|
|
@@ -961,14 +978,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
961
978
|
// 提交时间切片,绑定到对应购物车的商品上,更新购物车
|
|
962
979
|
submitTimeSlot(timeSlots) {
|
|
963
980
|
const cartItems = this.store.cart.getItems();
|
|
964
|
-
const itemsByAccount = cartItems.reduce(
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
acc[holderId]
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
981
|
+
const itemsByAccount = cartItems.reduce(
|
|
982
|
+
(acc, item) => {
|
|
983
|
+
const holderId = item.holder_id;
|
|
984
|
+
if (!acc[holderId]) {
|
|
985
|
+
acc[holderId] = [];
|
|
986
|
+
}
|
|
987
|
+
acc[holderId].push(item);
|
|
988
|
+
return acc;
|
|
989
|
+
},
|
|
990
|
+
{}
|
|
991
|
+
);
|
|
972
992
|
Object.values(itemsByAccount).forEach((accountItems) => {
|
|
973
993
|
let currentStartTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
974
994
|
accountItems.forEach((item, index) => {
|
|
@@ -1118,6 +1138,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1118
1138
|
bundle,
|
|
1119
1139
|
options
|
|
1120
1140
|
});
|
|
1141
|
+
if (date) {
|
|
1142
|
+
const cartItems = this.store.cart.getItems();
|
|
1143
|
+
const cartItemsByDate = cartItems.filter(
|
|
1144
|
+
(n) => !(0, import_dayjs.default)(n.start_date).isSame((0, import_dayjs.default)(date.startTime), "day")
|
|
1145
|
+
);
|
|
1146
|
+
if (cartItemsByDate.length) {
|
|
1147
|
+
cartItemsByDate.forEach((n) => {
|
|
1148
|
+
this.store.cart.removeItem(n._id);
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1121
1152
|
}
|
|
1122
1153
|
setOtherData(key, value) {
|
|
1123
1154
|
this.otherData[key] = value;
|