fix(core): 设置CLI默认文件掩码避免权限冲突,完善用户筛选代理方法

这个提交包含在:
chen
2026-09-17 17:17:08 +08:00
父节点 6865b268fd
当前提交 13b087b753
共有 2 个文件被更改,包括 101 次插入 和 0 次删除

查看文件

@@ -177,6 +177,104 @@ class UserFilter extends BaseFilter
});
}
/**
* 酒道馆筛选 (存在于 shopro_commission_agent 表)
*/
public function isVenue($query, $data)
{
$value = $this->plainValue($data);
if ($value === '' || $value === null) {
return $query;
}
$current = $query->getTable();
$agentTable = (new AgentModel())->getQuery()->getTable();
$val = intval($value);
if ($val === 1) {
return $query->whereExists(function ($sub) use ($current, $agentTable) {
$sub->table($agentTable)->where($agentTable . '.user_id=' . $current . '.id')->where('is_venue', 1);
});
} else {
return $query->where(function (Query $q) use ($current, $agentTable) {
$q->whereNotExists(function ($sub) use ($current, $agentTable) {
$sub->table($agentTable)->where($agentTable . '.user_id=' . $current . '.id');
})->whereOrExists(function ($sub) use ($current, $agentTable) {
$sub->table($agentTable)->where($agentTable . '.user_id=' . $current . '.id')->where('is_venue', 0);
});
});
}
}
/**
* 区县代理筛选 (存在于 shopro_commission_agent 表)
*/
public function isCounty($query, $data)
{
$value = $this->plainValue($data);
if ($value === '' || $value === null) {
return $query;
}
$current = $query->getTable();
$agentTable = (new AgentModel())->getQuery()->getTable();
$val = intval($value);
if ($val === 1) {
return $query->whereExists(function ($sub) use ($current, $agentTable) {
$sub->table($agentTable)->where($agentTable . '.user_id=' . $current . '.id')->where('is_county', 1);
});
} else {
return $query->where(function (Query $q) use ($current, $agentTable) {
$q->whereNotExists(function ($sub) use ($current, $agentTable) {
$sub->table($agentTable)->where($agentTable . '.user_id=' . $current . '.id');
})->whereOrExists(function ($sub) use ($current, $agentTable) {
$sub->table($agentTable)->where($agentTable . '.user_id=' . $current . '.id')->where('is_county', 0);
});
});
}
}
/**
* 合伙股东筛选 (存在于 shopro_commission_agent 表)
*/
public function isPartner($query, $data)
{
$value = $this->plainValue($data);
if ($value === '' || $value === null) {
return $query;
}
$current = $query->getTable();
$agentTable = (new AgentModel())->getQuery()->getTable();
$val = intval($value);
$hasPartnerCol = false;
try {
$fields = (new AgentModel())->getTableFields();
$hasPartnerCol = in_array('is_partner', $fields);
} catch (\Exception $e) {
$hasPartnerCol = false;
}
if ($val === 1) {
if (!$hasPartnerCol) {
return $query->whereRaw('1=0');
}
return $query->whereExists(function ($sub) use ($current, $agentTable) {
$sub->table($agentTable)->where($agentTable . '.user_id=' . $current . '.id')->where('is_partner', 1);
});
} else {
if (!$hasPartnerCol) {
return $query;
}
return $query->where(function (Query $q) use ($current, $agentTable) {
$q->whereNotExists(function ($sub) use ($current, $agentTable) {
$sub->table($agentTable)->where($agentTable . '.user_id=' . $current . '.id');
})->whereOrExists(function ($sub) use ($current, $agentTable) {
$sub->table($agentTable)->where($agentTable . '.user_id=' . $current . '.id')->where('is_partner', 0);
});
});
}
}
protected function plainValue($data)
{
if (is_array($data)) {

3
think
查看文件

@@ -13,5 +13,8 @@
// 定义项目路径
define('APP_PATH', __DIR__ . '/application/');
// 设置默认文件掩码,确保 CLI 创建的缓存/日志文件同组及 Web 用户有读写权限
umask(0000);
// 加载框架引导文件
require __DIR__ . '/thinkphp/console.php';