$this->orgId, 'user_id'=>$this->userId, 'content'=>$content, 'images'=>$imgs, 'create_time'=>date('Y-m-d H:i:s'), 'create_yyyy'=>date('Y'), 'create_yyyymm'=>date('Ym'), 'create_yyyymmdd'=>date('Ymd'), 'green_addr_id'=>$addrId, 'green_cate_id'=>$cateId, ]; $add = Db::name('green_record')->insert($data); if($add){ HelpHander::success('操作成功'); }else{ HelpHander::error('操作失败'); } } public function recordList(){ $page = input('page',1); $size = input('size',10); $type = input('type/d',0); $addId = input('greenAddrId'); if(!$addId){ HelpHander::error('地点不存在'); } if($type == 1){ // 查看全部记录 $auth = (new Roles())->getAppAuth($this->userId,AppAuth::GREEN_LOOK_ALL_AUTH); if(!$auth){ // 无权限 $m[] = ['user_id','=',-1]; } }else{ // 查看个人记录 $m[] = ['user_id','=',$this->userId]; } $m[] = ['org_id','=',$this->orgId]; $m[] = ['green_addr_id','=',$addId]; $list = Db::name('green_record') ->field('id,create_time,user_id,green_cate_id') ->where($m) ->page($page,$size) ->order('id desc') ->select(); foreach ($list as $k=>$v){ $list[$k]['user_name'] = Db::name('user') ->where('id',$v['user_id']) ->value('real_name'); $list[$k]['cate_name'] = Db::name('green_cate') ->where('id',$v['green_cate_id']) ->value('title'); } HelpHander::success($list); } public function details(){ $id = input('id',0); $info = Db::name('green_record') ->where('id',$id) ->find(); if(!$info){ HelpHander::error('参数错误'); } $addr = Db::name('green_addr')->where('id',$info['green_addr_id'])->find(); $info['addr_name'] = $addr?$addr['title']:''; $info['addr_img'] = $addr?$addr['img']:''; $info['addr_content'] =$addr? $addr['content']:''; $info['cate_name'] = Db::name('green_cate') ->where('id',$info['green_cate_id']) ->value('title'); $info['user_name'] = Db::name('user') ->where('id',$info['user_id']) ->value('real_name'); HelpHander::success($info); } }