fix(core): 设置CLI默认文件掩码避免权限冲突,完善用户筛选代理方法
这个提交包含在:
@@ -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)) {
|
||||
|
||||
在新工单中引用
屏蔽一个用户