|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import cn.hutool.core.util.IdcardUtil; | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.api.R; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | 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.biz.system.SystemDictDataBiz; | 
|---|
|  |  |  | import com.doumee.core.annotation.excel.ExcelExporter; | 
|---|
|  |  |  | import com.doumee.core.constants.ResponseStatus; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.doumee.core.utils.DateUtil; | 
|---|
|  |  |  | import com.doumee.core.utils.Utils; | 
|---|
|  |  |  | import com.doumee.dao.business.*; | 
|---|
|  |  |  | import com.doumee.dao.business.dto.*; | 
|---|
|  |  |  | import com.doumee.dao.business.dto.ApplyChangeCyclePriceDTO; | 
|---|
|  |  |  | import com.doumee.dao.business.dto.ApplyChangeOptDTO; | 
|---|
|  |  |  | import com.doumee.dao.business.dto.SaveUnionChangeDTO; | 
|---|
|  |  |  | import com.doumee.dao.business.dto.SmsCheckDTO; | 
|---|
|  |  |  | import com.doumee.dao.business.join.*; | 
|---|
|  |  |  | import com.doumee.dao.business.model.*; | 
|---|
|  |  |  | import com.doumee.dao.business.vo.ChangeDealTypeVO; | 
|---|
|  |  |  | import com.doumee.dao.business.vo.CountCyclePriceVO; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemUser; | 
|---|
|  |  |  | import com.doumee.service.business.ApplyChangeService; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | 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.InsuranceApplyService; | 
|---|
|  |  |  | import com.doumee.service.business.SmsEmailService; | 
|---|
|  |  |  | import com.doumee.service.business.third.SignService; | 
|---|
|  |  |  | import com.github.xiaoymin.knife4j.core.util.CollectionUtils; | 
|---|
|  |  |  | import com.github.yulichang.wrapper.MPJLambdaWrapper; | 
|---|
|  |  |  | import org.apache.commons.lang3.StringUtils; | 
|---|
|  |  |  | import org.apache.shiro.SecurityUtils; | 
|---|
|  |  |  | import org.checkerframework.checker.units.qual.A; | 
|---|
|  |  |  | import org.slf4j.Logger; | 
|---|
|  |  |  | import org.slf4j.LoggerFactory; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Value; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.math.BigDecimal; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.math.RoundingMode; | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Objects; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | pidanFile.setObjType(Constants.MultiFile.CA_PD_PDF.getKey()); | 
|---|
|  |  |  | pidanFile.setType(Constants.TWO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | multifileMapper.insertBatchSomeColumn(pidanFileList); | 
|---|
|  |  |  | multifileMapper.insert(pidanFileList); | 
|---|
|  |  |  | update.setApplyId(model.getApplyId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | pidanFile.setObjType(Constants.MultiFile.CA_PD_PDF.getKey()); | 
|---|
|  |  |  | pidanFile.setType(Constants.TWO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | multifileMapper.insertBatchSomeColumn(param.getPidanFileList()); | 
|---|
|  |  |  | multifileMapper.insert(param.getPidanFileList()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //        param.getPidanFile().setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | //        param.getPidanFile().setObjId(update.getId()); | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq(ApplyDetail::getMemberId, detail.getMemberId()) | 
|---|
|  |  |  | .orderByDesc(ApplyDetail::getCreateDate) | 
|---|
|  |  |  | .last("limit 1")); | 
|---|
|  |  |  | if (oldModel == null || oldModel.getStartTime() == null || oldModel.getStartTime().getTime() > update.getApplyStartTime().getTime()) { | 
|---|
|  |  |  | //            if (oldModel == null || oldModel.getStartTime() == null || oldModel.getStartTime().getTime() > update.getApplyStartTime().getTime()) { | 
|---|
|  |  |  | //                throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对不起,用户【" + detail.getMemberName() + "】原保单信息有误,当前申请不支持减保处理!"); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //            if(!(oldModel.getStartTime().getTime()<=update.getDelValidTime().getTime()&& oldModel.getEndTime().getTime()>=update.getDelValidTime().getTime())){ | 
|---|
|  |  |  | //                throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对不起,用户【" + detail.getMemberName() + "】减保日期未在保单记录日期中!"); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | if (oldModel == null || oldModel.getEndTime() == null || oldModel.getEndTime().getTime() < update.getDelValidTime().getTime()) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对不起,用户【" + detail.getMemberName() + "】原保单信息有误,当前申请不支持减保处理!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!(oldModel.getStartTime().getTime()<=update.getDelValidTime().getTime()&& oldModel.getEndTime().getTime()>=update.getDelValidTime().getTime())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对不起,用户【" + detail.getMemberName() + "】减保日期未在保单记录日期中!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | BigDecimal sumFee = Objects.isNull(insuranceApply.getServerCost())? | 
|---|
|  |  |  | solutions.getPrice(): | 
|---|
|  |  |  | 
|---|
|  |  |  | sumFee | 
|---|
|  |  |  | ,insuranceApply.getStartTime(),insuranceApply.getFinalEndTime(),oldModel.getStartTime(),delValidTime | 
|---|
|  |  |  | ) ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | delValidTime  = oldModel.getStartTime(); | 
|---|
|  |  |  | updateFee = BigDecimal.ZERO; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (oldModel.getStartTime().getTime() < System.currentTimeMillis()) { | 
|---|
|  |  |  | //// 2024年5月8日17:37:23 修改 计算产生费用 | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //查询人员信息是否存在相同的方案下是否存在 冲突数据 | 
|---|
|  |  |  | InsuranceApplyServiceImpl.checkStaticMemberSolution(solutions.getBaseId(), | 
|---|
|  |  |  | member.getIdcardNo(),member.getName(),detail.getStartTime(),detail.getEndTime(), | 
|---|
|  |  |  | member.getId(),member.getIdcardNo(),member.getName(),detail.getStartTime(),detail.getEndTime(), | 
|---|
|  |  |  | applyDetailJoinMapper); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查询加保人员是否存在 冲突的 保单明细数据 | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (memberInsuranceList != null && memberInsuranceList.size() > 0) { | 
|---|
|  |  |  | memberInsuranceJoinMapper.insertBatchSomeColumn(memberInsuranceList); | 
|---|
|  |  |  | memberInsuranceJoinMapper.insert(memberInsuranceList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (totalFee.compareTo(new BigDecimal(0)) != 0) { | 
|---|
|  |  |  | 
|---|
|  |  |  | Constants.ApplyLogType applyLogType = Constants.ApplyLogType.CA_COMPANY_COMMIT; | 
|---|
|  |  |  | ApplyLog log = new ApplyLog(applyChange,applyLogType.getName(),"",applyChange.getId(),applyLogType.getKey(), null, null); | 
|---|
|  |  |  | applyLogMapper.insert(log); | 
|---|
|  |  |  | //        if(1==1){ | 
|---|
|  |  |  | //            throw new BusinessException(ResponseStatus.DATA_EMPTY ); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | return applyChange.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static Logger logger = LoggerFactory.getLogger(ApplyChangeServiceImpl.class); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public BigDecimal dealApplyChangeData(ApplyChange applyChange,InsuranceApply insuranceApply | 
|---|
|  |  |  | ,CompanySolution companySolution,Solutions solutions,LoginUserInfo loginUserInfo,BigDecimal fee){ | 
|---|
|  |  |  | Long start = System.currentTimeMillis(); | 
|---|
|  |  |  | logger.error("处理加减保保单数据开始时间:=========================>"+start); | 
|---|
|  |  |  | if(Constants.equalsInteger(applyChange.getType(),Constants.ZERO)){ | 
|---|
|  |  |  | if(Objects.nonNull(solutions.getDelOnlyReplace())&& solutions.getDelOnlyReplace().equals(Constants.ONE)){ | 
|---|
|  |  |  | if(applyChange.getDelDetailList().size() > applyChange.getAddDetailList().size()){ | 
|---|
|  |  |  | 
|---|
|  |  |  | List<ApplyChagneDetail> delDetailList = applyChange.getDelDetailList(); | 
|---|
|  |  |  | //加保数据 | 
|---|
|  |  |  | List<ApplyChagneDetail> addDetailList = applyChange.getAddDetailList(); | 
|---|
|  |  |  | //换厂业务 | 
|---|
|  |  |  | List<ApplyChagneDetail> changeDetailList = applyChange.getChangeDetailList(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(CollectionUtils.isEmpty(delDetailList) | 
|---|
|  |  |  | && CollectionUtils.isEmpty(addDetailList) | 
|---|
|  |  |  | && CollectionUtils.isEmpty(changeDetailList)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,未添加人员数据无法进行提交"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (CollectionUtils.isNotEmpty(addDetailList)) { | 
|---|
|  |  |  | if(Objects.isNull(solutions.getCanAdd()) || solutions.getCanAdd().equals(Constants.ZERO)){ | 
|---|
|  |  |  | 
|---|
|  |  |  | fee = fee.add(delDetailList.stream().map(ApplyChagneDetail::getFee).reduce(BigDecimal.ZERO,BigDecimal::add)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //换厂业务 | 
|---|
|  |  |  | List<ApplyChagneDetail> changeDetailList = applyChange.getChangeDetailList(); | 
|---|
|  |  |  | if (CollectionUtils.isNotEmpty(changeDetailList)) { | 
|---|
|  |  |  | if(Objects.isNull(solutions.getCanChangeUnit()) || solutions.getCanChangeUnit().equals(Constants.ZERO)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "该保险方案无法进行换厂操作"); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | this.changeDetail(applyChange,changeDetailList,duSolutionList,loginUserInfo,solutions,worktypeIdList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Long end = System.currentTimeMillis(); | 
|---|
|  |  |  | logger.error("处理加减保保单数据结束时间:=========================>"+end +";单条耗时:====》"+(end-start)); | 
|---|
|  |  |  | return fee; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "减保人员【" + applyChagneDetail.getMemberName() + "】已出险无法进行减保"); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | //2024-10-29 15:17:54 查询人员是否已减保 已减保后无法再次减保 | 
|---|
|  |  |  | if(applyChangeDetailJoinMapper.selectJoinCount(new MPJLambdaWrapper<ApplyChagneDetail>() | 
|---|
|  |  |  | //            if(applyChangeDetailJoinMapper.selectJoinCount(new MPJLambdaWrapper<ApplyChagneDetail>() | 
|---|
|  |  |  | //                    .leftJoin(ApplyChange.class,ApplyChange::getId,ApplyChagneDetail::getApplyChangeId) | 
|---|
|  |  |  | //                    .eq(ApplyChagneDetail::getType,Constants.ONE) | 
|---|
|  |  |  | //                    .eq(ApplyChange::getApplyId,applyChange.getApplyId()) | 
|---|
|  |  |  | //                            .eq(ApplyChagneDetail::getMemberId,applyChagneDetail.getMemberId()) | 
|---|
|  |  |  | //                    .notIn(ApplyChange::getStatus,Constants.ApplyChangeStatus.CLOSE.getKey() | 
|---|
|  |  |  | //                            ,Constants.ApplyChangeStatus.PALTFORM_CHECK_PASS_NO.getKey() | 
|---|
|  |  |  | //                    ) | 
|---|
|  |  |  | //            )>Constants.ZERO){ | 
|---|
|  |  |  | //                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "减保人员【" + applyChagneDetail.getMemberName() + "】已减保无法再次进行减保"); | 
|---|
|  |  |  | //            }; | 
|---|
|  |  |  | //2025-1-16 09:11:14 根据查询当前人员最后一次的加减保记录 如果最后一条记录是加保进入 则可以减保 如果最后一条记录是减保记录 则不可以减保 如果为空 这可以进行操作 | 
|---|
|  |  |  | ApplyChagneDetail lastApplyChagneDetail = applyChangeDetailJoinMapper.selectJoinOne(ApplyChagneDetail.class, | 
|---|
|  |  |  | new MPJLambdaWrapper<ApplyChagneDetail>() | 
|---|
|  |  |  | .leftJoin(ApplyChange.class,ApplyChange::getId,ApplyChagneDetail::getApplyChangeId) | 
|---|
|  |  |  | .eq(ApplyChagneDetail::getType,Constants.ONE) | 
|---|
|  |  |  | .ne(ApplyChagneDetail::getType,Constants.TWO) | 
|---|
|  |  |  | .eq(ApplyChange::getApplyId,applyChange.getApplyId()) | 
|---|
|  |  |  | .eq(ApplyChagneDetail::getMemberId,applyChagneDetail.getMemberId()) | 
|---|
|  |  |  | .eq(ApplyChagneDetail::getMemberId,applyChagneDetail.getMemberId()) | 
|---|
|  |  |  | .notIn(ApplyChange::getStatus,Constants.ApplyChangeStatus.CLOSE.getKey() | 
|---|
|  |  |  | ,Constants.ApplyChangeStatus.PALTFORM_CHECK_PASS_NO.getKey() | 
|---|
|  |  |  | ,Constants.ApplyChangeStatus.PALTFORM_CHECK_PASS_NO.getKey() | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | )>Constants.ZERO){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "减保人员【" + applyChagneDetail.getMemberName() + "】已减保无法再次进行减保"); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | .orderByDesc(ApplyChagneDetail::getId) | 
|---|
|  |  |  | .last(" limit 1 ") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(Objects.nonNull(lastApplyChagneDetail)){ | 
|---|
|  |  |  | if(Constants.equalsInteger(lastApplyChagneDetail.getType(),Constants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "减保人员【" + applyChagneDetail.getMemberName() + "】已减保无法再次进行减保"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //查询减保人员是否存在 冲突的 保单明细数据 | 
|---|
|  |  |  | if(applyDetailJoinMapper.selectCount(new QueryWrapper<ApplyDetail>() | 
|---|
|  |  |  | .lambda() | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //查询员工是在主单下 是否存在生效中的数据 | 
|---|
|  |  |  | List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectList(new QueryWrapper<ApplyDetail>().lambda() | 
|---|
|  |  |  | .eq(ApplyDetail::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(ApplyDetail::getApplyId, applyChange.getApplyId()) | 
|---|
|  |  |  | .eq(ApplyDetail::getMemberId, applyChagneDetail.getMemberId()) | 
|---|
|  |  |  | //                    .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(applyChange.getDelValidTime(),1)) | 
|---|
|  |  |  | 
|---|
|  |  |  | if(!Constants.equalsInteger(applyDetail.getChangeStatus(),Constants.ZERO)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"减保人员【" + applyChagneDetail.getMemberName() + "】保单信息异常,数据已被减保无法再次减保"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | applyChagneDetail.setPrice(applyDetail.getPrice()); | 
|---|
|  |  |  | applyChagneDetail.setCreateDate(new Date()); | 
|---|
|  |  |  | applyChagneDetail.setCreator(loginUserInfo.getId()); | 
|---|
|  |  |  | applyChagneDetail.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | 
|---|
|  |  |  | applyChagneDetail.setReduceMoney(solutions.getPrice().multiply(new BigDecimal(-1))); | 
|---|
|  |  |  | applyChagneDetail.setFee(BigDecimal.ZERO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | applyChagneDetail.setId(null); | 
|---|
|  |  |  | applyChagneDetailJoinMapper.insert(applyChagneDetail); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | ) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "加保人员【" + applyChagneDetail.getMemberName() + "】必填项缺失"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //查询人员信息是否存在相同的方案下是否存在 冲突数据 | 
|---|
|  |  |  | InsuranceApplyServiceImpl.checkStaticMemberSolution(solutions.getBaseId(), | 
|---|
|  |  |  | applyChagneDetail.getIdcardNo(),applyChagneDetail.getMemberName(),applyChange.getApplyStartTime(),insuranceApply.getEndTime(), | 
|---|
|  |  |  | applyDetailJoinMapper); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查询加保人员是否存在 冲突的 保单明细数据 | 
|---|
|  |  |  | if(applyDetailJoinMapper.selectCount(new QueryWrapper<ApplyDetail>() | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq(ApplyDetail::getApplyId,applyChange.getApplyId()) | 
|---|
|  |  |  | .eq(ApplyDetail::getIdcardNo,applyChagneDetail.getIdcardNo()) | 
|---|
|  |  |  | .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(applyChange.getApplyStartTime(),1)) | 
|---|
|  |  |  | .ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(insuranceApply.getEndTime(),2)) | 
|---|
|  |  |  | .ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(insuranceApply.getEndTime(),2)) | 
|---|
|  |  |  | )>Constants.ZERO){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "当前保单下,加保人员【" + applyChagneDetail.getMemberName() + "】存在日期冲突的数据"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | member.setApplyId(insuranceApply.getId()); | 
|---|
|  |  |  | member.setDuId(applyChagneDetail.getDuId()); | 
|---|
|  |  |  | member.setWorktypeId(applyChagneDetail.getWorktypeId()); | 
|---|
|  |  |  | //                    member.setStartTime(applyChagneDetail.getStartTime()); | 
|---|
|  |  |  | //                    member.setEndTime(applyChagneDetail.getEndTime()); | 
|---|
|  |  |  | memberMapper.insert(member); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | member.setApplyId(insuranceApply.getId()); | 
|---|
|  |  |  | member.setDuId(applyChagneDetail.getDuId()); | 
|---|
|  |  |  | member.setWorktypeId(applyChagneDetail.getWorktypeId()); | 
|---|
|  |  |  | //                    member.setStartTime(applyChagneDetail.getStartTime()); | 
|---|
|  |  |  | //                    member.setEndTime(applyChagneDetail.getEndTime()); | 
|---|
|  |  |  | memberMapper.updateById(member); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | applyChagneDetail.setMemberId(member.getId()); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | member = memberMapper.selectById(applyChagneDetail.getMemberId()); | 
|---|
|  |  |  | if(Objects.isNull(member)){ | 
|---|
|  |  |  | 
|---|
|  |  |  | member.setEndTime(applyChagneDetail.getEndTime()); | 
|---|
|  |  |  | memberMapper.updateById(member); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查询人员信息是否存在相同的方案下是否存在 冲突数据 | 
|---|
|  |  |  | InsuranceApplyServiceImpl.checkStaticMemberSolution(solutions.getBaseId(), | 
|---|
|  |  |  | applyChagneDetail.getMemberId(),applyChagneDetail.getIdcardNo(),applyChagneDetail.getMemberName(),applyChange.getApplyStartTime(),insuranceApply.getEndTime(), | 
|---|
|  |  |  | applyDetailJoinMapper); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //根据员工身份证进行判断年龄 | 
|---|
|  |  |  | long age = Constants.getAgeByIdCard(member.getIdcardNo()); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //查询员工是在主单下 是否存在生效中的数据 | 
|---|
|  |  |  | List<ApplyDetail>  applyDetailList = applyDetailJoinMapper.selectList(new QueryWrapper<ApplyDetail>().lambda() | 
|---|
|  |  |  | .eq(ApplyDetail::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(ApplyDetail::getApplyId, applyChange.getApplyId()) | 
|---|
|  |  |  | .eq(ApplyDetail::getMemberId, applyChagneDetail.getMemberId()) | 
|---|
|  |  |  | .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(applyChange.getApplyStartTime(),1)) | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询方案信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String fileUrl = null; | 
|---|
|  |  |  | //        if(Constants.equalsObject(model.getType(), Constants.ONE)){ | 
|---|
|  |  |  | //              fileUrl = ExcelExporter.build(ApplyChange.class).exportChangeUnitExcelToPdf(model,"换厂申请表","投保企业"); | 
|---|
|  |  |  | //        }else{ | 
|---|
|  |  |  | //            fileUrl = ExcelExporter.build(ApplyChange.class).exportJiajianBaoExcelToPdf(model,"加减保申请表","投保企业"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | if(Constants.equalsObject(model.getType(), Constants.ONE)){ | 
|---|
|  |  |  | fileUrl = ExcelExporter.build(ApplyChange.class).exportChangeUnitExcelToPdf(model,"换厂申请表","投保企业"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | fileUrl = ExcelExporter.build(ApplyChange.class).exportJiajianBaoExcelToPdf(model,"加减保申请表","投保企业"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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.applySignLocalFile(company.getName(),company.getName(),fileUrl,company.getCode(),company.getEmail(),"投保企业签章",company.getSignId(),notifyUrl); | 
|---|
|  |  |  | notifyUrl = notifyUrl.replace("${type}","0").replace("${id}",model.getId().toString()); | 
|---|
|  |  |  | String applyNo = signService.applySignLocalFileByParam(company.getName(),company.getName(),fileUrl,company.getCode(),company.getEmail(),"投保企业签章",company.getSignId(),notifyUrl,new Float(0.7)); | 
|---|
|  |  |  | //临时使用 | 
|---|
|  |  |  | fileUrl = | 
|---|
|  |  |  | "https://yybred.oss-cn-hangzhou.aliyuncs.com/apply/20241120/1c80f0d7-ab35-4355-b9fe-944464643115.pdf"; | 
|---|
|  |  |  | String applyNo = signService.applySign(companyName,fileUrl,companyName,creditCode,email,"人员名单签章",null,notifyUrl); | 
|---|
|  |  |  | //        fileUrl = | 
|---|
|  |  |  | //                "https://yybred.oss-cn-hangzhou.aliyuncs.com/apply/20241120/1c80f0d7-ab35-4355-b9fe-944464643115.pdf"; | 
|---|
|  |  |  | //        String applyNo = signService.applySign(companyName,fileUrl,companyName,creditCode,email,"人员名单签章",null,notifyUrl); | 
|---|
|  |  |  | if(StringUtils.isBlank(applyNo) ){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,获取在线签章地址失败,请稍后重试!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | if(!Constants.equalsInteger(Constants.ZERO,model.getStatus())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,该申请状态已流转,当前不支持签章操作!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //            if(Constants.equalsObject(model.getType(), Constants.ONE)){ | 
|---|
|  |  |  | //                fileUrl = ExcelExporter.build(ApplyChange.class).exportChangeUnitExcelToPdf(model,"换厂申请表","被保险人"); | 
|---|
|  |  |  | //            }else{ | 
|---|
|  |  |  | //                fileUrl = ExcelExporter.build(ApplyChange.class).exportJiajianBaoExcelToPdf(model,"加减保申请表","被保险人"); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | if(Constants.equalsObject(model.getType(), Constants.ONE)){ | 
|---|
|  |  |  | fileUrl = ExcelExporter.build(ApplyChange.class).exportChangeUnitExcelToPdf(model,"换厂申请表","被保险人"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | fileUrl = ExcelExporter.build(ApplyChange.class).exportJiajianBaoExcelToPdf(model,"加减保申请表","被保险人"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String notifyUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.SIGN_DONE_NOTIFY_URL).getCode(); | 
|---|
|  |  |  | notifyUrl = notifyUrl.replace("${type}","0").replace("${id}",model.getId().toString()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //临时使用 | 
|---|
|  |  |  | fileUrl =  "https://yybred.oss-cn-hangzhou.aliyuncs.com/apply/20241120/1c80f0d7-ab35-4355-b9fe-944464643115.pdf"; | 
|---|
|  |  |  | String applyNo = signService.applySign(company.getName(),fileUrl,company.getName(),company.getCode(),company.getEmail(),"人员名单签章",company.getSignId(),notifyUrl); | 
|---|
|  |  |  | //            fileUrl =  "https://yybred.oss-cn-hangzhou.aliyuncs.com/apply/20241230/a0d128f2-ba6c-4ad4-b86b-b2610a513d41.pdf"; | 
|---|
|  |  |  | //            String applyNo = signService.applySignDoByParam(company.getName(),fileUrl,company.getName(),company.getCode(),company.getEmail(),"人员名单签章",company.getSignId(),notifyUrl,new Float(0.7)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //            String applyNo = signService.applySignLocalFile(company.getName(),company.getName(),fileUrl,company.getCode(),company.getEmail(),"人员名单签章",company.getSignId(),notifyUrl); | 
|---|
|  |  |  | String applyNo = signService.applySignLocalFileByParam(company.getName(),company.getName(),fileUrl,company.getCode(),company.getEmail(),"人员名单签章",company.getSignId(),notifyUrl,new Float(0.7)); | 
|---|
|  |  |  | if(StringUtils.isBlank(applyNo) ){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,获取在线签章地址失败,请稍后重试!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到保单数据"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | SaveUnionChangeDTO saveUnionChangeDTO = new SaveUnionChangeDTO(); | 
|---|
|  |  |  | saveUnionChangeDTO.setApplyDate(update.getApplyStartTime()); | 
|---|
|  |  |  | saveUnionChangeDTO.setApplyDate(model.getValidTime()); | 
|---|
|  |  |  | List<Integer> applyIds = new ArrayList<>(); | 
|---|
|  |  |  | applyIds.add(model.getId()); | 
|---|
|  |  |  | saveUnionChangeDTO.setApplyIds(applyIds); | 
|---|
|  |  |  | saveUnionChangeDTO.setApplyChange(model); | 
|---|
|  |  |  | saveUnionChangeDTO.setUnionApplyId(insuranceApply.getUnionApplyId()); | 
|---|
|  |  |  | saveUnionChangeDTO.setBusinessType(model.getType()); | 
|---|
|  |  |  | if(Constants.equalsInteger(model.getType(),Constants.ONE)){ | 
|---|
|  |  |  | saveUnionChangeDTO.setApplyDate(model.getApplyStartTime()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(Constants.equalsInteger(user.getType(),Constants.TWO)){ | 
|---|
|  |  |  | saveUnionChangeDTO.setShopId(user.getCompanyId()); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | CompanySolution companySolution = companySolutionMapper.selectOne(new QueryWrapper<CompanySolution>().lambda().eq(CompanySolution::getSolutionId,solutions.getId()).eq(CompanySolution::getCompanyId,insuranceApply.getCompanyId()).last(" limit 1 ")); | 
|---|
|  |  |  | CompanySolution companySolution = companySolutionMapper.selectOne(new QueryWrapper<CompanySolution>() | 
|---|
|  |  |  | .lambda().eq(CompanySolution::getSolutionBaseId,solutions.getBaseId()) | 
|---|
|  |  |  | .eq(CompanySolution::getCompanyId,insuranceApply.getCompanyId()).last(" limit 1 ")); | 
|---|
|  |  |  | if(Objects.isNull(companySolution)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到企业方案信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | saveUnionChangeDTO.setShopId(companySolution.getShopId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | unionChangeService.merge(saveUnionChangeDTO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return  1; | 
|---|