deason 1 месяц назад
Родитель
Сommit
d177e00a41

+ 2 - 1
src/main/java/com/qmth/exam/reserve/service/StudentService.java

@@ -15,7 +15,7 @@ public interface StudentService extends IService<StudentEntity> {
 
     StudentEntity findByStudentCode(Long applyTaskId, String studentCode);
 
-    StudentEntity findByOpenIdAndUid(String openId, String uid);
+    StudentEntity findByOpenIdAndUid(Long applyTaskId, String openId, String uid);
 
     StudentEntity findLessInfoByStudentId(Long studentId);
 
@@ -44,4 +44,5 @@ public interface StudentService extends IService<StudentEntity> {
     void uploadStudentPhoto(Long operateId, MultipartFile file);
 
     List<StudentExportVO> exportPage(StudentReq req);
+
 }

+ 11 - 7
src/main/java/com/qmth/exam/reserve/service/impl/AuthServiceImpl.java

@@ -14,7 +14,6 @@ import com.qmth.exam.reserve.bean.org.OrgInfo;
 import com.qmth.exam.reserve.cache.impl.ApplyTaskCacheService;
 import com.qmth.exam.reserve.cache.impl.LoginSessionManager;
 import com.qmth.exam.reserve.cache.impl.OrgCacheService;
-import com.qmth.exam.reserve.entity.ApplyTaskEntity;
 import com.qmth.exam.reserve.entity.StudentEntity;
 import com.qmth.exam.reserve.entity.UserEntity;
 import com.qmth.exam.reserve.enums.Role;
@@ -160,17 +159,22 @@ public class AuthServiceImpl implements AuthorizationService<LoginUser>, AuthSer
             throw new StatusException("微信OID不能为空");
         }
 
-        log.info("[WECHAT_LOGIN] verifying... openId:{} uid:{}", req.getOpenId(), req.getUid());
-        StudentEntity student = studentService.findByOpenIdAndUid(req.getOpenId(), req.getUid());
-        if (student == null) {
-            throw new StatusException("尚未绑定微信账号");
+        OrgInfo org = orgCacheService.currentOrg();
+        if (org == null) {
+            throw new StatusException("尚未启用当前机构");
         }
 
-        ApplyTaskEntity curApplyTask = applyTaskService.getLessInfoApplyTaskById(student.getApplyTaskId());
-        if (curApplyTask == null || !curApplyTask.getEnable()) {
+        CurrentApplyTaskVO curApplyTask = applyTaskCacheService.currentApplyTask(org.getOrgId());
+        if (curApplyTask == null) {
             throw new StatusException("尚未开启预约任务");
         }
 
+        log.info("[WECHAT_LOGIN] verifying... applyTaskId:{} openId:{} uid:{}", curApplyTask.getTaskId(), req.getOpenId(), req.getUid());
+        StudentEntity student = studentService.findByOpenIdAndUid(curApplyTask.getTaskId(), req.getOpenId(), req.getUid());
+        if (student == null) {
+            throw new StatusException("尚未绑定微信账号");
+        }
+
         LoginUser loginUser = new LoginUser();
         loginUser.setId(student.getId());
         loginUser.setAccount(student.getStudentCode());

+ 11 - 5
src/main/java/com/qmth/exam/reserve/service/impl/StudentServiceImpl.java

@@ -25,7 +25,6 @@ import com.qmth.exam.reserve.entity.StudentCourseEntity;
 import com.qmth.exam.reserve.entity.StudentEntity;
 import com.qmth.exam.reserve.enums.AsyncTaskType;
 import com.qmth.exam.reserve.enums.EventType;
-import com.qmth.exam.reserve.enums.FileUploadType;
 import com.qmth.exam.reserve.enums.Role;
 import com.qmth.exam.reserve.service.*;
 import com.qmth.exam.reserve.template.execute.StudentPhotoUploadService;
@@ -44,7 +43,10 @@ import org.springframework.web.multipart.MultipartFile;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.*;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.StringJoiner;
 import java.util.stream.Collectors;
 
 @Service
@@ -102,12 +104,16 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
     }
 
     @Override
-    public StudentEntity findByOpenIdAndUid(String openId, String uid) {
+    public StudentEntity findByOpenIdAndUid(Long applyTaskId, String openId, String uid) {
+        if (applyTaskId == null) {
+            throw new StatusException("预约任务ID不能为空");
+        }
         if (StringUtils.isEmpty(openId)) {
             throw new StatusException("微信OID不能为空");
         }
 
         LambdaQueryWrapper<StudentEntity> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(StudentEntity::getApplyTaskId, applyTaskId);
         wrapper.eq(StudentEntity::getOpenId, openId);
         if (StringUtils.isNotEmpty(uid)) {
             wrapper.eq(StudentEntity::getUid, uid);
@@ -228,9 +234,9 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
     @Transactional
     public void delete(Long[] studentCourseIds, LoginUser loginUser) {
         // 考生科目ID
-        for(Long studentCourseId : studentCourseIds) {
+        for (Long studentCourseId : studentCourseIds) {
             StudentCourseEntity studentCourseEntity = studentCourseService.getById(studentCourseId);
-            if(studentCourseEntity == null) {
+            if (studentCourseEntity == null) {
                 throw new StatusException("考生科目不存在");
             }
             Long studentId = studentCourseEntity.getStudentId();