| | |
| | | .set(ApplyDetail::getEditor, update.getEditor()) |
| | | .set(ApplyDetail::getEditDate, update.getEditDate()) |
| | | .eq(ApplyDetail::getId, oldModel.getId()); |
| | | BigDecimal reduceMoney = BigDecimal.ZERO; |
| | | |
| | | if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE) |
| | | && Constants.equalsInteger(solutions.getTimeUnit(),solutions.getInsureCycleUnit())){ |
| | |
| | | updateWrapper.lambda().set(ApplyDetail::getFee,updateFee) |
| | | .set(ApplyDetail::getChangeStatus,Constants.TWO); |
| | | }else{ |
| | | reduceMoney = solutions.getPrice().multiply(new BigDecimal(-1)); |
| | | //标记数据已被替换 |
| | | updateWrapper.lambda().set(ApplyDetail::getReduceMoney,solutions.getPrice().multiply(new BigDecimal(-1))) |
| | | updateWrapper.lambda().set(ApplyDetail::getReduceMoney,reduceMoney) |
| | | .set(ApplyDetail::getChangeStatus,Constants.ONE); |
| | | } |
| | | detail.setApplyDetailId(oldModel.getId()); |
| | |
| | | |
| | | |
| | | applyDetailJoinMapper.update(null, updateWrapper); |
| | | totalFee = totalFee.add(updateFee).subtract(oldModel.getFee()); |
| | | totalFee = totalFee.add(updateFee).subtract(oldModel.getFee()).add(reduceMoney); |
| | | currentFee = currentFee.add(updateCurrentFee); |
| | | |
| | | //修改 员工投保明细记录 历史数据 |
| | |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "未查询到员工数据"); |
| | | } |
| | | //查询人员信息是否存在相同的方案下是否存在 冲突数据 |
| | | InsuranceApplyServiceImpl.checkStaticMemberSolution(solutions.getId(), |
| | | InsuranceApplyServiceImpl.checkStaticMemberSolution(solutions.getBaseId(), |
| | | member.getIdcardNo(),member.getName(),detail.getStartTime(),detail.getEndTime(), |
| | | applyDetailJoinMapper); |
| | | |
| | |
| | | .lambda() |
| | | .eq(ApplyDetail::getApplyId,update.getApplyId()) |
| | | .eq(ApplyDetail::getIdcardNo,detail.getIdcardNo()) |
| | | // .apply(" ( " + |
| | | // " '"+DateUtil.getLongDateTime(DateUtil.getMontageDate(update.getApplyStartTime(),1))+"' <= t.start_time AND t.start_time < '"+DateUtil.getLongDateTime(DateUtil.getMontageDate(detail.getEndTime(),2))+"' " + |
| | | // " or " + |
| | | // " ( '"+DateUtil.getLongDateTime(DateUtil.getMontageDate(update.getApplyStartTime(),1))+"' < t.end_time AND t.end_time < '"+DateUtil.getLongDateTime(DateUtil.getMontageDate(detail.getEndTime(),2))+"' ) " + |
| | | // " or " + |
| | | // " ( '"+DateUtil.getLongDateTime(DateUtil.getMontageDate(update.getApplyStartTime(),1))+"' > t.start_time AND '"+DateUtil.getLongDateTime(DateUtil.getMontageDate(detail.getEndTime(),2))+"' < t.end_time )" + |
| | | // " ) " ) |
| | | .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(update.getApplyStartTime(),1)) |
| | | .ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(detail.getEndTime(),2)) |
| | | )>Constants.ZERO){ |
| | |
| | | add.setEndTime(DateUtil.getMontageDate(detail.getEndTime(), 2)); |
| | | add.setFee(Constants.addFee(solutions,solutions.getPrice(),insuranceApply.getStartTime(),insuranceApply.getFinalEndTime(),update.getApplyStartTime(),insuranceApply.getEndTime())); |
| | | add.setChangeStatus(Constants.ZERO); |
| | | |
| | | if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE) |
| | | && Constants.equalsInteger(solutions.getTimeUnit(),solutions.getInsureCycleUnit())){ |
| | | && Constants.equalsInteger(solutions.getTimeUnit(),solutions.getInsureCycleUnit()) && i < reduceList.size()){ |
| | | add.setReduceId(reduceList.get(i).getId()); |
| | | } |
| | | if(new Date().compareTo(DateUtil.getMontageDate(detail.getStartTime(), 2))>=0){ |
| | |
| | | add.setCurrentFee(BigDecimal.ZERO); |
| | | } |
| | | applyDetailJoinMapper.insert(add); |
| | | //如果不是替换业务的加保数据 则添加实际产生费用 |
| | | detail.setFee(Objects.isNull(add.getReduceId())?add.getFee():BigDecimal.ZERO); |
| | | totalFee = totalFee.add(add.getFee()); |
| | | currentFee = currentFee.add(add.getCurrentFee()); |
| | | |
| | | if(Objects.isNull(add.getReduceId())){ |
| | | currentFee = currentFee.add(add.getCurrentFee()); |
| | | } |
| | | MemberInsurance memberInsurance = new MemberInsurance(detail, update, update.getEditor(), add.getId(),solutions.getId()); |
| | | memberInsurance.setStartTime(add.getStartTime()); |
| | | memberInsurance.setEndTime(add.getEndTime()); |
| | |
| | | member.setEndTime(detail.getEndTime()); |
| | | memberMapper.updateById(member); |
| | | } |
| | | |
| | | |
| | | |
| | | /*for (ApplyChagneDetail detail : detailList) { |
| | | Member member = memberMapper.selectById(detail.getMemberId()); |
| | | if(Objects.isNull(member)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到员工数据"); |
| | | } |
| | | if (Constants.equalsInteger(detail.getType(), Constants.ZERO)) { |
| | | //查询加保人员是否存在 冲突的 保单明细数据 |
| | | if(applyDetailJoinMapper.selectCount(new QueryWrapper<ApplyDetail>() |
| | | .lambda() |
| | | .eq(ApplyDetail::getApplyId,update.getApplyId()) |
| | | .eq(ApplyDetail::getIdcardNo,detail.getIdcardNo()) |
| | | .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(update.getApplyStartTime(),1)) |
| | | .ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(detail.getEndTime(),2)) |
| | | )>Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "当前保单下,加保人员【" + detail.getMemberName() + "】存在日期冲突的数据"); |
| | | } |
| | | //加保 |
| | | ApplyDetail add = new ApplyDetail(); |
| | | add.setApplyId(update.getApplyId()); |
| | | add.setValidCode(update.getValidCode()); |
| | | add.setFee(detail.getFee()); |
| | | add.setIsdeleted(Constants.ZERO); |
| | | add.setCreator(update.getEditor()); |
| | | add.setCreateDate(update.getEditDate()); |
| | | add.setMemberId(detail.getMemberId()); |
| | | add.setMemberName(detail.getMemberName()); |
| | | add.setWorktypeId(detail.getWorktypeId()); |
| | | add.setIsdeleted(Constants.ZERO); |
| | | add.setIdcardNo(detail.getIdcardNo()); |
| | | add.setSex(Constants.getSexByIdCard(detail.getIdcardNo())); |
| | | add.setMemberName(detail.getMemberName()); |
| | | add.setRemark(detail.getRemark()); |
| | | add.setDuId(detail.getDuId()); |
| | | add.setStartTime(DateUtil.getMontageDate(update.getApplyStartTime(), 1)); |
| | | add.setEndTime(DateUtil.getMontageDate(detail.getEndTime(), 2)); |
| | | add.setFee(Constants.addFee(solutions,solutions.getPrice(),insuranceApply.getStartTime(),insuranceApply.getFinalEndTime(),update.getApplyStartTime(),insuranceApply.getEndTime())); |
| | | |
| | | if(new Date().compareTo(DateUtil.getMontageDate(detail.getStartTime(), 2))>=0){ |
| | | //2024年5月8日17:37:23 修改 计算产生费用 |
| | | add.setCurrentFee( |
| | | Constants.produceFee(solutions,add.getFee(),add.getStartTime(),add.getEndTime(),add.getStartTime()) |
| | | ); |
| | | }else{ |
| | | add.setCurrentFee(BigDecimal.ZERO); |
| | | } |
| | | applyDetailJoinMapper.insert(add); |
| | | totalFee = totalFee.add(add.getFee()); |
| | | currentFee = currentFee.add(add.getCurrentFee()); |
| | | |
| | | MemberInsurance memberInsurance = new MemberInsurance(detail, update, update.getEditor(), add.getId(),solutions.getId()); |
| | | memberInsurance.setStartTime(add.getStartTime()); |
| | | memberInsurance.setEndTime(add.getEndTime()); |
| | | memberInsurance.setRelationType(Constants.ONE); |
| | | memberInsuranceList.add(memberInsurance); |
| | | |
| | | applyChangeDetailJoinMapper.update(null,new UpdateWrapper<ApplyChagneDetail>().lambda() |
| | | .set(ApplyChagneDetail::getFee,add.getFee()) |
| | | .set(ApplyChagneDetail::getStartTime,DateUtil.getMontageDate(update.getApplyStartTime(), 1)) |
| | | .eq(ApplyChagneDetail::getId,detail.getId()) |
| | | ); |
| | | |
| | | |
| | | } else { |
| | | //减保操作 |
| | | //查询员工是在主单下 是否存在生效中的数据 |
| | | ApplyDetail oldModel = applyDetailJoinMapper.selectOne(new QueryWrapper<ApplyDetail>().lambda() |
| | | .eq(ApplyDetail::getApplyId, update.getApplyId()) |
| | | .eq(ApplyDetail::getMemberId, detail.getMemberId()) |
| | | .orderByDesc(ApplyDetail::getCreateDate) |
| | | .last("limit 1")); |
| | | 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() + "】减保日期未在保单记录日期中!"); |
| | | } |
| | | |
| | | Date delValidTime = oldModel.getStartTime().compareTo(update.getDelValidTime())!=0? |
| | | DateUtil.getMontageDate(update.getDelValidTime(), 3): |
| | | DateUtil.getMontageDate(update.getDelValidTime(), 2); |
| | | |
| | | BigDecimal sumFee = Objects.isNull(insuranceApply.getServerCost())? |
| | | solutions.getPrice(): |
| | | solutions.getPrice().add(insuranceApply.getServerCost()); |
| | | // 减保后 总费用 |
| | | BigDecimal updateFee = Constants.reduceFee( |
| | | solutions, |
| | | sumFee |
| | | ,insuranceApply.getStartTime(),insuranceApply.getFinalEndTime(),oldModel.getStartTime(),delValidTime |
| | | ) ; |
| | | //当审批时间 大于 申请的时间时 计算实际减少金额 因为已扣金额会大于 应扣金额 |
| | | BigDecimal updateCurrentFee = BigDecimal.ZERO; |
| | | if (DateUtil.daysBetweenDates(DateUtil.getMontageDate(new Date(), 2),oldModel.getStartTime()) > 0) { |
| | | //// 2024年5月8日17:37:23 修改 计算产生费用 |
| | | updateCurrentFee = Constants.produceFee(solutions,sumFee,insuranceApply.getStartTime(),insuranceApply.getEndTime(), |
| | | oldModel.getStartTime() |
| | | ); |
| | | } |
| | | |
| | | UpdateWrapper<ApplyDetail> updateWrapper = new UpdateWrapper<ApplyDetail>(); |
| | | updateWrapper.lambda() |
| | | .setSql(" fee = " + updateFee) |
| | | .setSql(" current_fee = " + updateCurrentFee) |
| | | .set(ApplyDetail::getEndTime, delValidTime) |
| | | .set(ApplyDetail::getEditor, update.getEditor()) |
| | | .set(ApplyDetail::getEditDate, update.getEditDate()) |
| | | .eq(ApplyDetail::getId, oldModel.getId()); |
| | | |
| | | if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE) |
| | | && Constants.equalsInteger(solutions.getTimeUnit(),solutions.getInsureCycleUnit())){ |
| | | if(delValidTime.getTime()<=oldModel.getStartTime().getTime()){ |
| | | updateFee = BigDecimal.ZERO; |
| | | updateWrapper.lambda().set(ApplyDetail::getFee,updateFee) |
| | | .set(ApplyDetail::getChangeStatus,Constants.TWO); |
| | | }else{ |
| | | //标记数据已被替换 |
| | | updateWrapper.lambda().set(ApplyDetail::getReduceMoney,solutions.getPrice().multiply(new BigDecimal(-1))) |
| | | .set(ApplyDetail::getChangeStatus,Constants.ONE); |
| | | } |
| | | } |
| | | |
| | | |
| | | applyDetailJoinMapper.update(null, updateWrapper); |
| | | totalFee = totalFee.add(updateFee).subtract(oldModel.getFee()); |
| | | currentFee = currentFee.add(updateCurrentFee); |
| | | |
| | | //修改 员工投保明细记录 历史数据 |
| | | memberInsuranceJoinMapper.update(null, new UpdateWrapper<MemberInsurance>().lambda() |
| | | .setSql(" fee = " + updateFee) |
| | | .set(MemberInsurance::getEndTime, delValidTime) |
| | | .eq(MemberInsurance::getRelationId, oldModel.getId()) |
| | | ); |
| | | |
| | | //修改业务明细行数据实际批单日期 |
| | | applyChangeDetailJoinMapper.update(null,new UpdateWrapper<ApplyChagneDetail>().lambda() |
| | | .set(ApplyChagneDetail::getFee,updateFee.subtract(oldModel.getFee())) |
| | | .set( ApplyChagneDetail::getEndTime, delValidTime) |
| | | .eq(ApplyChagneDetail::getId,detail.getId()) |
| | | ); |
| | | } |
| | | |
| | | member.setApplyId(update.getApplyId()); |
| | | member.setDuId(detail.getDuId()); |
| | | member.setWorktypeId(detail.getWorktypeId()); |
| | | member.setStartTime(detail.getStartTime()); |
| | | member.setEndTime(detail.getEndTime()); |
| | | memberMapper.updateById(member); |
| | | |
| | | }*/ |
| | | |
| | | if (memberInsuranceList != null && memberInsuranceList.size() > 0) { |
| | | memberInsuranceJoinMapper.insertBatchSomeColumn(memberInsuranceList); |
| | |
| | | if (DateUtil.compareDate(insuranceApply.getEndTime(),new Date()) >= Constants.ZERO ) { |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "保单已过保,无法进行该操作"); |
| | | } |
| | | if (DateUtil.compareDate(applyChange.getValidTime(),insuranceApply.getStartTime()) >= Constants.ZERO) { |
| | | //如果保单尚未生效,设置期望生效日期为保单生效开始时间 |
| | | applyChange.setValidTime(insuranceApply.getStartTime()); |
| | | } |
| | | // if (DateUtil.compareDate(applyChange.getValidTime(),insuranceApply.getStartTime()) >= Constants.ZERO) { |
| | | // //如果保单尚未生效,设置期望生效日期为保单生效开始时间 |
| | | // applyChange.setValidTime(insuranceApply.getStartTime()); |
| | | // } |
| | | Solutions solutions = solutionsMapper.selectById(insuranceApply.getSolutionId()); |
| | | if(Objects.isNull(solutions)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到保险方案"); |
| | |
| | | applyChange.setIsdeleted(Constants.ZERO); |
| | | //根据申请日期 处理加减保的 实际生效日期 |
| | | if(applyChange.getType().equals(Constants.ZERO)){ |
| | | if(Objects.nonNull(solutions.getAddValidDays())){ |
| | | applyChange.setApplyStartTime( |
| | | DateUtil.afterDateByType(applyChange.getValidTime(),0,solutions.getAddValidDays()) |
| | | ); |
| | | }else{ |
| | | applyChange.setApplyStartTime(applyChange.getValidTime()); |
| | | } |
| | | if(Objects.nonNull(solutions.getDelValidDays())){ |
| | | applyChange.setDelValidTime( |
| | | DateUtil.afterDateByType(applyChange.getValidTime(),0,solutions.getDelValidDays()) |
| | | ); |
| | | }else{ |
| | | applyChange.setDelValidTime(applyChange.getValidTime()); |
| | | } |
| | | //仅支持替换 保证加减保日期为同一天 |
| | | if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)){ |
| | | applyChange.setApplyStartTime( |
| | | applyChange.getDelValidTime() |
| | | ); |
| | | } |
| | | initJJBValidTime(applyChange,insuranceApply,solutions); |
| | | }else{ |
| | | applyChange.setApplyStartTime(applyChange.getValidTime()); |
| | | } |
| | | |
| | | applyChange.setStatus(Constants.ZERO); |
| | | applyChangeMapper.insert(applyChange); |
| | | |
| | |
| | | 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.NOT_ALLOWED.getCode(), "存在进行中的加减保/换厂申请"); |
| | | // } |
| | | |
| | | return applyChange.getId(); |
| | | } |
| | | |
| | |
| | | ) { |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "保单已过保,无法进行该操作"); |
| | | } |
| | | if (DateUtil.compareDate(applyChange.getValidTime(),insuranceApply.getStartTime()) >= Constants.ZERO) { |
| | | //如果保单尚未生效,设置期望生效日期为保单生效开始时间 |
| | | applyChange.setValidTime(insuranceApply.getStartTime()); |
| | | } |
| | | // if (DateUtil.compareDate(applyChange.getValidTime(),insuranceApply.getStartTime()) > Constants.ZERO) { |
| | | // applyChange.setValidTime(insuranceApply.getStartTime()); |
| | | // } |
| | | Solutions solutions = solutionsMapper.selectById(insuranceApply.getSolutionId()); |
| | | if(Objects.isNull(solutions)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到保险方案"); |
| | |
| | | }; |
| | | |
| | | if(applyChange.getType().equals(Constants.ZERO)){ |
| | | if(Objects.nonNull(solutions.getAddValidDays())){ |
| | | applyChange.setApplyStartTime( |
| | | DateUtil.afterDateByType(applyChange.getValidTime(),0,solutions.getAddValidDays()) |
| | | ); |
| | | }else{ |
| | | applyChange.setApplyStartTime(applyChange.getValidTime()); |
| | | } |
| | | if(Objects.nonNull(solutions.getDelValidDays())){ |
| | | applyChange.setDelValidTime( |
| | | DateUtil.afterDateByType(applyChange.getValidTime(),0,solutions.getDelValidDays()) |
| | | ); |
| | | }else{ |
| | | applyChange.setDelValidTime(applyChange.getValidTime()); |
| | | } |
| | | //仅支持替换 保证加减保日期为同一天 |
| | | if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)){ |
| | | applyChange.setApplyStartTime( |
| | | applyChange.getDelValidTime() |
| | | ); |
| | | } |
| | | |
| | | //处理期望生效日期 |
| | | initJJBValidTime(applyChange,insuranceApply,solutions); |
| | | }else{ |
| | | applyChange.setApplyStartTime(applyChange.getValidTime()); |
| | | } |
| | |
| | | noticesMapper.delete(new QueryWrapper<Notices>().lambda().eq(Notices::getObjType,noticeObjectType.getKey()).eq(Notices::getObjId,applyChange.getId())); |
| | | |
| | | return applyChange.getId(); |
| | | } |
| | | |
| | | private void initJJBValidTime(ApplyChange applyChange, InsuranceApply insuranceApply, Solutions solutions) { |
| | | if( applyChange.getValidTime().getTime()>=insuranceApply.getStartTime().getTime() |
| | | && Objects.nonNull(solutions.getAddValidDays())){ |
| | | //如果保单已生效,按照t+n的规则 |
| | | applyChange.setApplyStartTime( |
| | | DateUtil.afterDateByType(applyChange.getValidTime(),0,solutions.getAddValidDays()) |
| | | ); |
| | | }else{ |
| | | //如果保单未生或者没有配置生效天数,设置期望生效日期为保单生效开始时间 |
| | | applyChange.setApplyStartTime(applyChange.getValidTime().getTime()>=insuranceApply.getStartTime().getTime()?applyChange.getValidTime():insuranceApply.getStartTime()); |
| | | } |
| | | if(applyChange.getValidTime().getTime()>=insuranceApply.getStartTime().getTime() |
| | | &&Objects.nonNull(solutions.getDelValidDays())){ |
| | | applyChange.setDelValidTime( |
| | | DateUtil.afterDateByType(applyChange.getValidTime(),0,solutions.getDelValidDays()) |
| | | ); |
| | | }else{ |
| | | applyChange.setDelValidTime(applyChange.getValidTime().getTime()>=insuranceApply.getStartTime().getTime()?applyChange.getValidTime():insuranceApply.getStartTime()); |
| | | } |
| | | //仅支持替换 保证加减保日期为同一天 |
| | | if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)){ |
| | | applyChange.setApplyStartTime( |
| | | applyChange.getDelValidTime() |
| | | ); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "减保人员【" + applyChagneDetail.getMemberName() + "】必填项缺失"); |
| | | } |
| | | |
| | | |
| | | //查询减保人员是否存在 冲突的 保单明细数据 |
| | | if(applyDetailJoinMapper.selectCount(new QueryWrapper<ApplyDetail>() |
| | | .lambda() |
| | | .eq(ApplyDetail::getApplyId,applyChange.getApplyId()) |
| | | .eq(ApplyDetail::getIdcardNo,applyChagneDetail.getIdcardNo()) |
| | | // .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(applyChange.getDelValidTime(),1)) |
| | | .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(applyChange.getDelValidTime(),1)) |
| | | .ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(applyChange.getDelValidTime(),3)) |
| | | )<=Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "当前保单下,减保人员【" + applyChagneDetail.getMemberName() + "】未查询到符合批单日期的数据"); |
| | |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "加保人员【" + applyChagneDetail.getMemberName() + "】必填项缺失"); |
| | | } |
| | | //查询人员信息是否存在相同的方案下是否存在 冲突数据 |
| | | InsuranceApplyServiceImpl.checkStaticMemberSolution(solutions.getId(), |
| | | applyChagneDetail.getMemberIdcardNo(),applyChagneDetail.getMemberName(),insuranceApply.getStartTime(),insuranceApply.getEndTime(), |
| | | InsuranceApplyServiceImpl.checkStaticMemberSolution(solutions.getBaseId(), |
| | | applyChagneDetail.getIdcardNo(),applyChagneDetail.getMemberName(),applyChange.getApplyStartTime(),insuranceApply.getEndTime(), |
| | | applyDetailJoinMapper); |
| | | |
| | | //查询加保人员是否存在 冲突的 保单明细数据 |
| | |
| | | .lambda() |
| | | .eq(ApplyDetail::getApplyId,applyChange.getApplyId()) |
| | | .eq(ApplyDetail::getIdcardNo,applyChagneDetail.getIdcardNo()) |
| | | // .apply(" ( " + |
| | | // " '"+DateUtil.getLongDateTime(DateUtil.getMontageDate(applyChange.getApplyStartTime(),1))+"' <= t.start_time AND t.start_time < '"+DateUtil.getLongDateTime(DateUtil.getMontageDate(insuranceApply.getEndTime(),2))+"' " + |
| | | // " or " + |
| | | // " ( '"+DateUtil.getLongDateTime(DateUtil.getMontageDate(applyChange.getApplyStartTime(),1))+"' < t.end_time AND t.end_time < '"+DateUtil.getLongDateTime(DateUtil.getMontageDate(insuranceApply.getEndTime(),2))+"' ) " + |
| | | // " or " + |
| | | // " ( '"+DateUtil.getLongDateTime(DateUtil.getMontageDate(applyChange.getApplyStartTime(),1))+"' > t.start_time AND '"+DateUtil.getLongDateTime(DateUtil.getMontageDate(insuranceApply.getEndTime(),2))+"' < t.end_time )" + |
| | | // " ) " ) |
| | | .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(applyChange.getApplyStartTime(),1)) |
| | | .ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(insuranceApply.getEndTime(),2)) |
| | | //.ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(applyChange.getApplyStartTime(),3)) |
| | | )>Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "当前保单下,加保人员【" + applyChagneDetail.getMemberName() + "】存在日期冲突的数据"); |
| | | } |
| | |
| | | member.setName(applyChagneDetail.getMemberName()); |
| | | member.setCompanyId(insuranceApply.getCompanyId()); |
| | | member.setSex(Constants.getSexByIdCard(applyChagneDetail.getIdcardNo())); |
| | | if(!IdcardUtil.isValidCard(applyDetail.getIdcardNo())){ |
| | | if(!IdcardUtil.isValidCard(applyChagneDetail.getIdcardNo())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"加保员工信息身份证信息错误["+member.getName()+"]"); |
| | | } |
| | | member.setIdcardNo(applyChagneDetail.getIdcardNo()); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<ApplyChange> monthTotalList(ApplyChange model){ |
| | | if(model.getApplyId() ==null || model.getYear() == null){ |
| | | return new ArrayList<>(); |
| | | } |
| | | MPJLambdaWrapper<ApplyChange> queryWrapper = new MPJLambdaWrapper<>(); |
| | | queryWrapper |
| | | .select("count(t.id)",ApplyChange::getCountNum) |
| | | .select("sum(t.fee)",ApplyChange::getFee) |
| | | .select("DATE_FORMAT(t.create_date, '%Y-%m')",ApplyChange::getMonth) |
| | | .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyChange::getApplyId) |
| | | .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId) |
| | | .eq(!Objects.isNull(model.getType()),ApplyChange::getType,model.getType()) |
| | | .eq(ApplyChange::getApplyId,model.getApplyId()) |
| | | .eq(!Objects.isNull(model.getStatus())&&!model.getStatus().equals(Constants.ApplyChangeStatus.RETURN_APPLY_UPLOAD.getKey()),ApplyChange::getStatus,model.getStatus()) |
| | | .in(!Objects.isNull(model.getStatus())&&model.getStatus().equals(Constants.ApplyChangeStatus.RETURN_APPLY_UPLOAD.getKey()), |
| | | ApplyChange::getStatus, |
| | | Constants.ApplyChangeStatus.RETURN_APPLY_UPLOAD.getKey(), |
| | | Constants.ApplyChangeStatus.RETURN_APPLY_SIGNATURE.getKey()) |
| | | .eq(!Objects.isNull(model.getSolutionType()),Solutions::getType,model.getSolutionType()) |
| | | .eq(!Objects.isNull(model.getBaseSolutionsId()),Solutions::getBaseId,model.getBaseSolutionsId()) |
| | | .like(StringUtils.isNotBlank(model.getSolutionsName()),Solutions::getName,model.getSolutionsName()) |
| | | .ge( ApplyChange::getCreateDate, model.getYear()+"-01-01 00:00:00" ) |
| | | .lt(ApplyChange::getCreateDate, (model.getYear()+1)+"-01-01 00:00:00") |
| | | .groupBy("month" ); |
| | | /* LoginUserInfo loginUserInfo =(LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | //企业人员查看本企业数据 |
| | | if(loginUserInfo.getType().equals(Constants.ONE)){ |
| | | queryWrapper.eq(InsuranceApply::getCompanyId, loginUserInfo.getCompanyId()); |
| | | }else if(loginUserInfo.getType().equals(Constants.TWO)){ |
| | | //如果是商户查看 |
| | | if(model.getSolutionType()!=null && model.getSolutionType() ==0){ |
| | | queryWrapper.exists("select cs.id from company_solution cs where cs.isdeleted=0 and cs.company_id=t1.company_id and cs.shop_id="+loginUserInfo.getCompanyId()); |
| | | }else if(model.getSolutionType()!=null && model.getSolutionType() ==1){ |
| | | queryWrapper.eq(Solutions::getShopId,loginUserInfo.getCompanyId()); |
| | | }else{ |
| | | queryWrapper.apply("((t2.type=0 and exists(select cs.id from company_solution cs where cs.isdeleted=0 and cs.company_id=t1.company_id and cs.shop_id="+loginUserInfo.getCompanyId()+")) or (" + |
| | | "t2.type=1 and t2.shop_id="+loginUserInfo.getCompanyId()+"))") ; |
| | | } |
| | | }else{ |
| | | if(loginUserInfo.getCompanyIdList()!=null && loginUserInfo.getCompanyIdList().size()>0){ |
| | | queryWrapper.in(InsuranceApply::getCompanyId, loginUserInfo.getCompanyIdList()); |
| | | }else{ |
| | | queryWrapper.eq(InsuranceApply::getCompanyId, -1); |
| | | } |
| | | queryWrapper.eq(model.getCompanyId()!=null,InsuranceApply::getCompanyId, model.getCompanyId()); |
| | | }*/ |
| | | |
| | | List<ApplyChange> list =applyChangeJoinMapper.selectJoinList(ApplyChange.class,queryWrapper); |
| | | List<ApplyChange> result = new ArrayList<>(); |
| | | for (int i = 1; i <= 12; i++) { |
| | | if(i<10){ |
| | | result.add(getMonthDayFromList(model.getYear() +"-0"+i,list)); |
| | | }else{ |
| | | result.add(getMonthDayFromList(model.getYear() +"-"+i,list)); |
| | | } |
| | | } |
| | | return result; |
| | | |
| | | } |
| | | |
| | | private ApplyChange getMonthDayFromList(String s, List<ApplyChange> list) { |
| | | for(ApplyChange d : list){ |
| | | if(StringUtils.equals(s,d.getMonth())){ |
| | | return d; |
| | | } |
| | | } |
| | | ApplyChange d = new ApplyChange(); |
| | | d.setMonth(s); |
| | | d.setFee(new BigDecimal(0)); |
| | | d.setCountNum(0); |
| | | return d; |
| | | } |
| | | |
| | | @Override |
| | | public List<ApplyChange> findListForCompany(ApplyChange model) { |
| | | MPJLambdaWrapper<ApplyChange> queryWrapper = new MPJLambdaWrapper<>(); |
| | | queryWrapper |
| | |
| | | .selectAs(Solutions::getName,ApplyChange::getSolutionsName) |
| | | .selectAs(Solutions::getType,ApplyChange::getSolutionType) |
| | | .selectAs(Solutions::getId,ApplyChange::getSolutionsId) |
| | | .selectAs(Solutions::getDelOnlyReplace,ApplyChange::getDelOnlyReplace) |
| | | .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 0 )",ApplyChange::getAddNum) |
| | | .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 1 )",ApplyChange::getDelNum) |
| | | .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 2 )",ApplyChange::getChangeNum) |
| | |
| | | // } |
| | | BigDecimal sumPrice = Objects.isNull(insuranceApply.getServerCost())?solutions.getPrice():solutions.getPrice().add(insuranceApply.getServerCost()); |
| | | CountCyclePriceVO returnCountCyclePriceVO = new CountCyclePriceVO(); |
| | | returnCountCyclePriceVO.setCyclePrice(Constants.addFee(solutions, |
| | | sumPrice |
| | | ,insuranceApply.getStartTime(),insuranceApply.getFinalEndTime(), |
| | | DateUtil.afterDateByType(applyChangeCyclePriceDTO.getValidTime(),0,solutions.getAddValidDays()),insuranceApply.getEndTime())); |
| | | Date addStartTime = DateUtil.afterDateByType(applyChangeCyclePriceDTO.getValidTime(),0,solutions.getAddValidDays()); |
| | | if(addStartTime.getTime()<insuranceApply.getStartTime().getTime()){ |
| | | returnCountCyclePriceVO.setCyclePrice(solutions.getPrice()); |
| | | }else{ |
| | | returnCountCyclePriceVO.setCyclePrice(Constants.addFee(solutions, |
| | | sumPrice |
| | | ,insuranceApply.getStartTime(),insuranceApply.getFinalEndTime(),addStartTime |
| | | ,insuranceApply.getEndTime())); |
| | | } |
| | | BigDecimal reducePrice = solutions.getPrice().subtract(Constants.reduceFee(solutions, |
| | | sumPrice |
| | | ,insuranceApply.getStartTime(),insuranceApply.getFinalEndTime() |