feat: 1.修改统计跟随查询变化
2.修改账单分页查询排序,新增按状态排序权重表
3.新增修改账单金额接口
7个文件已修改
300 ■■■■ 已修改文件
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBillController.java 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TBillController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/dto/TbillSaveDto.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TBillMapper.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java 73 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TBillMapper.xml 166 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBillController.java
@@ -22,6 +22,7 @@
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotEmpty;
import java.math.BigDecimal;
import java.util.List;
/**
@@ -58,6 +59,14 @@
        return R.ok(pageInfo);
    }
    @ApiOperation("统计")
    @PostMapping("statistics")
    public R<BillStatisticsDto> statistics(@RequestBody TBillQuery query){
        query.setBusinessDeptId(SecurityUtils.getBusinessDeptId());
        BillStatisticsDto dto = tBillService.statistics(query);
        return R.ok(dto);
    }
    @ApiOperation(value = "获取合同分页列表")
    @PostMapping(value = "/contractList")
@@ -69,9 +78,25 @@
    @PreAuthorize("@ss.hasPermi('bill:list:addRent')")
    @PostMapping("add")
    @ApiOperation("新增账单")
    public R<PageInfo<TBillDto>> add(@Validated @RequestBody TbillSaveDto bill){
    public R add(@Validated @RequestBody TbillSaveDto bill){
        bill.setBusinessDeptId(SecurityUtils.getBusinessDeptId());
        tBillService.saveBill(bill);
        return R.ok();
    }
    @PreAuthorize("@ss.hasPermi('bill:list:editAmount')")
    @PostMapping("editAmount")
    @ApiOperation("修改账单金额")
    public R editAmount(@Validated @RequestBody TbillSaveDto bill){
        if (StringUtils.isEmpty(bill.getId())){
            return R.fail("参数错误");
        }
        if (bill.getEditAmount().compareTo(BigDecimal.ZERO)==0){
            return R.fail("调整金额不能为0");
        }
        tBillService.editAmount(bill);
        return R.ok();
    }
@@ -134,12 +159,7 @@
    }
    @ApiOperation("统计")
    @GetMapping("statistics")
    public R<BillStatisticsDto> statistics(){
        BillStatisticsDto dto = tBillService.statistics(SecurityUtils.getBusinessDeptId());
        return R.ok(dto);
    }
ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TBillController.java
@@ -64,7 +64,7 @@
    public R<PageInfo<TBillDto>> list(@RequestBody TBillQuery query){
        String userId = tokenService.getLoginUserApplet().getUserId();
        query.setUserId(userId);
        PageInfo<TBillDto> pageInfo = tBillService.queryPage(query);
        PageInfo<TBillDto> pageInfo = tBillService.queryPageForApplet(query);
        return R.ok(pageInfo);
    }
ruoyi-system/src/main/java/com/ruoyi/system/dto/TbillSaveDto.java
@@ -6,6 +6,7 @@
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
@Data
@@ -13,8 +14,11 @@
    @ApiModelProperty(value = "水电费列表")
    private List<TBillDetail> details;
    /**
     *
     */
    @ApiModelProperty(value = "调整金额(有违约金,就调整违约金并调整欠费,没有违约金,就直接调整欠费)")
    private BigDecimal editAmount;
}
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TBillMapper.java
@@ -25,6 +25,8 @@
    PageInfo<TBillDto> page(@Param("pageInfo") PageInfo<TBill> pageInfo, @Param("query") TBillQuery query);
    PageInfo<TBillDto> pageForApplet(@Param("pageInfo") PageInfo<TBill> pageInfo, @Param("query") TBillQuery query);
    List<TBillDto> getBillList(@Param("query")TBillQuery query);
    /**
@@ -37,13 +39,13 @@
    TBillDto selectDetailByBillId(@Param("billId") String billId);
    BigDecimal statisticsAllRent(@Param("busDeptId") String busDeptId);
    BigDecimal statisticsAllRent(@Param("query") TBillQuery query);
    BigDecimal statisticsNoPay(@Param("busDeptId") String busDeptId);
    BigDecimal statisticsNoPay(@Param("query") TBillQuery query);
    BigDecimal statisticsPayed(@Param("busDeptId") String busDeptId);
    BigDecimal statisticsPayed(@Param("query") TBillQuery query);
    BigDecimal statisticsOverdue(@Param("busDeptId") String busDeptId);
    BigDecimal statisticsOverdue(@Param("query") TBillQuery query);
    Integer batchBillCount(@Param("userId")String userId, @Param("billIds")List<String> billIds);
    /**
ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java
@@ -30,6 +30,9 @@
    PageInfo<TBillDto> queryPage(TBillQuery query);
    PageInfo<TBillDto> queryPageForApplet(TBillQuery query);
    /**
     *
     * 更新类型  1.仅更新信息及状态 2.更新金额及状态
@@ -87,7 +90,7 @@
    Boolean cashPay(CachPayDto offlinePayDto);
    BillStatisticsDto statistics(String busdeptId);
    BillStatisticsDto statistics(TBillQuery query);
    Integer batchBillCount(String userId, List<String> billIds);
@@ -96,4 +99,6 @@
     * @return
     */
    List<ScreenRentRankVO> getStreetRentRank();
    void editAmount(TbillSaveDto bill);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java
@@ -6,11 +6,7 @@
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.OrderNos;
import com.ruoyi.common.utils.SmsUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.TencentMailUtil;
import com.ruoyi.common.utils.*;
import com.ruoyi.common.utils.uuid.UUID;
import com.ruoyi.system.dto.BillStatisticsDto;
import com.ruoyi.system.dto.CachPayDto;
@@ -40,6 +36,7 @@
import com.taxi591.bankapi.dto.ChargeBillRequest;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.joda.time.LocalDateTime;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -105,6 +102,12 @@
    public PageInfo<TBillDto> queryPage(TBillQuery query){
        PageInfo<TBill> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        PageInfo<TBillDto> info = tBillMapper.page(pageInfo, query);
        return info;
    }
    public PageInfo<TBillDto> queryPageForApplet(TBillQuery query){
        PageInfo<TBill> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        PageInfo<TBillDto> info = tBillMapper.pageForApplet(pageInfo, query);
        return info;
    }
@@ -182,6 +185,7 @@
                            BigDecimal outstand = presist.getPayableFeesMoney()
                                    .add(save.getPayableFeesPenalty())
                                    .subtract(presist.getPayFeesMoney());
                            save.setOutstandingMoney(outstand);
                        }
                        //处理缴费金额
@@ -567,12 +571,12 @@
    }
    @Override
    public BillStatisticsDto statistics(String busDeptId) {
    public BillStatisticsDto statistics(TBillQuery query) {
        BillStatisticsDto dto = new BillStatisticsDto();
        dto.setRent(getBaseMapper().statisticsAllRent(busDeptId));
        dto.setNopay(getBaseMapper().statisticsNoPay(busDeptId));
        dto.setPayed(getBaseMapper().statisticsPayed(busDeptId));
        dto.setOverdue(getBaseMapper().statisticsOverdue(busDeptId));
        dto.setRent(getBaseMapper().statisticsAllRent(query));
        dto.setNopay(getBaseMapper().statisticsNoPay(query));
        dto.setPayed(getBaseMapper().statisticsPayed(query));
        dto.setOverdue(getBaseMapper().statisticsOverdue(query));
        return dto;
    }
@@ -589,4 +593,53 @@
    public List<ScreenRentRankVO> getStreetRentRank() {
        return baseMapper.getStreetRentRank();
    }
    @Override
    public void editAmount(TbillSaveDto bill) {
        String requestId = UUID.fastUUID().toString();
        String lockkey = CacheConstants.BILL_UPDATE_LOCK_KEY + bill.getId();
        boolean isok = redisCache.trylockLoop(lockkey, requestId, 60);
        if (isok){
            try {
                TBill presist = getById(bill.getId());
                TBill save = new TBill();
                save.setId(bill.getId());
                BigDecimal preOutstand = presist.getOutstandingMoney();
                // 如果传入的金额小于0,则是扣减,如果大于0,是增加金额,增加金额只加入欠费金额中
                if (bill.getEditAmount().compareTo(BigDecimal.ZERO)<0
                        && presist.getPayableFeesPenalty().compareTo(BigDecimal.ZERO)>0){
                    BigDecimal prePayableFeesPenalty = presist.getPayableFeesPenalty();
                    //违约金大于调整金额,够减
                    if (prePayableFeesPenalty.compareTo(bill.getEditAmount().abs())>=0){
                        BigDecimal afterPenalty = prePayableFeesPenalty.add(bill.getEditAmount());
                        save.setPayableFeesPenalty(afterPenalty);
                    }else{
                        BigDecimal afterPenalty = BigDecimal.ZERO;
                        save.setPayableFeesPenalty(afterPenalty);
                    }
                }
                BigDecimal afterOutstand = preOutstand.add(bill.getEditAmount());
                save.setOutstandingMoney(afterOutstand);
                updateById(save);
            }finally {
                redisCache.unlock(lockkey,requestId);
            }
        }
        //todo 记录金额修改记录
//        TFlowManagement flow = new TFlowManagement();
//        flow.setPayType(3);
//        flow.setPayer("管理员修改");
//        flow.setBusinessDeptId(presist.getBusinessDeptId());
//        flow.setPayTime(DateUtils.dateToLocalDateTime(new Date()));
//        flow.setSysSerialNumber(OrderNos.getDid(30));
//        flow.setFlowType(1);
//        flow.setPaymentBillId(back.getId());
//        flow.setDeductionMoney(back.getDeductionMoney());
//        flow.setFlowMoney(save.getOutstandingMoney());
//        flow.setRemainingMoney(back.getOutstandingMoney());
//        flow.setPreOutstand(back.getPreOutstand());
//        flow.setCreateBy(SecurityUtils.getUsername());
//        tFlowManagementService.save(flow);
    }
}
ruoyi-system/src/main/resources/mapper/system/TBillMapper.xml
@@ -45,6 +45,7 @@
        LEFT JOIN t_contract c ON c.contract_number = b.contract_number and c.disabled=0
        LEFT JOIN t_house h ON h.id = c.house_id and h.disabled=0
        LEFT JOIN t_tenant t ON t.id = c.tenant_id and t.disabled=0
        LEFT JOIN t_bill_type_sort_weight sw on sw.code=b.pay_fees_status
        <where>
            b.disabled=0
            <if test="query.payFeesStatus != null">
@@ -69,8 +70,50 @@
                and b.bill_type = #{query.billType}
            </if>
        </where>
        order by b.payable_fees_time desc,b.create_time desc
        order by sw.sort_weight desc,b.payable_fees_time asc
<!--        order by b.payable_fees_time desc,b.create_time desc-->
    </select>
    <select id="pageForApplet" resultType="com.ruoyi.system.dto.TBillDto">
        SELECT
        b.*,
        t.resident_name as residentName,
        t.phone,
        t.account,
        h.house_name as houseName
        FROM
        t_bill b
        LEFT JOIN t_contract c ON c.contract_number = b.contract_number and c.disabled=0
        LEFT JOIN t_house h ON h.id = c.house_id and h.disabled=0
        LEFT JOIN t_tenant t ON t.id = c.tenant_id and t.disabled=0
        LEFT JOIN t_bill_type_sort_weight sw on sw.code=b.pay_fees_status
        <where>
            b.disabled=0
            <if test="query.payFeesStatus != null">
                and b.pay_fees_status = #{query.payFeesStatus}
            </if>
            <if test="query.phone != null and query.phone !=''">
                and t.phone = #{query.phone}
            </if>
            <if test="query.residentName != null and query.residentName !=''">
                and t.resident_name like concat('%',#{query.residentName},'%')
            </if>
            <if test="query.contractNumber != null and query.contractNumber !=''">
                and b.contract_number = #{query.contractNumber}
            </if>
            <if test="query.userId != null and query.userId !=''">
                and t.id = #{query.userId}
            </if>
            <if test='query.businessDeptId != null and query.businessDeptId != "" and query.businessDeptId!="0"'>
                and b.business_dept_id = #{query.businessDeptId}
            </if>
            <if test="query.billType != null">
                and b.bill_type = #{query.billType}
            </if>
        </where>
        order by sw.sort_weight desc,b.payable_fees_time asc
    </select>
    <select id="getBillList" resultType="com.ruoyi.system.dto.TBillDto">
        SELECT
        b.*,
@@ -157,31 +200,128 @@
    </select>
    <select id="statisticsAllRent" resultType="java.math.BigDecimal">
        SELECT ifnull(sum(payable_fees_money),0) as amount FROM t_bill where pay_fees_status!='5'
        <if test='busDeptId != null and busDeptId != "" and busDeptId!="0"'>
            and business_dept_id = #{busDeptId}
        SELECT ifnull(sum(payable_fees_money),0) as amount FROM t_bill b
        LEFT JOIN t_contract c ON c.contract_number = b.contract_number and c.disabled=0
        LEFT JOIN t_house h ON h.id = c.house_id and h.disabled=0
        LEFT JOIN t_tenant t ON t.id = c.tenant_id and t.disabled=0
        <where>
            b.disabled=0 and b.pay_fees_status!='5'
            <if test="query.payFeesStatus != null">
                and b.pay_fees_status = #{query.payFeesStatus}
        </if>
            <if test="query.phone != null and query.phone !=''">
                and t.phone = #{query.phone}
            </if>
            <if test="query.residentName != null and query.residentName !=''">
                and t.resident_name like concat('%',#{query.residentName},'%')
            </if>
            <if test="query.contractNumber != null and query.contractNumber !=''">
                and b.contract_number = #{query.contractNumber}
            </if>
            <if test="query.userId != null and query.userId !=''">
                and t.id = #{query.userId}
            </if>
            <if test='query.businessDeptId != null and query.businessDeptId != "" and query.businessDeptId!="0"'>
                and b.business_dept_id = #{query.businessDeptId}
            </if>
            <if test="query.billType != null">
                and b.bill_type = #{query.billType}
            </if>
        </where>
    </select>
    <select id="statisticsNoPay" resultType="java.math.BigDecimal">
        SELECT ifnull(sum(outstanding_money),0) as amount FROM t_bill where pay_fees_status!='3' and pay_fees_status!='5'
        <if test='busDeptId != null and busDeptId != "" and busDeptId!="0"'>
            and business_dept_id = #{busDeptId}
        SELECT ifnull(sum(outstanding_money),0) as amount FROM t_bill b
        LEFT JOIN t_contract c ON c.contract_number = b.contract_number and c.disabled=0
        LEFT JOIN t_house h ON h.id = c.house_id and h.disabled=0
        LEFT JOIN t_tenant t ON t.id = c.tenant_id and t.disabled=0
        <where>
            b.disabled=0 and b.pay_fees_status!='3' and b.pay_fees_status!='5'
            <if test="query.payFeesStatus != null">
                and b.pay_fees_status = #{query.payFeesStatus}
        </if>
            <if test="query.phone != null and query.phone !=''">
                and t.phone = #{query.phone}
            </if>
            <if test="query.residentName != null and query.residentName !=''">
                and t.resident_name like concat('%',#{query.residentName},'%')
            </if>
            <if test="query.contractNumber != null and query.contractNumber !=''">
                and b.contract_number = #{query.contractNumber}
            </if>
            <if test="query.userId != null and query.userId !=''">
                and t.id = #{query.userId}
            </if>
            <if test='query.businessDeptId != null and query.businessDeptId != "" and query.businessDeptId!="0"'>
                and b.business_dept_id = #{query.businessDeptId}
            </if>
            <if test="query.billType != null">
                and b.bill_type = #{query.billType}
            </if>
        </where>
    </select>
    <select id="statisticsPayed" resultType="java.math.BigDecimal">
        SELECT ifnull(sum(pay_fees_money),0) as amount FROM t_bill where pay_fees_status!='5'
        <if test='busDeptId != null and busDeptId != "" and busDeptId!="0"'>
            and business_dept_id = #{busDeptId}
        SELECT ifnull(sum(pay_fees_money),0) as amount FROM t_bill b
        LEFT JOIN t_contract c ON c.contract_number = b.contract_number and c.disabled=0
        LEFT JOIN t_house h ON h.id = c.house_id and h.disabled=0
        LEFT JOIN t_tenant t ON t.id = c.tenant_id and t.disabled=0
        <where>
            b.disabled=0 and b.pay_fees_status!='5'
            <if test="query.payFeesStatus != null">
                and b.pay_fees_status = #{query.payFeesStatus}
        </if>
            <if test="query.phone != null and query.phone !=''">
                and t.phone = #{query.phone}
            </if>
            <if test="query.residentName != null and query.residentName !=''">
                and t.resident_name like concat('%',#{query.residentName},'%')
            </if>
            <if test="query.contractNumber != null and query.contractNumber !=''">
                and b.contract_number = #{query.contractNumber}
            </if>
            <if test="query.userId != null and query.userId !=''">
                and t.id = #{query.userId}
            </if>
            <if test='query.businessDeptId != null and query.businessDeptId != "" and query.businessDeptId!="0"'>
                and b.business_dept_id = #{query.businessDeptId}
            </if>
            <if test="query.billType != null">
                and b.bill_type = #{query.billType}
            </if>
        </where>
    </select>
    <select id="statisticsOverdue" resultType="java.math.BigDecimal">
        SELECT ifnull(sum(outstanding_money),0) as amount FROM t_bill where pay_fees_status='4'
        <if test='busDeptId != null and busDeptId != "" and busDeptId!="0"'>
            and business_dept_id = #{busDeptId}
        SELECT ifnull(sum(outstanding_money),0) as amount FROM t_bill b
        LEFT JOIN t_contract c ON c.contract_number = b.contract_number and c.disabled=0
        LEFT JOIN t_house h ON h.id = c.house_id and h.disabled=0
        LEFT JOIN t_tenant t ON t.id = c.tenant_id and t.disabled=0
        <where>
            b.disabled=0 and b.pay_fees_status='4'
            <if test="query.payFeesStatus != null">
                and b.pay_fees_status = #{query.payFeesStatus}
        </if>
            <if test="query.phone != null and query.phone !=''">
                and t.phone = #{query.phone}
            </if>
            <if test="query.residentName != null and query.residentName !=''">
                and t.resident_name like concat('%',#{query.residentName},'%')
            </if>
            <if test="query.contractNumber != null and query.contractNumber !=''">
                and b.contract_number = #{query.contractNumber}
            </if>
            <if test="query.userId != null and query.userId !=''">
                and t.id = #{query.userId}
            </if>
            <if test='query.businessDeptId != null and query.businessDeptId != "" and query.businessDeptId!="0"'>
                and b.business_dept_id = #{query.businessDeptId}
            </if>
            <if test="query.billType != null">
                and b.bill_type = #{query.billType}
            </if>
        </where>
    </select>
    <select id="batchBillCount" resultType="java.lang.Integer">
        SELECT