|
|
@@ -12,6 +12,7 @@ import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
@@ -23,6 +24,7 @@ import com.ylx.common.core.domain.AjaxResult;
|
|
|
import com.ylx.common.core.domain.model.LoginUser;
|
|
|
import com.ylx.common.exception.ServiceException;
|
|
|
import com.ylx.common.utils.DateUtils;
|
|
|
+import com.ylx.common.utils.DistanceUtil;
|
|
|
import com.ylx.common.utils.StringUtils;
|
|
|
import com.ylx.fareSetting.service.IMaProjectFareSettingService;
|
|
|
import com.ylx.massage.controller.CityOperationApplicationController;
|
|
|
@@ -49,9 +51,12 @@ import com.ylx.massage.domain.vo.MerchantVo;
|
|
|
import com.ylx.massage.mapper.ContractRecordMapper;
|
|
|
import com.ylx.massage.mapper.MaProjectMapper;
|
|
|
import com.ylx.massage.mapper.MaTeProjectMapper;
|
|
|
+import com.ylx.massage.service.TAddressService;
|
|
|
import com.ylx.massage.service.TbFileService;
|
|
|
+import com.ylx.merchant.domain.dto.MerchantDetailDTO;
|
|
|
import com.ylx.merchant.domain.dto.MerchantListDTO;
|
|
|
import com.ylx.merchant.domain.dto.MerchantProjectDTO;
|
|
|
+import com.ylx.merchant.domain.vo.MerchantDetailVO;
|
|
|
import com.ylx.merchant.domain.vo.MerchantListVO;
|
|
|
import com.ylx.order.domain.TOrder;
|
|
|
import com.ylx.order.mapper.TOrderMapper;
|
|
|
@@ -126,9 +131,11 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
@Autowired
|
|
|
private IMaTechnicianService maTechnicianService;
|
|
|
@Resource
|
|
|
- private CityOperationApplicationMapper cityOperationApplicationMapper;
|
|
|
+ private CityOperationApplicationMapper cityOperationApplicationMapper;
|
|
|
@Resource
|
|
|
private IMaProjectFareSettingService maProjectFareSettingService;
|
|
|
+ @Resource
|
|
|
+ private TAddressService addressService;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -157,6 +164,7 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
|
|
|
/**
|
|
|
* 添加城市管理地址
|
|
|
+ *
|
|
|
* @param req
|
|
|
* @param maTechnician1
|
|
|
* @param maTechnician
|
|
|
@@ -768,14 +776,14 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
}
|
|
|
|
|
|
List<Project> projects = projectMapper.selectList(new LambdaQueryWrapper<Project>()
|
|
|
- .in(Project::getId, distinctProjectIds)
|
|
|
- .eq(Project::getIsDelete, 0));
|
|
|
+ .in(Project::getId, distinctProjectIds)
|
|
|
+ .eq(Project::getIsDelete, 0));
|
|
|
if (projects.size() != distinctProjectIds.size()) {
|
|
|
throw new ServiceException("服务项目不存在或已删除");
|
|
|
}
|
|
|
|
|
|
Map<Integer, Project> projectMap = projects.stream()
|
|
|
- .collect(Collectors.toMap(project -> project.getId(), Function.identity(), (left, right) -> left));
|
|
|
+ .collect(Collectors.toMap(project -> project.getId(), Function.identity(), (left, right) -> left));
|
|
|
Set<Integer> projectCategoryIds = new LinkedHashSet<>();
|
|
|
for (Integer projectId : distinctProjectIds) {
|
|
|
Project project = projectMap.get(projectId);
|
|
|
@@ -815,16 +823,16 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
|
|
|
private String joinIds(Set<Integer> ids) {
|
|
|
return ids.stream()
|
|
|
- .map(String::valueOf)
|
|
|
- .collect(Collectors.joining(","));
|
|
|
+ .map(String::valueOf)
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
}
|
|
|
|
|
|
private String joinProjectTitles(Set<Integer> projectIds, Map<Integer, Project> projectMap) {
|
|
|
return projectIds.stream()
|
|
|
- .map(projectMap::get)
|
|
|
- .map(Project::getTitle)
|
|
|
- .filter(StringUtils::isNotBlank)
|
|
|
- .collect(Collectors.joining(","));
|
|
|
+ .map(projectMap::get)
|
|
|
+ .map(Project::getTitle)
|
|
|
+ .filter(StringUtils::isNotBlank)
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -940,6 +948,7 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
merchantAuditFile.setMerchantAuditFile(merchantApplyFile);
|
|
|
return merchantAuditFile;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 查询商户合同记录信息
|
|
|
*
|
|
|
@@ -947,17 +956,17 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<ContractRecord> getContractRecords(Long userId){
|
|
|
+ public List<ContractRecord> getContractRecords(Long userId) {
|
|
|
LambdaQueryWrapper<ContractRecord> query = new LambdaQueryWrapper<>();
|
|
|
query.eq(ContractRecord::getMerchantId, userId);
|
|
|
List<ContractRecord> contractRecordList = contractRecordMapper.selectList(query);
|
|
|
- if(contractRecordList.size() == 0) {
|
|
|
+ if (contractRecordList.size() == 0) {
|
|
|
return new ArrayList<>();
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
Set<String> seen = new HashSet<>();
|
|
|
contractRecordList = contractRecordList.stream()
|
|
|
- .filter(record -> record.getContractName() != null && seen.add(record.getContractName()))
|
|
|
- .collect(Collectors.toList());
|
|
|
+ .filter(record -> record.getContractName() != null && seen.add(record.getContractName()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -1005,6 +1014,34 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
return this.baseMapper.getByMerchantProject(page, dto);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public MerchantDetailVO getDetail(MerchantDetailDTO dto) {
|
|
|
+
|
|
|
+ // 1. 获取商户信息
|
|
|
+ MerchantDetailVO detail = this.baseMapper.getDetail(dto);
|
|
|
+ if (ObjectUtil.isNull(detail)) {
|
|
|
+ throw new ServiceException("商户不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 获取商户的默认地址
|
|
|
+ TAddress address = this.addressService.getOne(new LambdaQueryWrapper<TAddress>()
|
|
|
+ .eq(TAddress::getMerchantId, dto.getMerchantId())
|
|
|
+ .eq(TAddress::getIsDefault, 1)
|
|
|
+ .eq(TAddress::getIsDelete, 0));
|
|
|
+ if (ObjectUtil.isNull(address)) {
|
|
|
+ throw new ServiceException("无法获取商户的默认地址");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 计算当前用户距离商户距离
|
|
|
+ String distanceStr = DistanceUtil.formatDistanceInKilometers(
|
|
|
+ dto.getLatitude(),dto.getLongitude(),
|
|
|
+ address.getLatitude(),address.getLongitude()
|
|
|
+ );
|
|
|
+ detail.setDistance(distanceStr);
|
|
|
+
|
|
|
+ return detail;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private void extracted(MaProjectSaveDto dto) {
|
|
|
LambdaQueryWrapper<Project> query = new LambdaQueryWrapper<>();
|
|
|
@@ -1060,8 +1097,8 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
long minutesOnline = 0;
|
|
|
if (attendance != null && attendance.getAttendanceStartTime() != null) {
|
|
|
LocalDateTime localDateTime = attendance.getAttendanceStartTime().toInstant()
|
|
|
- .atZone(ZoneId.systemDefault())
|
|
|
- .toLocalDateTime();
|
|
|
+ .atZone(ZoneId.systemDefault())
|
|
|
+ .toLocalDateTime();
|
|
|
//计算截止现在的时长,单位为分钟
|
|
|
minutesOnline = Duration.between(localDateTime, LocalDateTime.now()).toMinutes();
|
|
|
// 计算今日的累加在线时长
|
|
|
@@ -1079,8 +1116,8 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
if (!forceConfirm) {
|
|
|
// 返回特定错误码或数据结构,告诉前端弹出“我在想想/确认下线”的模态框
|
|
|
return Result.ok("平台对您的在线时间做了约定,每日在线需满足"
|
|
|
- + (requiredMinutes / 60) + "小时,距离您下线时间还剩余" + ((requiredMinutes / 60) - minutesOnline) + "小时"
|
|
|
- + "不满足在线时间将收到平台处罚,是否确认下线?");
|
|
|
+ + (requiredMinutes / 60) + "小时,距离您下线时间还剩余" + ((requiredMinutes / 60) - minutesOnline) + "小时"
|
|
|
+ + "不满足在线时间将收到平台处罚,是否确认下线?");
|
|
|
}
|
|
|
// 情况 B: 超时了,但用户已经点击了“确认下线”,允许通过
|
|
|
}
|
|
|
@@ -1102,8 +1139,8 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
MerchantDailyAttendance update = merchantDailyAttendanceMapper.selectOne(query);
|
|
|
if (update != null) {
|
|
|
LocalDateTime localDateTime = update.getAttendanceStartTime().toInstant()
|
|
|
- .atZone(ZoneId.systemDefault())
|
|
|
- .toLocalDateTime();
|
|
|
+ .atZone(ZoneId.systemDefault())
|
|
|
+ .toLocalDateTime();
|
|
|
LambdaUpdateWrapper<MerchantDailyAttendance> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
updateWrapper.eq(MerchantDailyAttendance::getId, update.getId())
|
|
|
.set(MerchantDailyAttendance::getAttendanceEndTime, DateUtils.getNowDate())
|
|
|
@@ -1119,12 +1156,12 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
updateStatus(userId, TechnicianStatusEnum.ONLINE);
|
|
|
// 插入今日考勤记录
|
|
|
MerchantDailyAttendance merchantDailyAttendance = new MerchantDailyAttendance()
|
|
|
- .setMerchantId(userId.intValue())
|
|
|
- .setAttendanceDate(DateUtils.getNowDate())
|
|
|
- .setMerchantName(technician.getTeName())
|
|
|
- .setAttendanceStartTime(DateUtils.getNowDate())
|
|
|
- .setCreateBy(technician.getTeName())
|
|
|
- .setCreateTime(LocalDateTime.now());
|
|
|
+ .setMerchantId(userId.intValue())
|
|
|
+ .setAttendanceDate(DateUtils.getNowDate())
|
|
|
+ .setMerchantName(technician.getTeName())
|
|
|
+ .setAttendanceStartTime(DateUtils.getNowDate())
|
|
|
+ .setCreateBy(technician.getTeName())
|
|
|
+ .setCreateTime(LocalDateTime.now());
|
|
|
merchantDailyAttendanceMapper.insert(merchantDailyAttendance);
|
|
|
}
|
|
|
return Result.ok("状态已切换成功");
|
|
|
@@ -1160,9 +1197,9 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
if (attendances == null || attendances.isEmpty()) return 0;
|
|
|
// 计算指定日期的总分钟数
|
|
|
long totalMinutes = attendances.stream()
|
|
|
- .filter(attendance -> DateUtils.getNowDate().toString().equals(attendance.getAttendanceDate().toString()))
|
|
|
- .mapToLong(MerchantDailyAttendance::getTotalWorkMinutes)
|
|
|
- .sum();
|
|
|
+ .filter(attendance -> DateUtils.getNowDate().toString().equals(attendance.getAttendanceDate().toString()))
|
|
|
+ .mapToLong(MerchantDailyAttendance::getTotalWorkMinutes)
|
|
|
+ .sum();
|
|
|
return totalMinutes;
|
|
|
}
|
|
|
|
|
|
@@ -1352,8 +1389,8 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
|
|
|
// 3.距离升序:近的排在最前面
|
|
|
return dtoList.stream()
|
|
|
- .sorted(Comparator.comparing(WaitOrderDTO::getDistanceMeter))
|
|
|
- .collect(Collectors.toList());
|
|
|
+ .sorted(Comparator.comparing(WaitOrderDTO::getDistanceMeter))
|
|
|
+ .collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1388,6 +1425,7 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
doAcceptOrder(techId, orderId);
|
|
|
return OrderTipEnum.ALREADY_ACCEPT.getTip();
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 技师接单确认接单
|
|
|
*
|
|
|
@@ -1396,7 +1434,7 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public String confirmRestAccept(Long techId, Long orderId){
|
|
|
+ public String confirmRestAccept(Long techId, Long orderId) {
|
|
|
LambdaUpdateWrapper<MaTechnician> update = new LambdaUpdateWrapper<>();
|
|
|
update.eq(MaTechnician::getId, techId);
|
|
|
update.set(MaTechnician::getPostState, TechnicianStatusEnum.ONLINE.getCode());
|
|
|
@@ -1404,6 +1442,7 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
doAcceptOrder(techId, orderId);
|
|
|
return OrderTipEnum.ALREADY_ACCEPT.getTip();
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 技师拒绝接单
|
|
|
*
|
|
|
@@ -1411,7 +1450,7 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public void refuseOrder(RefuseOrderReqDTO req){
|
|
|
+ public void refuseOrder(RefuseOrderReqDTO req) {
|
|
|
LambdaUpdateWrapper<TOrder> update = new LambdaUpdateWrapper<>();
|
|
|
update.eq(TOrder::getId, req.getOrderId());
|
|
|
update.set(TOrder::getStatus, OrderStatusEnum.REFUSE.getCode());
|
|
|
@@ -1441,8 +1480,8 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
double dLat = latRad2 - latRad1;
|
|
|
double dLng = lngRad2 - lngRad1;
|
|
|
double a = Math.pow(Math.sin(dLat / 2), 2)
|
|
|
- + Math.cos(latRad1) * Math.cos(latRad2)
|
|
|
- * Math.pow(Math.sin(dLng / 2), 2);
|
|
|
+ + Math.cos(latRad1) * Math.cos(latRad2)
|
|
|
+ * Math.pow(Math.sin(dLng / 2), 2);
|
|
|
double dis = 2 * 6371000 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
|
return BigDecimal.valueOf(dis).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
}
|