|
@@ -2,22 +2,34 @@ package com.zhongzheng.modules.distribution.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.github.pagehelper.Page;
|
|
|
+import com.zhongzheng.common.core.domain.entity.SysRole;
|
|
|
+import com.zhongzheng.common.core.domain.entity.SysUser;
|
|
|
+import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
-import com.zhongzheng.modules.distribution.bo.DistributionCashWithdrawalAddBo;
|
|
|
-import com.zhongzheng.modules.distribution.bo.DistributionCashWithdrawalEditBo;
|
|
|
-import com.zhongzheng.modules.distribution.bo.DistributionCashWithdrawalQueryBo;
|
|
|
+import com.zhongzheng.modules.distribution.bo.*;
|
|
|
import com.zhongzheng.modules.distribution.domain.DistributionCashWithdrawal;
|
|
|
+import com.zhongzheng.modules.distribution.domain.DistributionCheck;
|
|
|
import com.zhongzheng.modules.distribution.mapper.DistributionCashWithdrawalMapper;
|
|
|
import com.zhongzheng.modules.distribution.service.IDistributionCashWithdrawalService;
|
|
|
+import com.zhongzheng.modules.distribution.service.IDistributionCheckService;
|
|
|
import com.zhongzheng.modules.distribution.vo.DistributionCashWithdrawalVo;
|
|
|
+import com.zhongzheng.modules.distribution.vo.DistributionCheckDetailVo;
|
|
|
+import com.zhongzheng.modules.distribution.vo.DistributionCheckVo;
|
|
|
+import com.zhongzheng.modules.system.domain.SysUserRole;
|
|
|
+import com.zhongzheng.modules.system.service.ISysRoleService;
|
|
|
+import com.zhongzheng.modules.system.service.ISysUserRoleService;
|
|
|
+import com.zhongzheng.modules.system.service.ISysUserService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import com.github.pagehelper.Page;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Collection;
|
|
|
-import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -30,6 +42,15 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class DistributionCashWithdrawalServiceImpl extends ServiceImpl<DistributionCashWithdrawalMapper, DistributionCashWithdrawal> implements IDistributionCashWithdrawalService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysRoleService iSysRoleService;
|
|
|
+ @Autowired
|
|
|
+ public ISysUserService iSysUserService;
|
|
|
+ @Autowired
|
|
|
+ public ISysUserRoleService iSysUserRoleService;
|
|
|
+ @Autowired
|
|
|
+ public IDistributionCheckService iDistributionCheckService;
|
|
|
+
|
|
|
@Override
|
|
|
public DistributionCashWithdrawalVo queryById(Long id){
|
|
|
DistributionCashWithdrawal db = this.baseMapper.selectById(id);
|
|
@@ -106,4 +127,117 @@ public class DistributionCashWithdrawalServiceImpl extends ServiceImpl<Distribut
|
|
|
}
|
|
|
return this.removeByIds(ids);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<DistributionCheckVo> queryCheckList(DistributionCheckQueryBo bo) {
|
|
|
+ List<DistributionCheckVo> checkVos = baseMapper.queryCheckList(bo);
|
|
|
+ return checkVos;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean checkHandle(DistributionCheckHandleBo bo) {
|
|
|
+ DistributionCashWithdrawal warning = getById(bo.getCwId());
|
|
|
+ if (ObjectUtils.isNotNull(warning)){
|
|
|
+ throw new CustomException("提现记录获取失败!");
|
|
|
+ }
|
|
|
+// validStatus(bo,warning);
|
|
|
+ DistributionCheck check = BeanUtil.toBean(bo, DistributionCheck.class);
|
|
|
+ check.setStatus(1);
|
|
|
+ check.setCreateTime(DateUtils.getNowTime());
|
|
|
+ check.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ String roleKey1 = "edu";
|
|
|
+ String roleKey2 = "accounting";
|
|
|
+ String roleKey3 = "boss";
|
|
|
+ Integer checkStatus = 0;
|
|
|
+ if (bo.getCheckStatus() == 1){
|
|
|
+ //一审教务
|
|
|
+ validPermission(bo,roleKey1);
|
|
|
+ if (bo.getCheckResult() == 1){
|
|
|
+ //通过
|
|
|
+ addNextAuditor(check,2,roleKey2);
|
|
|
+ checkStatus = 1;
|
|
|
+ }else {
|
|
|
+ //拒绝 打回上一层
|
|
|
+ addNextAuditor(check,1,roleKey1);
|
|
|
+ checkStatus = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (bo.getCheckStatus() == 2){
|
|
|
+ //二审财务
|
|
|
+ validPermission(bo,roleKey2);
|
|
|
+ if (bo.getCheckResult() == 1){
|
|
|
+ //通过
|
|
|
+ addNextAuditor(check,3,roleKey3);
|
|
|
+ checkStatus = 2;
|
|
|
+ }else {
|
|
|
+ //拒绝 打回上一层
|
|
|
+ addNextAuditor(check,1,roleKey1);
|
|
|
+ checkStatus = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (bo.getCheckStatus() == 3){
|
|
|
+ //三审老板
|
|
|
+ validPermission(bo,roleKey3);
|
|
|
+ if (bo.getCheckResult() == 1){
|
|
|
+ //通过
|
|
|
+ checkStatus = 3;
|
|
|
+ }else {
|
|
|
+ //拒绝 打回上一层
|
|
|
+ addNextAuditor(check,2,roleKey2);
|
|
|
+ checkStatus = 2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //保存审核记录
|
|
|
+ iDistributionCheckService.save(check);
|
|
|
+ //修改提现状态
|
|
|
+ warning.setCwStatus(checkStatus);
|
|
|
+ return updateById(warning);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<DistributionCheckDetailVo> checkDetail(Long id) {
|
|
|
+ List<DistributionCheck> list = iDistributionCheckService.list(new LambdaQueryWrapper<DistributionCheck>()
|
|
|
+ .eq(DistributionCheck::getCwId, id)
|
|
|
+ .eq(DistributionCheck::getStatus, 1));
|
|
|
+ if (CollectionUtils.isEmpty(list)){
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ return list.stream().map(item -> BeanUtil.toBean(item,DistributionCheckDetailVo.class)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addNextAuditor(DistributionCheck check,Integer nextStatus,String nextKey){
|
|
|
+ check.setNextStatus(nextStatus);//初审
|
|
|
+ List<String> userNames = iSysUserService.getUserNameByRoleKey(nextKey);
|
|
|
+ if (CollectionUtils.isNotEmpty(userNames)){
|
|
|
+ check.setNextAuditor(userNames.stream().collect(Collectors.joining()));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void validPermission(DistributionCheckHandleBo bo,String roleKey) {
|
|
|
+
|
|
|
+ SysRole edu = iSysRoleService.getOne(new LambdaQueryWrapper<SysRole>().eq(SysRole::getRoleKey, roleKey));
|
|
|
+ if (ObjectUtils.isNull(edu)){
|
|
|
+ throw new CustomException("没有当前审核角色");
|
|
|
+ }
|
|
|
+ List<SysUserRole> list = iSysUserRoleService
|
|
|
+ .list(new LambdaQueryWrapper<SysUserRole>()
|
|
|
+ .eq(SysUserRole::getRoleId, edu.getRoleId()));
|
|
|
+ if (CollectionUtils.isEmpty(list)){
|
|
|
+ throw new CustomException("没有当前审核账号");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SysUser> sysUsers = iSysUserService.listByIds(list.stream().map(SysUserRole::getUserId).collect(Collectors.toList()));
|
|
|
+ if (sysUsers.stream().noneMatch(item -> item.getUserId().equals(bo.getAuditorId()))){
|
|
|
+ throw new CustomException("该账号没有审核权限");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void validStatus(DistributionCheckHandleBo bo,DistributionCashWithdrawal warning ) {
|
|
|
+ //校验审核状态
|
|
|
+ Integer checkStatus = bo.getCheckStatus();//当前状态
|
|
|
+// if(checkStatus == 1 && warning.getStatus() ){
|
|
|
+//
|
|
|
+// }
|
|
|
+ }
|
|
|
}
|