diff --git a/addons/shopro/filter/user/UserFilter.php b/addons/shopro/filter/user/UserFilter.php index a8181a8..4c02f56 100755 --- a/addons/shopro/filter/user/UserFilter.php +++ b/addons/shopro/filter/user/UserFilter.php @@ -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)) { diff --git a/think b/think index 8eeb81b..3e63d12 100755 --- a/think +++ b/think @@ -13,5 +13,8 @@ // 定义项目路径 define('APP_PATH', __DIR__ . '/application/'); +// 设置默认文件掩码,确保 CLI 创建的缓存/日志文件同组及 Web 用户有读写权限 +umask(0000); + // 加载框架引导文件 require __DIR__ . '/thinkphp/console.php'; \ No newline at end of file