|
@@ -66,6 +66,9 @@ public class AdminController {
|
|
|
@Resource
|
|
@Resource
|
|
|
private AssessmentAppointmentMapper assessmentAppointmentMapper;
|
|
private AssessmentAppointmentMapper assessmentAppointmentMapper;
|
|
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private AssessmentOrderMapper assessmentOrderMapper;
|
|
|
|
|
+
|
|
|
// 用户管理
|
|
// 用户管理
|
|
|
@PostMapping("/users")
|
|
@PostMapping("/users")
|
|
|
public Result<Page<User>> getUsers(@RequestBody Map<String, Object> params) {
|
|
public Result<Page<User>> getUsers(@RequestBody Map<String, Object> params) {
|
|
@@ -1053,6 +1056,126 @@ public class AdminController {
|
|
|
return Result.success(list);
|
|
return Result.success(list);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // ========== 测评订单管理(基于预约表) ==========
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/assessment/orders")
|
|
|
|
|
+ public Result<Map<String, Object>> getAssessmentOrderList(@RequestBody Map<String, Object> params) {
|
|
|
|
|
+ int page = params.get("page") != null ? ((Number) params.get("page")).intValue() : 1;
|
|
|
|
|
+ int size = params.get("size") != null ? ((Number) params.get("size")).intValue() : 20;
|
|
|
|
|
+ Page<AssessmentAppointment> pageParam = new Page<>(page, size);
|
|
|
|
|
+
|
|
|
|
|
+ LambdaQueryWrapper<AssessmentAppointment> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ // 按状态筛选
|
|
|
|
|
+ if (params.containsKey("status") && params.get("status") != null && !params.get("status").toString().isEmpty()) {
|
|
|
|
|
+ wrapper.eq(AssessmentAppointment::getStatus, Integer.parseInt(params.get("status").toString()));
|
|
|
|
|
+ }
|
|
|
|
|
+ // 按关键词搜索(用户昵称/规划师昵称)
|
|
|
|
|
+ if (params.containsKey("keyword") && params.get("keyword") != null && !params.get("keyword").toString().isEmpty()) {
|
|
|
|
|
+ // 先查匹配的用户ID和规划师ID
|
|
|
|
|
+ String kw = params.get("keyword").toString();
|
|
|
|
|
+ LambdaQueryWrapper<User> userWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ userWrapper.like(User::getNickname, kw).select(User::getId);
|
|
|
|
|
+ java.util.List<User> matchedUsers = userMapper.selectList(userWrapper);
|
|
|
|
|
+ java.util.List<Long> matchedIds = new java.util.ArrayList<>();
|
|
|
|
|
+ for (User u : matchedUsers) { matchedIds.add(u.getId()); }
|
|
|
|
|
+ if (matchedIds.isEmpty()) {
|
|
|
|
|
+ matchedIds.add(-1L); // 无匹配时返回空
|
|
|
|
|
+ }
|
|
|
|
|
+ wrapper.and(w -> w.in(AssessmentAppointment::getUserId, matchedIds)
|
|
|
|
|
+ .or().in(AssessmentAppointment::getGuideId, matchedIds));
|
|
|
|
|
+ }
|
|
|
|
|
+ wrapper.orderByDesc(AssessmentAppointment::getCreatedAt);
|
|
|
|
|
+
|
|
|
|
|
+ Page<AssessmentAppointment> result = assessmentAppointmentMapper.selectPage(pageParam, wrapper);
|
|
|
|
|
+
|
|
|
|
|
+ java.util.List<Map<String, Object>> list = new java.util.ArrayList<>();
|
|
|
|
|
+ for (AssessmentAppointment app : result.getRecords()) {
|
|
|
|
|
+ Map<String, Object> item = new HashMap<>();
|
|
|
|
|
+ item.put("id", app.getId());
|
|
|
|
|
+ item.put("familyId", app.getFamilyId());
|
|
|
|
|
+ item.put("userId", app.getUserId());
|
|
|
|
|
+ item.put("childId", app.getChildId());
|
|
|
|
|
+ item.put("guideId", app.getGuideId());
|
|
|
|
|
+ item.put("teacherId", app.getTeacherId());
|
|
|
|
|
+ item.put("packageId", app.getPackageId());
|
|
|
|
|
+ item.put("appointmentDate", app.getAppointmentDate());
|
|
|
|
|
+ item.put("appointmentTime", app.getAppointmentTime());
|
|
|
|
|
+ item.put("durationMinutes", app.getDurationMinutes());
|
|
|
|
|
+ item.put("appointmentType", app.getAppointmentType());
|
|
|
|
|
+ item.put("notes", app.getNotes());
|
|
|
|
|
+ item.put("contactPhone", app.getContactPhone());
|
|
|
|
|
+ item.put("status", app.getStatus());
|
|
|
|
|
+ item.put("createdAt", app.getCreatedAt());
|
|
|
|
|
+
|
|
|
|
|
+ // 关联查询用户昵称
|
|
|
|
|
+ User user = userMapper.selectById(app.getUserId());
|
|
|
|
|
+ item.put("userName", user != null ? user.getNickname() : "未知用户");
|
|
|
|
|
+
|
|
|
|
|
+ // 关联查询孩子昵称
|
|
|
|
|
+ if (app.getChildId() != null) {
|
|
|
|
|
+ FamilyMember child = familyMemberMapper.selectById(app.getChildId());
|
|
|
|
|
+ item.put("childName", child != null ? child.getNickname() : "未知");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ item.put("childName", "");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 关联查询规划师昵称
|
|
|
|
|
+ Long guideId = app.getGuideId() != null ? app.getGuideId() : app.getTeacherId();
|
|
|
|
|
+ if (guideId != null) {
|
|
|
|
|
+ User guide = userMapper.selectById(guideId);
|
|
|
|
|
+ item.put("guideName", guide != null ? guide.getNickname() : "未知规划师");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ item.put("guideName", "");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 关联查询方案名称
|
|
|
|
|
+ if (app.getPackageId() != null) {
|
|
|
|
|
+ GuidePackage pkg = guidePackageMapper.selectById(app.getPackageId());
|
|
|
|
|
+ item.put("packageName", pkg != null ? pkg.getName() : "未知方案");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ item.put("packageName", "");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ list.add(item);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
|
|
+ resultMap.put("records", list);
|
|
|
|
|
+ resultMap.put("total", result.getTotal());
|
|
|
|
|
+ resultMap.put("current", result.getCurrent());
|
|
|
|
|
+ resultMap.put("size", result.getSize());
|
|
|
|
|
+ return Result.success(resultMap);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/assessment/change-guide")
|
|
|
|
|
+ public Result<Void> changeAssessmentGuide(@RequestBody Map<String, Object> body) {
|
|
|
|
|
+ Long appointmentId = body.get("orderId") != null ? Long.valueOf(body.get("orderId").toString()) : null;
|
|
|
|
|
+ Long guideId = body.get("guideId") != null ? Long.valueOf(body.get("guideId").toString()) : null;
|
|
|
|
|
+ if (appointmentId == null || guideId == null) {
|
|
|
|
|
+ return Result.error("appointmentId 和 guideId 不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ AssessmentAppointment appointment = assessmentAppointmentMapper.selectById(appointmentId);
|
|
|
|
|
+ if (appointment == null) {
|
|
|
|
|
+ return Result.error("预约记录不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ User guide = userMapper.selectById(guideId);
|
|
|
|
|
+ if (guide == null || !"teacher".equals(guide.getRole())) {
|
|
|
|
|
+ return Result.error("规划师不存在或角色不正确");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ appointment.setGuideId(guideId);
|
|
|
|
|
+ appointment.setTeacherId(guideId);
|
|
|
|
|
+ if (appointment.getStatus() != null && appointment.getStatus() == 0) {
|
|
|
|
|
+ appointment.setStatus(1); // 待确认 → 已确认
|
|
|
|
|
+ }
|
|
|
|
|
+ appointment.setUpdatedAt(new Date());
|
|
|
|
|
+ assessmentAppointmentMapper.updateById(appointment);
|
|
|
|
|
+
|
|
|
|
|
+ return Result.success(null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@PostMapping("/assessment/assign-guide")
|
|
@PostMapping("/assessment/assign-guide")
|
|
|
public Result<Void> assignGuide(@RequestBody Map<String, Object> body) {
|
|
public Result<Void> assignGuide(@RequestBody Map<String, Object> body) {
|
|
|
Long appointmentId = body.get("appointmentId") != null ? Long.valueOf(body.get("appointmentId").toString()) : null;
|
|
Long appointmentId = body.get("appointmentId") != null ? Long.valueOf(body.get("appointmentId").toString()) : null;
|