2 Commits

Author SHA1 Message Date
tianyongbao
a5a3eaf893 fix: 分润,讨论后,发现问题统一修复。 2026-06-03 23:17:10 +08:00
tianyongbao
771d46edbb fix: 分润发现问题,统一修复。 2026-05-30 16:42:12 +08:00
3 changed files with 58 additions and 11 deletions

View File

@@ -5,6 +5,7 @@ import java.util.Arrays;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.limap.common.core.domain.entity.SysUser;
import com.limap.common.core.domain.entity.SysRole;
import com.limap.common.utils.StringUtils;
import com.limap.core.basic.service.IBasicUserWithdrawService;
@@ -40,6 +41,10 @@ import com.limap.core.basic.vo.SharingRecordSearchVo;
@RestController
@RequestMapping("/basic/sharingRecord")
public class BasicProfitSharingRecordController extends BaseController {
private static final String DATA_SCOPE_ALL = "1";
private static final String DATA_SCOPE_DEPT = "3";
private static final String DATA_SCOPE_DEPT_AND_CHILD = "4";
@Autowired
private IBasicProfitSharingRecordService basicProfitSharingRecordService;
@Autowired
@@ -53,10 +58,7 @@ public class BasicProfitSharingRecordController extends BaseController {
@GetMapping("/list")
public TableDataInfo list(BasicProfitSharingRecord basicProfitSharingRecord) {
startPage();
List<SysRole> roles = getLoginUser().getUser().getRoles();
if(roles.stream().noneMatch(role -> role.getRoleId().compareTo(100L) <0)){
basicProfitSharingRecord.setUserId(getUserId());
}
applySharingRecordDataScope(basicProfitSharingRecord);
List<BasicProfitSharingRecord> list = basicProfitSharingRecordService.selectBasicProfitSharingRecordList(basicProfitSharingRecord);
return getDataTable(list);
}
@@ -66,12 +68,7 @@ public class BasicProfitSharingRecordController extends BaseController {
@PreAuthorize("@ss.hasPermi('basic:sharingRecord:list')")
@GetMapping("/report")
public AjaxResult reportData(SharingRecordSearchVo searchVo) {
List<SysRole> roles = getLoginUser().getUser().getRoles();
if(roles.stream().noneMatch(role -> role.getRoleId().compareTo(100L) >=0)){
searchVo.setUserId(getUserId());
}else{
searchVo.setDeptId(getDeptId());
}
applySharingRecordDataScope(searchVo);
Map<String, Object> resultMap = basicProfitSharingRecordService.getReportData(searchVo);
return success(resultMap);
}
@@ -84,6 +81,7 @@ public class BasicProfitSharingRecordController extends BaseController {
@Log(title = "分润记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, BasicProfitSharingRecord basicProfitSharingRecord) {
applySharingRecordDataScope(basicProfitSharingRecord);
List<BasicProfitSharingRecord> list = basicProfitSharingRecordService.selectBasicProfitSharingRecordList(basicProfitSharingRecord);
ExcelUtil<BasicProfitSharingRecord> util = new ExcelUtil<BasicProfitSharingRecord>(BasicProfitSharingRecord.class);
util.exportExcel(response, list, "分润记录数据");
@@ -149,4 +147,40 @@ public class BasicProfitSharingRecordController extends BaseController {
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(basicProfitSharingRecordService.removeByIds(Arrays.asList(ids)));
}
private void applySharingRecordDataScope(BasicProfitSharingRecord record) {
SysUser user = getLoginUser().getUser();
if (user == null || user.isAdmin() || hasDataScope(user.getRoles(), DATA_SCOPE_ALL)) {
return;
}
if (hasDataScope(user.getRoles(), DATA_SCOPE_DEPT_AND_CHILD)) {
record.getParams().put("scopeType", "deptAndChild");
record.getParams().put("scopeDeptId", getDeptId());
} else if (hasDataScope(user.getRoles(), DATA_SCOPE_DEPT)) {
record.getParams().put("scopeType", "dept");
record.getParams().put("scopeDeptId", getDeptId());
} else {
record.setUserId(getUserId());
}
}
private void applySharingRecordDataScope(SharingRecordSearchVo searchVo) {
SysUser user = getLoginUser().getUser();
if (user == null || user.isAdmin() || hasDataScope(user.getRoles(), DATA_SCOPE_ALL)) {
return;
}
if (hasDataScope(user.getRoles(), DATA_SCOPE_DEPT_AND_CHILD)) {
searchVo.setDeptId(getDeptId());
searchVo.getParams().put("scopeType", "deptAndChild");
} else if (hasDataScope(user.getRoles(), DATA_SCOPE_DEPT)) {
searchVo.setDeptId(getDeptId());
searchVo.getParams().put("scopeType", "dept");
} else {
searchVo.setUserId(getUserId());
}
}
private boolean hasDataScope(List<SysRole> roles, String dataScope) {
return roles != null && roles.stream().anyMatch(role -> dataScope.equals(role.getDataScope()));
}
}

View File

@@ -91,6 +91,16 @@ public class BasicProfitSharingRecordServiceImpl extends ServiceImpl<BasicProfit
}
// 兼容前端params[beginTime]/params[endTime]传参方式
Map<String, Object> params = basicProfitSharingRecord.getParams();
String scopeType = (String) params.get("scopeType");
Long scopeDeptId = (Long) params.get("scopeDeptId");
if (StringUtils.isNotNull(scopeDeptId)) {
if ("deptAndChild".equals(scopeType)) {
queryWrapper.inSql(BasicProfitSharingRecord::getDeptId,
"SELECT dept_id FROM sys_dept WHERE dept_id = " + scopeDeptId + " OR find_in_set(" + scopeDeptId + ", ancestors)");
} else if ("dept".equals(scopeType)) {
queryWrapper.eq(BasicProfitSharingRecord::getDeptId, scopeDeptId);
}
}
String beginTime = (String) params.get("beginTime");
String endTime = (String) params.get("endTime");
if (StringUtils.isNotEmpty(beginTime) && StringUtils.isNotEmpty(endTime)) {

View File

@@ -27,7 +27,10 @@
<if test="userId != null">
AND user_id = #{userId}
</if>
<if test="deptId != null">
<if test="deptId != null and params.scopeType == 'dept'">
and dept_id = #{deptId}
</if>
<if test="deptId != null and (params.scopeType == null or params.scopeType == 'deptAndChild')">
and dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = #{deptId} or find_in_set( #{deptId} , ancestors ))
</if>
</where>