Deal.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace app\bug\controller;
  3. use think\facade\Db;
  4. use think\App;use think\facade\Validate;
  5. class Deal extends Base
  6. {
  7. public $noLogin=[];
  8. public function __construct(App $app)
  9. {
  10. parent::__construct($app);
  11. }
  12. /**处理人添加
  13. * @return \think\Response|\think\response\Json|void
  14. */
  15. public function create(){
  16. $param=$this->request->param(["bugNo"=>"","level"=>0,"type"=>0,"status"=>1],"post","trim");
  17. $valid = Validate::rule([
  18. 'bugNo|工单编号'=>'require|max:255',
  19. 'level|优先级'=>'require|number',
  20. 'type|问题类型'=>'require|number',
  21. 'status|处理状态'=>'require|number|in:0,1',
  22. ]);
  23. if($valid->check($param)==false) return error($valid->getError());
  24. $data=[
  25. "bugNo"=>$param['bugNo'],
  26. "deal_name"=>$this->uname,
  27. "deal_id"=>$this->uid,
  28. "level"=>$param['level'],
  29. "type"=>$param['type'],
  30. "status"=>$param['status']
  31. ];
  32. \app\bug\model\Deal::create($data);
  33. return success("新建成功");
  34. }
  35. public function add(){
  36. $param=$this->request->param(['id'=>'','deal_id'=>0,'status'=>1],'post','trim');
  37. $valid = Validate::rule([
  38. 'id|工单id'=>'require|number|gt:0',
  39. 'deal_id|处理人'=>'number',
  40. 'status|处理状态'=>'require|number|in:0,1',
  41. ]);
  42. if($valid->check($param)==false) return error($valid->getError());
  43. $info = \app\bug\model\Note::where(["id"=>$param['id'],"is_del"=>0])->findOrEmpty();
  44. if($info->isEmpty()){
  45. return error('未找到数据');
  46. }
  47. $deal = \app\bug\model\Manange::where(["manange_id"=>$param['deal_id'],"is_del"=>0])->findOrEmpty();
  48. if($deal->isEmpty()){
  49. \app\bug\model\Deal::where(['bugNo'=>$info['bugNo'],'status'=>0,'is_del'=>0])->save(["is_del"=>0]);
  50. }else{
  51. \app\bug\model\Deal::create(["deal_name"=>$deal->manange_name,'deal_id'=>$deal->manange_id,
  52. 'bugNo'=>$info['bugNo']]);
  53. }
  54. return success('添加成功');
  55. }
  56. // public function MenuAllList(){
  57. // $company_type = isset($this->post['company_type']) && $this->post['company_type']!==""? trim($this->post['company_type']):"";
  58. // if ($company_type== "") {
  59. // return error_show(1002,"参数company_type不能为空");
  60. // }
  61. // $where=['company_type'=>$company_type,'pid'=>0,'is_del'=>0,"status"=>1];
  62. // $level = isset($this->post['level']) && $this->post['level']!==""? trim($this->post['level']):"";
  63. // if ($level== "") {
  64. // $where['level'] = explode(",",$level);
  65. // }
  66. // $data = Db::name("model")->where($where)->order("weight desc")->select();
  67. // $l=[];
  68. // foreach ($data as $key=>$value){
  69. // $temp = Db::name("model")->where(['pid'=>$value['id'],'is_del'=>0,"level"=>[2,3],"status"=>1])->order("weight desc")
  70. // ->select()->toArray();
  71. // $value['child']=$temp;
  72. // if(empty($temp)) continue;
  73. // $l[]=$value;
  74. // }
  75. // return app_show(0,"获取成功",$l);
  76. // }
  77. }