feat(oa): 新增奖金池分配功能

- 新增奖金池分配实体类 OaBonusAllocation 及其相关业务对象
- 实现奖金池分配的增删改查接口和服务层逻辑- 添加奖金池分配的控制器和Mapper配置
- 移除奖金池中的总金额和剩余金额字段及相关逻辑
- 更新Excel导出和导入注解以支持新字段展示
This commit is contained in:
2025-10-24 10:30:24 +08:00
parent a939fab3bb
commit 40e56ab051
13 changed files with 460 additions and 34 deletions

View File

@@ -0,0 +1,101 @@
package com.ruoyi.oa.controller;
import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.oa.domain.vo.OaBonusAllocationVo;
import com.ruoyi.oa.domain.bo.OaBonusAllocationBo;
import com.ruoyi.oa.service.IOaBonusAllocationService;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 奖金池分配(记录奖金池向用户的分配比例及金额)
*
* @author ruoyi
* @date 2025-10-24
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/oa/bonusAllocation")
public class OaBonusAllocationController extends BaseController {
private final IOaBonusAllocationService iOaBonusAllocationService;
/**
* 查询奖金池分配(记录奖金池向用户的分配比例及金额)列表
*/
@GetMapping("/list")
public TableDataInfo<OaBonusAllocationVo> list(OaBonusAllocationBo bo, PageQuery pageQuery) {
return iOaBonusAllocationService.queryPageList(bo, pageQuery);
}
/**
* 导出奖金池分配(记录奖金池向用户的分配比例及金额)列表
*/
@Log(title = "奖金池分配(记录奖金池向用户的分配比例及金额)", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(OaBonusAllocationBo bo, HttpServletResponse response) {
List<OaBonusAllocationVo> list = iOaBonusAllocationService.queryList(bo);
ExcelUtil.exportExcel(list, "奖金池分配(记录奖金池向用户的分配比例及金额)", OaBonusAllocationVo.class, response);
}
/**
* 获取奖金池分配(记录奖金池向用户的分配比例及金额)详细信息
*
* @param allocationId 主键
*/
@GetMapping("/{allocationId}")
public R<OaBonusAllocationVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long allocationId) {
return R.ok(iOaBonusAllocationService.queryById(allocationId));
}
/**
* 新增奖金池分配(记录奖金池向用户的分配比例及金额)
*/
@Log(title = "奖金池分配(记录奖金池向用户的分配比例及金额)", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody OaBonusAllocationBo bo) {
return toAjax(iOaBonusAllocationService.insertByBo(bo));
}
/**
* 修改奖金池分配(记录奖金池向用户的分配比例及金额)
*/
@Log(title = "奖金池分配(记录奖金池向用户的分配比例及金额)", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody OaBonusAllocationBo bo) {
return toAjax(iOaBonusAllocationService.updateByBo(bo));
}
/**
* 删除奖金池分配(记录奖金池向用户的分配比例及金额)
*
* @param allocationIds 主键串
*/
@Log(title = "奖金池分配(记录奖金池向用户的分配比例及金额)", businessType = BusinessType.DELETE)
@DeleteMapping("/{allocationIds}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] allocationIds) {
return toAjax(iOaBonusAllocationService.deleteWithValidByIds(Arrays.asList(allocationIds), true));
}
}

View File

@@ -0,0 +1,53 @@
package com.ruoyi.oa.domain;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
import java.math.BigDecimal;
import java.math.BigDecimal;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 奖金池分配(记录奖金池向用户的分配比例及金额)对象 oa_bonus_allocation
*
* @author ruoyi
* @date 2025-10-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("oa_bonus_allocation")
public class OaBonusAllocation extends BaseEntity {
private static final long serialVersionUID=1L;
/**
* 主键ID
*/
@TableId(value = "allocation_id")
private Long allocationId;
/**
* 奖金池ID关联oa_bonus_pool表pool_id
*/
private Long poolId;
/**
* 用户昵称
*/
private String nickName;
/**
* 分配比例(单位:%如20.00表示20%
*/
private BigDecimal allocationRatio;
/**
* 删除标识0未删除 1已删除
*/
@TableLogic
private String delFlag;
/**
* 备注
*/
private String remark;
}

View File

@@ -42,14 +42,6 @@ public class OaBonusPool extends BaseEntity {
* 结束日期
*/
private Date endDate;
/**
* 奖金池总金额(单位:元)
*/
private BigDecimal totalAmount;
/**
* 剩余金额(单位:元)
*/
private BigDecimal remainingAmount;
/**
* 删除标识0未删除 1已删除
*/

View File

@@ -0,0 +1,51 @@
package com.ruoyi.oa.domain.bo;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.*;
import java.util.Date;
import java.math.BigDecimal;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 奖金池分配(记录奖金池向用户的分配比例及金额)业务对象 oa_bonus_allocation
*
* @author ruoyi
* @date 2025-10-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class OaBonusAllocationBo extends BaseEntity {
/**
* 主键ID
*/
private Long allocationId;
/**
* 奖金池ID关联oa_bonus_pool表pool_id
*/
private Long poolId;
/**
* 用户昵称
*/
private String nickName;
/**
* 分配比例(单位:%如20.00表示20%
*/
private BigDecimal allocationRatio;
/**
* 备注
*/
private String remark;
}

View File

@@ -46,15 +46,6 @@ public class OaBonusPoolBo extends BaseEntity {
*/
private Date endDate;
/**
* 奖金池总金额(单位:元)
*/
private BigDecimal totalAmount;
/**
* 剩余金额(单位:元)
*/
private BigDecimal remainingAmount;
/**
* 备注

View File

@@ -0,0 +1,58 @@
package com.ruoyi.oa.domain.vo;
import java.math.BigDecimal;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.ruoyi.common.annotation.ExcelDictFormat;
import com.ruoyi.common.convert.ExcelDictConvert;
import lombok.Data;
import java.util.Date;
/**
* 奖金池分配(记录奖金池向用户的分配比例及金额)视图对象 oa_bonus_allocation
*
* @author ruoyi
* @date 2025-10-24
*/
@Data
@ExcelIgnoreUnannotated
public class OaBonusAllocationVo {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
@ExcelProperty(value = "主键ID")
private Long allocationId;
/**
* 奖金池ID关联oa_bonus_pool表pool_id
*/
@ExcelProperty(value = "奖金池ID", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "关=联oa_bonus_pool表pool_id")
private Long poolId;
/**
* 用户昵称
*/
@ExcelProperty(value = "用户昵称")
private String nickName;
/**
* 分配比例(单位:%如20.00表示20%
*/
@ExcelProperty(value = "分配比例", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "单=位:%如20.00表示20%")
private BigDecimal allocationRatio;
/**
* 备注
*/
@ExcelProperty(value = "备注")
private String remark;
}

View File

@@ -48,19 +48,6 @@ public class OaBonusPoolVo {
@ExcelProperty(value = "结束日期")
private Date endDate;
/**
* 奖金池总金额(单位:元)
*/
@ExcelProperty(value = "奖金池总金额", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "单=位:元")
private BigDecimal totalAmount;
/**
* 剩余金额(单位:元)
*/
@ExcelProperty(value = "剩余金额", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "单=位:元")
private BigDecimal remainingAmount;
/**
* 备注

View File

@@ -0,0 +1,15 @@
package com.ruoyi.oa.mapper;
import com.ruoyi.oa.domain.OaBonusAllocation;
import com.ruoyi.oa.domain.vo.OaBonusAllocationVo;
import com.ruoyi.common.core.mapper.BaseMapperPlus;
/**
* 奖金池分配记录奖金池向用户的分配比例及金额Mapper接口
*
* @author ruoyi
* @date 2025-10-24
*/
public interface OaBonusAllocationMapper extends BaseMapperPlus<OaBonusAllocationMapper, OaBonusAllocation, OaBonusAllocationVo> {
}

View File

@@ -0,0 +1,49 @@
package com.ruoyi.oa.service;
import com.ruoyi.oa.domain.OaBonusAllocation;
import com.ruoyi.oa.domain.vo.OaBonusAllocationVo;
import com.ruoyi.oa.domain.bo.OaBonusAllocationBo;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.PageQuery;
import java.util.Collection;
import java.util.List;
/**
* 奖金池分配记录奖金池向用户的分配比例及金额Service接口
*
* @author ruoyi
* @date 2025-10-24
*/
public interface IOaBonusAllocationService {
/**
* 查询奖金池分配(记录奖金池向用户的分配比例及金额)
*/
OaBonusAllocationVo queryById(Long allocationId);
/**
* 查询奖金池分配(记录奖金池向用户的分配比例及金额)列表
*/
TableDataInfo<OaBonusAllocationVo> queryPageList(OaBonusAllocationBo bo, PageQuery pageQuery);
/**
* 查询奖金池分配(记录奖金池向用户的分配比例及金额)列表
*/
List<OaBonusAllocationVo> queryList(OaBonusAllocationBo bo);
/**
* 新增奖金池分配(记录奖金池向用户的分配比例及金额)
*/
Boolean insertByBo(OaBonusAllocationBo bo);
/**
* 修改奖金池分配(记录奖金池向用户的分配比例及金额)
*/
Boolean updateByBo(OaBonusAllocationBo bo);
/**
* 校验并批量删除奖金池分配(记录奖金池向用户的分配比例及金额)信息
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
}

View File

@@ -0,0 +1,112 @@
package com.ruoyi.oa.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import com.ruoyi.oa.domain.bo.OaBonusAllocationBo;
import com.ruoyi.oa.domain.vo.OaBonusAllocationVo;
import com.ruoyi.oa.domain.OaBonusAllocation;
import com.ruoyi.oa.mapper.OaBonusAllocationMapper;
import com.ruoyi.oa.service.IOaBonusAllocationService;
import java.util.List;
import java.util.Map;
import java.util.Collection;
/**
* 奖金池分配记录奖金池向用户的分配比例及金额Service业务层处理
*
* @author ruoyi
* @date 2025-10-24
*/
@RequiredArgsConstructor
@Service
public class OaBonusAllocationServiceImpl implements IOaBonusAllocationService {
private final OaBonusAllocationMapper baseMapper;
/**
* 查询奖金池分配(记录奖金池向用户的分配比例及金额)
*/
@Override
public OaBonusAllocationVo queryById(Long allocationId){
return baseMapper.selectVoById(allocationId);
}
/**
* 查询奖金池分配(记录奖金池向用户的分配比例及金额)列表
*/
@Override
public TableDataInfo<OaBonusAllocationVo> queryPageList(OaBonusAllocationBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<OaBonusAllocation> lqw = buildQueryWrapper(bo);
Page<OaBonusAllocationVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
/**
* 查询奖金池分配(记录奖金池向用户的分配比例及金额)列表
*/
@Override
public List<OaBonusAllocationVo> queryList(OaBonusAllocationBo bo) {
LambdaQueryWrapper<OaBonusAllocation> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<OaBonusAllocation> buildQueryWrapper(OaBonusAllocationBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<OaBonusAllocation> lqw = Wrappers.lambdaQuery();
lqw.eq(bo.getPoolId() != null, OaBonusAllocation::getPoolId, bo.getPoolId());
lqw.like(StringUtils.isNotBlank(bo.getNickName()), OaBonusAllocation::getNickName, bo.getNickName());
lqw.eq(bo.getAllocationRatio() != null, OaBonusAllocation::getAllocationRatio, bo.getAllocationRatio());
lqw.orderByDesc(OaBonusAllocation::getCreateTime);
return lqw;
}
/**
* 新增奖金池分配(记录奖金池向用户的分配比例及金额)
*/
@Override
public Boolean insertByBo(OaBonusAllocationBo bo) {
OaBonusAllocation add = BeanUtil.toBean(bo, OaBonusAllocation.class);
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setAllocationId(add.getAllocationId());
}
return flag;
}
/**
* 修改奖金池分配(记录奖金池向用户的分配比例及金额)
*/
@Override
public Boolean updateByBo(OaBonusAllocationBo bo) {
OaBonusAllocation update = BeanUtil.toBean(bo, OaBonusAllocation.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
}
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(OaBonusAllocation entity){
//TODO 做一些数据校验,如唯一约束
}
/**
* 批量删除奖金池分配(记录奖金池向用户的分配比例及金额)
*/
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteBatchIds(ids) > 0;
}
}

View File

@@ -73,8 +73,6 @@ public class OaBonusPoolServiceImpl implements IOaBonusPoolService {
lqw.like(StringUtils.isNotBlank(bo.getPoolName()), OaBonusPool::getPoolName, bo.getPoolName());
lqw.eq(bo.getStartDate() != null, OaBonusPool::getStartDate, bo.getStartDate());
lqw.eq(bo.getEndDate() != null, OaBonusPool::getEndDate, bo.getEndDate());
lqw.eq(bo.getTotalAmount() != null, OaBonusPool::getTotalAmount, bo.getTotalAmount());
lqw.eq(bo.getRemainingAmount() != null, OaBonusPool::getRemainingAmount, bo.getRemainingAmount());
return lqw;
}

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.oa.mapper.OaBonusAllocationMapper">
<resultMap type="com.ruoyi.oa.domain.OaBonusAllocation" id="OaBonusAllocationResult">
<result property="allocationId" column="allocation_id"/>
<result property="poolId" column="pool_id"/>
<result property="nickName" column="nick_name"/>
<result property="allocationRatio" column="allocation_ratio"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="delFlag" column="del_flag"/>
<result property="remark" column="remark"/>
</resultMap>
</mapper>

View File

@@ -9,8 +9,6 @@
<result property="poolName" column="pool_name"/>
<result property="startDate" column="start_date"/>
<result property="endDate" column="end_date"/>
<result property="totalAmount" column="total_amount"/>
<result property="remainingAmount" column="remaining_amount"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>