|
@@ -57,6 +57,9 @@ public class AssessmentAppointmentService extends ServiceImpl<AssessmentAppointm
|
|
|
public boolean confirmAppointment(Long id, Long userId) {
|
|
public boolean confirmAppointment(Long id, Long userId) {
|
|
|
AssessmentAppointment appointment = assessmentAppointmentMapper.selectById(id);
|
|
AssessmentAppointment appointment = assessmentAppointmentMapper.selectById(id);
|
|
|
if (appointment == null) return false;
|
|
if (appointment == null) return false;
|
|
|
|
|
+ // 状态守卫(teacher.appointment.guard / SC-T-09):仅待确认(0)可流转到已确认(1),
|
|
|
|
|
+ // 重复确认、已完成(2)/未到(4)等状态一律拒绝,且拒绝时不写库
|
|
|
|
|
+ if (appointment.getStatus() == null || appointment.getStatus() != 0) return false;
|
|
|
// 允许被指派的测评师(assessorId)或规划师(guideId)确认
|
|
// 允许被指派的测评师(assessorId)或规划师(guideId)确认
|
|
|
Long expectedId = appointment.getAssessorId() != null ? appointment.getAssessorId() : appointment.getGuideId();
|
|
Long expectedId = appointment.getAssessorId() != null ? appointment.getAssessorId() : appointment.getGuideId();
|
|
|
if (!userId.equals(expectedId)) return false;
|
|
if (!userId.equals(expectedId)) return false;
|
|
@@ -68,6 +71,9 @@ public class AssessmentAppointmentService extends ServiceImpl<AssessmentAppointm
|
|
|
public boolean completeAppointment(Long id, Long teacherId) {
|
|
public boolean completeAppointment(Long id, Long teacherId) {
|
|
|
AssessmentAppointment appointment = assessmentAppointmentMapper.selectById(id);
|
|
AssessmentAppointment appointment = assessmentAppointmentMapper.selectById(id);
|
|
|
if (appointment == null) return false;
|
|
if (appointment == null) return false;
|
|
|
|
|
+ // 状态守卫(teacher.appointment.guard / SC-T-10):仅已确认(1)可流转到已完成(2),
|
|
|
|
|
+ // 待确认(0)/已完成(2)/未到(4)一律拒绝,拒绝时不写库、不重复发放完成能量
|
|
|
|
|
+ if (appointment.getStatus() == null || appointment.getStatus() != 1) return false;
|
|
|
if (!teacherId.equals(appointment.getGuideId())) return false;
|
|
if (!teacherId.equals(appointment.getGuideId())) return false;
|
|
|
appointment.setStatus(2); // completed
|
|
appointment.setStatus(2); // completed
|
|
|
appointment.setUpdatedAt(new Date());
|
|
appointment.setUpdatedAt(new Date());
|
|
@@ -88,11 +94,31 @@ 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;
|
|
|
|
|
+ // 状态守卫(teacher.appointment.guard / SC-T-10):仅待确认(0)/已确认(1)可取消;
|
|
|
|
|
+ // 已完成(2)/未到(4)等终态一律拒绝,且拒绝时不写库
|
|
|
|
|
+ if (appointment.getStatus() == null
|
|
|
|
|
+ || (appointment.getStatus() != 0 && appointment.getStatus() != 1)) return false;
|
|
|
appointment.setStatus(3); // cancelled
|
|
appointment.setStatus(3); // cancelled
|
|
|
appointment.setUpdatedAt(new Date());
|
|
appointment.setUpdatedAt(new Date());
|
|
|
return assessmentAppointmentMapper.updateById(appointment) > 0;
|
|
return assessmentAppointmentMapper.updateById(appointment) > 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 将预约标记为「未到」(status=4)—— 契约缺口 G-1:规划师「完成/未到」闭环的「未到」分支。
|
|
|
|
|
+ * 仅待确认(0)/已确认(1)可流转到未到(4);已完成(2)/已取消(3)/未到(4)等终态一律拒绝。
|
|
|
|
|
+ */
|
|
|
|
|
+ public boolean noShowAppointment(Long id, Long teacherId) {
|
|
|
|
|
+ AssessmentAppointment appointment = assessmentAppointmentMapper.selectById(id);
|
|
|
|
|
+ if (appointment == null) return false;
|
|
|
|
|
+ // 状态守卫:仅待确认(0)/已确认(1)可标记未到;终态一律拒绝且不写库
|
|
|
|
|
+ if (appointment.getStatus() == null
|
|
|
|
|
+ || (appointment.getStatus() != 0 && appointment.getStatus() != 1)) return false;
|
|
|
|
|
+ if (!teacherId.equals(appointment.getGuideId())) return false;
|
|
|
|
|
+ appointment.setStatus(4); // no-show
|
|
|
|
|
+ appointment.setUpdatedAt(new Date());
|
|
|
|
|
+ return assessmentAppointmentMapper.updateById(appointment) > 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public List<AssessmentAppointment> getByUserId(Long userId) {
|
|
public List<AssessmentAppointment> getByUserId(Long userId) {
|
|
|
LambdaQueryWrapper<AssessmentAppointment> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<AssessmentAppointment> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(AssessmentAppointment::getUserId, userId);
|
|
wrapper.eq(AssessmentAppointment::getUserId, userId);
|