|
|
@@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
import com.xjrsoft.common.annotation.XjrLog;
|
|
|
+import com.xjrsoft.common.enums.DeleteMark;
|
|
|
+import com.xjrsoft.common.enums.EnabledMark;
|
|
|
import com.xjrsoft.common.model.result.RT;
|
|
|
import com.xjrsoft.common.page.ConventPage;
|
|
|
import com.xjrsoft.common.page.PageOutput;
|
|
|
@@ -34,6 +36,7 @@ import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @title: 奖学金发放记录表
|
|
|
@@ -103,9 +106,23 @@ public class BaseStudentScholarshipReleaseController {
|
|
|
@SaCheckPermission("basestudentscholarshiprelease:add")
|
|
|
@XjrLog(value = "新增奖学金发放记录表", saveResponseData = true)
|
|
|
public RT<Boolean> add(@Valid @RequestBody AddBaseStudentScholarshipReleaseDto dto) {
|
|
|
+ //查询已发放的金额
|
|
|
+ List<BaseStudentScholarshipRelease> releaseList = releaseService.list(
|
|
|
+ new QueryWrapper<BaseStudentScholarshipRelease>().lambda()
|
|
|
+ .eq(BaseStudentScholarshipRelease::getBaseStudentScholarshipApplicantId, dto.getBaseStudentScholarshipApplicantId())
|
|
|
+ .eq(BaseStudentScholarshipRelease::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ .eq(BaseStudentScholarshipRelease::getEnabledMark, EnabledMark.ENABLED.getCode())
|
|
|
+ );
|
|
|
+
|
|
|
+ double releaseAmount = releaseList.stream().mapToDouble(BaseStudentScholarshipRelease::getAmount).sum();
|
|
|
+
|
|
|
BaseStudentScholarshipApplicant applicant = applicantService.getById(dto.getBaseStudentScholarshipApplicantId());
|
|
|
- if (dto.getAmount() > applicant.getAmount()) {
|
|
|
- return RT.error("发放金额不能大于获奖金额");
|
|
|
+ if(releaseAmount == applicant.getAmount()){
|
|
|
+ return RT.error("已发放足够金额,无法再发放");
|
|
|
+ }
|
|
|
+ double v = applicant.getAmount() - releaseAmount;
|
|
|
+ if (dto.getAmount() > v) {
|
|
|
+ return RT.error("发放金额不能大于" + v);
|
|
|
}
|
|
|
BaseStudentScholarshipRelease baseStudentScholarshipRelease = BeanUtil.toBean(dto, BaseStudentScholarshipRelease.class);
|
|
|
boolean isSuccess = releaseService.save(baseStudentScholarshipRelease);
|