field(true) ->where($where) ->with(['category','user']) ->order('sort', 'asc') ->paginate([ 'page' => $get['page'], 'list_rows' => $get['limit'], 'var_page' => 'page' ]) ->toArray(); foreach ($lists['data'] as &$item) { $item['username'] = $item['user']['nickname'] ?? '未知'; $item['is_complate'] = $item['is_complate'] ==1?'已处理': '未处理'; $item['avatar'] = $item['user']['avatar'] ?UrlServer::getFileUrl($item['user']['avatar']) : ''; } return ['count'=>$lists['total'], 'lists'=>$lists['data']]; } catch (Exception $e) { return ['error'=>$e->getMessage()]; } } public static function getAddr(){ } /** * @Notes: 资料详细 * @Author: * @param $id * @return array */ public static function detail($id) { $model = new Complain(); $detail = $model->field(true)->with(['category'])->findOrEmpty($id)->toArray(); $detail['category'] = $detail['category']['name'] ?? '未知'; $detail['image'] = $detail['image'] ? UrlServer::getFileUrl($detail['image']) : ''; return $detail; } /** * @Notes: 添加帮助 * @Author: * @param $post * @return bool */ public static function add($post) { try { Complain::create([ 'cid' => $post['cid'], 'uid' => $post['uid'], 'image' => $post['image'] ?? '', 'content' => $post['content'] ?? '', 'is_complate' => 0 ]); return true; } catch (\Exception $e) { static::$error = $e->getMessage(); return false; } } /** * @Notes: 删除 * @Author: * @param $id * @return bool */ public static function del($id) { try { Complain::update([ 'del' => 1, 'update_time' => time() ], ['id'=>$id]); return true; } catch (\Exception $e) { static::$error = $e->getMessage(); return false; } } /** * @Notes: 处理 * @Author: 张无忌 * @param $id * @return bool */ public static function complate($post) { try { $model = new Complain(); $article = $model->findOrEmpty($post['id'])->toArray(); Complain::update([ 'is_complate' =>1, 'remark' => $post['remark'], 'update_time' => time() ], ['id'=>$post['id']]); return true; } catch (\Exception $e) { static::$error = $e->getMessage(); return false; } } //获取用户投诉列表 public static function getUserComplain($get,$user_id) { try { $model = new Complain(); $lists = $model->field('*') ->order('id', 'desc') ->where([ ['uid', '=', $user_id], ['del', '=', 0] ]) ->page($get['page_no'], $get['page_size']) ->select() ->toArray(); $count = $model ->where([ ['uid', '=', $user_id], ['del', '=', 0] ]) ->count(); return [ 'count' => $count, 'lists' => $lists, 'page_no' => $get['page_no'], 'page_size' => $get['page_size'], 'more' => is_more($count, $get['page_no'], $get['page_size']) ]; } catch (\Exception $e) { return ['error'=>$e->getMessage()]; } } }