alias = $alias; $this->join_alis = $join_alias; /** @var User $user */ $user = app()->make($this->joinModel()); $table = $user->getName(); return parent::getModel()->join($table . ' ' . $join_alias, $alias . '.uid = ' . $join_alias . '.uid', $join)->alias($alias); } /** * 列表 * @param array $where * @param int $page * @param int $limit * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function sysPage(array $where, int $page, int $limit) { return $this->searchWhere($where)->page($page, $limit)->order('id desc')->select()->toArray(); } /** * 总数 * @param array $where * @return int */ public function sysCount(array $where) { return $this->searchWhere($where)->count(); } /** * 筛选条件 * @param array $where * @return \crmeb\basic\BaseModel */ public function searchWhere(array $where = []) { return $this->getModel() ->when($where['nickname'] != '', function ($query) use ($where) { $query->where('u.nickname', 'like', '%' . $where['nickname'] . '%'); })->when($where['status'] != '', function ($query) use ($where) { $query->where('c.status', $where['status']); })->when($where['coupon_title'] != '', function ($query) use ($where) { $query->where('c.coupon_title', 'like', '%' . $where['coupon_title'] . '%'); })->field('c.*,u.nickname'); } }