|
|
@@ -6,11 +6,13 @@ import com.train.cfc.entity.CfcActivity;
|
|
|
import com.train.cfc.mapper.CfcActivityMapper;
|
|
|
import com.train.dto.EnrollmentVO;
|
|
|
import com.train.entity.TrainClass;
|
|
|
+import com.train.entity.TrainCourse;
|
|
|
import com.train.entity.TrainEnrollment;
|
|
|
import com.train.entity.TrainInvite;
|
|
|
import com.train.entity.TrainOrder;
|
|
|
import com.train.entity.TrainUser;
|
|
|
import com.train.mapper.TrainClassMapper;
|
|
|
+import com.train.mapper.TrainCourseMapper;
|
|
|
import com.train.mapper.TrainEnrollmentMapper;
|
|
|
import com.train.mapper.TrainInviteMapper;
|
|
|
import com.train.mapper.TrainOrderMapper;
|
|
|
@@ -39,6 +41,8 @@ public class EnrollmentController {
|
|
|
@Resource
|
|
|
private TrainClassMapper trainClassMapper;
|
|
|
@Resource
|
|
|
+ private TrainCourseMapper trainCourseMapper;
|
|
|
+ @Resource
|
|
|
private TrainEnrollmentMapper trainEnrollmentMapper;
|
|
|
@Resource
|
|
|
private TrainInviteMapper trainInviteMapper;
|
|
|
@@ -70,6 +74,10 @@ public class EnrollmentController {
|
|
|
.in(TrainEnrollment::getStatus, OCCUPY_STATUS));
|
|
|
Map<String, Object> row = new HashMap<>();
|
|
|
row.put("id", c.getId());
|
|
|
+ row.put("courseId", c.getCourseId());
|
|
|
+ // 报名=报课程:带课程名便于前端按课程分组展示该课程下的可报班次
|
|
|
+ TrainCourse course = c.getCourseId() == null ? null : trainCourseMapper.selectById(c.getCourseId());
|
|
|
+ row.put("courseName", course == null ? c.getName() : (course.getLevel() + ' ' + course.getName()));
|
|
|
row.put("name", c.getName());
|
|
|
row.put("time", c.getTime());
|
|
|
row.put("place", c.getPlace());
|
|
|
@@ -114,6 +122,14 @@ public class EnrollmentController {
|
|
|
if (trainClass == null || !"active".equals(trainClass.getStatus())) {
|
|
|
return Result.error("班次不存在或不可报名");
|
|
|
}
|
|
|
+ // 报名=报课程:显式传入 courseId 优先,否则由班次所属课程推导(两者不一致时以班次为准)
|
|
|
+ Long courseId = null;
|
|
|
+ if (body.get("courseId") != null && !body.get("courseId").toString().trim().isEmpty()) {
|
|
|
+ courseId = Long.valueOf(body.get("courseId").toString());
|
|
|
+ }
|
|
|
+ if (courseId == null) {
|
|
|
+ courseId = trainClass.getCourseId();
|
|
|
+ }
|
|
|
// 容量校验(并发下允许少量超卖,最终以支付为准)
|
|
|
Long occupied = trainEnrollmentMapper.selectCount(
|
|
|
new LambdaQueryWrapper<TrainEnrollment>()
|
|
|
@@ -135,6 +151,7 @@ public class EnrollmentController {
|
|
|
String inviteCode = body.get("inviteCode") == null ? "" : body.get("inviteCode").toString().trim();
|
|
|
TrainEnrollment e = new TrainEnrollment();
|
|
|
e.setUid(userId);
|
|
|
+ e.setCourseId(courseId);
|
|
|
e.setClassId(classId);
|
|
|
e.setName(name);
|
|
|
e.setPhone(phone);
|
|
|
@@ -202,6 +219,16 @@ public class EnrollmentController {
|
|
|
row.put("classId", e.getClassId());
|
|
|
TrainClass c = e.getClassId() == null ? null : trainClassMapper.selectById(e.getClassId());
|
|
|
row.put("className", c != null ? c.getName() : null);
|
|
|
+ // 报名=报课程:回填课程信息,前端「我的报名」按课程展示
|
|
|
+ row.put("courseId", e.getCourseId());
|
|
|
+ String courseName = null;
|
|
|
+ if (e.getCourseId() != null) {
|
|
|
+ TrainCourse course = trainCourseMapper.selectById(e.getCourseId());
|
|
|
+ if (course != null) {
|
|
|
+ courseName = course.getLevel() + ' ' + course.getName();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ row.put("courseName", courseName);
|
|
|
row.put("name", e.getName());
|
|
|
row.put("phone", e.getPhone());
|
|
|
row.put("source", e.getSource());
|