|
|
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ylx.common.exception.ServiceException;
|
|
|
+import com.ylx.massage.domain.MaTechnician;
|
|
|
import com.ylx.massage.domain.MomentMedia;
|
|
|
import com.ylx.massage.domain.TJs;
|
|
|
import com.ylx.massage.domain.TechnicianMoment;
|
|
|
@@ -13,6 +14,7 @@ import com.ylx.massage.domain.dto.MomentAuditDTO;
|
|
|
import com.ylx.massage.domain.dto.MomentManageQueryDTO;
|
|
|
import com.ylx.massage.domain.dto.PublishMomentDTO;
|
|
|
import com.ylx.massage.domain.vo.*;
|
|
|
+import com.ylx.massage.mapper.MaTechnicianMapper;
|
|
|
import com.ylx.massage.mapper.MomentMediaMapper;
|
|
|
import com.ylx.massage.mapper.TJsMapper;
|
|
|
import com.ylx.massage.mapper.TechnicianMomentMapper;
|
|
|
@@ -47,6 +49,9 @@ public class TechnicianMomentServiceImpl extends ServiceImpl<TechnicianMomentMap
|
|
|
@Autowired
|
|
|
private TJsMapper tJsMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private MaTechnicianMapper maTechnicianMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 查询推荐动态列表(不分地区,按日期倒序,同一天按浏览量倒序)
|
|
|
*
|
|
|
@@ -63,18 +68,18 @@ public class TechnicianMomentServiceImpl extends ServiceImpl<TechnicianMomentMap
|
|
|
}
|
|
|
|
|
|
// 查询技师信息
|
|
|
- List<String> technicianIds = moments.stream().map(TechnicianMoment::getTechnicianId).collect(Collectors.toList());
|
|
|
- Map<String, TJs> technicianMap = getTechnicianMap(technicianIds);
|
|
|
+ List<Integer> technicianIds = moments.stream().map(TechnicianMoment::getTechnicianId).collect(Collectors.toList());
|
|
|
+ Map<Integer, MaTechnician> technicianMap = getTechnicianMap(technicianIds);
|
|
|
|
|
|
// 组装VO
|
|
|
return moments.stream().map(moment -> {
|
|
|
MomentListVO vo = new MomentListVO();
|
|
|
BeanUtils.copyProperties(moment, vo);
|
|
|
|
|
|
- TJs technician = technicianMap.get(moment.getTechnicianId());
|
|
|
+ MaTechnician technician = technicianMap.get(moment.getTechnicianId());
|
|
|
if (technician != null) {
|
|
|
- vo.setTechnicianNickName(technician.getcNickName());
|
|
|
- vo.setTechnicianAvatar(technician.getcPortrait());
|
|
|
+ vo.setTechnicianNickName(technician.getTeNickName());
|
|
|
+ vo.setTechnicianAvatar(technician.getTeAvatar());
|
|
|
vo.setTechnicianStatus(getTechnicianStatus(technician));
|
|
|
}
|
|
|
return vo;
|
|
|
@@ -93,18 +98,18 @@ public class TechnicianMomentServiceImpl extends ServiceImpl<TechnicianMomentMap
|
|
|
}
|
|
|
|
|
|
// 查询技师信息
|
|
|
- List<String> technicianIds = moments.stream().map(TechnicianMoment::getTechnicianId).collect(Collectors.toList());
|
|
|
- Map<String, TJs> technicianMap = getTechnicianMap(technicianIds);
|
|
|
+ List<Integer> technicianIds = moments.stream().map(TechnicianMoment::getTechnicianId).collect(Collectors.toList());
|
|
|
+ Map<Integer, MaTechnician> technicianMap = getTechnicianMap(technicianIds);
|
|
|
|
|
|
// 组装VO
|
|
|
return moments.stream().map(moment -> {
|
|
|
MomentListVO vo = new MomentListVO();
|
|
|
BeanUtils.copyProperties(moment, vo);
|
|
|
|
|
|
- TJs technician = technicianMap.get(moment.getTechnicianId());
|
|
|
+ MaTechnician technician = technicianMap.get(moment.getTechnicianId());
|
|
|
if (technician != null) {
|
|
|
- vo.setTechnicianNickName(technician.getcNickName());
|
|
|
- vo.setTechnicianAvatar(technician.getcPortrait());
|
|
|
+ vo.setTechnicianNickName(technician.getTeNickName());
|
|
|
+ vo.setTechnicianAvatar(technician.getTeAvatar());
|
|
|
vo.setTechnicianStatus(getTechnicianStatus(technician));
|
|
|
}
|
|
|
return vo;
|
|
|
@@ -132,21 +137,19 @@ public class TechnicianMomentServiceImpl extends ServiceImpl<TechnicianMomentMap
|
|
|
}
|
|
|
|
|
|
// 查询技师信息
|
|
|
- List<String> technicianIds = moments.stream()
|
|
|
- .map(TechnicianMoment::getTechnicianId)
|
|
|
- .collect(Collectors.toList());
|
|
|
+ List<Integer> technicianIds = moments.stream().map(TechnicianMoment::getTechnicianId).collect(Collectors.toList());
|
|
|
|
|
|
- Map<String, TJs> technicianMap = getTechnicianMap(technicianIds);
|
|
|
+ Map<Integer, MaTechnician> technicianMap = getTechnicianMap(technicianIds);
|
|
|
|
|
|
// 组装VO(需要计算距离)
|
|
|
return moments.stream().map(moment -> {
|
|
|
MomentListVO vo = new MomentListVO();
|
|
|
BeanUtils.copyProperties(moment, vo);
|
|
|
|
|
|
- TJs technician = technicianMap.get(String.valueOf(moment.getTechnicianId()));
|
|
|
+ MaTechnician technician = technicianMap.get(moment.getTechnicianId());
|
|
|
if (technician != null) {
|
|
|
- vo.setTechnicianNickName(technician.getcNickName());
|
|
|
- vo.setTechnicianAvatar(technician.getcPortrait());
|
|
|
+ vo.setTechnicianNickName(technician.getTeNickName());
|
|
|
+ vo.setTechnicianAvatar(technician.getTeAvatar());
|
|
|
vo.setTechnicianStatus(getTechnicianStatus(technician));
|
|
|
|
|
|
// 计算距离
|
|
|
@@ -183,8 +186,8 @@ public class TechnicianMomentServiceImpl extends ServiceImpl<TechnicianMomentMap
|
|
|
momentMapper.incrementViewCount(momentId);
|
|
|
moment.setViewCount(moment.getViewCount() + 1);
|
|
|
|
|
|
- // 查询技师信息
|
|
|
- TJs technician = tJsMapper.selectById(moment.getTechnicianId());
|
|
|
+ // 查询商户信息
|
|
|
+ MaTechnician technician = maTechnicianMapper.selectById(moment.getTechnicianId());
|
|
|
|
|
|
// 查询媒体列表
|
|
|
List<MomentMedia> mediaList = mediaMapper.selectMediaListByMomentId(momentId);
|
|
|
@@ -199,19 +202,21 @@ public class TechnicianMomentServiceImpl extends ServiceImpl<TechnicianMomentMap
|
|
|
BeanUtils.copyProperties(moment, vo);
|
|
|
|
|
|
if (technician != null) {
|
|
|
- vo.setTechnicianNickName(technician.getcNickName());
|
|
|
- vo.setTechnicianAvatar(technician.getcPortrait());
|
|
|
+ vo.setTechnicianNickName(technician.getTeNickName());
|
|
|
+ vo.setTechnicianAvatar(technician.getTeAvatar());
|
|
|
vo.setTechnicianStatus(getTechnicianStatus(technician));
|
|
|
}
|
|
|
vo.setMediaList(mediaVOList);
|
|
|
// 计算距离(如果有位置信息)
|
|
|
if (moment.getLatitude() != null && moment.getLongitude() != null) {
|
|
|
- // 传入用户位置,计算用户与技师之间的距离
|
|
|
- double distance = calculateDistance(
|
|
|
- latitude.doubleValue(), longitude.doubleValue(),
|
|
|
- moment.getLatitude().doubleValue(), moment.getLongitude().doubleValue()
|
|
|
- );
|
|
|
- vo.setDistance(Math.round(distance * 100.0) / 100.0); // 保留两位小数
|
|
|
+ if(latitude != null && longitude != null){
|
|
|
+ // 传入用户位置,计算用户与技师之间的距离
|
|
|
+ double distance = calculateDistance(
|
|
|
+ latitude.doubleValue(), longitude.doubleValue(),
|
|
|
+ moment.getLatitude().doubleValue(), moment.getLongitude().doubleValue()
|
|
|
+ );
|
|
|
+ vo.setDistance(Math.round(distance * 100.0) / 100.0); // 保留两位小数
|
|
|
+ }
|
|
|
}
|
|
|
return vo;
|
|
|
}
|
|
|
@@ -222,11 +227,10 @@ public class TechnicianMomentServiceImpl extends ServiceImpl<TechnicianMomentMap
|
|
|
* @param technicianIds 技师ID列表
|
|
|
* @return Map<String, TJs> 技师ID-技师实体映射
|
|
|
*/
|
|
|
- private Map<String, TJs> getTechnicianMap(List<String> technicianIds) {
|
|
|
- List<String> ids = technicianIds.stream()
|
|
|
- .map(String::valueOf)
|
|
|
+ private Map<Integer, MaTechnician> getTechnicianMap(List<Integer> technicianIds) {
|
|
|
+ List<Integer> ids = technicianIds.stream()
|
|
|
.collect(Collectors.toList());
|
|
|
- return tJsMapper.selectBatchIds(ids).stream().collect(Collectors.toMap(TJs::getId, t -> t));
|
|
|
+ return maTechnicianMapper.selectBatchIds(ids).stream().collect(Collectors.toMap(MaTechnician::getId, t -> t));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -234,10 +238,10 @@ public class TechnicianMomentServiceImpl extends ServiceImpl<TechnicianMomentMap
|
|
|
* 1-可服务(当前时间技师空闲)
|
|
|
* 2-可预约(当前时间技师"已接单-服务中")
|
|
|
*/
|
|
|
- private Integer getTechnicianStatus(TJs technician) {
|
|
|
- if (technician.getnStatus() != null && technician.getnStatus() == 0) {
|
|
|
+ private Integer getTechnicianStatus(MaTechnician technician) {
|
|
|
+ if (technician.getServiceState() != null && technician.getServiceState() == 1) {
|
|
|
return 1; // 可服务
|
|
|
- } else if (technician.getnStatus() != null && technician.getnStatus() == 1) {
|
|
|
+ } else if (technician.getServiceState() != null && technician.getServiceState() == 0) {
|
|
|
return 2; // 可预约(服务中)
|
|
|
}
|
|
|
return null;
|
|
|
@@ -279,11 +283,11 @@ public class TechnicianMomentServiceImpl extends ServiceImpl<TechnicianMomentMap
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Long publishMoment(PublishMomentDTO dto, String openId) {
|
|
|
// 根据openId查询技师信息
|
|
|
- LambdaQueryWrapper<TJs> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(TJs::getcOpenId, openId);
|
|
|
- TJs technician = tJsMapper.selectOne(queryWrapper);
|
|
|
+ LambdaQueryWrapper<MaTechnician> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(MaTechnician::getCOpenid, openId);
|
|
|
+ MaTechnician technician = maTechnicianMapper.selectOne(queryWrapper);
|
|
|
if (technician == null) {
|
|
|
- throw new ServiceException("技师信息不存在");
|
|
|
+ throw new ServiceException("商户信息不存在");
|
|
|
}
|
|
|
|
|
|
//查询是否保存为草稿
|
|
|
@@ -299,7 +303,7 @@ public class TechnicianMomentServiceImpl extends ServiceImpl<TechnicianMomentMap
|
|
|
throw new ServiceException("动态标题不能为空");
|
|
|
}
|
|
|
// 校验动态内容
|
|
|
- if (dto.getContent() == null || dto.getContent().trim().isEmpty()) {
|
|
|
+ if (StringUtils.isBlank(dto.getContent())) {
|
|
|
throw new ServiceException("动态内容不能为空");
|
|
|
}
|
|
|
// 校验媒体类型和媒体文件
|
|
|
@@ -316,16 +320,12 @@ public class TechnicianMomentServiceImpl extends ServiceImpl<TechnicianMomentMap
|
|
|
}
|
|
|
} else if (dto.getMediaType() == 2) {
|
|
|
// 视频类型
|
|
|
- if (dto.getVideoUrl() == null || dto.getVideoUrl().trim().isEmpty()) {
|
|
|
+ if (StringUtils.isBlank(dto.getVideoUrl())) {
|
|
|
throw new ServiceException("视频不能为空");
|
|
|
}
|
|
|
} else {
|
|
|
throw new ServiceException("媒体类型不正确");
|
|
|
}
|
|
|
- // 校验可见范围
|
|
|
- if (dto.getVisibleRange() == null || dto.getVisibleRange() != 1) {
|
|
|
- throw new ServiceException("可见范围只能选择公开");
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
// 创建动态对象
|
|
|
@@ -334,7 +334,6 @@ public class TechnicianMomentServiceImpl extends ServiceImpl<TechnicianMomentMap
|
|
|
moment.setTitle(dto.getTitle());
|
|
|
moment.setContent(dto.getContent());
|
|
|
moment.setMediaType(dto.getMediaType());
|
|
|
- moment.setVisibleRange(dto.getVisibleRange());
|
|
|
moment.setLatitude(dto.getLatitude());
|
|
|
moment.setLongitude(dto.getLongitude());
|
|
|
moment.setLocation(dto.getLocation());
|
|
|
@@ -583,14 +582,14 @@ public class TechnicianMomentServiceImpl extends ServiceImpl<TechnicianMomentMap
|
|
|
}
|
|
|
|
|
|
// 1. 根据openId查询技师信息
|
|
|
- LambdaQueryWrapper<TJs> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(TJs::getcOpenId, openId);
|
|
|
- TJs technician = tJsMapper.selectOne(queryWrapper);
|
|
|
+ LambdaQueryWrapper<MaTechnician> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(MaTechnician::getCOpenid, openId);
|
|
|
+ MaTechnician technician = maTechnicianMapper.selectOne(queryWrapper);
|
|
|
if (technician == null) {
|
|
|
- throw new ServiceException("技师信息不存在");
|
|
|
+ throw new ServiceException("商户信息不存在");
|
|
|
}
|
|
|
|
|
|
- // 2. 查询该技师的草稿列表
|
|
|
+ // 2. 查询该商户的草稿列表
|
|
|
Page<TechnicianMoment> page = new Page<>(pageNum, pageSize);
|
|
|
LambdaQueryWrapper<TechnicianMoment> momentWrapper = new LambdaQueryWrapper<>();
|
|
|
momentWrapper.eq(TechnicianMoment::getTechnicianId, technician.getId())
|
|
|
@@ -610,15 +609,14 @@ public class TechnicianMomentServiceImpl extends ServiceImpl<TechnicianMomentMap
|
|
|
List<MomentListVO> collect = moments.stream().map(moment -> {
|
|
|
MomentListVO vo = new MomentListVO();
|
|
|
BeanUtils.copyProperties(moment, vo);
|
|
|
- vo.setTechnicianNickName(technician.getcNickName());
|
|
|
- vo.setTechnicianAvatar(technician.getcPortrait());
|
|
|
+ vo.setTechnicianNickName(technician.getTeNickName());
|
|
|
+ vo.setTechnicianAvatar(technician.getTeAvatar());
|
|
|
vo.setTechnicianStatus(getTechnicianStatus(technician));
|
|
|
// 草稿的发布时间使用创建时间
|
|
|
vo.setPublishTime(moment.getCreateTime());
|
|
|
return vo;
|
|
|
}).collect(Collectors.toList());
|
|
|
//返回Page对象
|
|
|
-
|
|
|
voPage.setTotal(momentPage.getTotal());
|
|
|
voPage.setRecords(collect);
|
|
|
return voPage;
|
|
|
@@ -674,6 +672,7 @@ public class TechnicianMomentServiceImpl extends ServiceImpl<TechnicianMomentMap
|
|
|
MyMomentVO vo = new MyMomentVO();
|
|
|
vo.setId(moment.getId());
|
|
|
vo.setTitle(moment.getTitle());
|
|
|
+ vo.setContent(moment.getContent());
|
|
|
vo.setAuditStatus(moment.getAuditStatus());
|
|
|
vo.setCoverUrl(moment.getCoverUrl());
|
|
|
vo.setPublishTime(moment.getPublishTime());
|
|
|
@@ -804,10 +803,8 @@ public class TechnicianMomentServiceImpl extends ServiceImpl<TechnicianMomentMap
|
|
|
}
|
|
|
|
|
|
// 5. 批量查询技师信息
|
|
|
- List<String> technicianIds = moments.stream()
|
|
|
- .map(TechnicianMoment::getTechnicianId)
|
|
|
- .collect(Collectors.toList());
|
|
|
- Map<String, TJs> technicianMap = getTechnicianMap(technicianIds);
|
|
|
+ List<Integer> technicianIds = moments.stream().map(TechnicianMoment::getTechnicianId).collect(Collectors.toList());
|
|
|
+ Map<Integer, MaTechnician> technicianMap = getTechnicianMap(technicianIds);
|
|
|
|
|
|
// 6. 组装VO列表
|
|
|
List<MomentManageVO> voList = moments.stream().map(moment -> {
|
|
|
@@ -815,12 +812,12 @@ public class TechnicianMomentServiceImpl extends ServiceImpl<TechnicianMomentMap
|
|
|
BeanUtils.copyProperties(moment, vo);
|
|
|
|
|
|
// 设置技师信息
|
|
|
- TJs technician = technicianMap.get(moment.getTechnicianId());
|
|
|
+ MaTechnician technician = technicianMap.get(moment.getTechnicianId());
|
|
|
if (technician != null) {
|
|
|
// 设置技师姓名
|
|
|
- vo.setTechnicianName(technician.getcName());
|
|
|
+ vo.setTechnicianName(technician.getTeName());
|
|
|
// 设置技师昵称
|
|
|
- vo.setTechnicianNickname(technician.getcNickName());
|
|
|
+ vo.setTechnicianNickname(technician.getTeNickName());
|
|
|
}
|
|
|
return vo;
|
|
|
}).collect(Collectors.toList());
|