|
@@ -3,12 +3,11 @@ package com.zxyj.service;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.zxyj.entity.AssessmentAppointment;
|
|
import com.zxyj.entity.AssessmentAppointment;
|
|
|
|
|
+import com.zxyj.entity.AssessmentOrder;
|
|
|
import com.zxyj.mapper.AssessmentAppointmentMapper;
|
|
import com.zxyj.mapper.AssessmentAppointmentMapper;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
-import java.text.ParseException;
|
|
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
@@ -25,10 +24,10 @@ public class AssessmentAppointmentService extends ServiceImpl<AssessmentAppointm
|
|
|
appointment.setChildId(childId);
|
|
appointment.setChildId(childId);
|
|
|
appointment.setGuideId(guideId);
|
|
appointment.setGuideId(guideId);
|
|
|
appointment.setPackageId(packageId);
|
|
appointment.setPackageId(packageId);
|
|
|
- appointment.setAppointmentDate(parseDate(appointmentDate));
|
|
|
|
|
- appointment.setAppointmentTime(parseDate(appointmentTime));
|
|
|
|
|
|
|
+ appointment.setAppointmentDate(appointmentDate);
|
|
|
|
|
+ appointment.setAppointmentTime(appointmentTime);
|
|
|
appointment.setTeacherId(guideId);
|
|
appointment.setTeacherId(guideId);
|
|
|
- appointment.setStatus("pending");
|
|
|
|
|
|
|
+ appointment.setStatus(0); // pending
|
|
|
appointment.setNotes(notes);
|
|
appointment.setNotes(notes);
|
|
|
appointment.setCreatedAt(new Date());
|
|
appointment.setCreatedAt(new Date());
|
|
|
appointment.setUpdatedAt(new Date());
|
|
appointment.setUpdatedAt(new Date());
|
|
@@ -40,7 +39,7 @@ public class AssessmentAppointmentService extends ServiceImpl<AssessmentAppointm
|
|
|
AssessmentAppointment appointment = assessmentAppointmentMapper.selectById(id);
|
|
AssessmentAppointment appointment = assessmentAppointmentMapper.selectById(id);
|
|
|
if (appointment == null) return false;
|
|
if (appointment == null) return false;
|
|
|
if (!teacherId.equals(appointment.getGuideId())) return false;
|
|
if (!teacherId.equals(appointment.getGuideId())) return false;
|
|
|
- appointment.setStatus("confirmed");
|
|
|
|
|
|
|
+ appointment.setStatus(1); // confirmed
|
|
|
appointment.setUpdatedAt(new Date());
|
|
appointment.setUpdatedAt(new Date());
|
|
|
return assessmentAppointmentMapper.updateById(appointment) > 0;
|
|
return assessmentAppointmentMapper.updateById(appointment) > 0;
|
|
|
}
|
|
}
|
|
@@ -49,7 +48,7 @@ public class AssessmentAppointmentService extends ServiceImpl<AssessmentAppointm
|
|
|
AssessmentAppointment appointment = assessmentAppointmentMapper.selectById(id);
|
|
AssessmentAppointment appointment = assessmentAppointmentMapper.selectById(id);
|
|
|
if (appointment == null) return false;
|
|
if (appointment == null) return false;
|
|
|
if (!teacherId.equals(appointment.getGuideId())) return false;
|
|
if (!teacherId.equals(appointment.getGuideId())) return false;
|
|
|
- appointment.setStatus("completed");
|
|
|
|
|
|
|
+ appointment.setStatus(2); // completed
|
|
|
appointment.setUpdatedAt(new Date());
|
|
appointment.setUpdatedAt(new Date());
|
|
|
return assessmentAppointmentMapper.updateById(appointment) > 0;
|
|
return assessmentAppointmentMapper.updateById(appointment) > 0;
|
|
|
}
|
|
}
|
|
@@ -57,7 +56,7 @@ public class AssessmentAppointmentService extends ServiceImpl<AssessmentAppointm
|
|
|
public boolean cancelAppointment(Long id) {
|
|
public boolean cancelAppointment(Long id) {
|
|
|
AssessmentAppointment appointment = assessmentAppointmentMapper.selectById(id);
|
|
AssessmentAppointment appointment = assessmentAppointmentMapper.selectById(id);
|
|
|
if (appointment == null) return false;
|
|
if (appointment == null) return false;
|
|
|
- appointment.setStatus("cancelled");
|
|
|
|
|
|
|
+ appointment.setStatus(3); // cancelled
|
|
|
appointment.setUpdatedAt(new Date());
|
|
appointment.setUpdatedAt(new Date());
|
|
|
return assessmentAppointmentMapper.updateById(appointment) > 0;
|
|
return assessmentAppointmentMapper.updateById(appointment) > 0;
|
|
|
}
|
|
}
|
|
@@ -76,16 +75,20 @@ public class AssessmentAppointmentService extends ServiceImpl<AssessmentAppointm
|
|
|
return assessmentAppointmentMapper.selectList(wrapper);
|
|
return assessmentAppointmentMapper.selectList(wrapper);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private Date parseDate(String dateStr) {
|
|
|
|
|
- if (dateStr == null || dateStr.isEmpty()) return null;
|
|
|
|
|
- try {
|
|
|
|
|
- return new SimpleDateFormat("yyyy-MM-dd").parse(dateStr);
|
|
|
|
|
- } catch (ParseException e) {
|
|
|
|
|
- try {
|
|
|
|
|
- return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(dateStr);
|
|
|
|
|
- } catch (ParseException e2) {
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ public void confirmAppointmentByOrder(AssessmentOrder order) {
|
|
|
|
|
+ LambdaQueryWrapper<AssessmentAppointment> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ wrapper.eq(AssessmentAppointment::getUserId, order.getUserId());
|
|
|
|
|
+ wrapper.eq(AssessmentAppointment::getGuideId, order.getGuideId());
|
|
|
|
|
+ wrapper.eq(AssessmentAppointment::getPackageId, order.getPackageId());
|
|
|
|
|
+ wrapper.eq(AssessmentAppointment::getStatus, 0);
|
|
|
|
|
+ wrapper.orderByDesc(AssessmentAppointment::getCreatedAt);
|
|
|
|
|
+ wrapper.last("LIMIT 1");
|
|
|
|
|
+ List<AssessmentAppointment> list = assessmentAppointmentMapper.selectList(wrapper);
|
|
|
|
|
+ if (!list.isEmpty()) {
|
|
|
|
|
+ AssessmentAppointment appointment = list.get(0);
|
|
|
|
|
+ appointment.setStatus(1);
|
|
|
|
|
+ appointment.setUpdatedAt(new Date());
|
|
|
|
|
+ assessmentAppointmentMapper.updateById(appointment);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|