From d66b806d685672f2f817986e89f69fb09d130f11 Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期三, 09 四月 2025 18:02:32 +0800 Subject: [PATCH] Merge branch 'xizang-changyun' of https://gitee.com/xiaochen991015/xizang into dev --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBillController.java | 33 ++++- ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TBillController.java | 2 ruoyi-system/src/main/java/com/ruoyi/system/dto/TbillSaveDto.java | 8 + ruoyi-system/src/main/java/com/ruoyi/system/mapper/TBillMapper.java | 10 + ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java | 73 ++++++++++- ruoyi-system/src/main/resources/mapper/system/TBillMapper.xml | 174 ++++++++++++++++++++++++++-- ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java | 8 + 7 files changed, 267 insertions(+), 41 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBillController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBillController.java index de6f98f..7077198 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBillController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBillController.java @@ -32,6 +32,8 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import javax.validation.constraints.NotEmpty; +import java.math.BigDecimal; import java.util.List; import java.util.Objects; @@ -69,6 +71,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") @@ -90,6 +100,22 @@ } bill.setBusinessDeptId(businessDeptId); 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(); } @@ -152,12 +178,7 @@ } - @ApiOperation("统计") - @GetMapping("statistics") - public R<BillStatisticsDto> statistics(){ - BillStatisticsDto dto = tBillService.statistics(SecurityUtils.getBusinessDeptId()); - return R.ok(dto); - } + diff --git a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TBillController.java b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TBillController.java index a1dd1b2..b9d8a9e 100644 --- a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TBillController.java +++ b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TBillController.java @@ -65,7 +65,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); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/dto/TbillSaveDto.java b/ruoyi-system/src/main/java/com/ruoyi/system/dto/TbillSaveDto.java index c7869f5..53a19ad 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/dto/TbillSaveDto.java +++ b/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; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TBillMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TBillMapper.java index 8b750ea..e0c85e5 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TBillMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TBillMapper.java @@ -26,6 +26,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); /** @@ -38,13 +40,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); /** diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java index cc4ff80..619dd06 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java @@ -31,6 +31,9 @@ PageInfo<TBillDto> queryPage(TBillQuery query); + + PageInfo<TBillDto> queryPageForApplet(TBillQuery query); + /** * * 更新类型 1.仅更新信息及状态 2.更新金额及状态 @@ -88,7 +91,7 @@ Boolean cashPay(CachPayDto offlinePayDto); - BillStatisticsDto statistics(String busdeptId); + BillStatisticsDto statistics(TBillQuery query); Integer batchBillCount(String userId, List<String> billIds); @@ -113,4 +116,7 @@ * @return */ List<TBill> getJiFuBillListByTime(String businessDeptId, Date first, Date last); + List<ScreenRentRankVO> getStreetRentRank(); + + void editAmount(TbillSaveDto bill); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java index a5aaeda..dcc56e1 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java @@ -7,11 +7,7 @@ import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.enums.DisabledEnum; 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; @@ -41,6 +37,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; @@ -106,6 +103,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; } @@ -183,6 +186,7 @@ BigDecimal outstand = presist.getPayableFeesMoney() .add(save.getPayableFeesPenalty()) .subtract(presist.getPayFeesMoney()); + save.setOutstandingMoney(outstand); } //处理缴费金额 @@ -569,12 +573,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; } @@ -612,4 +616,53 @@ public List<TBill> getJiFuBillListByTime(String businessDeptId, Date first, Date last) { return baseMapper.getJiFuBillList(businessDeptId,first,last); } + + @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); + } } diff --git a/ruoyi-system/src/main/resources/mapper/system/TBillMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TBillMapper.xml index 1e814c7..d362ce5 100644 --- a/ruoyi-system/src/main/resources/mapper/system/TBillMapper.xml +++ b/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} - </if> + 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} - </if> + 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} - </if> + 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} - </if> + 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 -- Gitblit v1.7.1