From d6a6513dd8ff55449844264b24a3051c683febb7 Mon Sep 17 00:00:00 2001 From: jiangping <jp@doumee.com> Date: 星期一, 22 一月 2024 10:03:34 +0800 Subject: [PATCH] 开发业务接口 --- server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java | 203 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 193 insertions(+), 10 deletions(-) diff --git a/server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java index 55425d6..115644b 100644 --- a/server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java +++ b/server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java @@ -9,7 +9,9 @@ import com.doumee.core.utils.DateUtil; import com.doumee.core.utils.Utils; import com.doumee.dao.business.*; +import com.doumee.dao.business.dto.InsuranceApplyOptDTO; import com.doumee.dao.business.dto.InsuranceApplyQueryDTO; +import com.doumee.dao.business.join.ApplyLogJoinMapper; import com.doumee.dao.business.join.InsuranceApplyJoinMapper; import com.doumee.dao.business.model.*; import com.doumee.dao.system.model.SystemUser; @@ -21,6 +23,7 @@ import com.github.xiaoymin.knife4j.core.util.CollectionUtils; import com.github.yulichang.wrapper.MPJLambdaWrapper; import io.swagger.models.auth.In; +import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -51,6 +54,9 @@ private ApplyLogMapper applyLogMapper; @Autowired + private ApplyLogJoinMapper applyLogJoinMapper; + + @Autowired private SolutionsMapper solutionsMapper; @Autowired @@ -59,6 +65,66 @@ private DuSolutionMapper duSolutionMapper; @Autowired private DuWorktypeMapper duWorktypeMapper; + + @Override + @Transactional(rollbackFor = {Exception.class,BusinessException.class}) + public Integer back(InsuranceApply insuranceApply) { + if(insuranceApply.getId() == null ||StringUtils.isBlank(insuranceApply.getCheckInfo())){ + throw new BusinessException(ResponseStatus.BAD_REQUEST); + } + InsuranceApply model = insuranceApplyMapper.selectById(insuranceApply.getId()); + + if(model == null ||!Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO)){ + throw new BusinessException(ResponseStatus.DATA_EMPTY); + } + if(Constants.equalsInteger(model.getStatus(),Constants.InsuranceApplyStatus.UPLOAD.getKey())){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝璇ョ敵璇风姸鎬佸凡娴佽浆锛屽綋鍓嶄笉鏀寔璇ユ搷浣渵"); + } + LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); + InsuranceApply update = new InsuranceApply(); + update.setEditDate(new Date()); + update.setEditor(user.getId()); + update.setStatus(Constants.InsuranceApplyStatus.PLATFORM_RETURN.getKey()); + update.setCheckDate(update.getEditDate()); + update.setCheckInfo(insuranceApply.getCheckInfo()); + update.setCheckUserId(user.getId()); + update.setId(model.getId()); + insuranceApplyMapper.updateById(update); + + Constants.ApplyLogType applyLogType = Constants.ApplyLogType.PLATFORM_RETURN; + String info =applyLogType.getInfo(); + info = info.replace("${param}", update.getCheckInfo()); + ApplyLog log = new ApplyLog(update,applyLogType.getName(),info,update.getId(),applyLogType.getKey(),null,null); + applyLogMapper.insert(log); + return null; + + } + + @Override + @Transactional(rollbackFor = {Exception.class,BusinessException.class}) + public Integer uploadBaoxiandan(InsuranceApply insuranceApply) { + return null; + + } + @Override + @Transactional(rollbackFor = {Exception.class,BusinessException.class}) + public Integer refuseBackApply(InsuranceApply insuranceApply) { + return null; + + } + @Override + @Transactional(rollbackFor = {Exception.class,BusinessException.class}) + public Integer uploadToubaodan(InsuranceApply insuranceApply) { + return null; + + } + @Override + @Transactional(rollbackFor = {Exception.class,BusinessException.class}) + public Integer check(InsuranceApply insuranceApply) { + return null; + + } + @Override @Transactional(rollbackFor = {Exception.class,BusinessException.class}) @@ -137,7 +203,7 @@ } applyDetail.setIdcardNo(member.getIdcardNo()); applyDetail.setSex(member.getSex()); - applyDetail.setFee(this.countDetailFee(solutions,insuranceApply.getApplyEndTime(),insuranceApply.getApplyStartTime())); + applyDetail.setFee(Constants.countDetailFee(solutions,insuranceApply.getApplyEndTime(),insuranceApply.getApplyStartTime())); //楠岃瘉娲鹃仯鍗曚綅淇℃伅鏄惁瀛樺湪 if(duSolutionList.stream().filter(d->d.getDispatchUnitId().equals(applyDetail.getDuId())).collect(Collectors.toList()).size()<=Constants.ZERO){ throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"銆�"+applyDetail.getMemberName()+"銆戝憳宸ユ淳閬e崟浣嶆湭鏌ヨ鍒帮紒"); @@ -148,19 +214,36 @@ } applyDetailMapper.insert(applyDetail); } - + //瀛樺偍鏃ュ織鏁版嵁 + this.saveApplyLog(insuranceApply,insuranceApplyStatus,null); return insuranceApply.getId(); } - - public BigDecimal countDetailFee(Solutions solutions ,Date startDate,Date endDate){ - //鏌ヨ淇濋櫓瀹為檯鍛ㄦ湡 - Integer cycle = DateUtil.calculateBetween(endDate,startDate,solutions.getDataType()); - if(cycle==-1){ - throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"鏃ユ湡淇℃伅閿欒!"); - } - return solutions.getPrice().multiply(new BigDecimal(cycle)); + public void saveApplyLog(InsuranceApply insuranceApply,Constants.InsuranceApplyStatus insuranceApplyStatus,String content){ + LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); + ApplyLog applyLog = new ApplyLog(); + applyLog.setCreateDate(new Date()); + applyLog.setCreator(loginUserInfo.getId()); + applyLog.setIsdeleted(Constants.ZERO); + applyLog.setApplyId(insuranceApply.getId()); + applyLog.setTitle(insuranceApplyStatus.getName()); + applyLog.setContent(content); + applyLog.setObjType(insuranceApplyStatus.getKey()); + applyLog.setObjId( insuranceApply.getId()); + applyLog.setStatus(insuranceApply.getStatus()); + applyLogMapper.insert(applyLog); } + + + +// public BigDecimal countDetailFee(Solutions solutions ,Date startDate,Date endDate){ +// //鏌ヨ淇濋櫓瀹為檯鍛ㄦ湡 +// Integer cycle = DateUtil.calculateBetween(endDate,startDate,solutions.getDataType()); +// if(cycle==-1){ +// throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"鏃ユ湡淇℃伅閿欒!"); +// } +// return solutions.getPrice().multiply(new BigDecimal(cycle)); +// } // public static void main(String[] args) { // Date date1 = DateUtil.StringToDate("2023-03-01 00:00:00"); @@ -253,6 +336,13 @@ if (pageWrap.getModel().getStartTimeE() != null) { queryWrapper.le(InsuranceApply::getStartTime, Utils.Date.getEnd(pageWrap.getModel().getStartTimeE())); } + if (pageWrap.getModel().getCreateTimeS() != null) { + queryWrapper.ge(InsuranceApply::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateTimeS())); + } + if (pageWrap.getModel().getCreateTimeE() != null) { + queryWrapper.le(InsuranceApply::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateTimeE())); + } + if (pageWrap.getModel().getCode() != null) { queryWrapper.eq(InsuranceApply::getCode, pageWrap.getModel().getCode()); } @@ -277,4 +367,97 @@ QueryWrapper<InsuranceApply> wrapper = new QueryWrapper<>(insuranceApply); return insuranceApplyMapper.selectCount(wrapper); } + + + + @Override + public InsuranceApply findDetail(Integer id) { + InsuranceApply insuranceApply = insuranceApplyMapper.selectById(id); + if(Objects.isNull(insuranceApply)){ + throw new BusinessException(ResponseStatus.DATA_EMPTY); + } + insuranceApply.setInsureNum(applyDetailMapper.selectCount(new QueryWrapper<ApplyDetail>().lambda().eq(ApplyDetail::getApplyId,insuranceApply.getId()) + .eq(ApplyDetail::getIsdeleted,Constants.ZERO))); + + //璁剧疆鍦ㄤ繚鏃堕暱锛堝ぉ鏁帮級 + if(insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey())){ + //濡傛灉褰撳墠鏃堕棿澶т簬缁撴潫鏃ユ湡 鍒欎娇鐢ㄧ粨鏉熸棩鏈熷姣斿紑濮嬫棩鏈� + if(DateUtil.compareDate(new Date(),insuranceApply.getEndTime())>=Constants.ZERO){ + insuranceApply.setServiceDays(DateUtil.daysBetweenDates(insuranceApply.getEndTime(),insuranceApply.getStartTime())); + }else if(DateUtil.compareDate(insuranceApply.getStartTime(),new Date())>=Constants.ZERO){ + //鏈紑濮� + insuranceApply.setServiceDays(Constants.ZERO); + }else{ + insuranceApply.setServiceDays(DateUtil.daysBetweenDates(new Date(),insuranceApply.getStartTime())); + } + } + + + + //鏌ヨ鎿嶄綔璁板綍 + List<ApplyLog> applyLogList = applyLogJoinMapper.selectJoinList(ApplyLog.class, + new MPJLambdaWrapper<ApplyLog>() + .selectAll(ApplyLog.class) + .selectAs(Member::getName,ApplyLog::getCreatorName) + .selectAs(Company::getName,ApplyLog::getCompanyName) + .leftJoin(Member.class,Member::getId,ApplyLog::getCreator) + .leftJoin(Company.class,Company::getId,Member::getCompanyId) + .eq(ApplyLog::getApplyId,insuranceApply.getId()) + .orderByAsc(ApplyLog::getCreateDate) + ); + insuranceApply.setApplyLogList(applyLogList); + return insuranceApply; + } + + + @Override + @Transactional(rollbackFor = {Exception.class,BusinessException.class}) + public void applyOpt(InsuranceApplyOptDTO insuranceApplyOptDTO){ + if(Objects.isNull(insuranceApplyOptDTO) + ||Objects.isNull(insuranceApplyOptDTO.getApplyId()) + ||StringUtils.isBlank(insuranceApplyOptDTO.getOptIllustration())){ + throw new BusinessException(ResponseStatus.BAD_REQUEST); + } + LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); + if(loginUserInfo.getType().equals(Constants.ZERO)){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炰紒涓氱鐢ㄦ埛鏃犳硶杩涜璇ユ搷浣�"); + } + InsuranceApply insuranceApply = insuranceApplyMapper.selectById(insuranceApplyOptDTO.getApplyId()); + if(Objects.isNull(insuranceApply)){ + throw new BusinessException(ResponseStatus.DATA_EMPTY); + } + if(insuranceApply.getIsdeleted().equals(Constants.ONE)){ + throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"鏁版嵁宸插垹闄�,鏃犳硶杩涜璇ユ搷浣�"); + } + Constants.InsuranceApplyStatus insuranceApplyStatus = Constants.InsuranceApplyStatus.COMPANY_APPLY_RETURN; + if(insuranceApplyOptDTO.getOptType().equals(Constants.ONE)){ + if(insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.COMPANY_APPLY_RETURN.getKey())){ + throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"閫�鍥炵敵璇蜂腑锛岃鍕块噸澶嶆搷浣�"); + } + if(!(insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.UPLOAD.getKey()) + ||insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.WAIT_SIGNATURE.getKey()) + ||insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.SIGNATURE.getKey()))){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏁版嵁鐘舵�侀潪鍙敵璇烽��鍥�!"); + } + }else if(insuranceApplyOptDTO.getOptType().equals(Constants.TWO)){ + insuranceApplyStatus = Constants.InsuranceApplyStatus.CLOSE; + if(insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.CLOSE.getKey())){ + throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"宸插叧闂紝璇峰嬁閲嶅鎿嶄綔"); + } + if(!(insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.PLATFORM_AGREE.getKey()) + ||insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.PLATFORM_RETURN.getKey()))){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏁版嵁鐘舵�侀潪鍙敵璇烽��鍥�!"); + } + } + insuranceApply.setStatus(insuranceApplyStatus.getKey()); + insuranceApply.setCheckDate(new Date()); + insuranceApply.setCheckInfo(insuranceApplyOptDTO.getOptIllustration()); + insuranceApply.setCheckUserId(loginUserInfo.getId()); + insuranceApplyMapper.updateById(insuranceApply); + //瀛樺偍鏃ュ織鏁版嵁 + this.saveApplyLog(insuranceApply,insuranceApplyStatus,null); + } + + + } -- Gitblit v1.9.3