title = '资料列表'; $datum_cate = \app\common\model\DatumCate::field('id,title')->select()->toArray(); $this->datum_cate = array_column($datum_cate,null,'id'); $sel_where = []; $sel_where[] = ['v.is_deleted','=',0]; if($title = $this->request->get('title')) $sel_where[] = ['v.title','like','%'.$title.'%']; if($phone = $this->request->get('phone')) $sel_where[] = ['m.phone','like','%'.$phone.'%']; $this->status = $this->request->get('status',-1); if( $this->status >= 0 ) $sel_where[] = ['v.status','=', $this->status ]; $query = $this->_query($this->table)->field('v.*,m.phone,m.name user_name, m.headimg')->alias('v') ->leftJoin('StoreMember m','m.id = v.user_id'); $arr = ['is_new' => 0]; \app\common\model\UserDatum::alias('f')->where('is_new',1)->update($arr); $query->where($sel_where)->order('v.sort desc,v.id desc')->page(); } /** * 数据列表处理 * @auth true * @menu true * @param array $data * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ protected function _index_page_filter(&$data) { } /** * 编辑 * @auth true * @menu true * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException */ public function edit() { $this->title = '编辑资料'; $this->_form($this->table, 'form'); } /** * 表单数据处理 * @auth true * @menu true * @param array $data */ protected function _form_filter(&$data) { if($this->request->isPost() && in_array($this->request->action(),['add','edit'])) { if($data['status'] > 0 ) UserMessage::sendUserMessage($data['user_id'],'datum',2,$data['status']-1,0,$data['id']); // if($data['status'] = 1) \app\common\model\TopSearch::saveData($data['id'],'datum'); } } protected function _form_result($result){ } /** * 资料添加到系列 * @auth true * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException */ public function series() { if ($this->request->isGet()) { $id = $this->request->get('id'); $has_series = \app\common\model\DatumUrl::where('rel_id',$id)->column('datum_id'); $user_datum = \app\common\model\UserDatum::where(['id' => $id])->find()->toArray(); $series_list = DatumIntro::where(['is_deleted'=>0,'type'=>2])->where('id','not in',$has_series)->column('title','id'); $this->fetch('', ['vo' => $user_datum,'series_list'=>$series_list]); } else { $id = input('post.id'); $series_id = input('post.series_id'); $sort = input('post.sort'); $is_vip = input('post.is_vip'); if(!$series_id) $this->error('请选择系列'); $user_datum = \app\common\model\UserDatum::where(['id' => $id])->find()->toArray(); \app\common\model\DatumUrl::create([ 'datum_id'=>$series_id, 'url'=>$user_datum['datum_url'], 'sort'=>$sort, 'is_vip'=>$is_vip, 'source'=>2, 'rel_id'=>$id, 'title'=>$user_datum['title'], ]); DatumIntro::where('id',$series_id)->setInc('url_num'); $this->success('添加成功!'); } } public function new_datum() { if($this->request->isAjax()) { $id = input('id'); $user_datum = \app\common\model\UserDatum::where(['id' => $id])->find()->toArray(); $new_datum = [ 'title' => $user_datum['title'], 'desc' => $user_datum['desc'], 'datum_url' => $user_datum['datum_url'], 'label' => $user_datum['label'], 'is_over' => 1, 'is_vip' => 0, ]; $result = DatumIntro::create($new_datum); $datum_url = [ 'datum_id' => $result->id, 'url' => $new_datum['datum_url'], 'sort' => 0, 'is_deleted' => 0, 'is_vip' => $new_datum['is_vip'], 'source' => 2, 'title' => $new_datum['title'], 'rel_id' => $id, ]; Data::save('DatumUrl',$datum_url,'datum_id',['datum_id' => $result->id]); $this->success('创建成功'); } } /** * 删除资料 * @auth true * @menu true * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException */ public function del() { $this->_save($this->table, ['is_deleted' => 1]); } }