feat(system): 租户余额列表新增租户名称字段并支持变动描述

- 在分页查询中联表返回租户名称,提升列表可读性
- 新增变动描述字段,支持充值等操作记录具体原因
- 优化 Mapper 与 Service 返回类型,统一使用 TenantBalanceRespVO
This commit is contained in:
2025-11-20 19:15:31 +08:00
parent 3466996f07
commit 78b6f5624b
8 changed files with 40 additions and 9 deletions

View File

@@ -84,8 +84,8 @@ public class TenantBalanceController {
@Operation(summary = "获得租户余额分页")
@PreAuthorize("@ss.hasPermission('system:tenant-balance:query')")
public CommonResult<PageResult<TenantBalanceRespVO>> getTenantBalancePage(@Valid TenantBalancePageReqVO pageReqVO) {
PageResult<TenantBalanceDO> pageResult = tenantBalanceService.getTenantBalancePage(pageReqVO);
return success(BeanUtils.toBean(pageResult, TenantBalanceRespVO.class));
PageResult<TenantBalanceRespVO> tenantBalancePage = tenantBalanceService.getTenantBalancePage(pageReqVO);
return success(BeanUtils.toBean(tenantBalancePage, TenantBalanceRespVO.class));
}
@GetMapping("/export-excel")
@@ -95,7 +95,7 @@ public class TenantBalanceController {
public void exportTenantBalanceExcel(@Valid TenantBalancePageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<TenantBalanceDO> list = tenantBalanceService.getTenantBalancePage(pageReqVO).getList();
List<TenantBalanceRespVO> list = tenantBalanceService.getTenantBalancePage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "租户余额.xls", "数据", TenantBalanceRespVO.class,
BeanUtils.toBean(list, TenantBalanceRespVO.class));

View File

@@ -20,4 +20,8 @@ public class TenantBalanceAddReqVO {
@Schema(description = "增加的余额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000000")
@NotNull(message = "增加的余额不能为空")
private Integer amount;
@Schema(description = "变动描述", example = "充值")
@NotNull(message = "变动描述不能为空")
private String description;
}

View File

@@ -13,6 +13,9 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@Data
public class TenantBalancePageReqVO extends PageParam {
@Schema(description = "租户编号", example = "1024")
private Long id;
@Schema(description = "当前积分余额")
private Integer balance;

View File

@@ -28,4 +28,8 @@ public class TenantBalanceRespVO {
@ExcelProperty("更新时间")
private LocalDateTime updatedAt;
@Schema(description = "代理名称")
@ExcelProperty("代理名称")
private String tenantName;
}

View File

@@ -7,8 +7,10 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.dal.dataobject.tenantbalance.TenantBalanceDO;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.system.controller.admin.tenantbalance.vo.*;
import org.apache.ibatis.annotations.Param;
/**
* 租户余额 Mapper
@@ -40,4 +42,7 @@ public interface TenantBalanceMapper extends BaseMapperX<TenantBalanceDO> {
return this.update(null, wrapper);
}
IPage<TenantBalanceRespVO> selectPageWithTenantName(IPage<TenantBalanceRespVO> iPage,@Param("req") TenantBalancePageReqVO pageReqVO);
}

View File

@@ -57,7 +57,7 @@ public interface TenantBalanceService {
* @param pageReqVO 分页查询
* @return 租户余额分页
*/
PageResult<TenantBalanceDO> getTenantBalancePage(TenantBalancePageReqVO pageReqVO);
PageResult<TenantBalanceRespVO> getTenantBalancePage(TenantBalancePageReqVO pageReqVO);
void addTenantBalance(@Valid TenantBalanceAddReqVO updateReqVO);
}

View File

@@ -1,20 +1,21 @@
package cn.iocoder.yudao.module.system.service.tenantbalance;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.RandomUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.module.system.controller.admin.tenantbalance.vo.TenantBalanceAddReqVO;
import cn.iocoder.yudao.module.system.controller.admin.tenantbalance.vo.TenantBalancePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.tenantbalance.vo.TenantBalanceRespVO;
import cn.iocoder.yudao.module.system.controller.admin.tenantbalance.vo.TenantBalanceSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.tenantbalance.TenantBalanceDO;
import cn.iocoder.yudao.module.system.dal.dataobject.tenantpoints.TenantPointsDO;
import cn.iocoder.yudao.module.system.dal.mysql.tenantbalance.TenantBalanceMapper;
import cn.iocoder.yudao.module.system.dal.mysql.tenantpoints.TenantPointsMapper;
import cn.iocoder.yudao.module.system.util.BizNoGenerator;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
@@ -94,8 +95,10 @@ public class TenantBalanceServiceImpl implements TenantBalanceService {
}
@Override
public PageResult<TenantBalanceDO> getTenantBalancePage(TenantBalancePageReqVO pageReqVO) {
return tenantBalanceMapper.selectPage(pageReqVO);
public PageResult<TenantBalanceRespVO> getTenantBalancePage(TenantBalancePageReqVO pageReqVO) {
IPage<TenantBalanceRespVO> iPage = new Page<>(pageReqVO.getPageNo(),pageReqVO.getPageSize());
IPage<TenantBalanceRespVO> tenantBalanceRespVOIPage = tenantBalanceMapper.selectPageWithTenantName(iPage, pageReqVO);
return new PageResult<>(tenantBalanceRespVOIPage.getRecords(),tenantBalanceRespVOIPage.getTotal());
}
@Override
@@ -137,7 +140,7 @@ public class TenantBalanceServiceImpl implements TenantBalanceService {
tenantPointsDO.setBalance(newBalance);
tenantPointsDO.setOperatorId(loginUser.getId());
tenantPointsDO.setType(RECHARGE.getDesc()); // RECHARGE / BONUS / ...
tenantPointsDO.setDescription("后台变动积分");
tenantPointsDO.setDescription(addReqVO.getDescription());
tenantPointsDO.setBizNo(recharge);
tenantPointsMapper.insert(tenantPointsDO);
}

View File

@@ -9,4 +9,16 @@
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="selectPageWithTenantName"
resultType="cn.iocoder.yudao.module.system.controller.admin.tenantbalance.vo.TenantBalanceRespVO">
select stb.*, st.name as tenantName from system_tenant_balance as stb
left join system_tenant as st on stb.id = st.id
<where>
<if test="req.id != null">
and stb.id = #{req.id,jdbcType=BIGINT}
</if>
</where>
order by stb.id desc
</select>
</mapper>