|
@@ -1,7 +1,9 @@
|
|
|
package com.tourism.webadmin.back.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.tourism.webadmin.app.website.dto.TourProjectGroupPurchaseDtoToWebDto;
|
|
|
import com.tourism.webadmin.back.service.*;
|
|
|
import com.tourism.webadmin.back.dao.*;
|
|
|
import com.tourism.webadmin.back.model.*;
|
|
@@ -18,7 +20,9 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 拼团设置主表数据操作服务类。
|
|
@@ -128,6 +132,35 @@ public class TourProjectGroupPurchaseServiceImpl extends BaseService<TourProject
|
|
|
return tourProjectGroupPurchaseMapper.getLowestPriceGroupPurchaseList(projectIds, endTime);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<String> queryUniqueGroupPurchaseDates(TourProjectGroupPurchaseDtoToWebDto dto) {
|
|
|
+ LambdaQueryWrapper<TourProjectGroupPurchase> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+
|
|
|
+ // 查询条件:根据 project_id 和 end_time 筛选
|
|
|
+ queryWrapper.eq(TourProjectGroupPurchase::getProjectId, dto.getProjectId())
|
|
|
+ .eq(TourProjectGroupPurchase::getState, 1) // 只查启用状态的记录
|
|
|
+// .ne(TourProjectGroupPurchase::getDataState, -1) // 排除已删除的记录
|
|
|
+ .ge(TourProjectGroupPurchase::getEndTime, new Date())
|
|
|
+ .ge(dto.getTravelStartTimeStart() != null, TourProjectGroupPurchase::getTravelStartTime, dto.getTravelStartTimeStart())
|
|
|
+ .le(dto.getTravelStartTimeEnd() != null, TourProjectGroupPurchase::getTravelStartTime, dto.getTravelStartTimeEnd())
|
|
|
+ .orderBy(true, true, TourProjectGroupPurchase::getTravelStartTime); // 按照拼团结束时间筛选
|
|
|
+
|
|
|
+ // 查询出符合条件的出行开始时间
|
|
|
+ queryWrapper.select(TourProjectGroupPurchase::getTravelStartTime);
|
|
|
+
|
|
|
+ // 执行查询,获取符合条件的结果
|
|
|
+ List<TourProjectGroupPurchase> groupPurchases = tourProjectGroupPurchaseMapper.selectList(queryWrapper);
|
|
|
+
|
|
|
+ // 创建另一个 SimpleDateFormat 对象来格式化为新的格式
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+
|
|
|
+ // 返回去重后的出行开始时间,转为字符串形式
|
|
|
+ return groupPurchases.stream()
|
|
|
+ .map(item -> sdf.format(item.getTravelStartTime()))
|
|
|
+ .distinct() // 去重
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
private TourProjectGroupPurchase buildDefaultValue(TourProjectGroupPurchase tourProjectGroupPurchase) {
|
|
|
if (tourProjectGroupPurchase.getId() == null) {
|
|
|
tourProjectGroupPurchase.setId(idGenerator.nextLongId());
|