feat: 部门改价配置功能完善
- 修复部门改价配置保存问题(Mapstruct转换失败) - 添加部门改价比例和开关字段 - 实现自动改价功能(根据部门配置) - 改价金额抹零到十位数(58->50, 65->60) - 修复部门缓存清除问题
This commit is contained in:
@@ -88,6 +88,7 @@ public class SysDeptController extends BaseController {
|
||||
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated @RequestBody SysDeptBo dept) {
|
||||
// System.out.println("[Controller] 接收到的部门数据: deptId=" + dept.getDeptId() + ", isAutoChangePrice=" + dept.getIsAutoChangePrice() + ", changePriceRate=" + dept.getChangePriceRate());
|
||||
Long deptId = dept.getDeptId();
|
||||
deptService.checkDeptDataScope(deptId);
|
||||
if (!deptService.checkDeptNameUnique(dept)) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.dromara.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -8,6 +9,7 @@ import lombok.EqualsAndHashCode;
|
||||
import org.dromara.common.tenant.core.TenantEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 部门表 sys_dept
|
||||
@@ -75,6 +77,18 @@ public class SysDept extends TenantEntity {
|
||||
@TableLogic
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 是否自动改价(1=否,2=是)
|
||||
*/
|
||||
@TableField("is_auto_change_price")
|
||||
private Integer isAutoChangePrice;
|
||||
|
||||
/**
|
||||
* 改价比例(如0.1000表示10%)
|
||||
*/
|
||||
@TableField("change_price_rate")
|
||||
private BigDecimal changePriceRate;
|
||||
|
||||
/**
|
||||
* 祖级列表
|
||||
*/
|
||||
|
||||
@@ -10,6 +10,8 @@ import lombok.EqualsAndHashCode;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.system.domain.SysDept;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 部门业务对象 sys_dept
|
||||
*
|
||||
@@ -93,4 +95,14 @@ public class SysDeptBo extends BaseEntity {
|
||||
*/
|
||||
private Integer isNull;
|
||||
|
||||
/**
|
||||
* 是否自动改价(1=否,2=是)
|
||||
*/
|
||||
private Integer isAutoChangePrice;
|
||||
|
||||
/**
|
||||
* 改价比例(如0.1000表示10%)
|
||||
*/
|
||||
private BigDecimal changePriceRate;
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.dromara.system.domain.SysDept;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@@ -99,4 +100,14 @@ public class SysDeptVo implements Serializable {
|
||||
@ExcelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 是否自动改价(1=否,2=是)
|
||||
*/
|
||||
private Integer isAutoChangePrice;
|
||||
|
||||
/**
|
||||
* 改价比例(如0.1000表示10%)
|
||||
*/
|
||||
private BigDecimal changePriceRate;
|
||||
|
||||
}
|
||||
|
||||
@@ -272,11 +272,28 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
*/
|
||||
@Caching(evict = {
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DEPT, key = "#bo.deptId"),
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DEPT_AND_CHILD, allEntries = true)
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DEPT_AND_CHILD, allEntries = true),
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DEPT, allEntries = true)
|
||||
})
|
||||
@Override
|
||||
public int updateDept(SysDeptBo bo) {
|
||||
SysDept dept = MapstructUtils.convert(bo, SysDept.class);
|
||||
// 强制清除所有部门缓存,避免改价配置缓存问题
|
||||
CacheUtils.clear(CacheNames.SYS_DEPT);
|
||||
// System.out.println("[部门更新] 接收到的数据: deptId=" + bo.getDeptId() + ", isAutoChangePrice=" + bo.getIsAutoChangePrice() + ", changePriceRate=" + bo.getChangePriceRate());
|
||||
SysDept dept = new SysDept();
|
||||
// 手动复制所有字段
|
||||
dept.setDeptId(bo.getDeptId());
|
||||
dept.setParentId(bo.getParentId());
|
||||
dept.setDeptName(bo.getDeptName());
|
||||
dept.setDeptCategory(bo.getDeptCategory());
|
||||
dept.setOrderNum(bo.getOrderNum());
|
||||
dept.setLeader(bo.getLeader());
|
||||
dept.setPhone(bo.getPhone());
|
||||
dept.setEmail(bo.getEmail());
|
||||
dept.setStatus(bo.getStatus());
|
||||
dept.setIsAutoChangePrice(bo.getIsAutoChangePrice());
|
||||
dept.setChangePriceRate(bo.getChangePriceRate());
|
||||
// System.out.println("[部门更新] 转换后的数据: isAutoChangePrice=" + dept.getIsAutoChangePrice() + ", changePriceRate=" + dept.getChangePriceRate());
|
||||
SysDept oldDept = baseMapper.selectById(dept.getDeptId());
|
||||
if (ObjectUtil.isNull(oldDept)) {
|
||||
throw new ServiceException("部门不存在,无法修改");
|
||||
@@ -294,6 +311,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
} else {
|
||||
dept.setAncestors(oldDept.getAncestors());
|
||||
}
|
||||
// System.out.println("[部门更新] 即将执行updateById, dept=" + dept);
|
||||
int result = baseMapper.updateById(dept);
|
||||
if (SystemConstants.NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
|
||||
&& !StringUtils.equals(SystemConstants.NORMAL, dept.getAncestors())) {
|
||||
|
||||
Reference in New Issue
Block a user