瀏覽代碼

奖助学金发放,修改发放状态

dzx 5 月之前
父節點
當前提交
feefda0bc8

+ 1 - 0
src/main/java/com/xjrsoft/module/student/controller/BaseStudentScholarshipReleaseController.java

@@ -126,6 +126,7 @@ public class BaseStudentScholarshipReleaseController {
         }
         BaseStudentScholarshipRelease baseStudentScholarshipRelease = BeanUtil.toBean(dto, BaseStudentScholarshipRelease.class);
         boolean isSuccess = releaseService.save(baseStudentScholarshipRelease);
+        applicantService.updateReleaseStatus(applicant);
         return RT.ok(isSuccess);
     }
 

+ 2 - 0
src/main/java/com/xjrsoft/module/student/service/IBaseStudentScholarshipApplicantService.java

@@ -37,4 +37,6 @@ public interface IBaseStudentScholarshipApplicantService extends MPJBaseService<
     Page<BaseStudentScholarshipApplicantCategoryPageVo> getScholarshiPage(Page<BaseStudentScholarshipApplicantCategoryPageDto> page, BaseStudentScholarshipApplicantCategoryPageDto dto);
 
     List<Map<String, String>> importData(MultipartFile file) throws IOException;
+
+    Boolean updateReleaseStatus(BaseStudentScholarshipApplicant scholarshipApplicant);
 }

+ 33 - 0
src/main/java/com/xjrsoft/module/student/service/impl/BaseStudentScholarshipApplicantServiceImpl.java

@@ -15,8 +15,10 @@ import com.xjrsoft.module.organization.service.IUserService;
 import com.xjrsoft.module.student.dto.BaseStudentScholarshipApplicantCategoryPageDto;
 import com.xjrsoft.module.student.entity.BaseStudentScholarshipApplicant;
 import com.xjrsoft.module.student.entity.BaseStudentScholarshipCategory;
+import com.xjrsoft.module.student.entity.BaseStudentScholarshipRelease;
 import com.xjrsoft.module.student.mapper.BaseStudentMapper;
 import com.xjrsoft.module.student.mapper.BaseStudentScholarshipApplicantMapper;
+import com.xjrsoft.module.student.mapper.BaseStudentScholarshipReleaseMapper;
 import com.xjrsoft.module.student.service.IBaseStudentScholarshipApplicantService;
 import com.xjrsoft.module.student.service.IBaseStudentScholarshipCategoryService;
 import com.xjrsoft.module.student.vo.BaseStudentScholarshipApplicantCategoryPageVo;
@@ -25,6 +27,7 @@ import com.xjrsoft.module.student.vo.ScholarshipApplicantImportVo;
 import com.xjrsoft.module.student.vo.StudentInfoVo;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
@@ -51,6 +54,7 @@ public class BaseStudentScholarshipApplicantServiceImpl extends MPJBaseServiceIm
     private final IUserService userService;
     private final BaseStudentScholarshipApplicantMapper scholarshipApplicantMapper;
     private final BaseStudentMapper studentMapper;
+    private final BaseStudentScholarshipReleaseMapper releaseMapper;
 
     @Override
     public Page<BaseStudentScholarshipApplicantCategoryPageVo> getScholarshiPage(Page<BaseStudentScholarshipApplicantCategoryPageDto> page, BaseStudentScholarshipApplicantCategoryPageDto dto) {
@@ -156,4 +160,33 @@ public class BaseStudentScholarshipApplicantServiceImpl extends MPJBaseServiceIm
         }
         return errorList;
     }
+
+    /**
+     * 每次发放时根据已经发放的金额判断这次申请的发放状态
+     * @param scholarshipApplicant
+     * @return
+     */
+    @Override
+    @Transactional
+    public Boolean updateReleaseStatus(BaseStudentScholarshipApplicant scholarshipApplicant) {
+        List<BaseStudentScholarshipRelease> releaseList = releaseMapper.selectList(
+                new QueryWrapper<BaseStudentScholarshipRelease>().lambda()
+                        .eq(BaseStudentScholarshipRelease::getDeleteMark, DeleteMark.NODELETE.getCode())
+                        .eq(BaseStudentScholarshipRelease::getBaseStudentScholarshipApplicantId, scholarshipApplicant.getId())
+        );
+        if(releaseList.isEmpty()){
+            scholarshipApplicant.setReleaseStatus(0);
+        }
+        double sum = releaseList.stream().filter(x -> x.getAmount() != null).mapToDouble(BaseStudentScholarshipRelease::getAmount).sum();
+        if(sum == 0){
+            scholarshipApplicant.setReleaseStatus(0);
+        }else if(sum < scholarshipApplicant.getAmount()){
+            scholarshipApplicant.setReleaseStatus(1);
+        }else if(sum == scholarshipApplicant.getAmount()){
+            scholarshipApplicant.setReleaseStatus(2);
+        }
+
+        this.updateById(scholarshipApplicant);
+        return true;
+    }
 }

+ 3 - 0
src/main/java/com/xjrsoft/module/student/service/impl/BaseStudentScholarshipReleaseServiceImpl.java

@@ -8,6 +8,7 @@ import com.xjrsoft.module.student.entity.BaseStudentScholarshipApplicant;
 import com.xjrsoft.module.student.entity.BaseStudentScholarshipRelease;
 import com.xjrsoft.module.student.mapper.BaseStudentScholarshipApplicantMapper;
 import com.xjrsoft.module.student.mapper.BaseStudentScholarshipReleaseMapper;
+import com.xjrsoft.module.student.service.IBaseStudentScholarshipApplicantService;
 import com.xjrsoft.module.student.service.IBaseStudentScholarshipReleaseService;
 import com.xjrsoft.module.student.vo.BaseStudentScholarshipReleasePageVo;
 import lombok.AllArgsConstructor;
@@ -25,6 +26,7 @@ import java.util.List;
 @AllArgsConstructor
 public class BaseStudentScholarshipReleaseServiceImpl extends MPJBaseServiceImpl<BaseStudentScholarshipReleaseMapper, BaseStudentScholarshipRelease> implements IBaseStudentScholarshipReleaseService {
     private BaseStudentScholarshipApplicantMapper applicantMapper;
+    private final IBaseStudentScholarshipApplicantService applicantService;
 
     @Override
     public Page<BaseStudentScholarshipReleasePageVo> getPage(Page<BaseStudentScholarshipReleasePageVo> page, BaseStudentScholarshipReleasePageDto dto) {
@@ -39,6 +41,7 @@ public class BaseStudentScholarshipReleaseServiceImpl extends MPJBaseServiceImpl
             updateWrapper.eq("id", applicant.getId());
             updateWrapper.setSql("review_status = 0");
             applicantMapper.update(applicant, updateWrapper);
+            applicantService.updateReleaseStatus(applicant);
         }
 
         return this.removeBatchByIds(ids);