jiangping
2024-06-20 09da100729793848bc01b51f7b05ca3f1e7ec64f
server/service/src/main/java/com/doumee/service/business/impl/SolutionsServiceImpl.java
@@ -71,13 +71,21 @@
        )>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);//基础版本
        //如果有工种,则产生一个新的有效历史版本 ~
@@ -161,7 +169,10 @@
        ){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        if(!(Constants.equalsInteger(solutions.getInsureCycleUnit(),Constants.ZERO)
                ||Constants.equalsInteger(solutions.getInsureCycleUnit(),solutions.getInsureCycleUnit()))){
            solutions.setDelOnlyReplace(Constants.ZERO);
        }
    }
    @Override
@@ -206,6 +217,11 @@
        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>()
@@ -370,12 +386,13 @@
        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);
    }
  
@@ -483,13 +500,14 @@
        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;
@@ -541,7 +559,7 @@
                .eq(Company::getStatus,Constants.ZERO)
                .eq(Insurance::getIsdeleted,Constants.ZERO)
                .eq(Insurance::getStatus,Constants.ZERO)
                .orderByAsc(Solutions::getSortnum)
                .orderByDesc(Solutions::getCreateDate)
        );
        return solutionsList;
    }
@@ -580,5 +598,18 @@
    }
    @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);
    }
}