jiangping
2025-06-06 a2299a6d4a6f99e9c11132138f5d3e9ec68f03ea
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractBillServiceImpl.java
@@ -28,6 +28,7 @@
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@@ -66,11 +67,17 @@
    private YwContractMapper ywContractMapper;
    @Autowired
    private YwAccountMapper ywAccountMapper;
    @Autowired
    private MemberMapper memberMapper;
    @Autowired
    private YwTempConfigMapper ywTempConfigMapper;
    @Value("${zip_file_path}")
    private String zipFilePath;
    @Override
    public Integer create(YwContractBill ywContractBill) {
@@ -225,6 +232,17 @@
                ywContractBill.getReceivableFee().subtract(ywContractBill.getActReceivableFee())
        );
        if(Constants.equalsInteger(ywContractBill.getStatus(),Constants.ZERO)
                && (Constants.equalsInteger(ywContractBill.getPayStatus(),Constants.ZERO)
                || Constants.equalsInteger(ywContractBill.getPayStatus(),Constants.TWO)
                || Constants.equalsInteger(ywContractBill.getPayStatus(),Constants.THREE)
                || Constants.equalsInteger(ywContractBill.getPayStatus(),Constants.FOUR))
                && Utils.Date.getEnd(ywContractBill.getPlanPayDate()).getTime() < System.currentTimeMillis()){
            ywContractBill.setIsOverdue(Constants.ONE);
        }else{
            ywContractBill.setIsOverdue(Constants.ZERO);
        }
        //房源数据
        ywContractBill.setYwContractRoomList(
                ywContractRoomMapper.selectJoinList(YwContractRoom.class,new MPJLambdaWrapper<YwContractRoom>()
@@ -232,8 +250,8 @@
                .selectAs(YwProject::getName,YwRoom::getProjectName)
                .selectAs(YwFloor::getName,YwRoom::getFloorName)
                .selectAs(YwBuilding::getName,YwRoom::getBuildingName)
                .selectAs(YwRoom::getCode,YwContractRoom::getRoomName)
                .selectAs(YwRoom::getArea,YwContractRoom::getArea)
                .selectAs(YwRoom::getRoomNum,YwContractRoom::getRoomName)
                .selectAs(YwRoom::getRentArea,YwContractRoom::getArea)
                .leftJoin(YwRoom.class,YwRoom::getId,YwContractRoom::getRoomId)
                .leftJoin(YwFloor.class,YwFloor::getId,YwRoom::getFloor)
                .leftJoin(YwProject.class,YwProject::getId,YwRoom::getProjectId)
@@ -338,7 +356,7 @@
                || Constants.equalsInteger(ywContractBill.getPayStatus(),Constants.TWO)
                || Constants.equalsInteger(ywContractBill.getPayStatus(),Constants.THREE)
                || Constants.equalsInteger(ywContractBill.getPayStatus(),Constants.FOUR))
            && ywContractBill.getPlanPayDate().getTime() < System.currentTimeMillis()){
            && Utils.Date.getEnd(ywContractBill.getPlanPayDate()).getTime() < System.currentTimeMillis()){
                ywContractBill.setIsOverdue(Constants.ONE);
            }else{
                ywContractBill.setIsOverdue(Constants.ZERO);
@@ -385,6 +403,8 @@
        IPage<YwContractBill> iPage = ywContractBillMapper.selectJoinPage(page,YwContractBill.class,
                queryWrapper.selectAll(YwContractBill.class)
                        .select(" ( select ifnull( sum( CASE WHEN t.bill_type = 0 and yw.REVENUE_TYPE = 0 THEN yw.ACT_RECEIVABLE_FEE when  t.bill_type = 0 and yw.REVENUE_TYPE = 1 then -yw.ACT_RECEIVABLE_FEE  when t.bill_type = 1 and yw.REVENUE_TYPE = 0 then -yw.ACT_RECEIVABLE_FEE else  yw.ACT_RECEIVABLE_FEE END),0) from  yw_contract_revenue yw where yw.bill_id = t.id and yw.status = 0 and yw.isdeleted = 0 ) as  actReceivableFee  ")
                        .select(" ifnull((select s.status  from sms_email s where s.OBJ_ID = t.id and s.OBJ_TYPE = 2 order by s.CREATE_DATE desc  limit 1 ),0)  ",YwContractBill::getIsSendEmail)
                        .select(" ifnull((select s.status  from sms_email s where s.OBJ_ID = t.id and s.OBJ_TYPE = 1 order by s.CREATE_DATE desc  limit 1 ),0)  ",YwContractBill::getIsSendSms)
                        .selectAs(YwContract::getCode,YwContractBill::getContractCode)
                        .selectAs(YwCustomer::getName,YwContractBill::getCustomerName)
                        .leftJoin(YwContract.class,YwContract::getId,YwContractBill::getContractId)
@@ -398,12 +418,12 @@
                                YwContractBill::getBillType,model.getBillType())
                        .eq(Objects.nonNull(model)&&Objects.nonNull(model.getPayStatus()),
                                YwContractBill::getPayStatus,model.getPayStatus())
                        .in(Objects.nonNull(model)&&Objects.nonNull(model.getPayStatus()),
                                YwContractBill::getPayStatus,Constants.ZERO,Constants.THREE,Constants.TWO,Constants.FOUR)
                        .in(YwContractBill::getPayStatus,Constants.ZERO,Constants.TWO,Constants.THREE)
                        .eq(Objects.nonNull(model)&&Objects.nonNull(model.getType()),
                                YwContractBill::getType,model.getType())
                        .le(Objects.nonNull(model)&&Objects.nonNull(model.getIsOverdue())&&Constants.equalsInteger(model.getIsOverdue(),Constants.ONE),
                                YwContractBill::getPlanPayDate, DateUtil.getCurrDateTime())
                        .lt(YwContractBill::getPlanPayDate, DateUtil.getDate(new Date(),"yyyy-MM-dd"))
                        .eq(Objects.nonNull(model)&&Objects.nonNull(model.getIsOverdue())&&Constants.equalsInteger(model.getIsOverdue(),Constants.ONE),
                                YwContractBill::getStatus, Constants.ZERO)
                        .ge(Objects.nonNull(model)&&Objects.nonNull(model.getPlanPayDateStart()),YwContractBill::getPlanPayDate, Utils.Date.getStart(model.getPlanPayDateStart()))
@@ -448,7 +468,7 @@
        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractBillList)){
            //获取所有数据
            List<Integer> billIdList = ywContractBillList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.ONE)).map(i->i.getId()).collect(Collectors.toList());
            List<Integer> contractIdList = ywContractBillList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.ZERO)).map(i->i.getContractId()).collect(Collectors.toList());
            List<Integer> contractIdList = ywContractBillList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.ZERO)||Constants.equalsInteger(i.getType(),Constants.TWO)).map(i->i.getContractId()).collect(Collectors.toList());
            List<YwContractRoom> ywContractRoomList  = new ArrayList<>();
            if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(billIdList)){
                ywContractRoomList.addAll( ywContractRoomMapper.selectJoinList(YwContractRoom.class,new MPJLambdaWrapper<YwContractRoom>()
@@ -456,7 +476,7 @@
                        .selectAs(YwProject::getName,YwRoom::getProjectName)
                        .selectAs(YwFloor::getName,YwRoom::getFloorName)
                        .selectAs(YwBuilding::getName,YwRoom::getBuildingName)
                        .selectAs(YwRoom::getCode,YwContractRoom::getRoomName)
                        .selectAs(YwRoom::getRoomNum,YwContractRoom::getRoomName)
                        .leftJoin(YwRoom.class,YwRoom::getId,YwContractRoom::getRoomId)
                        .leftJoin(YwFloor.class,YwFloor::getId,YwRoom::getFloor)
                        .leftJoin(YwProject.class,YwProject::getId,YwRoom::getProjectId)
@@ -472,7 +492,7 @@
                        .selectAs(YwProject::getName,YwRoom::getProjectName)
                        .selectAs(YwFloor::getName,YwRoom::getFloorName)
                        .selectAs(YwBuilding::getName,YwRoom::getBuildingName)
                        .selectAs(YwRoom::getCode,YwContractRoom::getRoomName)
                        .selectAs(YwRoom::getRoomNum,YwContractRoom::getRoomName)
                        .leftJoin(YwRoom.class,YwRoom::getId,YwContractRoom::getRoomId)
                        .leftJoin(YwFloor.class,YwFloor::getId,YwRoom::getFloor)
                        .leftJoin(YwProject.class,YwProject::getId,YwRoom::getProjectId)
@@ -593,6 +613,7 @@
            .leftJoin(YwContract.class,YwContract::getId,YwContractBill::getContractId)
            .leftJoin(YwCustomer.class,YwCustomer::getId,YwContract::getRenterId)
            .eq(YwContractBill::getIsdeleted,Constants.ZERO)
            .eq(YwContractBill::getStatus,Constants.ZERO)
            .in(YwContractBill::getPayStatus,Constants.ZERO,Constants.TWO,Constants.THREE,Constants.FOUR)
            .eq(YwContractBill::getContractId,contractId)
            .orderByDesc(YwContractBill::getId);
@@ -682,12 +703,14 @@
                    .selectAs(YwContractDetail::getType,YwContractBill::getDetailType)
                    .selectAs(YwContract::getZlPayType,YwContractBill::getZlPayType)
                    .selectAs(YwContract::getWyPayType,YwContractBill::getWyPayType)
                    .select(" ( select ifnull(sum(r.rent_area),0) from yw_room y left join yw_contract_room yr on y.id = yr.room_id where yr.contract_id = t.contract_id and y.IS_INVESTMENT = 0 and yr.type = 0 )  " , YwContractBill::getTotalArea)
                    .select(" ( select ifnull(sum(y.rent_area),0) from yw_room y left join yw_contract_room yr on y.id = yr.room_id where yr.contract_id = t.contract_id and y.IS_INVESTMENT = 1 and yr.type = 0 )  " , YwContractBill::getTotalArea)
                    .select(" ( select ifnull( sum( CASE WHEN t.bill_type = 0 and yw.REVENUE_TYPE = 0 THEN yw.ACT_RECEIVABLE_FEE when  t.bill_type = 0 and yw.REVENUE_TYPE = 1 then -yw.ACT_RECEIVABLE_FEE  when t.bill_type = 1 and yw.REVENUE_TYPE = 0 then -yw.ACT_RECEIVABLE_FEE else  yw.ACT_RECEIVABLE_FEE END),0) from  yw_contract_revenue yw where yw.bill_id = t.id and yw.status = 0 and yw.isdeleted = 0 ) as  actReceivableFee  ")
                    .leftJoin(YwContract.class,YwContract::getId,YwContractBill::getContractId)
                    .leftJoin(YwCustomer.class,YwCustomer::getId,YwContract::getRenterId)
                    .leftJoin(YwContractDetail.class,YwContractDetail::getId,YwContractBill::getDetailId)
                    .in(YwContractBill::getId,billIds)
            );
            this.dealRoomDetail(ywContractBillList);
            List<YwTempConfig> ywTempConfigList = ywTempConfigMapper.selectList(new QueryWrapper<YwTempConfig>().lambda().eq(YwTempConfig::getIsdeleted,Constants.ZERO));
            if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(ywTempConfigList)){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未查询到模板配置项,请联系管理员");
@@ -700,7 +723,7 @@
            }
            List<File> fileList = new ArrayList<>();
            for (YwContractBill ywContractBill:ywContractBillList) {
                this.dealTempData(tempList,ywContractBill,loginUserInfo);
                List<YwTempConfig> dealList = this.dealTempData(tempList,ywContractBill,loginUserInfo);
                String fileName =  "催费通知单_" +ywContractBill.getCode() +"_" + System.currentTimeMillis()+".docx";
                YwTempConfig ywTempConfig = new YwTempConfig();
                if(Constants.equalsInteger(ywContractBill.getType(),Constants.ZERO)){
@@ -717,7 +740,7 @@
                if(Objects.isNull(ywTempConfig)){
                    throw  new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"模板信息异常,请联系管理员");
                }
                String path = ExcelReplaceCommon.modifyWordTemplate(ywTempConfig.getUrl(),tempList,fileName);
                String path = ExcelReplaceCommon.modifyWordTemplate(ywTempConfig.getUrl(),dealList,fileName,zipFilePath);
                File f = new File(path);
                if(f !=null && f.isFile()){
                    fileList.add(f);
@@ -739,9 +762,13 @@
    }
    public void dealTempData(List<YwTempConfig> ywTempConfigList , YwContractBill ywContractBill, LoginUserInfo loginUserInfo){
    public List<YwTempConfig> dealTempData(List<YwTempConfig> ywTempConfigList , YwContractBill ywContractBill, LoginUserInfo loginUserInfo){
        //查询收支账号数据
        YwAccount ywAccount = ywAccountMapper.selectOne(new QueryWrapper<YwAccount>().lambda().eq(YwAccount::getIsdeleted,Constants.ZERO).eq(YwAccount::getStatus,Constants.ZERO).eq(YwAccount::getCompanyId,ywContractBill.getCompanyId())
                        .orderByDesc(YwAccount::getId)
                .last(" limit 1 "));
        List<YwTempConfig> dealList = new ArrayList<>();
        for (YwTempConfig y:ywTempConfigList) {
            if(y.getTitle().equals("${费用名称}")&&Objects.nonNull(ywContractBill.getCostType())){
                //费用类型:0=租赁费;1=物业费;2=租赁押金;3=物业押金;4=水电费;5=杂项费;6=其他; 7=保证金
@@ -798,21 +825,21 @@
                    y.setUrl("元每平米天");
                }else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.ONE)){
                    y.setUrl("元每平米月");
                }else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.ONE)){
                }else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.TWO)){
                    y.setUrl("元每平米年");
                } else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.ONE)){
                } else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.THREE)){
                    y.setUrl("元每天");
                } else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.ONE)){
                } else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.FOUR)){
                    y.setUrl("元每月");
                } else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.ONE)){
                } else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.FIVE)){
                    y.setUrl("元每年");
                } else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.ONE)){
                } else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.SIX)){
                    y.setUrl("元每场");
                }
            }else if(y.getTitle().equals("${应收日期}")&&Objects.nonNull(ywContractBill.getPlanPayDate())){
                y.setUrl(DateUtil.formatDate(ywContractBill.getPlanPayDate(),"yyyy-MM-dd"));
            }else if(y.getTitle().equals("${应收金额}")&&Objects.nonNull(ywContractBill.getReceivableFee())){
                y.setUrl(ywContractBill.getReceivableFee().toString());
                y.setUrl((ywContractBill.getReceivableFee().subtract(ywContractBill.getActReceivableFee())).setScale(2).toString());
            }else if(y.getTitle().equals("${账单备注}")){
                if(StringUtils.isNotBlank(ywContractBill.getRemark())){
                    y.setUrl(ywContractBill.getRemark());
@@ -821,7 +848,7 @@
                }
            }else if(y.getTitle().equals("${租客名称}")&&StringUtils.isNotBlank(ywContractBill.getCustomerName())){
                y.setUrl(ywContractBill.getCustomerName());
            }else if(y.getTitle().equals("${楼宇/楼层/房源}")){
            }else if(y.getTitle().equals("${房间信息}")){
                if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractBill.getYwContractRoomList())){
                    StringBuilder roomPathName = new StringBuilder();
                    for (YwContractRoom ywContractRoom:ywContractBill.getYwContractRoomList()) {
@@ -846,21 +873,37 @@
            }else if(y.getTitle().equals("${租赁面积}")&&Objects.nonNull(ywContractBill.getTotalArea())){
                y.setUrl(ywContractBill.getTotalArea().toString());
            }else if(y.getTitle().equals("${所属公司账户名称}")){
                y.setUrl("所属公司账户名称");
                if(Objects.nonNull(ywAccount)&&StringUtils.isNotBlank(ywAccount.getName())){
                    y.setUrl(ywAccount.getName());
                }else{
                    y.setUrl("-");
                }
            }else if(y.getTitle().equals("${所属公司银行账号}")){
                y.setUrl("所属公司银行账号");
                if(Objects.nonNull(ywAccount)&&StringUtils.isNotBlank(ywAccount.getName())){
                    y.setUrl(ywAccount.getName());
                }else{
                    y.setUrl("-");
                }
            }else if(y.getTitle().equals("${所属公司开户银行}")){
                y.setUrl("所属公司开户银行");
                if(Objects.nonNull(ywAccount)&&StringUtils.isNotBlank(ywAccount.getBankNo())){
                    y.setUrl(ywAccount.getBankNo());
                }else{
                    y.setUrl("-");
                }
            }else if(y.getTitle().equals("${通知单生成日期}")){
                y.setUrl(DateUtil.formatDate(new Date(),"yyyy-MM-dd"));
            }else if(y.getTitle().equals("${当前用户姓名}")){
            }else if(y.getTitle().equals("${制表人名称}")){
                y.setUrl(loginUserInfo.getRealname());
            }
            dealList.add(y);
        }
        return dealList;
    }
    public void sendSmsEmail(List<YwSmsEmailBillCallDTO> ywSmsEmailBillCallDTOList,LoginUserInfo loginUserInfo){
    @Override
    public void sendSmsEmail(List<YwSmsEmailBillCallDTO> ywSmsEmailBillCallDTOList,SmsEmailServiceImpl smsEmailService,LoginUserInfo loginUserInfo){
        if(CollectionUtils.isEmpty(ywSmsEmailBillCallDTOList)){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
@@ -874,12 +917,15 @@
        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(tempList)){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未查询到模板配置项,请联系管理员");
        }
        Optional<YwTempConfig> smsTempConfigOptional = ywTempConfigList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.ZERO)).findAny();
        Optional<YwTempConfig> emailTempConfigOptional = ywTempConfigList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.ONE)).findAny();
        for (YwSmsEmailBillCallDTO ywSmsEmailBillCallDTO:ywSmsEmailBillCallDTOList) {
            if(Objects.isNull(ywSmsEmailBillCallDTO)
            || Objects.isNull(ywSmsEmailBillCallDTO.getBillId())
                    || Objects.isNull(ywSmsEmailBillCallDTO.getBillId())
                    || Objects.isNull(ywSmsEmailBillCallDTO.getUserId())
            ||Objects.isNull(ywSmsEmailBillCallDTO.getSendEmail())
                    || Objects.isNull(ywSmsEmailBillCallDTO.getSendSms())){
                    ||Objects.isNull(ywSmsEmailBillCallDTO.getSendEmail())
                    || Objects.isNull(ywSmsEmailBillCallDTO.getSendSms())
            ){
                throw new BusinessException(ResponseStatus.BAD_REQUEST);
            }
@@ -894,41 +940,177 @@
                    .selectAs(YwContractDetail::getType,YwContractBill::getDetailType)
                    .selectAs(YwContract::getZlPayType,YwContractBill::getZlPayType)
                    .selectAs(YwContract::getWyPayType,YwContractBill::getWyPayType)
                    .select(" ( select ifnull(sum(r.rent_area),0) from yw_room y left join yw_contract_room yr on y.id = yr.room_id where yr.contract_id = t.contract_id and y.IS_INVESTMENT = 0 and yr.type = 0 )  " , YwContractBill::getTotalArea)
                    .select(" ( select ifnull(sum(y.rent_area),0) from yw_room y left join yw_contract_room yr on y.id = yr.room_id where yr.contract_id = t.contract_id and y.IS_INVESTMENT = 1 and yr.type = 0 )  " , YwContractBill::getTotalArea)
                    .leftJoin(YwContract.class,YwContract::getId,YwContractBill::getContractId)
                    .leftJoin(YwCustomer.class,YwCustomer::getId,YwContract::getRenterId)
                    .leftJoin(YwContractDetail.class,YwContractDetail::getId,YwContractBill::getDetailId)
                    .eq(YwContractBill::getId,ywSmsEmailBillCallDTO.getBillId())
                    .last( "limit 1" )
            );
            this.dealTempData(tempList,ywContractBill,loginUserInfo);
            List<YwContractBill> ywContractBillList = new ArrayList<>();
            ywContractBillList.add(ywContractBill);
            this.dealRoomDetail(ywContractBillList);
//            this.dealTempData(tempList,ywContractBill,loginUserInfo);
            Member member = memberMapper.selectById(ywSmsEmailBillCallDTO.getUserId());
            if(Objects.isNull(member)){
                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"存在未查询到的人员信息");
            }
            if(Objects.nonNull(member)){
                if(Constants.equalsInteger(ywSmsEmailBillCallDTO.getSendSms(),Constants.ONE) && StringUtils.isNotBlank(member.getPhone())
                 && smsTempConfigOptional.isPresent()){
                    String content = this.dealTempSmsEmailData(smsTempConfigOptional.get().getTitle(),tempList,ywContractBill,loginUserInfo);
                    smsEmailService.sendBillSms(content,member.getPhone(),ywContractBill.getId());
                }
                if(Constants.equalsInteger(ywSmsEmailBillCallDTO.getSendEmail(),Constants.ONE) && StringUtils.isNotBlank(member.getEmail())
                        && emailTempConfigOptional.isPresent()){
                    String content = this.dealTempSmsEmailData(emailTempConfigOptional.get().getTitle(),tempList,ywContractBill,loginUserInfo);
                    smsEmailService.sendEmail(member.getEmail(),content,ywContractBill.getId());
                }
            }
        }
    }
        for (YwSmsEmailBillCallDTO ywSmsEmailBillCallDTO:ywSmsEmailBillCallDTOList) {
    public String  dealTempSmsEmailData(String tempStr,List<YwTempConfig> ywTempConfigList , YwContractBill ywContractBill, LoginUserInfo loginUserInfo){
        //查询收支账号数据
        YwAccount ywAccount = ywAccountMapper.selectOne(new QueryWrapper<YwAccount>().lambda().eq(YwAccount::getIsdeleted,Constants.ZERO).eq(YwAccount::getStatus,Constants.ZERO).eq(YwAccount::getCompanyId,ywContractBill.getCompanyId())
                .orderByDesc(YwAccount::getId)
                .last(" limit 1 "));
        for (YwTempConfig y:ywTempConfigList) {
            if(y.getTitle().equals("${费用名称}")&&Objects.nonNull(ywContractBill.getCostType())){
                //费用类型:0=租赁费;1=物业费;2=租赁押金;3=物业押金;4=水电费;5=杂项费;6=其他; 7=保证金
                if(Constants.equalsInteger(ywContractBill.getCostType(),Constants.ZERO)){
                    tempStr = tempStr.replace("${费用名称}","租赁费");
                }else if(Constants.equalsInteger(ywContractBill.getCostType(),Constants.ONE)){
                    tempStr = tempStr.replace("${费用名称}","物业费");
                }else if(Constants.equalsInteger(ywContractBill.getCostType(),Constants.TWO)){
                    tempStr = tempStr.replace("${费用名称}","租赁押金");
                }else if(Constants.equalsInteger(ywContractBill.getCostType(),Constants.THREE)){
                  tempStr =   tempStr.replace("${费用名称}","物业押金");
                }else if(Constants.equalsInteger(ywContractBill.getCostType(),Constants.FOUR)){
                  tempStr =   tempStr.replace("${费用名称}","水电费");
                }else if(Constants.equalsInteger(ywContractBill.getCostType(),Constants.FIVE)){
                  tempStr =   tempStr.replace("${费用名称}","杂项费");
                }else if(Constants.equalsInteger(ywContractBill.getCostType(),Constants.SIX)){
                  tempStr =   tempStr.replace("${费用名称}","其他");
                }else if(Constants.equalsInteger(ywContractBill.getCostType(),Constants.SEVEN)){
                  tempStr =   tempStr.replace("${费用名称}","保证金");
                }
            }else if(y.getTitle().equals("${计费周期}")){
                if(Objects.nonNull(ywContractBill.getDetailType())){
                    if(Constants.equalsInteger(ywContractBill.getDetailType(),Constants.ZERO)){
                        //租赁支付方式 0=一次性付款;1=每三个月一付;2=六个月一付;3=一年一付
                        if(Objects.nonNull(ywContractBill.getZlPayType())){
                            if(Constants.equalsInteger(ywContractBill.getZlPayType(),Constants.ZERO)){
                                tempStr = tempStr.replace("${计费周期}","一次性付款");
                            }else if(Constants.equalsInteger(ywContractBill.getZlPayType(),Constants.ONE)){
                                tempStr = tempStr.replace("${计费周期}","每三个月一付");
                            }else if(Constants.equalsInteger(ywContractBill.getZlPayType(),Constants.TWO)){
                                tempStr = tempStr.replace("${计费周期}","六个月一付");
                            }else if(Constants.equalsInteger(ywContractBill.getZlPayType(),Constants.THREE)){
                                tempStr = tempStr.replace("${计费周期}","一年一付");
                            }
                        }
                    }else{
                        //物业支付方式 0=一次性付款;1=每三个月一付;2=六个月一付;3=一年一付
                        if(Objects.nonNull(ywContractBill.getWyPayType())){
                            if(Constants.equalsInteger(ywContractBill.getWyPayType(),Constants.ZERO)){
                                tempStr = tempStr.replace("${计费周期}","一次性付款");
                            }else if(Constants.equalsInteger(ywContractBill.getWyPayType(),Constants.ONE)){
                                tempStr = tempStr.replace("${计费周期}","每三个月一付");
                            }else if(Constants.equalsInteger(ywContractBill.getWyPayType(),Constants.TWO)){
                                tempStr = tempStr.replace("${计费周期}","六个月一付");
                            }else if(Constants.equalsInteger(ywContractBill.getWyPayType(),Constants.THREE)){
                                tempStr.replace("${计费周期}","一年一付");
                            }
                        }
                    }
                }else{
                    tempStr = tempStr.replace("${计费周期}","");
                }
            }else if(y.getTitle().equals("${单价}")&&Objects.nonNull(ywContractBill.getPrice())){
                tempStr = tempStr.replace("${单价}",ywContractBill.getPrice().setScale(2).toString());
            }else if(y.getTitle().equals("${单位}")&&Objects.nonNull(ywContractBill.getCircleType())){
                //付款周期类型 0=元每平米天;1=元每平米月;2=元每平米年;3=元每天;4=元每月;5=元每年;6=元每场;
                if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.ZERO)){
                  tempStr =   tempStr.replace("${单位}","元每平米天");
                }else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.ONE)){
                  tempStr =   tempStr.replace("${单位}","元每平米月");
                }else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.TWO)){
                  tempStr =   tempStr.replace("${单位}","元每平米年");
                } else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.THREE)){
                  tempStr =   tempStr.replace("${单位}","元每天");
                } else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.FOUR)){
                  tempStr =   tempStr.replace("${单位}","元每月");
                } else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.FIVE)){
                  tempStr =   tempStr.replace("${单位}","元每年");
                } else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.SIX)){
                  tempStr =   tempStr.replace("${单位}","元每场");
                }
            }else if(y.getTitle().equals("${应收日期}")&&Objects.nonNull(ywContractBill.getPlanPayDate())){
                tempStr = tempStr.replace("${应收日期}",DateUtil.formatDate(ywContractBill.getPlanPayDate(),"yyyy-MM-dd"));
            }else if(y.getTitle().equals("${应收金额}")&&Objects.nonNull(ywContractBill.getReceivableFee())){
                tempStr = tempStr.replace("${应收金额}",(ywContractBill.getReceivableFee().subtract(ywContractBill.getActReceivableFee())).setScale(2).toString());
            }else if(y.getTitle().equals("${账单备注}")){
                if(StringUtils.isNotBlank(ywContractBill.getRemark())){
                  tempStr =   tempStr.replace("${账单备注}",ywContractBill.getRemark());
                }else{
                  tempStr =   tempStr.replace("${账单备注}","");
                }
            }else if(y.getTitle().equals("${租客名称}")&&StringUtils.isNotBlank(ywContractBill.getCustomerName())){
                tempStr = tempStr.replace("${租客名称}",ywContractBill.getCustomerName());
            }else if(y.getTitle().equals("${房间信息}")){
                if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractBill.getYwContractRoomList())){
                    StringBuilder roomPathName = new StringBuilder();
                    for (YwContractRoom ywContractRoom:ywContractBill.getYwContractRoomList()) {
                        if(StringUtils.isNotBlank(ywContractRoom.getProjectName())){
                            roomPathName.append(ywContractRoom.getProjectName()+"/");
                        }
                        if(StringUtils.isNotBlank(ywContractRoom.getBuildingName())){
                            roomPathName.append(ywContractRoom.getBuildingName()+"/");
                        }
                        if(StringUtils.isNotBlank(ywContractRoom.getFloorName())){
                            roomPathName.append(ywContractRoom.getFloorName()+"/");
                        }
                        if(StringUtils.isNotBlank(ywContractRoom.getRoomName())){
                            roomPathName.append(ywContractRoom.getRoomName());
                        }
                        if(StringUtils.isNotBlank(roomPathName)){
                            roomPathName.append(";");
                        }
                    }
                    tempStr = tempStr.replace("${房间信息}",roomPathName.toString());
                }
            }else if(y.getTitle().equals("${租赁面积}")&&Objects.nonNull(ywContractBill.getTotalArea())){
                tempStr.replace("${租赁面积}",ywContractBill.getTotalArea().toString());
            }else if(y.getTitle().equals("${所属公司账户名称}")){
                if(Objects.nonNull(ywAccount)&&StringUtils.isNotBlank(ywAccount.getName())){
                  tempStr =   tempStr.replace("${所属公司账户名称}",ywAccount.getName());
                }else{
                  tempStr =   tempStr.replace("${所属公司账户名称}","-");
                }
            }else if(y.getTitle().equals("${所属公司银行账号}")){
                if(Objects.nonNull(ywAccount)&&StringUtils.isNotBlank(ywAccount.getName())){
                  tempStr =   tempStr.replace("${所属公司银行账号}",ywAccount.getName());
                }else{
                  tempStr =   tempStr.replace("${所属公司银行账号}","-");
                }
            }else if(y.getTitle().equals("${所属公司开户银行}")){
                if(Objects.nonNull(ywAccount)&&StringUtils.isNotBlank(ywAccount.getBankNo())){
                  tempStr =   tempStr.replace("${所属公司开户银行}",ywAccount.getBankNo());
                }else{
                  tempStr =   tempStr.replace("${所属公司开户银行}","-");
                }
            }else if(y.getTitle().equals("${通知单生成日期}")){
                tempStr = tempStr.replace("${通知单生成日期}",DateUtil.formatDate(new Date(),"yyyy-MM-dd"));
            }else if(y.getTitle().equals("${制表人名称}")){
                tempStr = tempStr.replace("${制表人名称}",loginUserInfo.getRealname());
            }
        }
        return tempStr;
    }