123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- <?php
- namespace app\admin\controller;
- use app\BaseController;
- use think\facade\Db;
- use think\App;
- class Deal extends BaseController
- {
- public $post="";
- public function __construct(App $app)
- {
- parent::__construct($app);
- $this->post=$this->request->post();
- }
- public function create(){
- $token = isset($this->post['token']) && $this->post['token'] !=="" ?trim($this->post['token']):"";
- if($token==""){
- return error_show(101,'token不能为空');
- }
- $bugNo = isset($this->post['bugNo']) && $this->post['bugNo'] !=="" ? trim($this->post['bugNo']) :"";
- if($bugNo==""){
- return error_show(1002,"参数bugNo不能为空");
- }
- $apply_id =VerifyTokens($token);
- if(empty($apply_id)||$apply_id['code']!=0){
- return error_show(1002,"申请人数据不存在");
- }
- $rm= isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
- $ri= isset($apply_id["data"]['nickname']) ? $apply_id["data"]['nickname'] : "";
- // $depart= isset($apply_id["data"]['department']) ? $apply_id["data"]['department'] : "";
- $level = isset($this->post['level']) && $this->post['level'] !==""? trim($this->post['level']):"";
- $type = isset($this->post['type']) && $this->post['type'] !==""? intval($this->post['type']):"0";
- $status = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):"1";
- $data=[
- "bugNo"=>$bugNo,
- "deal_name"=>$ri,
- "deal_id"=>$rm,
- // "depart"=>$depart,
- "level"=>$level,
- "type"=>$type,
- "status"=>$status,
- "is_del"=>0,
- "addtime"=>date("Y-m-d H:i:s"),
- "updatetime"=>date("Y-m-d H:i:s")
- ];
- $datainfo=Db::name('deal')->insert($data);
- if($datainfo){
- return error_show(0,"新建成功");
- }else{
- return error_show(1002,"新建失败");
- }
- }
- public function add(){
- $token = isset($this->post['token']) && $this->post['token'] !==""? trim($this->post['token']) :"";
- // var_dump($this->post);
- $id = isset($this->post['id']) ? intval($this->post['id']) : "";
- if($id==""){
- return error_show(1001,'参数id不能为空');
- }
- $info = Db::name("note")->where(["id"=>$id,"is_del"=>0])->find();
- if(empty($info)){
- return error_show(1002,'未找到数据');
- }
- $company_type = isset($this->post['company_type']) && $this->post['company_type'] !=="" ?trim($this->post['company_type']):"";
- if($company_type==""){
- return error_show(1002,"参数company_type不能为空");
- }
- $deal_id = isset($this->post['deal_id']) && $this->post['deal_id'] !==""? intval($this->post['deal_id']) :"";
- if ($deal_id==""){
- $str['is_del']=1;
- $str['updatetime']=date("Y-m-d H:i:s");
- $inf=Db::name('deal')->where(['bugNo'=>$info['bugNo'],'status'=>0,"is_del"=>0])->save($str);
- return $inf ? app_show(0,"编辑成功") :error_show(1002,"编辑失败");
- }
- else{
- $to= GetInfoById($token,['id'=>$deal_id]);
- if((!empty($to) && $to['code']!=0) ||empty($to) ){
- return error_show($to['code'],$to['message']);
- }
- $datai=[];
- $in = $to['data'];
- $datai['deal_name'] = $in['nickname'];
- $datai['deal_id'] = $in['id'];
- $datai['bugNo'] = $info['bugNo'];
- $datai['is_del'] = 0;
- $datai['addtime'] = date("Y-m-d H:i:s");
- $datai['updatetime'] = date("Y-m-d H:i:s");
- $data= Db::name('deal')->insert($datai);
- if($data){
- return error_show(0,"添加成功");
- }else{
- return error_show(1002,"添加失败");
- }
- }
- }
- // public function list(){
- // $where =[['is_del','=',0]];
- // $deal_name = isset($this->post['deal_name']) && $this->post['deal_name'] !== "" ? trim($this->post['deal_name']) : "";
- // if ($deal_name !== "") {
- // $where[]= ["deal_name",'like',"%$deal_name%"];
- // }
- // $list=Db::name('deal')->where($where)->order("addtime desc")->select();
- // return app_show(0,"获取成功",['list'=>$list]);
- // }
- // public function select(){
- // $company_type = isset($this->post['company_type']) && $this->post['company_type']!==""? trim($this->post['company_type']):"";
- // if ($company_type== "") {
- // return error_show(1002,"参数company_type不能为空");
- // }
- // $info = Db::name('note')->where(['is_del'=>0])->field("model_id")->select();
- // foreach ($info as $value){
- // $value['can']= isset($value['model_id']) && $value['model_id'] !=0 ? made($value['model_id']):[];
- // $data[]=$value;
- // }
- // return app_show(0,"获取成功",$data);
- // }
- public function MenuAllList(){
- $company_type = isset($this->post['company_type']) && $this->post['company_type']!==""? trim($this->post['company_type']):"";
- if ($company_type== "") {
- return error_show(1002,"参数company_type不能为空");
- }
- $where=['company_type'=>$company_type,'pid'=>0,'is_del'=>0,"status"=>1];
- $level = isset($this->post['level']) && $this->post['level']!==""? trim($this->post['level']):"";
- if ($level== "") {
- $where['level'] = explode(",",$level);
- }
- $data = Db::name("model")->where($where)->order("weight desc")->select();
- $l=[];
- foreach ($data as $key=>$value){
- $temp = Db::name("model")->where(['pid'=>$value['id'],'is_del'=>0,"level"=>[2,3],"status"=>1])->order("weight desc")
- ->select()->toArray();
- $value['child']=$temp;
- if(empty($temp)) continue;
- $l[]=$value;
- }
- return app_show(0,"获取成功",$l);
- }
- // public function status(){
- // $id = isset($this->post['id']) ? intval($this->post['id']) : "";
- // if($id==""){
- // return error_show(1001,'参数id不能为空');
- // }
- // $info = Db::name("deal")->where(["id"=>$id,"is_del"=>0])->find();
- // if(empty($info)){
- // return error_show(1002,'未找到数据');
- // }
- // $status = isset($this->post['status'])&&$this->post['status']!=='' ? intval($this->post['status']) : "0";
- // if($status===""){
- // return error_show(1001,'参数status不能为空');
- // }
- // $level = isset($this->post['level']) && $this->post['level']!==""? trim($this->post['level']):"1";
- // if($level==""){
- // return error_show(1001,'参数level不能为空');
- // }
- // $type = isset($this->post['type'])&&$this->post['type']!=='' ? intval($this->post['type']) : "0";
- // if($type==""){
- // return error_show(1001,'参数type不能为空');
- // }
- // $deal_name= isset($this->post['deal_name'])&&$this->post['deal_name']!=='' ? intval($this->post['deal_name']) : "";
- // if($deal_name==""){
- // return error_show(1001,'参数deal_name不能为空');
- // }
- // $info['status']= $status;
- // $info['deal_name']= $deal_name;
- // $info['level']= $level;
- // $info['type']= $type;
- // $info['updatetime']=date("Y-m-d H:i:s");
- // $up = Db::name("deal")->update($info);
- // if($up){
- // return app_show(0,"更新成功");
- // }else{
- // return error_show(1005,"更新失败");
- // }
- // }
- }
|