field(true) ->where($where) ->order('sort', 'asc') ->order('id', 'desc') ->paginate([ 'page' => $get['page'], 'list_rows' => $get['limit'], 'var_page' => 'page' ]) ->toArray(); foreach ($lists['data'] as &$item) { $item['is_show'] = $item['is_show'] ? '显示' : '隐藏'; $item['address'] = $item['province_id']?AreaServer::getAddress([ $item['province_id'], $item['city_id'], ]):''; $item['username'] = "系统后台"; $item['mobile'] = ""; if($item['uid']>0){ $model = new User(); $user = $model->findOrEmpty($item['uid']); if($user){ $item['username'] = $user['nickname']; $item['mobile'] = $user['mobile']; } } } 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 OrganTeam(); $detail = $model->field(true)->findOrEmpty($id)->toArray(); // $detail['path'] = UrlServer::getFileUrl($detail['path']); $detail['address'] = $detail['province_id']?AreaServer::getAddress([ $detail['province_id'], $detail['city_id'], ]):''; return $detail; } /** * @Notes: 添加帮助 * @Author: * @param $post * @return bool */ public static function add($post,$uid=0) { try { OrganTeam::create([ 'uid' => $uid, 'name' => $post['name'], 'image' => $post['image'] ?? '', 'intro' => $post['intro'] ?? '', 'content' => $post['content'] ?? '', 'type' => $post['type'] ?? 0, 'province_id' => $post['province_id'] ?? 0, 'city_id' => $post['city_id'] ?? 0, 'district_id' => $post['district_id'] ?? 0, 'address_detail' => $post['address_detail'] ?? '', 'visit' => 0, 'contact' => $post['contact'] ?? '', 'sort' => $post['sort'] ?? 0, 'is_show' => $post['is_show']??0, 'company' => $post['company'] ?? '', 'audit_status' =>$post['audit_status'] ?? 1, ]); return true; } catch (\Exception $e) { static::$error = $e->getMessage(); return false; } } /** * @Notes: 编辑帮助 * @Author: 张无忌 * @param $post * @return bool */ public static function edit($post,$uid=0) { try { OrganTeam::update([ 'uid' => $uid, 'name' => $post['name'], 'image' => $post['image'] ?? '', 'intro' => $post['intro'] ?? '', 'content' => $post['content'] ?? '', 'company' => $post['company'] ?? '', 'type' => $post['type'] ?? 0, 'province_id' => $post['province_id'] ?? 0, 'city_id' => $post['city_id'] ?? 0, 'district_id' => $post['district_id'] ?? 0, 'address_detail' => $post['address_detail'] ?? '', 'visit' => 0, 'contact' => $post['contact'] ?? '', 'sort' => $post['sort'] ?? 0, 'is_show' => $post['is_show']??0, 'audit_status' =>$post['audit_status'] ?? 1, ], ['id'=>$post['id']]); return true; } catch (\Exception $e) { static::$error = $e->getMessage(); return false; } } /** * @Notes: 删除 * @Author: * @param $id * @return bool */ public static function del($id) { try { OrganTeam::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 hide($id) { try { $model = new OrganTeam(); $article = $model->findOrEmpty($id)->toArray(); OrganTeam::update([ 'is_show' => !$article['is_show'], 'update_time' => time() ], ['id'=>$id]); return true; } catch (\Exception $e) { static::$error = $e->getMessage(); return false; } } //获取用户投诉列表 public static function getUserOrgan($get,$user_id) { try { $model = new OrganTeam(); $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()]; } } /** * @notes 审核文章 * @param $post * @return bool * @author 段誉 * @date 2022/5/12 16:57 */ public static function audit($post) { try { $article = OrganTeam::findOrEmpty($post['id']); $article->audit_status = $post['audit_status']; $article->audit_remark = $post['audit_remark'] ?? ''; $article->audit_time = time(); $article->save(); return true; } catch (\Exception $e) { Db::rollback(); self::$error = $e->getMessage(); return false; } } }