k94314517
2024-04-09 142df5ee1c533f4b068e37b6ba524297a8f8617f
git ch
已添加1个文件
已修改4个文件
115 ■■■■■ 文件已修改
server/service/src/main/java/com/doumee/dao/system/vo/BigDecimalVO.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/DispatchUnitServiceImpl.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/TaxesServiceImpl.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/UnionChangeServiceImpl.java 67 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/dao/system/vo/BigDecimalVO.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,16 @@
package com.doumee.dao.system.vo;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class BigDecimalVO {
    private BigDecimal totalFee;
    private BigDecimal currentFee;
}
server/service/src/main/java/com/doumee/service/business/impl/DispatchUnitServiceImpl.java
@@ -10,10 +10,7 @@
import com.doumee.core.utils.Utils;
import com.doumee.dao.business.*;
import com.doumee.dao.business.dto.*;
import com.doumee.dao.business.join.DispatchUnitJoinMapper;
import com.doumee.dao.business.join.DuLogJoinMapper;
import com.doumee.dao.business.join.DuSolutionJoinMapper;
import com.doumee.dao.business.join.DuWorkTypeJoinMapper;
import com.doumee.dao.business.join.*;
import com.doumee.dao.business.model.*;
import com.doumee.dao.system.model.SystemUser;
import com.doumee.service.business.DispatchUnitService;
@@ -49,6 +46,9 @@
    @Autowired
    private DuSolutionMapper duSolutionMapper;
    @Autowired
    private SolutionWorktypeJoinMapper solutionWorktypeJoinMapper;
    @Autowired
    private DuWorktypeMapper    duWorktypeMapper;
@@ -507,6 +507,11 @@
                if(Objects.isNull(saveDuWorkTypeDTO.getWorkTypeId())){
                    throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+saveDuSolutionDTO.getSolutionName()+"】该方案下"+saveDuWorkTypeDTO.getWorkTypeName()+"该工种信息异常");
                }
                //验证方案与工种的关系
                if(solutionWorktypeJoinMapper.selectCount(new QueryWrapper<SolutionWorktype>().lambda().eq(SolutionWorktype::getSolutionId,saveDuSolutionDTO.getSolutionId())
                        .eq(SolutionWorktype::getWorktypeId,saveDuWorkTypeDTO.getWorkTypeId()))<=0){
                    throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+saveDuSolutionDTO.getSolutionName()+"】该方案下"+saveDuWorkTypeDTO.getWorkTypeName()+"该工种信息无绑定关系");
                };
                if(duWorktypeMapper.selectCount(new QueryWrapper<DuWorktype>()
                        .lambda().eq(DuWorktype::getDuSolutionId,duSolution.getId())
                        .eq(DuWorktype::getIsdeleted,Constants.ZERO)
server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java
@@ -1534,7 +1534,8 @@
        }
        if(solutions.getValidType().equals(Constants.ZERO)){
            if(DateUtil.getMontageDate(
                    DateUtil.addDaysToDate(new Date(),solutions.getValidType()),0).getTime()>insuranceApply.getApplyStartTime().getTime()){
                    DateUtil.addDaysToDate(new Date(),solutions.getValidTypeNum()),1).getTime()
                    >insuranceApply.getApplyStartTime().getTime()){
                throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"保单生效起期错误");
            }
        }else{
@@ -1919,7 +1920,7 @@
        queryWrapper.select(" DATEDIFF( t.END_TIME ,now()  ) AS loseEfficacyDays  ");
        queryWrapper.select(" ( select count(DISTINCT(ad.MEMBER_ID)) from apply_detail ad  where ad.apply_id = t.id ) as insureNum");
        if(!Objects.isNull(pageWrap.getModel())&&!Objects.isNull(pageWrap.getModel().getType())){
            queryWrapper.select(" ifnull(( select sum(td.fee) from taxes ts inner join tax_detial td on td.TAX_ID = ts.id  where ts.status  = 1 and td.INSURANCE_APPLY_ID = t.id ),0) as taxesMoney");
            queryWrapper.select(" ifnull(( select sum(td.fee) from taxes ts inner join tax_detial td on td.TAX_ID = ts.id  where ts.status != 2 and td.INSURANCE_APPLY_ID = t.id ),0) as taxesMoney");
            queryWrapper.select(" ( select td.CREATE_DATE from taxes ts inner join tax_detial td on td.TAX_ID = ts.id  where ts.status = 1 and td.INSURANCE_APPLY_ID = t.id order by td.CREATE_DATE desc limit 1 ) as taxesLast ");
        }
        queryWrapper.leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId);
server/service/src/main/java/com/doumee/service/business/impl/TaxesServiceImpl.java
@@ -477,15 +477,17 @@
            //查询每个保单下可以投保的金额
            InsuranceApply insuranceApply = insuranceApplyJoinMapper.selectJoinOne(InsuranceApply.class,new MPJLambdaWrapper<InsuranceApply>()
                    .selectAll(InsuranceApply.class)
//                    .select(" ifnull(( select sum(td.fee) from taxes ts inner join tax_detial td on td.TAX_ID = ts.id  where ts.status  = 1 and td.INSURANCE_APPLY_ID = t.id ),0) as taxesMoney")
                    .select(" ifnull(( select sum(td.fee) from taxes ts inner join tax_detial td on td.TAX_ID = ts.id  where ts.status != 2 and td.INSURANCE_APPLY_ID = t.id ),0) as taxesMoney ")
                    .eq(InsuranceApply::getId,taxDetial.getInsuranceApplyId())
            );
            if(Objects.isNull(insuranceApply)){
                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"保单号【"+taxDetial.getApplyCode()+"】未查询到保单信息");
            }
            if(insuranceApply.getCurrentFee().subtract(insuranceApply.getTaxesMoney()).compareTo(taxDetial.getFee())!=Constants.ZERO){
                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"保单号【"+taxDetial.getApplyCode()+"】可报销金额错误【"+insuranceApply.getCurrentFee().subtract(insuranceApply.getTaxesMoney())+"】");
            }
//            if(Objects.isNull(insuranceApply)){
//                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"保单号【"+taxDetial.getApplyCode()+"】未查询到保单信息");
//            }
//            if(insuranceApply.getCurrentFee().subtract(insuranceApply.getTaxesMoney()).compareTo(taxDetial.getFee())!=Constants.ZERO){
//                //throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"保单号【"+taxDetial.getApplyCode()+"】可报销金额错误【"+insuranceApply.getCurrentFee().subtract(insuranceApply.getTaxesMoney())+"】");
//                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"保单号【"+taxDetial.getApplyCode()+"】可报销金额错误");
//            }
            taxDetial.setCreator(user.getId());
            taxDetial.setCreateDate(new Date());
            taxDetial.setIsdeleted(Constants.ZERO);
server/service/src/main/java/com/doumee/service/business/impl/UnionChangeServiceImpl.java
@@ -18,6 +18,7 @@
import com.doumee.dao.business.model.*;
import com.doumee.dao.business.vo.CountCyclePriceVO;
import com.doumee.dao.system.model.SystemUser;
import com.doumee.dao.system.vo.BigDecimalVO;
import com.doumee.service.business.SmsEmailService;
import com.doumee.service.business.UnionChangeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -57,6 +58,9 @@
    @Autowired
    private ApplyChangeJoinMapper applyChangeJoinMapper;
    @Autowired
    private UnionApplyMapper unionApplyMapper;
    @Autowired
    private ApplyChagneDetailJoinMapper applyChagneDetailJoinMapper;
@@ -350,6 +354,13 @@
        ){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
//        UnionApply unionApply = unionApplyMapper.selectById(saveUnionChangeDTO.getUnionApplyId());
//        if(Objects.isNull(unionApply)){
//            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"未查询到合并保单数据");
//        }
        List<ApplyChange> applyChangeList = applyChangeJoinMapper.selectJoinList(ApplyChange.class,
                new MPJLambdaWrapper<ApplyChange>()
                        .selectAll(ApplyChange.class)
@@ -703,9 +714,6 @@
                ,unionChange.getId(),applyLogType.getKey(),null, JSONObject.toJSONString(unionChange));
        applyLogMapper.insert(log);
        if(true){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
    }
@@ -713,37 +721,39 @@
    public void dealApplyChangeDetail(ApplyChange applyChange,List<ApplyChagneDetail> applyChagneDetailList){
        BigDecimal totalFee = BigDecimal.ZERO;
        BigDecimal currentFee = BigDecimal.ZERO;
        BigDecimalVO bigDecimalVO = new BigDecimalVO();
        bigDecimalVO.setTotalFee(BigDecimal.ZERO);
        bigDecimalVO.setCurrentFee(BigDecimal.ZERO);
        for (ApplyChagneDetail detail:applyChagneDetailList) {
            Member member = memberMapper.selectById(detail.getMemberId());
            if(Objects.isNull(member)){
                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到员工数据");
            }
            if (Constants.equalsInteger(detail.getType(), Constants.ZERO)) {
               this.addChangeDetailData(applyChange,detail,detail.getPrice(),currentFee,totalFee);
               this.addChangeDetailData(applyChange,detail,bigDecimalVO);
            }else if(Constants.equalsInteger(detail.getType(),Constants.ONE)){
                this.reduceChangeDetailData(applyChange,detail,currentFee,totalFee);
                this.reduceChangeDetailData(applyChange,detail,bigDecimalVO);
            }else{
                this.otherChangeDetailData(applyChange,detail);
            }
        }
        if (totalFee.compareTo(new BigDecimal(0)) != 0) {
        if (bigDecimalVO.getTotalFee().compareTo(new BigDecimal(0)) != 0) {
            //如果保单金额发生编码,更新总保单金额
            insuranceApplyMapper.update(null, new UpdateWrapper<InsuranceApply>().lambda()
                    .setSql(" fee = ifnull(fee,0)+" + totalFee)
                    .setSql(" current_fee = ifnull(current_fee,0)+" + currentFee)
                    .setSql(" fee = ifnull(fee,0)+" + bigDecimalVO.getTotalFee())
                    .setSql(" current_fee = ifnull(current_fee,0)+" + bigDecimalVO.getCurrentFee())
                    .set(InsuranceApply::getEditor, applyChange.getEditor())
                    .set(InsuranceApply::getEditDate, applyChange.getEditDate())
                    .eq(InsuranceApply::getId, applyChange.getApplyId())
            );
            applyChangeJoinMapper.update(null, new UpdateWrapper<ApplyChange>().lambda()
                    .set(ApplyChange::getFee,totalFee)
                    .set(ApplyChange::getEditor, applyChange.getEditor())
                    .set(ApplyChange::getEditDate, applyChange.getEditDate())
                    .eq(ApplyChange::getId, applyChange.getApplyId())
            );
//            applyChangeJoinMapper.update(null, new UpdateWrapper<ApplyChange>().lambda()
//                    .set(ApplyChange::getFee,bigDecimalVO.getTotalFee())
//                    .set(ApplyChange::getEditor, applyChange.getEditor())
//                    .set(ApplyChange::getEditDate, applyChange.getEditDate())
//                    .eq(ApplyChange::getId, applyChange.getApplyId())
//            );
            applyChange.setFee(bigDecimalVO.getTotalFee());
        }
    }
@@ -753,12 +763,9 @@
     * åŠ ä¿æ•°æ®å¤„ç†
     * @param applyChange
     * @param detail
     * @param price
     * @param currentFee
     * @param totalFee
     */
    public void addChangeDetailData(ApplyChange applyChange,ApplyChagneDetail detail
            ,BigDecimal price,BigDecimal currentFee,BigDecimal totalFee){
    public void addChangeDetailData(ApplyChange applyChange, ApplyChagneDetail detail
            , BigDecimalVO bigDecimalVO){
        //查询加保人员是否存在 å†²çªçš„ ä¿å•明细数据
        if(applyDetailJoinMapper.selectCount(new QueryWrapper<ApplyDetail>()
                .lambda()
@@ -777,7 +784,7 @@
        if(new Date().compareTo(DateUtil.getMontageDate(applyChange.getApplyStartTime(), 2))>=0){
            Integer days =  DateUtil.calculateBetween(applyChange.getApplyStartTime(),DateUtil.getMontageDate(new Date(), 2),0);
            //如果已已产生费用,计算已已产生费用
            add.setCurrentFee(new BigDecimal(days).multiply(price));
            add.setCurrentFee(new BigDecimal(days).multiply(detail.getPrice()));
        }else{
            add.setCurrentFee(BigDecimal.ZERO);
        }
@@ -797,7 +804,7 @@
        add.setDuId(detail.getDuId());
        add.setStartTime(DateUtil.getMontageDate(applyChange.getApplyStartTime(), 1));
        add.setEndTime(DateUtil.getMontageDate(detail.getEndTime(), 2));
        add.setFee(new BigDecimal(countDays).multiply(price));
        add.setFee(new BigDecimal(countDays).multiply(detail.getPrice()));
        applyDetailJoinMapper.insert(add);
        detail.setFee(add.getFee());
@@ -806,9 +813,8 @@
                .set(ApplyChagneDetail::getStartTime,DateUtil.getMontageDate(applyChange.getApplyStartTime(), 1))
                .eq(ApplyChagneDetail::getId,detail.getId())
        );
        totalFee = totalFee.add(add.getFee());
        currentFee = currentFee.add(add.getCurrentFee());
        bigDecimalVO.setTotalFee(bigDecimalVO.getTotalFee().add(add.getFee()));
        bigDecimalVO.setCurrentFee(bigDecimalVO.getCurrentFee().add(add.getCurrentFee()));
        MemberInsurance memberInsurance = new MemberInsurance(detail, applyChange, applyChange.getEditor(), add.getId(),applyChange.getSolutionsId());
        memberInsurance.setStartTime(add.getStartTime());
@@ -821,10 +827,8 @@
     * å‡ä¿æ•°æ®å¤„理
     * @param applyChange
     * @param detail
     * @param currentFee
     * @param totalFee
     */
    public void reduceChangeDetailData(ApplyChange applyChange,ApplyChagneDetail detail,BigDecimal currentFee,BigDecimal totalFee){
    public void reduceChangeDetailData(ApplyChange applyChange,ApplyChagneDetail detail,BigDecimalVO bigDecimalVO){
        //查询员工是在主单下 æ˜¯å¦å­˜åœ¨ç”Ÿæ•ˆä¸­çš„æ•°æ®
        ApplyDetail oldModel = applyDetailJoinMapper.selectOne(new QueryWrapper<ApplyDetail>().lambda()
                .eq(ApplyDetail::getApplyId, applyChange.getApplyId())
@@ -859,8 +863,9 @@
                .set(ApplyDetail::getEditDate, applyChange.getEditDate())
                .eq(ApplyDetail::getId, oldModel.getId())
        );
        totalFee = totalFee.add(reduceFee);
        currentFee = currentFee.add(pullFee);
        bigDecimalVO.setTotalFee(bigDecimalVO.getTotalFee().add(reduceFee));
        bigDecimalVO.setCurrentFee(bigDecimalVO.getCurrentFee().add(pullFee));
        //修改 å‘˜å·¥æŠ•保明细记录 åŽ†å²æ•°æ®
        memberInsuranceJoinMapper.update(null, new UpdateWrapper<MemberInsurance>().lambda()