| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.doumee.service.business.third.SignService; |
| | | import com.github.xiaoymin.knife4j.core.util.CollectionUtils; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.jzq.common.bean.sign.NotifyDataReq; |
| | | import io.swagger.models.auth.In; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | |
| | | |
| | | @Autowired |
| | | private InsuranceApplyMapper insuranceApplyMapper; |
| | | @Autowired |
| | | private ApplyChangeMapper applyChangeMapper; |
| | | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | |
| | | |
| | | @Autowired |
| | | private ApplyLogMapper applyLogMapper; |
| | | @Autowired |
| | | private SignService signService; |
| | | @Autowired |
| | | private MultifileMapper multifileMapper; |
| | | |
| | |
| | | |
| | | } |
| | | @Override |
| | | public String getSignLink(Integer id) { |
| | | if(id == null ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | InsuranceApply model = insuranceApplyMapper.selectById(id); |
| | | if(model == null ||!Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | Constants.ApplyLogType applyLogType = null; |
| | | String info = ""; |
| | | //如果是驳回,只能可驳回已签章状态下的退回申请状态进行操作 |
| | | if(!Constants.equalsInteger(model.getStatus(),Constants.InsuranceApplyStatus.COMPANY_BACK_APPLY_WAIT_SIGNATURE.getKey())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,该申请状态已流转,当前不支持该操作~"); |
| | | } |
| | | Company company = user.getCompany(); |
| | | if(company== null || StringUtils.isBlank( company.getEmail()) || !Constants.equalsInteger(company.getSignStatus(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,企业尚未具备在线签章条件,请联系平台管理员确认~"); |
| | | } |
| | | |
| | | Multifile f = multifileMapper.selectOne(new QueryWrapper<Multifile>().lambda() |
| | | .eq(Multifile::getObjId,model.getId()) |
| | | .eq(Multifile::getObjType,Constants.MultiFile.BD_APPLY_PDF.getKey()) |
| | | .eq(Multifile::getIsdeleted,Constants.ZERO).last("limit 1")); |
| | | if(f == null || StringUtils.isBlank(f.getFileurl())){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,获取待签章文件失败,请联系平台管理员确认投保单是否正确!"); |
| | | } |
| | | String url = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()+systemDictDataBiz.queryByCode(Constants.OSS,Constants.APPLY_FILE).getCode()+f.getFileurl(); |
| | | String notifyUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.SIGN_DONE_NOTIFY_URL).getCode(); |
| | | notifyUrl = notifyUrl.replace("${type}","0").replace("${id}",model.getId().toString()); |
| | | String applyNo = signService.applySign(company.getName(),url,company.getName(),company.getCode(),company.getEmail(),null,company.getSignId(),notifyUrl); |
| | | if(StringUtils.isBlank(applyNo) ){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,获取在线签章地址失败,请稍后重试!"); |
| | | } |
| | | String link = signService.signLink(applyNo,company.getEmail(),company.getCode()); |
| | | if(StringUtils.isBlank(link) ){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,获取在线签章地址失败,请稍后重试!"); |
| | | } |
| | | InsuranceApply update= new InsuranceApply(); |
| | | update.setId(model.getId()); |
| | | update.setEditor(user.getId()); |
| | | update.setEditDate(new Date()); |
| | | update.setSignApplyNo(applyNo); |
| | | insuranceApplyMapper.updateById(update); |
| | | return link; |
| | | } |
| | | @Override |
| | | public void dealSignResult(NotifyDataReq data){ |
| | | if(data.getApplyNo() == null ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | InsuranceApply model = insuranceApplyMapper.selectOne(new QueryWrapper<InsuranceApply>().lambda().eq(InsuranceApply::getSignApplyNo,data.getApplyNo()).last("limit 1" )); |
| | | if(model != null ){ |
| | | //-----------------TUDO--------完善签约完成业务------ |
| | | |
| | | }else{ |
| | | ApplyChange applyChange = applyChangeMapper.selectOne(new QueryWrapper<ApplyChange>().lambda().eq(ApplyChange::getSignApplyNo,data.getApplyNo()).last("limit 1" )); |
| | | if(applyChange == null){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"系统未找到匹配合同号!"); |
| | | } |
| | | //-----------------TUDO-------完善签约完成------- |
| | | } |
| | | |
| | | |
| | | } |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | public Integer uploadToubaodan(InsuranceApply insuranceApply) { |
| | | if(insuranceApply.getId() == null |
| | |
| | | if(!CollectionUtils.isNotEmpty(duWorktypeList)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"数据异常:保险方案下未查询到工种信息"); |
| | | } |
| | | for (int i = 0; i < applyDetailList.size(); i++) { |
| | | ApplyDetail applyDetail = applyDetailList.get(i); |
| | | if(Objects.isNull(applyDetail) |
| | | ||Objects.isNull(applyDetail.getMemberId()) |
| | | ||Objects.isNull(applyDetail.getDuId()) |
| | | ||Objects.isNull(applyDetail.getWorktypeId()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"投保员工信息数据缺失"); |
| | | if(CollectionUtils.isNotEmpty(applyDetailList)){ |
| | | for (int i = 0; i < applyDetailList.size(); i++) { |
| | | ApplyDetail applyDetail = applyDetailList.get(i); |
| | | if(Objects.isNull(applyDetail) |
| | | ||Objects.isNull(applyDetail.getMemberId()) |
| | | ||Objects.isNull(applyDetail.getDuId()) |
| | | ||Objects.isNull(applyDetail.getWorktypeId()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"投保员工信息数据缺失"); |
| | | } |
| | | applyDetail.setCreateDate(new Date()); |
| | | applyDetail.setCreator(loginUserInfo.getId()); |
| | | applyDetail.setIsdeleted(Constants.ZERO); |
| | | applyDetail.setSortnum(i); |
| | | applyDetail.setApplyId(insuranceApply.getId()); |
| | | if(Objects.isNull(applyDetail.getMemberId())){ |
| | | throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"【"+applyDetail.getMemberName()+"】员工信息存在异常数据!"); |
| | | } |
| | | Member member = memberMapper.selectById(applyDetail.getMemberId()); |
| | | if(Objects.isNull(member)){ |
| | | throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"【"+applyDetail.getMemberName()+"】员工信息存在异常数据!"); |
| | | } |
| | | applyDetail.setIdcardNo(member.getIdcardNo()); |
| | | applyDetail.setSex(member.getSex()); |
| | | 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()+"】员工派遣单位未查询到!"); |
| | | } |
| | | if(duWorktypeList.stream().filter(d->d.getDuSolutionId().equals(applyDetail.getDuId())&&d.getWorkTypeId().equals(applyDetail.getWorktypeId())) |
| | | .collect(Collectors.toList()).size()<=Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"【"+applyDetail.getMemberName()+"】员工工种信息未查询到!"); |
| | | } |
| | | } |
| | | applyDetail.setCreateDate(new Date()); |
| | | applyDetail.setCreator(loginUserInfo.getId()); |
| | | applyDetail.setIsdeleted(Constants.ZERO); |
| | | applyDetail.setSortnum(i); |
| | | applyDetail.setApplyId(insuranceApply.getId()); |
| | | if(Objects.isNull(applyDetail.getMemberId())){ |
| | | throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"【"+applyDetail.getMemberName()+"】员工信息存在异常数据!"); |
| | | } |
| | | Member member = memberMapper.selectById(applyDetail.getMemberId()); |
| | | if(Objects.isNull(member)){ |
| | | throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"【"+applyDetail.getMemberName()+"】员工信息存在异常数据!"); |
| | | } |
| | | applyDetail.setIdcardNo(member.getIdcardNo()); |
| | | applyDetail.setSex(member.getSex()); |
| | | 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()+"】员工派遣单位未查询到!"); |
| | | } |
| | | if(duWorktypeList.stream().filter(d->d.getDuSolutionId().equals(applyDetail.getDuId())&&d.getWorkTypeId().equals(applyDetail.getWorktypeId())) |
| | | .collect(Collectors.toList()).size()<=Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"【"+applyDetail.getMemberName()+"】员工工种信息未查询到!"); |
| | | } |
| | | applyDetailMapper.insert(applyDetail); |
| | | applyDetailJoinMapper.insertBatchSomeColumn(applyDetailList); |
| | | } |
| | | |
| | | //存储日志数据 |
| | | this.saveApplyLog(insuranceApply,insuranceApplyStatus,null); |
| | | return insuranceApply.getId(); |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 更新保单实际金额 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public void updateApplyCurrentFee(){ |
| | | List<InsuranceApply> insuranceApplyList = insuranceApplyMapper.selectList(new QueryWrapper<InsuranceApply>().lambda() |
| | | .eq(InsuranceApply::getIsdeleted,Constants.ZERO) |
| | | .eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey()) |
| | | .ge(InsuranceApply::getStartTime,DateUtil.getDate(new Date(),"yyyy-MM-dd") + " 00:00:00") |
| | | .le(InsuranceApply::getEndTime,DateUtil.getDate(new Date(),"yyyy-MM-dd") + " 23:59:59") |
| | | ); |
| | | |
| | | if(CollectionUtils.isNotEmpty(insuranceApplyList)){ |
| | | for (InsuranceApply insuranceApply:insuranceApplyList) { |
| | | Solutions solutions = solutionsMapper.selectById(insuranceApply.getSolutionId()); |
| | | if(Objects.isNull(solutions)){ |
| | | continue; |
| | | } |
| | | BigDecimal sumAmount = BigDecimal.ZERO; |
| | | List<ApplyDetail> applyDetailList = applyDetailMapper.selectList(new QueryWrapper<ApplyDetail>().lambda().eq(ApplyDetail::getApplyId,insuranceApply.getId())); |
| | | if(CollectionUtils.isNotEmpty(applyDetailList)){ |
| | | for (ApplyDetail applyDetail: applyDetailList) { |
| | | applyDetail.setCurrentFee(Constants.countDetailFee(solutions,new Date(),applyDetail.getStartTime())); |
| | | applyDetailMapper.updateById(applyDetail); |
| | | sumAmount = sumAmount.add(applyDetail.getCurrentFee()); |
| | | } |
| | | } |
| | | insuranceApply.setCurrentFee(sumAmount); |
| | | insuranceApplyMapper.updateById(insuranceApply); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |