MrShi
2024-12-05 c40579692637afaecbd4b63422efa66f3fa9de42
Merge branch 'master' of http://139.186.142.91:10010/r/productDev/funingyunwei
已修改5个文件
138 ■■■■ 文件已修改
server/system_gateway/src/main/resources/bootstrap.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/YwContractCloudController.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_admin/src/main/resources/bootstrap.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/YwContractService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractServiceImpl.java 126 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/system_gateway/src/main/resources/bootstrap.yml
@@ -1,6 +1,6 @@
spring:
  profiles:
    active: test
    active: dev
  application:
    name: system_gateway
  # 安全配置
server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/YwContractCloudController.java
@@ -103,6 +103,12 @@
    public ApiResponse<List<YwContract>> list (@RequestBody YwContract model,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        return ApiResponse.success(ywContractService.findList(model));
    }
    @ApiOperation("列表")
    @PostMapping("/findForBills")
    @CloudRequiredPermission("business:ywcontract:query")
    public ApiResponse<YwContract> findForBills (@RequestBody YwContract model,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        return ApiResponse.success(ywContractService.findForBills(model));
    }
    @ApiOperation("导出Excel")
server/visits/dmvisit_admin/src/main/resources/bootstrap.yml
@@ -1,6 +1,6 @@
spring:
  profiles:
    active: test
    active: dev
  application:
    name: visitsAdmin
    # 安全配置
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/YwContractService.java
@@ -65,7 +65,7 @@
     * @return YwContract
     */
    YwContract findById(Integer id);
    YwContract findForBills(YwContract model);
    /**
     * 条件查询单条记录
     *
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractServiceImpl.java
@@ -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,10 +303,9 @@
        BigDecimal fee = Constants.formatBigdecimal(model.getBtFee());
        String str = "退租摘要:剩余未结清账单{param1}份,关闭账单{param2}份【退租日{param3},退租费用合计需{param4}{param5}元。】";
        str = str.replace("{param1}",model.getBtWaitBill()+"")
                .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?
                .replace("{param2}",DateUtil.getDateLongSlash(model.getBtDate()))
                .replace("{param3}",fee.compareTo(new BigDecimal(0)) >=0?"收":"付")
                .replace("{param4}",(fee.compareTo(new BigDecimal(0)) >=0?
                        Constants.formatBigdecimal(model.getBtFee()).intValue()
                        :(Constants.formatBigdecimal(model.getBtFee()).intValue() * -1))+"" );
        return  str;
@@ -353,6 +352,9 @@
        update.setBtFee(param.getBtFee());
        update.setBtRemark(getbackRentRemarkByParam(param));
        ywContractMapper.updateById(update);
//        if(1==1){
//            throw new BusinessException(ResponseStatus.NOT_ALLOWED);
//        }
        dealLogBiz(param,Constants.YwLogType.CONTRACT_BACK, param.getLoginUserInfo().getRealname(),getbackRentLogByParam(param));
        return param.getId();
    }
@@ -480,17 +482,12 @@
                totalBackFee = totalBackFee.add(fee);//累计退款金额
            }
        }
        List<YwContractBill> ywContractBillList = ywContractBillMapper.selectList(new QueryWrapper<YwContractBill>()
                .lambda().eq(YwContractBill::getContractId,param.getId()).orderByDesc(YwContractBill::getId));
        Integer sortNum = ywContractBillList.size();
        if(param.getAddBillList()!=null && param.getAddBillList().size()>0){
            for(YwContractBill addBill : param.getAddBillList()){
                sortNum = sortNum + 1 ;
                addBill.setIsdeleted(Constants.ZERO);
                addBill.setContractId(param.getId());
                addBill.setType(Constants.ONE);
                addBill.setStatus(Constants.ZERO);
                addBill.setTotleFee(addBill.getReceivableFee());
                if(Constants.equalsInteger(addBill.getFeeType(),Constants.ONE)){
                    addBill.setStartDate(addBill.getPlanPayDate());
                    addBill.setEndDate(addBill.getPlanPayDate());
@@ -506,8 +503,6 @@
                    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());
@@ -516,7 +511,6 @@
                addBill.setBtUserId(param.getBtUserId());
                addBill.setBtSignDate(param.getBtSignDate());
                addBill.setBtType(param.getBtType());
                addBill.setSortnum(sortNum );
                newBills.add(addBill);
            }
            ywContractBillMapper.insert(param.getAddBillList());//批量插入数据
@@ -535,18 +529,12 @@
                        yjBill.setEditDate(param.getEditDate());
                        yjBill.setEditor(param.getEditor());
                        yjBill.setReceivableFee(BigDecimal.ZERO);
                        if(bill.getActReceivableFee().compareTo(BigDecimal.ZERO)==Constants.ZERO){
                            yjBill.setPayStatus(Constants.FIVE);
                            yjBill.setStatus(Constants.ONE);
                        }else{
                            yjBill.setPayStatus(Constants.FOUR);
                            yjNoBills ++;
                        }
                        yjBill.setPayStatus(Constants.FOUR);
                        yjBill.setPlanPayDate(canBill.getPlanPayDate());
                        ywContractBillMapper.updateById(yjBill);
                    }
                }
                yjNoBills ++;
            }
        }
        param.setBtWaitBill(canBills.size() + newBills.size()+yjNoBills);//未清算的账单数量
@@ -701,15 +689,12 @@
        }
        int num =1;
        for(int i=0;i<billList1.size();i++){
            if(Constants.equalsInteger( billList1.get(i).getCostType(),Constants.ZERO)){
                billList1.get(i).setSortnum(num++);
            }
            billList1.get(i).setSortnum(num);
            num++;
        }
        num =1;
        for(int i=0;i<billList2.size();i++){
            if(Constants.equalsInteger( billList2.get(i).getCostType(),Constants.ONE)){
                billList2.get(i).setSortnum(num++);
            }
            billList2.get(i).setSortnum(num);
            num++;
        }
        if(model.getId()!=null){
            ywContractBillMapper.insert(billList1);
@@ -926,7 +911,6 @@
            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;
@@ -1046,7 +1030,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(),"对不起,请选择正确的租赁条款免租期信息!");
            }
@@ -1075,7 +1059,7 @@
                        Constants.equalsInteger(d.getCircleType(),Constants.SIX)){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,租赁条款只有选择一次性付款时,才能选择该按每场收费;");
                }
                if(model.getZlFirstPrice() == null){//首期信息
                if(model.getZlFirstCircle() == null){//首期信息
                    model.setZlFirstPrice(d.getPrice());
                    model.setZlFirstCircle(d.getCircleType());
                }
@@ -1124,7 +1108,7 @@
                        Constants.equalsInteger(d.getCircleType(),Constants.SIX)){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,物业条款只有选择一次性付款时,才能选择该按每场收费;");
                }
                if(model.getWyFirstPrice() == null){
                if(model.getWyFirstCircle() == null){
                    //首期信息
                    model.setWyFirstPrice(d.getPrice());
                    model.setWyFirstCircle(d.getCircleType());
@@ -1286,47 +1270,55 @@
                    .orderByAsc(YwWorkorderLog::getCreateDate)));
            //查询账单集合
            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 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)));
            for (YwContractBill ywContractBill:model.getBillList()) {
                ywContractBill.setNeedReceivableFee(ywContractBill.getReceivableFee().subtract(ywContractBill.getActReceivableFee()));
            }
            queryBillListByModel(model,new Date());
        }
        return model;
    }
    @Override
    public YwContract findForBills(YwContract model) {
        queryBillListByModel(model,model.getBtDate());
        return model;
            model.setCanBackRentBills(new ArrayList<>());
            long nowStart = Utils.Date.getStart(new Date()).getTime();
            long nowEnd = Utils.Date.getEnd(new Date()).getTime();
            if(model.getBillList()!=null && model.getBillList().size()>0){
                for(YwContractBill bill: model.getBillList()){
                    //付款状态:0=待收款;1=已结清;2=部分结清;3=待付款;4=待退款;5=已关闭
                    if(Constants.equalsInteger(bill.getPayStatus(),Constants.ZERO)
                            ||Constants.equalsInteger(bill.getPayStatus(),Constants.THREE)){
                        if(bill.getStartDate().getTime()>nowEnd){
                            //如果还没开始,账单直接关闭
                            continue;
                        }
                        model.getCanBackRentBills().add(bill);
    }
    private void queryBillListByModel(YwContract model,Date date) {
        //查询账单集合
        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 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)));
                    }else  if(Constants.equalsInteger(bill.getPayStatus(),Constants.ONE) ){
                        if(bill.getEndDate().getTime()<nowStart){
                            //如果已结清,账单直接关闭
                            continue;
                        }
                        model.getCanBackRentBills().add(bill);
                    }else  if(Constants.equalsInteger(bill.getPayStatus(),Constants.TWO) ){
                        model.getCanBackRentBills().add(bill);
        for (YwContractBill ywContractBill:model.getBillList()) {
            ywContractBill.setNeedReceivableFee(ywContractBill.getReceivableFee().subtract(ywContractBill.getActReceivableFee()));
        }
        model.setCanBackRentBills(new ArrayList<>());
        long nowStart = Utils.Date.getStart(date).getTime();
        long nowEnd = Utils.Date.getEnd(date).getTime();
        if(model.getBillList()!=null && model.getBillList().size()>0){
            for(YwContractBill bill: model.getBillList()){
                //付款状态:0=待收款;1=已结清;2=部分结清;3=待付款;4=待退款;5=已关闭
                if(Constants.equalsInteger(bill.getPayStatus(),Constants.ZERO)
                        ||Constants.equalsInteger(bill.getPayStatus(),Constants.THREE)){
                    if(bill.getStartDate().getTime()>nowEnd){
                        //如果还没开始,账单直接关闭
                        continue;
                    }
                    model.getCanBackRentBills().add(bill);
                }else  if(Constants.equalsInteger(bill.getPayStatus(),Constants.ONE) ){
                    if(bill.getEndDate().getTime()<nowStart){
                        //如果已结清,账单直接关闭
                        continue;
                    }
                    model.getCanBackRentBills().add(bill);
                }else  if(Constants.equalsInteger(bill.getPayStatus(),Constants.TWO) ){
                    model.getCanBackRentBills().add(bill);
                }
            }
        }
        return model;
    }
    @Override