123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- namespace app\operate\controller;
- use app\common\model\User;
- use app\common\model\UserMessage;
- use library\Controller;
- use think\Db;
- use library\tools\Data;
- /**
- * 需求
- * Class Demand
- * @package app\operate\controller
- */
- class Demand extends Controller
- {
- protected $table = 'UserDemand';
- /**
- * 列表
- * @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 index()
- {
- $this->title = '列表';
- $where = [];
- $where[] = ['f.is_deleted','=',0];
- if($title = input('title')) $where[] = ['f.title','like','%'.$title.'%'];
- if($name = input('name')) $where[] = ['u.name','like','%'.$name.'%'];
- if($phone = input('phone')) $where[] = ['u.phone','=',$phone];
- $query = $this->_query($this->table)->alias('f')
- ->field('f.*,u.name,u.phone,u.headimg')
- ->leftJoin('store_member u','u.id = f.user_id')
- ->where($where)
- ->order('sort desc,f.id desc')->page();
- }
- /**
- * 删除
- * @auth true
- * @throws \think\Exception
- * @throws \think\exception\PDOException
- */
- public function del()
- {
- $this->_save($this->table, ['is_deleted' => '1']);
- }
- /**
- * 编辑
- * @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');
- }
- protected function _form_filter(&$data)
- {
- if($this->request->isGet()) $this->user_info = Db::name('store_member')->find($data['user_id']);
- if($this->request->isPost())
- {
- $user_demand = Db::name('user_demand')->find($data['id']);
- // if($user_demand['status'] != 0) $this->error('不能重复审核');
- if($data['status'] > 0 ) UserMessage::sendUserMessage($data['user_id'],'demand',2,$data['status']-1,0,$data['id']);
- }
- }
- protected function _form_result($result){
- if($this->request->isPost() && in_array($this->request->action(),['edit']))
- {
- $user_demand = Db::name('user_demand')->find($result);
- if($user_demand['status'] == 1){
- $demand_data = [
- 'user_id' => $user_demand['user_id'],
- 'title' => $user_demand['title'],
- 'content' => $user_demand['content'],
- 'status' => 1,
- 'money' => $user_demand['money'],
- 'rel_id' => $user_demand['id'],
- 'cover' => $user_demand['cover'],
- 'company' => $user_demand['company'],
- 'images' => $user_demand['images'],
- 'label' => $user_demand['label'],
- 'company_logo' => $user_demand['company_logo'],
- ];
- Data::save("PlatformDemand",$demand_data,'rel_id',['rel_id'=>$result]);
- }
- $this->success('操作成功', 'javascript:history.back()');
- }
- }
- }
|