@pisell/pisellos 0.0.78 → 0.0.80
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.js +12 -4
- package/dist/solution/BookingByStep/index.d.ts +1 -0
- package/dist/solution/BookingByStep/index.js +161 -17
- package/lib/modules/Cart/utils.js +7 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -0
- package/lib/solution/BookingByStep/index.js +177 -18
- package/package.json +1 -1
|
@@ -550,6 +550,9 @@ export var getProductDeposit = function getProductDeposit(params) {
|
|
|
550
550
|
deposit_policy_data = _ref2.deposit_policy_data;
|
|
551
551
|
// 协议数据
|
|
552
552
|
protocols.push.apply(protocols, _toConsumableArray(deposit_policy_data || []));
|
|
553
|
+
// 是否存在定金,主商品has_deposit为1,但是自身没有定金设置,需要判定子商品是否存在定金,如果不存在最终判定也是不存在定金
|
|
554
|
+
var productHasDeposit = false;
|
|
555
|
+
|
|
553
556
|
// 判断主商品是否有定金规则
|
|
554
557
|
if (typeof deposit_fixed === 'string' && typeof deposit_percentage === 'string') {
|
|
555
558
|
var _handleProductDeposit = handleProductDeposit({
|
|
@@ -561,6 +564,7 @@ export var getProductDeposit = function getProductDeposit(params) {
|
|
|
561
564
|
result = _handleProductDeposit.result;
|
|
562
565
|
if (result) {
|
|
563
566
|
total = depositTotal;
|
|
567
|
+
productHasDeposit = true;
|
|
564
568
|
}
|
|
565
569
|
} else {
|
|
566
570
|
if (bundle !== null && bundle !== void 0 && bundle.length) {
|
|
@@ -573,16 +577,20 @@ export var getProductDeposit = function getProductDeposit(params) {
|
|
|
573
577
|
depositTotal = _handleProductDeposit2.depositTotal,
|
|
574
578
|
result = _handleProductDeposit2.result;
|
|
575
579
|
if (result) {
|
|
580
|
+
productHasDeposit = true;
|
|
576
581
|
return accumulator.plus(depositTotal);
|
|
577
582
|
}
|
|
578
583
|
return accumulator;
|
|
579
584
|
}, new Decimal(0));
|
|
580
585
|
}
|
|
581
586
|
}
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
587
|
+
if (productHasDeposit) {
|
|
588
|
+
return {
|
|
589
|
+
total: total.toNumber(),
|
|
590
|
+
protocols: protocols
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
return null;
|
|
586
594
|
}
|
|
587
595
|
return null;
|
|
588
596
|
};
|
|
@@ -147,6 +147,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
147
147
|
checkCartItems(type: ECartItemCheckType): string[];
|
|
148
148
|
destroy(): void;
|
|
149
149
|
getResourcesList(): any[];
|
|
150
|
+
checkResourceListForDate(): boolean;
|
|
150
151
|
getResourcesListByCartItem(id: string | number): {
|
|
151
152
|
id: number | undefined;
|
|
152
153
|
_id: string;
|
|
@@ -641,7 +641,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
641
641
|
key: "getAvailableDate",
|
|
642
642
|
value: function () {
|
|
643
643
|
var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
644
|
-
var _this3 = this
|
|
644
|
+
var _this3 = this,
|
|
645
|
+
_dateRange$,
|
|
646
|
+
_dateRange$2;
|
|
645
647
|
var params,
|
|
646
648
|
products,
|
|
647
649
|
startDate,
|
|
@@ -684,8 +686,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
684
686
|
})];
|
|
685
687
|
}
|
|
686
688
|
dateRange = this.store.date.getDateRange();
|
|
687
|
-
tempStartDate = startDate || (dateRange === null || dateRange === void 0 ? void 0 :
|
|
688
|
-
tempEndDate = endDate || (dateRange === null || dateRange === void 0 ? void 0 :
|
|
689
|
+
tempStartDate = startDate || (dateRange === null || dateRange === void 0 || (_dateRange$ = dateRange[0]) === null || _dateRange$ === void 0 ? void 0 : _dateRange$.date);
|
|
690
|
+
tempEndDate = endDate || (dateRange === null || dateRange === void 0 || (_dateRange$2 = dateRange[1]) === null || _dateRange$2 === void 0 ? void 0 : _dateRange$2.date);
|
|
689
691
|
if (tempProducts.length) {
|
|
690
692
|
_context13.next = 11;
|
|
691
693
|
break;
|
|
@@ -1058,7 +1060,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1058
1060
|
// 如果现在选择的是组合资源,需要判断
|
|
1059
1061
|
// 1、当前其他购物车里是否选了当前组合资源的子资源
|
|
1060
1062
|
// 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
|
|
1061
|
-
|
|
1062
1063
|
targetRes.metadata.combined_resource.resource_ids.includes(m.id) || targetRes.metadata.combined_resource.resource_ids.some(function (n) {
|
|
1063
1064
|
return m.metadata.combined_resource.resource_ids.includes(n);
|
|
1064
1065
|
}))) return true;
|
|
@@ -1196,7 +1197,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1196
1197
|
capacity: formatCapacity
|
|
1197
1198
|
});
|
|
1198
1199
|
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);
|
|
1199
|
-
debugger;
|
|
1200
1200
|
// 如果购物车里已经有了时间片,则需要按照时间片过滤
|
|
1201
1201
|
if (cartItem._origin.start_time) {
|
|
1202
1202
|
var startTime = dayjs("".concat(cartItem._origin.start_date, " ").concat(cartItem._origin.start_time));
|
|
@@ -1253,10 +1253,19 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1253
1253
|
} else {
|
|
1254
1254
|
productResources.forEach(function (item) {
|
|
1255
1255
|
// 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
|
|
1256
|
+
// 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
|
|
1256
1257
|
item.renderList = item.renderList.filter(function (n) {
|
|
1258
|
+
var _cartItem$_productOri3;
|
|
1257
1259
|
var recordCount = n.capacity || 0;
|
|
1258
1260
|
if (n.onlyComputed) return false;
|
|
1259
|
-
|
|
1261
|
+
// 查一下这个资源基于商品的可用时间片
|
|
1262
|
+
var timeSlots = getTimeSlicesByResource({
|
|
1263
|
+
resource: n,
|
|
1264
|
+
duration: ((_cartItem$_productOri3 = cartItem._productOrigin) === null || _cartItem$_productOri3 === void 0 || (_cartItem$_productOri3 = _cartItem$_productOri3.duration) === null || _cartItem$_productOri3 === void 0 ? void 0 : _cartItem$_productOri3.value) || 0,
|
|
1265
|
+
split: 10,
|
|
1266
|
+
currentDate: dateRange[0].date
|
|
1267
|
+
});
|
|
1268
|
+
return recordCount >= currentCapacity && timeSlots.length > 0;
|
|
1260
1269
|
});
|
|
1261
1270
|
});
|
|
1262
1271
|
}
|
|
@@ -1274,6 +1283,134 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1274
1283
|
return arr;
|
|
1275
1284
|
}
|
|
1276
1285
|
|
|
1286
|
+
// 在日期那边点击下一步的时候,检查这一天购物车里的商品是不是都有资源可以用
|
|
1287
|
+
}, {
|
|
1288
|
+
key: "checkResourceListForDate",
|
|
1289
|
+
value: function checkResourceListForDate() {
|
|
1290
|
+
var dateRange = this.store.date.getDateRange();
|
|
1291
|
+
var resources = [];
|
|
1292
|
+
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
1293
|
+
dateRange.forEach(function (n) {
|
|
1294
|
+
if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
|
|
1295
|
+
});
|
|
1296
|
+
}
|
|
1297
|
+
// 如果此时 resources 为空,视作购物车里已经有了 dateRange 数据,此时 dateList 里明确就是那一天的数据
|
|
1298
|
+
if (!resources.length) {
|
|
1299
|
+
var dateList = this.store.date.getDateList();
|
|
1300
|
+
dateList.forEach(function (n) {
|
|
1301
|
+
if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
|
|
1302
|
+
});
|
|
1303
|
+
}
|
|
1304
|
+
var resourcesMap = getResourcesMap(cloneDeep(resources));
|
|
1305
|
+
var cartItems = this.store.cart.getItems();
|
|
1306
|
+
var arr = [];
|
|
1307
|
+
var capacityMap = {};
|
|
1308
|
+
cartItems.forEach(function (cartItem) {
|
|
1309
|
+
var _cartItem$_productOri4, _cartItem$_productOri5;
|
|
1310
|
+
var selectedResources = [];
|
|
1311
|
+
if (cartItem.holder_id) {
|
|
1312
|
+
selectedResources = getOthersSelectedResources(cartItems, cartItem.holder_id, resourcesMap);
|
|
1313
|
+
} else {
|
|
1314
|
+
selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
|
|
1315
|
+
}
|
|
1316
|
+
var formatCapacity = formatDefaultCapacitys({
|
|
1317
|
+
capacity: (_cartItem$_productOri4 = cartItem._productOrigin) === null || _cartItem$_productOri4 === void 0 ? void 0 : _cartItem$_productOri4.capacity,
|
|
1318
|
+
product_bundle: cartItem._origin.product.product_bundle
|
|
1319
|
+
});
|
|
1320
|
+
cartItem._origin.metadata.capacity = formatCapacity;
|
|
1321
|
+
var currentCapacity = getSumCapacity({
|
|
1322
|
+
capacity: formatCapacity
|
|
1323
|
+
});
|
|
1324
|
+
var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri5 = cartItem._productOrigin) === null || _cartItem$_productOri5 === void 0 || (_cartItem$_productOri5 = _cartItem$_productOri5.product_resource) === null || _cartItem$_productOri5 === void 0 ? void 0 : _cartItem$_productOri5.resources) || [], selectedResources, currentCapacity);
|
|
1325
|
+
// 如果购物车里已经有了时间片,则需要按照时间片过滤
|
|
1326
|
+
if (cartItem._origin.start_time) {
|
|
1327
|
+
var startTime = dayjs("".concat(cartItem._origin.start_date, " ").concat(cartItem._origin.start_time));
|
|
1328
|
+
var endTime = dayjs("".concat(cartItem._origin.end_date, " ").concat(cartItem._origin.end_time));
|
|
1329
|
+
var resourcesUseableMap = {};
|
|
1330
|
+
productResources.forEach(function (n) {
|
|
1331
|
+
// 资源排下序,把单个资源靠前,组合资源排在后面
|
|
1332
|
+
n.renderList = n.renderList.sort(function (a, b) {
|
|
1333
|
+
var _a$metadata2, _b$metadata2;
|
|
1334
|
+
var aIsCombined = ((_a$metadata2 = a.metadata) === null || _a$metadata2 === void 0 || (_a$metadata2 = _a$metadata2.combined_resource) === null || _a$metadata2 === void 0 ? void 0 : _a$metadata2.status) === 1;
|
|
1335
|
+
var bIsCombined = ((_b$metadata2 = b.metadata) === null || _b$metadata2 === void 0 || (_b$metadata2 = _b$metadata2.combined_resource) === null || _b$metadata2 === void 0 ? void 0 : _b$metadata2.status) === 1;
|
|
1336
|
+
if (aIsCombined && !bIsCombined) return 1;
|
|
1337
|
+
if (!aIsCombined && bIsCombined) return -1;
|
|
1338
|
+
return 0;
|
|
1339
|
+
});
|
|
1340
|
+
n.renderList = n.renderList.filter(function (m) {
|
|
1341
|
+
var recordCount = capacityMap[m.id] || 0;
|
|
1342
|
+
// m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
|
|
1343
|
+
// time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
|
|
1344
|
+
// 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
|
|
1345
|
+
var mTimes = m.times.filter(function (n) {
|
|
1346
|
+
return !dayjs(n.start_at).isAfter(dayjs(startTime)) && !dayjs(n.end_at).isBefore(dayjs(endTime));
|
|
1347
|
+
});
|
|
1348
|
+
// 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
|
|
1349
|
+
if (mTimes.length === 0) {
|
|
1350
|
+
return false;
|
|
1351
|
+
}
|
|
1352
|
+
var canUseArr = mTimes.map(function (item) {
|
|
1353
|
+
var res = getIsUsableByTimeItem({
|
|
1354
|
+
timeSlice: {
|
|
1355
|
+
start_time: startTime.format('HH:mm'),
|
|
1356
|
+
end_time: endTime.format('HH:mm'),
|
|
1357
|
+
start_at: startTime,
|
|
1358
|
+
end_at: endTime
|
|
1359
|
+
},
|
|
1360
|
+
time: item,
|
|
1361
|
+
resource: m,
|
|
1362
|
+
currentCount: recordCount + (currentCapacity || 0),
|
|
1363
|
+
resourcesUseableMap: resourcesUseableMap
|
|
1364
|
+
});
|
|
1365
|
+
// 如果仅仅是因为子资源容量不够,不应该标记子资源是被占用的情况
|
|
1366
|
+
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
1367
|
+
resourcesUseableMap[m.id] = res.usable;
|
|
1368
|
+
}
|
|
1369
|
+
return res.usable;
|
|
1370
|
+
});
|
|
1371
|
+
if (m.onlyComputed) return false;
|
|
1372
|
+
// 在已经选定时间的情况下,只要canUseTime 里有一个 false,那就代表不可用
|
|
1373
|
+
return !canUseArr.some(function (n) {
|
|
1374
|
+
return n === false;
|
|
1375
|
+
});
|
|
1376
|
+
});
|
|
1377
|
+
});
|
|
1378
|
+
} else {
|
|
1379
|
+
productResources.forEach(function (item) {
|
|
1380
|
+
// 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
|
|
1381
|
+
// 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
|
|
1382
|
+
item.renderList = item.renderList.filter(function (n) {
|
|
1383
|
+
var _cartItem$_productOri6;
|
|
1384
|
+
var recordCount = n.capacity || 0;
|
|
1385
|
+
if (n.onlyComputed) return false;
|
|
1386
|
+
// 查一下这个资源基于商品的可用时间片
|
|
1387
|
+
var timeSlots = getTimeSlicesByResource({
|
|
1388
|
+
resource: n,
|
|
1389
|
+
duration: ((_cartItem$_productOri6 = cartItem._productOrigin) === null || _cartItem$_productOri6 === void 0 || (_cartItem$_productOri6 = _cartItem$_productOri6.duration) === null || _cartItem$_productOri6 === void 0 ? void 0 : _cartItem$_productOri6.value) || 0,
|
|
1390
|
+
split: 10,
|
|
1391
|
+
currentDate: dateRange[0].date
|
|
1392
|
+
});
|
|
1393
|
+
return recordCount >= currentCapacity && timeSlots.length > 0;
|
|
1394
|
+
});
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
arr.push({
|
|
1398
|
+
id: cartItem.id,
|
|
1399
|
+
// 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
|
|
1400
|
+
_id: cartItem._id,
|
|
1401
|
+
// 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
|
|
1402
|
+
productResources: productResources
|
|
1403
|
+
});
|
|
1404
|
+
});
|
|
1405
|
+
// 检查 productResources里是不是每一项资源的 renderList 里都有数据
|
|
1406
|
+
var hasResource = arr.every(function (n) {
|
|
1407
|
+
return n.productResources.every(function (m) {
|
|
1408
|
+
return m.renderList.length > 0;
|
|
1409
|
+
});
|
|
1410
|
+
});
|
|
1411
|
+
return hasResource;
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1277
1414
|
// 给单个购物车里的商品获取资源列表
|
|
1278
1415
|
}, {
|
|
1279
1416
|
key: "getResourcesListByCartItem",
|
|
@@ -1352,7 +1489,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1352
1489
|
}, {
|
|
1353
1490
|
key: "autoSelectAccountResources",
|
|
1354
1491
|
value: function autoSelectAccountResources(_ref8) {
|
|
1355
|
-
var _cartItem$
|
|
1492
|
+
var _cartItem$_productOri7, _allProductResources$;
|
|
1356
1493
|
var cartItem = _ref8.cartItem,
|
|
1357
1494
|
holder_id = _ref8.holder_id,
|
|
1358
1495
|
resources_code = _ref8.resources_code,
|
|
@@ -1401,15 +1538,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1401
1538
|
var resourcesMap = getResourcesMap(cloneDeep(AllResources));
|
|
1402
1539
|
var allCartItems = cloneDeep(this.store.cart.getItems());
|
|
1403
1540
|
var selectedResources = getOthersSelectedResources(allCartItems, holder_id, resourcesMap);
|
|
1404
|
-
var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$
|
|
1541
|
+
var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri7 = cartItem._productOrigin) === null || _cartItem$_productOri7 === void 0 || (_cartItem$_productOri7 = _cartItem$_productOri7.product_resource) === null || _cartItem$_productOri7 === void 0 ? void 0 : _cartItem$_productOri7.resources) || [], selectedResources, 1);
|
|
1405
1542
|
var resources = ((_allProductResources$ = allProductResources.find(function (n) {
|
|
1406
1543
|
return n.code === resources_code;
|
|
1407
1544
|
})) === null || _allProductResources$ === void 0 ? void 0 : _allProductResources$.renderList) || [];
|
|
1408
1545
|
// 资源排下序,把单个资源靠前,组合资源排在后面
|
|
1409
1546
|
resources.sort(function (a, b) {
|
|
1410
|
-
var _a$
|
|
1411
|
-
var aIsCombined = ((_a$
|
|
1412
|
-
var bIsCombined = ((_b$
|
|
1547
|
+
var _a$metadata3, _b$metadata3;
|
|
1548
|
+
var aIsCombined = ((_a$metadata3 = a.metadata) === null || _a$metadata3 === void 0 || (_a$metadata3 = _a$metadata3.combined_resource) === null || _a$metadata3 === void 0 ? void 0 : _a$metadata3.status) === 1;
|
|
1549
|
+
var bIsCombined = ((_b$metadata3 = b.metadata) === null || _b$metadata3 === void 0 || (_b$metadata3 = _b$metadata3.combined_resource) === null || _b$metadata3 === void 0 ? void 0 : _b$metadata3.status) === 1;
|
|
1413
1550
|
if (aIsCombined && !bIsCombined) return 1;
|
|
1414
1551
|
if (!aIsCombined && bIsCombined) return -1;
|
|
1415
1552
|
return 0;
|
|
@@ -1511,11 +1648,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1511
1648
|
}, {
|
|
1512
1649
|
key: "autoSelectAllProductResources",
|
|
1513
1650
|
value: function autoSelectAllProductResources(resources_code, timeSlots) {
|
|
1514
|
-
var _dateRange
|
|
1651
|
+
var _dateRange$3,
|
|
1515
1652
|
_this8 = this;
|
|
1516
1653
|
var dateRange = this.store.date.getDateRange();
|
|
1517
1654
|
var resources = [];
|
|
1518
|
-
if (dateRange !== null && dateRange !== void 0 && (_dateRange$ = dateRange[0]) !== null && _dateRange$ !== void 0 && _dateRange
|
|
1655
|
+
if (dateRange !== null && dateRange !== void 0 && (_dateRange$3 = dateRange[0]) !== null && _dateRange$3 !== void 0 && _dateRange$3.date) {
|
|
1519
1656
|
dateRange.forEach(function (n) {
|
|
1520
1657
|
if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
|
|
1521
1658
|
});
|
|
@@ -1607,8 +1744,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1607
1744
|
if ((_n$renderList = n.renderList) !== null && _n$renderList !== void 0 && _n$renderList.length) {
|
|
1608
1745
|
// 过滤掉 capacity 小于 currentCapacity 的资源
|
|
1609
1746
|
n.renderList = n.renderList.filter(function (m) {
|
|
1747
|
+
var _item$duration;
|
|
1610
1748
|
var recordCount = m.capacity || 0;
|
|
1611
|
-
|
|
1749
|
+
var timeSlots = getTimeSlicesByResource({
|
|
1750
|
+
resource: m,
|
|
1751
|
+
duration: (item === null || item === void 0 || (_item$duration = item.duration) === null || _item$duration === void 0 ? void 0 : _item$duration.value) || 0,
|
|
1752
|
+
split: 10,
|
|
1753
|
+
currentDate: dateRange[0].date
|
|
1754
|
+
});
|
|
1755
|
+
return recordCount >= currentCapacity && timeSlots.length > 0;
|
|
1612
1756
|
});
|
|
1613
1757
|
currentResourcesRenderList.push.apply(currentResourcesRenderList, _toConsumableArray(n.renderList || []));
|
|
1614
1758
|
}
|
|
@@ -1910,9 +2054,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1910
2054
|
});
|
|
1911
2055
|
// 资源排下序,把单个资源靠前,组合资源排在后面
|
|
1912
2056
|
allProductResources.sort(function (a, b) {
|
|
1913
|
-
var _a$
|
|
1914
|
-
var aIsCombined = ((_a$
|
|
1915
|
-
var bIsCombined = ((_b$
|
|
2057
|
+
var _a$metadata4, _b$metadata4;
|
|
2058
|
+
var aIsCombined = ((_a$metadata4 = a.metadata) === null || _a$metadata4 === void 0 || (_a$metadata4 = _a$metadata4.combined_resource) === null || _a$metadata4 === void 0 ? void 0 : _a$metadata4.status) === 1;
|
|
2059
|
+
var bIsCombined = ((_b$metadata4 = b.metadata) === null || _b$metadata4 === void 0 || (_b$metadata4 = _b$metadata4.combined_resource) === null || _b$metadata4 === void 0 ? void 0 : _b$metadata4.status) === 1;
|
|
1916
2060
|
if (aIsCombined && !bIsCombined) return 1;
|
|
1917
2061
|
if (!aIsCombined && bIsCombined) return -1;
|
|
1918
2062
|
return 0;
|
|
@@ -445,6 +445,7 @@ var getProductDeposit = (params) => {
|
|
|
445
445
|
let total = new import_decimal.default(0);
|
|
446
446
|
const { deposit_fixed, deposit_percentage, deposit_policy_data } = (product == null ? void 0 : product.custom_deposit_data) || {};
|
|
447
447
|
protocols.push(...deposit_policy_data || []);
|
|
448
|
+
let productHasDeposit = false;
|
|
448
449
|
if (typeof deposit_fixed === "string" && typeof deposit_percentage === "string") {
|
|
449
450
|
const { depositTotal, result } = handleProductDeposit({
|
|
450
451
|
depositData: product == null ? void 0 : product.custom_deposit_data,
|
|
@@ -453,6 +454,7 @@ var getProductDeposit = (params) => {
|
|
|
453
454
|
});
|
|
454
455
|
if (result) {
|
|
455
456
|
total = depositTotal;
|
|
457
|
+
productHasDeposit = true;
|
|
456
458
|
}
|
|
457
459
|
} else {
|
|
458
460
|
if (bundle == null ? void 0 : bundle.length) {
|
|
@@ -463,13 +465,17 @@ var getProductDeposit = (params) => {
|
|
|
463
465
|
num: currentBundleProduct.num
|
|
464
466
|
});
|
|
465
467
|
if (result) {
|
|
468
|
+
productHasDeposit = true;
|
|
466
469
|
return accumulator.plus(depositTotal);
|
|
467
470
|
}
|
|
468
471
|
return accumulator;
|
|
469
472
|
}, new import_decimal.default(0));
|
|
470
473
|
}
|
|
471
474
|
}
|
|
472
|
-
|
|
475
|
+
if (productHasDeposit) {
|
|
476
|
+
return { total: total.toNumber(), protocols };
|
|
477
|
+
}
|
|
478
|
+
return null;
|
|
473
479
|
}
|
|
474
480
|
return null;
|
|
475
481
|
};
|
|
@@ -147,6 +147,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
147
147
|
checkCartItems(type: ECartItemCheckType): string[];
|
|
148
148
|
destroy(): void;
|
|
149
149
|
getResourcesList(): any[];
|
|
150
|
+
checkResourceListForDate(): boolean;
|
|
150
151
|
getResourcesListByCartItem(id: string | number): {
|
|
151
152
|
id: number | undefined;
|
|
152
153
|
_id: string;
|
|
@@ -204,7 +204,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
204
204
|
{ date, status: "available", week: "", weekNum: 0 }
|
|
205
205
|
]);
|
|
206
206
|
const scheduleIds = scheduleList.filter((n) => n.date === date).flatMap((n) => n.schedule_id);
|
|
207
|
-
return await this.loadProducts({
|
|
207
|
+
return await this.loadProducts({
|
|
208
|
+
schedule_ids: scheduleIds,
|
|
209
|
+
product_ids,
|
|
210
|
+
category_ids,
|
|
211
|
+
schedule_date: date
|
|
212
|
+
});
|
|
208
213
|
}
|
|
209
214
|
// 加载当前店铺下所有 schedule
|
|
210
215
|
async loadAllSchedule() {
|
|
@@ -342,6 +347,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
342
347
|
}
|
|
343
348
|
// 获取商品/服务的可用日期
|
|
344
349
|
async getAvailableDate(params = {}) {
|
|
350
|
+
var _a, _b;
|
|
345
351
|
let { products, startDate, endDate, type } = params;
|
|
346
352
|
if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)(), "day") && ((0, import_dayjs.default)(endDate).isAfter((0, import_dayjs.default)(), "day") || (0, import_dayjs.default)(endDate).isSame((0, import_dayjs.default)(), "day"))) {
|
|
347
353
|
startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
@@ -364,8 +370,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
364
370
|
];
|
|
365
371
|
}
|
|
366
372
|
let dateRange = this.store.date.getDateRange();
|
|
367
|
-
const tempStartDate = startDate || (dateRange == null ? void 0 : dateRange[0].date);
|
|
368
|
-
const tempEndDate = endDate || (dateRange == null ? void 0 : dateRange[1].date);
|
|
373
|
+
const tempStartDate = startDate || ((_a = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _a.date);
|
|
374
|
+
const tempEndDate = endDate || ((_b = dateRange == null ? void 0 : dateRange[1]) == null ? void 0 : _b.date);
|
|
369
375
|
if (!tempProducts.length) {
|
|
370
376
|
return [];
|
|
371
377
|
}
|
|
@@ -514,9 +520,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
514
520
|
if (((_a3 = targetRes.metadata.combined_resource) == null ? void 0 : _a3.status) === 1 && // 如果现在选择的是组合资源,需要判断
|
|
515
521
|
// 1、当前其他购物车里是否选了当前组合资源的子资源
|
|
516
522
|
// 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
|
|
517
|
-
(targetRes.metadata.combined_resource.resource_ids.includes(
|
|
518
|
-
|
|
519
|
-
|
|
523
|
+
(targetRes.metadata.combined_resource.resource_ids.includes(
|
|
524
|
+
m.id
|
|
525
|
+
) || targetRes.metadata.combined_resource.resource_ids.some(
|
|
526
|
+
(n) => {
|
|
527
|
+
return m.metadata.combined_resource.resource_ids.includes(
|
|
528
|
+
n
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
)))
|
|
520
532
|
return true;
|
|
521
533
|
if (((_b = m.metadata.combined_resource) == null ? void 0 : _b.status) === 1 && m.metadata.combined_resource.resource_ids.includes(targetRes.id))
|
|
522
534
|
return true;
|
|
@@ -638,7 +650,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
638
650
|
selectedResources,
|
|
639
651
|
currentCapacity
|
|
640
652
|
);
|
|
641
|
-
debugger;
|
|
642
653
|
if (cartItem._origin.start_time) {
|
|
643
654
|
const startTime = (0, import_dayjs.default)(
|
|
644
655
|
`${cartItem._origin.start_date} ${cartItem._origin.start_time}`
|
|
@@ -692,10 +703,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
692
703
|
} else {
|
|
693
704
|
productResources.forEach((item) => {
|
|
694
705
|
item.renderList = item.renderList.filter((n) => {
|
|
706
|
+
var _a2, _b2;
|
|
695
707
|
const recordCount = n.capacity || 0;
|
|
696
708
|
if (n.onlyComputed)
|
|
697
709
|
return false;
|
|
698
|
-
|
|
710
|
+
const timeSlots = (0, import_resources.getTimeSlicesByResource)({
|
|
711
|
+
resource: n,
|
|
712
|
+
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 0,
|
|
713
|
+
split: 10,
|
|
714
|
+
currentDate: dateRange[0].date
|
|
715
|
+
});
|
|
716
|
+
return recordCount >= currentCapacity && timeSlots.length > 0;
|
|
699
717
|
});
|
|
700
718
|
});
|
|
701
719
|
}
|
|
@@ -712,6 +730,135 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
712
730
|
});
|
|
713
731
|
return arr;
|
|
714
732
|
}
|
|
733
|
+
// 在日期那边点击下一步的时候,检查这一天购物车里的商品是不是都有资源可以用
|
|
734
|
+
checkResourceListForDate() {
|
|
735
|
+
const dateRange = this.store.date.getDateRange();
|
|
736
|
+
const resources = [];
|
|
737
|
+
if (dateRange == null ? void 0 : dateRange.length) {
|
|
738
|
+
dateRange.forEach((n) => {
|
|
739
|
+
if (n.resource)
|
|
740
|
+
resources.push(...n.resource);
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
if (!resources.length) {
|
|
744
|
+
const dateList = this.store.date.getDateList();
|
|
745
|
+
dateList.forEach((n) => {
|
|
746
|
+
if (n.resource)
|
|
747
|
+
resources.push(...n.resource);
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
|
|
751
|
+
const cartItems = this.store.cart.getItems();
|
|
752
|
+
const arr = [];
|
|
753
|
+
const capacityMap = {};
|
|
754
|
+
cartItems.forEach((cartItem) => {
|
|
755
|
+
var _a, _b, _c;
|
|
756
|
+
let selectedResources = [];
|
|
757
|
+
if (cartItem.holder_id) {
|
|
758
|
+
selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
759
|
+
cartItems,
|
|
760
|
+
cartItem.holder_id,
|
|
761
|
+
resourcesMap
|
|
762
|
+
);
|
|
763
|
+
} else {
|
|
764
|
+
selectedResources = (0, import_resources.getOthersCartSelectedResources)(
|
|
765
|
+
cartItems,
|
|
766
|
+
cartItem._id,
|
|
767
|
+
resourcesMap
|
|
768
|
+
);
|
|
769
|
+
}
|
|
770
|
+
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
771
|
+
capacity: (_a = cartItem._productOrigin) == null ? void 0 : _a.capacity,
|
|
772
|
+
product_bundle: cartItem._origin.product.product_bundle
|
|
773
|
+
});
|
|
774
|
+
cartItem._origin.metadata.capacity = formatCapacity;
|
|
775
|
+
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
776
|
+
const productResources = (0, import_resources.getResourcesByProduct)(
|
|
777
|
+
resourcesMap,
|
|
778
|
+
((_c = (_b = cartItem._productOrigin) == null ? void 0 : _b.product_resource) == null ? void 0 : _c.resources) || [],
|
|
779
|
+
selectedResources,
|
|
780
|
+
currentCapacity
|
|
781
|
+
);
|
|
782
|
+
if (cartItem._origin.start_time) {
|
|
783
|
+
const startTime = (0, import_dayjs.default)(
|
|
784
|
+
`${cartItem._origin.start_date} ${cartItem._origin.start_time}`
|
|
785
|
+
);
|
|
786
|
+
const endTime = (0, import_dayjs.default)(
|
|
787
|
+
`${cartItem._origin.end_date} ${cartItem._origin.end_time}`
|
|
788
|
+
);
|
|
789
|
+
const resourcesUseableMap = {};
|
|
790
|
+
productResources.forEach((n) => {
|
|
791
|
+
n.renderList = n.renderList.sort((a, b) => {
|
|
792
|
+
var _a2, _b2, _c2, _d;
|
|
793
|
+
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
794
|
+
const bIsCombined = ((_d = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d.status) === 1;
|
|
795
|
+
if (aIsCombined && !bIsCombined)
|
|
796
|
+
return 1;
|
|
797
|
+
if (!aIsCombined && bIsCombined)
|
|
798
|
+
return -1;
|
|
799
|
+
return 0;
|
|
800
|
+
});
|
|
801
|
+
n.renderList = n.renderList.filter((m) => {
|
|
802
|
+
const recordCount = capacityMap[m.id] || 0;
|
|
803
|
+
const mTimes = m.times.filter((n2) => {
|
|
804
|
+
return !(0, import_dayjs.default)(n2.start_at).isAfter((0, import_dayjs.default)(startTime)) && !(0, import_dayjs.default)(n2.end_at).isBefore((0, import_dayjs.default)(endTime));
|
|
805
|
+
});
|
|
806
|
+
if (mTimes.length === 0) {
|
|
807
|
+
return false;
|
|
808
|
+
}
|
|
809
|
+
const canUseArr = mTimes.map((item) => {
|
|
810
|
+
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
811
|
+
timeSlice: {
|
|
812
|
+
start_time: startTime.format("HH:mm"),
|
|
813
|
+
end_time: endTime.format("HH:mm"),
|
|
814
|
+
start_at: startTime,
|
|
815
|
+
end_at: endTime
|
|
816
|
+
},
|
|
817
|
+
time: item,
|
|
818
|
+
resource: m,
|
|
819
|
+
currentCount: recordCount + (currentCapacity || 0),
|
|
820
|
+
resourcesUseableMap
|
|
821
|
+
});
|
|
822
|
+
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
|
|
823
|
+
resourcesUseableMap[m.id] = res.usable;
|
|
824
|
+
}
|
|
825
|
+
return res.usable;
|
|
826
|
+
});
|
|
827
|
+
if (m.onlyComputed)
|
|
828
|
+
return false;
|
|
829
|
+
return !canUseArr.some((n2) => n2 === false);
|
|
830
|
+
});
|
|
831
|
+
});
|
|
832
|
+
} else {
|
|
833
|
+
productResources.forEach((item) => {
|
|
834
|
+
item.renderList = item.renderList.filter((n) => {
|
|
835
|
+
var _a2, _b2;
|
|
836
|
+
const recordCount = n.capacity || 0;
|
|
837
|
+
if (n.onlyComputed)
|
|
838
|
+
return false;
|
|
839
|
+
const timeSlots = (0, import_resources.getTimeSlicesByResource)({
|
|
840
|
+
resource: n,
|
|
841
|
+
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 0,
|
|
842
|
+
split: 10,
|
|
843
|
+
currentDate: dateRange[0].date
|
|
844
|
+
});
|
|
845
|
+
return recordCount >= currentCapacity && timeSlots.length > 0;
|
|
846
|
+
});
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
arr.push({
|
|
850
|
+
id: cartItem.id,
|
|
851
|
+
// 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
|
|
852
|
+
_id: cartItem._id,
|
|
853
|
+
// 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
|
|
854
|
+
productResources
|
|
855
|
+
});
|
|
856
|
+
});
|
|
857
|
+
const hasResource = arr.every(
|
|
858
|
+
(n) => n.productResources.every((m) => m.renderList.length > 0)
|
|
859
|
+
);
|
|
860
|
+
return hasResource;
|
|
861
|
+
}
|
|
715
862
|
// 给单个购物车里的商品获取资源列表
|
|
716
863
|
getResourcesListByCartItem(id) {
|
|
717
864
|
var _a, _b, _c;
|
|
@@ -846,7 +993,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
846
993
|
return -1;
|
|
847
994
|
return 0;
|
|
848
995
|
});
|
|
849
|
-
const resourcesUseableMap = [
|
|
996
|
+
const resourcesUseableMap = [
|
|
997
|
+
...selectedResources
|
|
998
|
+
].reduce((acc, n) => {
|
|
850
999
|
acc[n] = false;
|
|
851
1000
|
return acc;
|
|
852
1001
|
}, {});
|
|
@@ -994,8 +1143,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
994
1143
|
var _a3;
|
|
995
1144
|
if ((_a3 = n.renderList) == null ? void 0 : _a3.length) {
|
|
996
1145
|
n.renderList = n.renderList.filter((m) => {
|
|
1146
|
+
var _a4;
|
|
997
1147
|
const recordCount = m.capacity || 0;
|
|
998
|
-
|
|
1148
|
+
const timeSlots2 = (0, import_resources.getTimeSlicesByResource)({
|
|
1149
|
+
resource: m,
|
|
1150
|
+
duration: ((_a4 = item == null ? void 0 : item.duration) == null ? void 0 : _a4.value) || 0,
|
|
1151
|
+
split: 10,
|
|
1152
|
+
currentDate: dateRange[0].date
|
|
1153
|
+
});
|
|
1154
|
+
return recordCount >= currentCapacity && timeSlots2.length > 0;
|
|
999
1155
|
});
|
|
1000
1156
|
currentResourcesRenderList.push(...n.renderList || []);
|
|
1001
1157
|
}
|
|
@@ -1149,14 +1305,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1149
1305
|
// 提交时间切片,绑定到对应购物车的商品上,更新购物车
|
|
1150
1306
|
submitTimeSlot(timeSlots) {
|
|
1151
1307
|
const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
1152
|
-
const itemsByAccount = cartItems.reduce(
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
acc[holderId]
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1308
|
+
const itemsByAccount = cartItems.reduce(
|
|
1309
|
+
(acc, item) => {
|
|
1310
|
+
const holderId = item.holder_id;
|
|
1311
|
+
if (!acc[holderId]) {
|
|
1312
|
+
acc[holderId] = [];
|
|
1313
|
+
}
|
|
1314
|
+
acc[holderId].push(item);
|
|
1315
|
+
return acc;
|
|
1316
|
+
},
|
|
1317
|
+
{}
|
|
1318
|
+
);
|
|
1160
1319
|
Object.values(itemsByAccount).forEach((accountItems) => {
|
|
1161
1320
|
let currentStartTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
1162
1321
|
accountItems.forEach((item, index) => {
|