where("uip",$post['uip'])->find(); if(!empty($m)) { $where[]=["c.uid","=",$m['uid']]; } }else if (!empty($post['mobile'])) { $m = Db::name("user")->where("mobile",$post['mobile'])->find(); if(!empty($m)) { $where[]=["c.uid","=",$m['uid']]; } }else if(!empty($post['nickname'])){ $m = Db::name("user")->where("nickname",$post['nickname'])->find(); if(!empty($m)) { $where[]=["c.uid","=",$m['uid']]; } } // if (!empty($post["title"])){ // $where[]=["c.title","like","%{$post['title']}%"]; // } $where2 = $where; $where2[]=["c.status","=",0];//待审核 if(in_array((string)$post["status"],['0','1','-1'])){ $where[]=["c.status","=",(int)$post["status"]]; } $data = (new UserCircle) ->field("c.*,u.nickname,g.imgs as pro_imgs,g.title as pro_title") ->alias("c") ->where($where) ->leftJoin("user u", "u.uid = c.uid") ->leftJoin("goods g", "g.id = c.pro_id") ->page((int)$post["page"], (int)$pageSize) ->order("c.id","desc") ->select() ->toArray(); $pageCount = (new UserCircle)->alias("c")->where($where)->count(); $waitCount = (new UserCircle)->alias("c")->where($where2)->count(); $data = empty($data)?[]:$data; foreach($data as $k=>$v){ $data[$k]["imgs"] = empty($v["imgs"])?[]:explode(",",$v["imgs"]); $data[$k]["time"] = date("Y-m-d H:i:s",$v["time"]); $data[$k]["pro_img"] = empty($v["pro_imgs"]) ? "" : explode(",", $v["pro_imgs"])[0]; } return app('json')->success([ 'list' => $data, 'pageCount' => $pageCount, 'pageSize' => $pageSize, 'page' => $post["page"], 'waitCount' => $waitCount, ]); } /** * 审核动态 * @param Request $request */ public function editStatus(Request $request) { [$id,$status] = UtilService::getMore([ ['id',0,'empty','参数错误'], ['status','','empty','参数错误'] ],$request,true); $data = (new UserCircle)->where("id",$id)->find(); if(empty($data)){ return app('json')->fail("数据不存在"); } //禁用 if($status==-1){ (new UserCircle)->where("id",$id)->update(["status"=>-1]); } //删除 if($status==-10){ (new UserCircle)->where("id",$id)->delete(); } //发布 if($status==1){ (new UserCircle)->where("id",$id)->update(["status"=>1]); } return app('json')->success("操作成功"); } }