renkang
2024-12-04 2a0d7762b0113bba17bd50203360ec669aa20b18
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractServiceImpl.java
@@ -131,8 +131,8 @@
                    .eq(YwContractRoom::getType,Constants.ZERO)
                    .in(YwContractRoom::getRoomId,roomIds)
                    .in(YwContract::getStatus,Constants.THREE)
                    .apply(" ( t.START_DATE < '"+DateUtil.getFomartDate(model.getBtDate(),"yyyy-MM-dd HH:mm:ss")+"' " +
                            " and t.END_DATE > '"+DateUtil.getFomartDate(model.getStartDate(),"yyyy-MM-dd HH:mm:ss")+"' ) " )
                    .apply(" ( t.START_DATE < '"+DateUtil.getFomartDate(model.getEndDate(),"yyyy-MM-dd HH:mm:ss")+"' " +
                            " and t.BT_DATE > '"+DateUtil.getFomartDate(model.getStartDate(),"yyyy-MM-dd HH:mm:ss")+"' ) " )
            )>Constants.ZERO){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"房源已被占用请刷新重试");
            };
@@ -189,7 +189,7 @@
            if(!(model.getZlFreeEndDate()==null &&  model.getZlFreeStartDate()==null) && (
                    (model.getZlFreeEndDate()!=null &&  model.getZlFreeStartDate()==null)
                            ||(model.getZlFreeEndDate()==null &&  model.getZlFreeStartDate()!=null)
                            ||model.getZlFreeEndDate().getTime()<= model.getZlFreeStartDate().getTime())
                            ||model.getZlFreeEndDate().getTime()< model.getZlFreeStartDate().getTime())
            ){
                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,请选择正确的租赁条款免租期信息!");
            }
@@ -242,7 +242,7 @@
                ){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,请按页面要求填写物业条款信息!");
                }
                if(d.getEndDate().getTime()<= d.getStartDate().getTime()){
                if(d.getEndDate().getTime()< d.getStartDate().getTime()){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,物业条款有效期结束时间不得早于开始时间!");
                }
                if(!Constants.equalsInteger(model.getWyPayType(),Constants.ZERO) &&
@@ -303,9 +303,10 @@
        BigDecimal fee = Constants.formatBigdecimal(model.getBtFee());
        String str = "退租摘要:剩余未结清账单{param1}份,关闭账单{param2}份【退租日{param3},退租费用合计需{param4}{param5}元。】";
        str = str.replace("{param1}",model.getBtWaitBill()+"")
                .replace("{param2}",DateUtil.getDateLongSlash(model.getBtDate()))
                .replace("{param3}",fee.compareTo(new BigDecimal(0)) >=0?"收":"付")
                .replace("{param4}",(fee.compareTo(new BigDecimal(0)) >=0?
                .replace("{param2}",Integer.toString(model.getBtCLoseBill()))
                .replace("{param3}",DateUtil.getDateLongSlash(model.getBtDate()))
                .replace("{param4}",fee.compareTo(new BigDecimal(0)) >=0?"收":"付")
                .replace("{param5}",(fee.compareTo(new BigDecimal(0)) >=0?
                        Constants.formatBigdecimal(model.getBtFee()).intValue()
                        :(Constants.formatBigdecimal(model.getBtFee()).intValue() * -1))+"" );
        return  str;
@@ -505,6 +506,8 @@
                    addBill.setBtFee(Constants.formatBigdecimal(addBill.getActReceivableFee()).multiply(new BigDecimal(-1)));
                }
                totalBackFee = totalBackFee.add(Constants.formatBigdecimal(addBill.getBtFee()));
                addBill.setCreator(param.getEditor());
                addBill.setCreateDate(param.getEditDate());
                addBill.setEditDate(param.getEditDate());
                addBill.setEditor(param.getEditor());
                addBill.setBtActDate(param.getBtActDate());
@@ -532,12 +535,18 @@
                        yjBill.setEditDate(param.getEditDate());
                        yjBill.setEditor(param.getEditor());
                        yjBill.setReceivableFee(BigDecimal.ZERO);
                        yjBill.setPayStatus(Constants.FOUR);
                        if(bill.getActReceivableFee().compareTo(BigDecimal.ZERO)==Constants.ZERO){
                            yjBill.setPayStatus(Constants.FIVE);
                            yjBill.setStatus(Constants.ONE);
                        }else{
                            yjBill.setPayStatus(Constants.FOUR);
                            yjNoBills ++;
                        }
                        yjBill.setPlanPayDate(canBill.getPlanPayDate());
                        ywContractBillMapper.updateById(yjBill);
                    }
                }
                yjNoBills ++;
            }
        }
        param.setBtWaitBill(canBills.size() + newBills.size()+yjNoBills);//未清算的账单数量
@@ -917,6 +926,7 @@
            bill.setTotleFee(getTotalFeeByStartEnd(model,d,bill,freeStart,freeEnd));
            bill.setReceivableFee(bill.getTotleFee());
            bill.setBillType(Constants.ZERO);
            bill.setCompanyId(model.getCompanyId());
            list.add(bill);
        }
        return list;
@@ -1036,7 +1046,7 @@
            if(!(model.getZlFreeEndDate()==null &&  model.getZlFreeStartDate()==null) && (
                        (model.getZlFreeEndDate()!=null &&  model.getZlFreeStartDate()==null)
                        ||(model.getZlFreeEndDate()==null &&  model.getZlFreeStartDate()!=null)
                        ||model.getZlFreeEndDate().getTime()<= model.getZlFreeStartDate().getTime())
                        ||model.getZlFreeEndDate().getTime()< model.getZlFreeStartDate().getTime())
                  ){
                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,请选择正确的租赁条款免租期信息!");
            }
@@ -1065,7 +1075,7 @@
                        Constants.equalsInteger(d.getCircleType(),Constants.SIX)){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,租赁条款只有选择一次性付款时,才能选择该按每场收费;");
                }
                if(model.getZlFirstCircle() == null){//首期信息
                if(model.getZlFirstPrice() == null){//首期信息
                    model.setZlFirstPrice(d.getPrice());
                    model.setZlFirstCircle(d.getCircleType());
                }
@@ -1114,7 +1124,7 @@
                        Constants.equalsInteger(d.getCircleType(),Constants.SIX)){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,物业条款只有选择一次性付款时,才能选择该按每场收费;");
                }
                if(model.getWyFirstCircle() == null){
                if(model.getWyFirstPrice() == null){
                    //首期信息
                    model.setWyFirstPrice(d.getPrice());
                    model.setWyFirstCircle(d.getCircleType());
@@ -1278,7 +1288,8 @@
            //查询账单集合
            model.setBillList(ywContractBillMapper.selectJoinList(YwContractBill.class,new MPJLambdaWrapper<YwContractBill>()
                            .selectAll(YwContractBill.class )
                            .select(" ( select ifnull(sum(case when 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(" ( select ifnull(sum(case when 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(" ( 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  ")
                            .eq(  YwContractBill::getContractId,model.getId())
                            .eq(YwContractBill::getIsdeleted,Constants.ZERO)
                            .orderByAsc(YwContractBill::getSortnum,YwContractBill::getCreateDate)));