|  |  |  | 
|---|
|  |  |  | )>Constants.ZERO){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"保险方案名称已存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | solutions.setCanAdd(Constants.formatIntegerNum(solutions.getCanAdd())); | 
|---|
|  |  |  | solutions.setCanReduce(Constants.formatIntegerNum(solutions.getCanReduce())); | 
|---|
|  |  |  | solutions.setCanChangeUnit(Constants.formatIntegerNum(solutions.getCanChangeUnit())); | 
|---|
|  |  |  | solutions.setAddValidDays(Constants.formatIntegerNum(solutions.getAddValidDays())); | 
|---|
|  |  |  | solutions.setDelValidDays(Constants.formatIntegerNum(solutions.getDelValidDays())); | 
|---|
|  |  |  | solutions.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | solutions.setCreator(user.getId()); | 
|---|
|  |  |  | solutions.setCreateDate(new Date()); | 
|---|
|  |  |  | solutions.setVersion(UUID.randomUUID().toString());//版本号 | 
|---|
|  |  |  | solutions.setDataType(Constants.ZERO); | 
|---|
|  |  |  | solutions.setStatus(Constants.ZERO); | 
|---|
|  |  |  | //2024年6月17日15:56:18 仅支持替换模式下,批增日期 等于 批减日期 | 
|---|
|  |  |  | if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)){ | 
|---|
|  |  |  | solutions.setAddValidDays(solutions.getDelValidDays()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | solutionsMapper.insert(solutions);//基础版本 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //如果有工种,则产生一个新的有效历史版本 ~ | 
|---|
|  |  |  | 
|---|
|  |  |  | //                ||Constants.formatIntegerNum(solutions.getPriceCycleUnit()) < 0 | 
|---|
|  |  |  | ||Constants.formatIntegerNum(solutions.getInsureCycle()) < 0 | 
|---|
|  |  |  | ||Constants.formatIntegerNum(solutions.getInsureCycleUnit()) < 0 | 
|---|
|  |  |  | || solutions.getMinAge() >solutions.getMaxAge() | 
|---|
|  |  |  | ||Constants.formatIntegerNum( solutions.getMinAge()) >Constants.formatIntegerNum(solutions.getMaxAge()) | 
|---|
|  |  |  | || Constants.formatBigdecimal(solutions.getPrice()).compareTo(new BigDecimal(0)) !=1 | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(!(Constants.equalsInteger(solutions.getInsureCycleUnit(),Constants.ZERO) | 
|---|
|  |  |  | ||Constants.equalsInteger(solutions.getInsureCycleUnit(),solutions.getInsureCycleUnit()))){ | 
|---|
|  |  |  | solutions.setDelOnlyReplace(Constants.ZERO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //数据有效性校验 | 
|---|
|  |  |  | initCreateParam(solutions); | 
|---|
|  |  |  | solutions.setType(null);//不支持修改投保方案 | 
|---|
|  |  |  | if(solutionsMapper.selectCount(new QueryWrapper<Solutions>().lambda() | 
|---|
|  |  |  | .eq(Solutions::getName,solutions.getName()) | 
|---|
|  |  |  | .eq(Solutions::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | 
|---|
|  |  |  | solutions.setEditor(user.getId()); | 
|---|
|  |  |  | solutions.setVersion(UUID.randomUUID().toString()); | 
|---|
|  |  |  | solutions.setEditDate(new Date()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //2024年6月17日15:56:18 仅支持替换模式下,批增日期 等于 批减日期 | 
|---|
|  |  |  | if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)){ | 
|---|
|  |  |  | solutions.setAddValidDays(solutions.getDelValidDays()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | solutionsMapper.updateById(solutions); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Solutions oldVersion = solutionsMapper.selectOne(new QueryWrapper<Solutions>() | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq(Solutions::getDataType,Constants.TWO) | 
|---|
|  |  |  | .last("limit 1") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(Objects.isNull(oldVersion)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到历史版本数据"); | 
|---|
|  |  |  | 
|---|
|  |  |  | .lambda() | 
|---|
|  |  |  | .eq(SolutionWorktype::getSolutionId,solutions.getId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(Constants.equalsObject(solutions.getType(),Constants.ONE) ){ | 
|---|
|  |  |  | if(Constants.equalsObject(model.getType(),Constants.ONE) ){ | 
|---|
|  |  |  | if  (solutions.getFanganFile()!=null && StringUtils.isNotBlank(solutions.getFanganFile().getFileurl())){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | multifileMapper.update(null,new UpdateWrapper<Multifile>().lambda() | 
|---|
|  |  |  | .set(Multifile::getIsdeleted,Constants.ONE) | 
|---|
|  |  |  | .set(Multifile::getEditDate,solutions.getEditDate()) | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq(Multifile::getObjId,solutions.getId()) | 
|---|
|  |  |  | .eq(Multifile::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Multifile::getObjType,Constants.MultiFile.SOLUTIONS_CONFIRMATION_LATTER.getKey())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Multifile file = solutions.getFanganFile(); | 
|---|
|  |  |  | file.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | file.setCreateDate(solutions.getEditDate()); | 
|---|
|  |  |  | 
|---|
|  |  |  | if(solutions.getDataType() == null){ | 
|---|
|  |  |  | solutions.setDataType(Constants.TWO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | QueryWrapper<Solutions> wrapper = new QueryWrapper<>(solutions); | 
|---|
|  |  |  | if(Constants.equalsObject(user.getType(),Constants.TWO)){ | 
|---|
|  |  |  | //如果是删除 | 
|---|
|  |  |  | solutions.setShopId(user.getCompanyId()); | 
|---|
|  |  |  | //                wrapper.lambda().exists("select c.id from company_solution c left join solutions d on c.solution_id=d.id where c.isdeleted=0 and d.base_id=solutions.base_id and c.shop_id="+user.getCompanyId());//设置无效访问 | 
|---|
|  |  |  | wrapper.apply("((solutions.type=0 and exists(select cs.id from company_solution cs left join solutions s on cs.solution_id=s.id where cs.isdeleted=0 and s.base_id=solutions.base_id and cs.shop_id="+user.getCompanyId()+")) or (" + | 
|---|
|  |  |  | "solutions.type=1 and solutions.shop_id="+user.getCompanyId()+"))") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | QueryWrapper<Solutions> wrapper = new QueryWrapper<>(solutions); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return solutionsMapper.selectList(wrapper); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | if (pageWrap.getModel().getBaseId() != null) { | 
|---|
|  |  |  | queryWrapper.eq(Solutions::getBaseId, pageWrap.getModel().getBaseId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for(PageWrap.SortData sortData: pageWrap.getSorts()) { | 
|---|
|  |  |  | if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { | 
|---|
|  |  |  | queryWrapper.orderByDesc(sortData.getProperty()); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | queryWrapper.orderByAsc(sortData.getProperty()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | queryWrapper.orderByDesc(Solutions::getCreateDate); | 
|---|
|  |  |  | //        for(PageWrap.SortData sortData: pageWrap.getSorts()) { | 
|---|
|  |  |  | //            if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { | 
|---|
|  |  |  | //                queryWrapper.orderByDesc(sortData.getProperty()); | 
|---|
|  |  |  | //            } else { | 
|---|
|  |  |  | //                queryWrapper.orderByAsc(sortData.getProperty()); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | PageData<Solutions> pageData = PageData.from(solutionsJoinMapper.selectJoinPage(page,Solutions.class, queryWrapper)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return pageData; | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq(Company::getStatus,Constants.ZERO) | 
|---|
|  |  |  | .eq(Insurance::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Insurance::getStatus,Constants.ZERO) | 
|---|
|  |  |  | .orderByAsc(Solutions::getSortnum) | 
|---|
|  |  |  | .orderByDesc(Solutions::getCreateDate) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | return solutionsList; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public BigDecimal testSolutionAddMoney(Integer id, BigDecimal fee, Date start,Date end,Date newDate,Date newEndTime){ | 
|---|
|  |  |  | return Constants.addFee(solutionsMapper.selectById(id),fee,start,end,newDate,newEndTime); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public BigDecimal testSolutionReduceMoney(Integer id, BigDecimal fee, Date start,Date end,Date reduceStartTime,Date reduceEndTime){ | 
|---|
|  |  |  | return Constants.reduceFee(solutionsMapper.selectById(id),fee,start,end,reduceStartTime,reduceEndTime); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public BigDecimal testSolutionProduceMoney(Integer id, BigDecimal fee, Date start,Date end,Date produceStart){ | 
|---|
|  |  |  | return Constants.produceFee(solutionsMapper.selectById(id),fee,start,end,produceStart); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|