|
@@ -814,9 +814,28 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
|
|
@Override
|
|
@Override
|
|
public R<?> financialReview(WmScorePackageSettleInput input) {
|
|
public R<?> financialReview(WmScorePackageSettleInput input) {
|
|
HnqzUser operator = SecurityUtils.getUser();
|
|
HnqzUser operator = SecurityUtils.getUser();
|
|
- this.checkAndUpdateFinancialReviewForReview(input, operator);
|
|
|
|
|
|
+ Boolean review = this.checkAndUpdateFinancialReviewForReview(input, operator);
|
|
|
|
+ if (!Boolean.TRUE.equals(review)) {
|
|
|
|
+ // 复核不通过,直接返回
|
|
|
|
+ return R.ok(null, "操作成功");
|
|
|
|
+ }
|
|
|
|
|
|
- return this.settleIssueBySubType(input);
|
|
|
|
|
|
+ R<?> r = this.settleIssueBySubType(input);
|
|
|
|
+
|
|
|
|
+ if (r.getCode() != 0) {
|
|
|
|
+ // 回退复核状态为待复核
|
|
|
|
+ Set<WmScorePackageSettleNote> updateNotes = input.getNotes().stream().map(note -> {
|
|
|
|
+ WmScorePackageSettleNote updateNote = new WmScorePackageSettleNote();
|
|
|
|
+ updateNote.setId(note.getId());
|
|
|
|
+ updateNote.setReviewStatus(UpmsState.SettleFinancialReviewStatus.TO_BE_REVIEWED);
|
|
|
|
+ updateNote.setReviewUser(operator.getId());
|
|
|
|
+ updateNote.setReviewTime(LocalDateTime.now());
|
|
|
|
+ return updateNote;
|
|
|
|
+ }).collect(Collectors.toSet());
|
|
|
|
+ noteService.updateBatchById(updateNotes);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return r;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -830,7 +849,11 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
|
|
HnqzUser operator = SecurityUtils.getUser();
|
|
HnqzUser operator = SecurityUtils.getUser();
|
|
SysDept sysDept = sysDeptService.getById(operator.getDeptId());
|
|
SysDept sysDept = sysDeptService.getById(operator.getDeptId());
|
|
// 校验是否财务复核并更新
|
|
// 校验是否财务复核并更新
|
|
- this.checkAndUpdateFinancialReviewForSettle(input, operator, sysDept);
|
|
|
|
|
|
+ Boolean review = this.checkAndUpdateFinancialReviewForSettle(input, operator, sysDept);
|
|
|
|
+ if (!Boolean.TRUE.equals(review)) {
|
|
|
|
+ // 复核不通过,直接返回
|
|
|
|
+ return R.ok(null, "提交复核成功");
|
|
|
|
+ }
|
|
|
|
|
|
return this.settleIssueBySubType(input);
|
|
return this.settleIssueBySubType(input);
|
|
}
|
|
}
|
|
@@ -841,7 +864,7 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
|
|
* @param input 结算入参
|
|
* @param input 结算入参
|
|
* @param operator 操作人
|
|
* @param operator 操作人
|
|
*/
|
|
*/
|
|
- private void checkAndUpdateFinancialReviewForReview(WmScorePackageSettleInput input, HnqzUser operator) {
|
|
|
|
|
|
+ private Boolean checkAndUpdateFinancialReviewForReview(WmScorePackageSettleInput input, HnqzUser operator) {
|
|
// 1.财务复核员操作通过,则直接发起结算
|
|
// 1.财务复核员操作通过,则直接发起结算
|
|
// 2.财务复核员操作不通过则改为复核不通过状态,结算状态也改为复核不通过
|
|
// 2.财务复核员操作不通过则改为复核不通过状态,结算状态也改为复核不通过
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
@@ -856,6 +879,18 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
|
|
return updateNote;
|
|
return updateNote;
|
|
}).collect(Collectors.toSet());
|
|
}).collect(Collectors.toSet());
|
|
noteService.updateBatchById(updateNotes);
|
|
noteService.updateBatchById(updateNotes);
|
|
|
|
+
|
|
|
|
+ if (UpmsState.SettleFinancialReviewStatus.REJECTED.equals(input.getReviewStatus())) {
|
|
|
|
+ WmScorePackage scorePackage = new WmScorePackage();
|
|
|
|
+ scorePackage.setId(input.getId());
|
|
|
|
+ scorePackage.setSettleStatus(Integer.valueOf(SettleStatusEnum.TO_BE_REVIEWED.getVal()));
|
|
|
|
+ scorePackage.setUpdateUser(operator.getId());
|
|
|
|
+ scorePackage.setUpdateTime(now);
|
|
|
|
+ wmScorePackageService.updateById(scorePackage);
|
|
|
|
+ return Boolean.FALSE;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return Boolean.TRUE;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -864,12 +899,13 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
|
|
* @param input 结算入参
|
|
* @param input 结算入参
|
|
* @param operator 操作人
|
|
* @param operator 操作人
|
|
* @param sysDept 企业信息
|
|
* @param sysDept 企业信息
|
|
|
|
+ * @return 是否可以发起结算
|
|
*/
|
|
*/
|
|
- private void checkAndUpdateFinancialReviewForSettle(WmScorePackageSettleInput input, HnqzUser operator, SysDept sysDept) {
|
|
|
|
|
|
+ private Boolean checkAndUpdateFinancialReviewForSettle(WmScorePackageSettleInput input, HnqzUser operator, SysDept sysDept) {
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
// 校验企业是否配置了财务复核, 有则到财务复核
|
|
// 校验企业是否配置了财务复核, 有则到财务复核
|
|
if (UpmsType.FinancialReviewType.AUTO.equals(sysDept.getFinancialReviewType())) {
|
|
if (UpmsType.FinancialReviewType.AUTO.equals(sysDept.getFinancialReviewType())) {
|
|
// 企业配置为自动的,则跳过复核,直接发起结算
|
|
// 企业配置为自动的,则跳过复核,直接发起结算
|
|
- LocalDateTime now = LocalDateTime.now();
|
|
|
|
Set<WmScorePackageSettleNote> updateNotes = input.getNotes().stream().map(note -> {
|
|
Set<WmScorePackageSettleNote> updateNotes = input.getNotes().stream().map(note -> {
|
|
WmScorePackageSettleNote updateNote = new WmScorePackageSettleNote();
|
|
WmScorePackageSettleNote updateNote = new WmScorePackageSettleNote();
|
|
updateNote.setId(note.getId());
|
|
updateNote.setId(note.getId());
|
|
@@ -879,16 +915,32 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
|
|
return updateNote;
|
|
return updateNote;
|
|
}).collect(Collectors.toSet());
|
|
}).collect(Collectors.toSet());
|
|
noteService.updateBatchById(updateNotes);
|
|
noteService.updateBatchById(updateNotes);
|
|
|
|
+
|
|
|
|
+ return Boolean.TRUE;
|
|
} else {
|
|
} else {
|
|
- // 企业配置为手动的,则判断是否复核通过,
|
|
|
|
- // 判断如果当前是复核通过,则直接发起结算,如果是不通过则不能发起
|
|
|
|
|
|
+ // 企业配置为手动的
|
|
|
|
+ // 判断如果当前是不通过或待复核,则不能发起(开发备注:手动的情况下,这里暂定为 即使状态为通过也不发起结算,由复核员操作)
|
|
Set<Integer> noteIds = input.getNotes().stream().map(WmScorePackageSettleNote::getId).collect(Collectors.toSet());
|
|
Set<Integer> noteIds = input.getNotes().stream().map(WmScorePackageSettleNote::getId).collect(Collectors.toSet());
|
|
List<WmScorePackageSettleNote> settleNotes = noteService.listByIds(noteIds);
|
|
List<WmScorePackageSettleNote> settleNotes = noteService.listByIds(noteIds);
|
|
- boolean allMatch = settleNotes.stream()
|
|
|
|
- .allMatch(note -> UpmsState.SettleFinancialReviewStatus.PASSED.equals(note.getReviewStatus()));
|
|
|
|
- if (!allMatch) {
|
|
|
|
|
|
+ boolean anyMatch = settleNotes.stream()
|
|
|
|
+ .anyMatch(note -> UpmsState.SettleFinancialReviewStatus.REJECTED.equals(note.getReviewStatus())
|
|
|
|
+ || UpmsState.SettleFinancialReviewStatus.TO_BE_REVIEWED.equals(note.getReviewStatus()));
|
|
|
|
+ if (anyMatch) {
|
|
throw new BizException("未复核或复核不通过,不能发起结算");
|
|
throw new BizException("未复核或复核不通过,不能发起结算");
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // 修改复核状态为待复核
|
|
|
|
+ Set<WmScorePackageSettleNote> updateNotes = input.getNotes().stream().map(note -> {
|
|
|
|
+ WmScorePackageSettleNote updateNote = new WmScorePackageSettleNote();
|
|
|
|
+ updateNote.setId(note.getId());
|
|
|
|
+ updateNote.setReviewStatus(UpmsState.SettleFinancialReviewStatus.TO_BE_REVIEWED);
|
|
|
|
+ updateNote.setReviewUser(operator.getId());
|
|
|
|
+ updateNote.setReviewTime(now);
|
|
|
|
+ return updateNote;
|
|
|
|
+ }).collect(Collectors.toSet());
|
|
|
|
+ noteService.updateBatchById(updateNotes);
|
|
|
|
+
|
|
|
|
+ return Boolean.FALSE;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|