Deal.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <?php
  2. namespace app\admin\controller;
  3. use app\BaseController;
  4. use think\facade\Db;
  5. use think\App;
  6. class Deal extends BaseController
  7. {
  8. public $post="";
  9. public function __construct(App $app)
  10. {
  11. parent::__construct($app);
  12. $this->post=$this->request->post();
  13. }
  14. public function create(){
  15. $token = isset($this->post['token']) && $this->post['token'] !=="" ?trim($this->post['token']):"";
  16. if($token==""){
  17. return error_show(101,'token不能为空');
  18. }
  19. $bugNo = isset($this->post['bugNo']) && $this->post['bugNo'] !=="" ? trim($this->post['bugNo']) :"";
  20. if($bugNo==""){
  21. return error_show(1002,"参数bugNo不能为空");
  22. }
  23. $apply_id =VerifyTokens($token);
  24. if(empty($apply_id)||$apply_id['code']!=0){
  25. return error_show(1002,"申请人数据不存在");
  26. }
  27. $rm= isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
  28. $ri= isset($apply_id["data"]['nickname']) ? $apply_id["data"]['nickname'] : "";
  29. // $depart= isset($apply_id["data"]['department']) ? $apply_id["data"]['department'] : "";
  30. $level = isset($this->post['level']) && $this->post['level'] !==""? trim($this->post['level']):"";
  31. $type = isset($this->post['type']) && $this->post['type'] !==""? intval($this->post['type']):"0";
  32. $status = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):"1";
  33. $data=[
  34. "bugNo"=>$bugNo,
  35. "deal_name"=>$ri,
  36. "deal_id"=>$rm,
  37. // "depart"=>$depart,
  38. "level"=>$level,
  39. "type"=>$type,
  40. "status"=>$status,
  41. "is_del"=>0,
  42. "addtime"=>date("Y-m-d H:i:s"),
  43. "updatetime"=>date("Y-m-d H:i:s")
  44. ];
  45. $datainfo=Db::name('deal')->insert($data);
  46. if($datainfo){
  47. return error_show(0,"新建成功");
  48. }else{
  49. return error_show(1002,"新建失败");
  50. }
  51. }
  52. public function add(){
  53. $token = isset($this->post['token']) && $this->post['token'] !==""? trim($this->post['token']) :"";
  54. // var_dump($this->post);
  55. $id = isset($this->post['id']) ? intval($this->post['id']) : "";
  56. if($id==""){
  57. return error_show(1001,'参数id不能为空');
  58. }
  59. $info = Db::name("note")->where(["id"=>$id,"is_del"=>0])->find();
  60. if(empty($info)){
  61. return error_show(1002,'未找到数据');
  62. }
  63. $company_type = isset($this->post['company_type']) && $this->post['company_type'] !=="" ?trim($this->post['company_type']):"";
  64. if($company_type==""){
  65. return error_show(1002,"参数company_type不能为空");
  66. }
  67. $deal_id = isset($this->post['deal_id']) && $this->post['deal_id'] !==""? intval($this->post['deal_id']) :"";
  68. if ($deal_id==""){
  69. $str['is_del']=1;
  70. $str['updatetime']=date("Y-m-d H:i:s");
  71. $inf=Db::name('deal')->where(['bugNo'=>$info['bugNo'],'status'=>0,"is_del"=>0])->save($str);
  72. return $inf ? app_show(0,"编辑成功") :error_show(1002,"编辑失败");
  73. }
  74. else{
  75. $to= GetInfoById($token,['id'=>$deal_id]);
  76. if((!empty($to) && $to['code']!=0) ||empty($to) ){
  77. return error_show($to['code'],$to['message']);
  78. }
  79. $datai=[];
  80. $in = $to['data'];
  81. $datai['deal_name'] = $in['nickname'];
  82. $datai['deal_id'] = $in['id'];
  83. $datai['bugNo'] = $info['bugNo'];
  84. $datai['is_del'] = 0;
  85. $datai['addtime'] = date("Y-m-d H:i:s");
  86. $datai['updatetime'] = date("Y-m-d H:i:s");
  87. $data= Db::name('deal')->insert($datai);
  88. if($data){
  89. return error_show(0,"添加成功");
  90. }else{
  91. return error_show(1002,"添加失败");
  92. }
  93. }
  94. }
  95. // public function list(){
  96. // $where =[['is_del','=',0]];
  97. // $deal_name = isset($this->post['deal_name']) && $this->post['deal_name'] !== "" ? trim($this->post['deal_name']) : "";
  98. // if ($deal_name !== "") {
  99. // $where[]= ["deal_name",'like',"%$deal_name%"];
  100. // }
  101. // $list=Db::name('deal')->where($where)->order("addtime desc")->select();
  102. // return app_show(0,"获取成功",['list'=>$list]);
  103. // }
  104. // public function select(){
  105. // $company_type = isset($this->post['company_type']) && $this->post['company_type']!==""? trim($this->post['company_type']):"";
  106. // if ($company_type== "") {
  107. // return error_show(1002,"参数company_type不能为空");
  108. // }
  109. // $info = Db::name('note')->where(['is_del'=>0])->field("model_id")->select();
  110. // foreach ($info as $value){
  111. // $value['can']= isset($value['model_id']) && $value['model_id'] !=0 ? made($value['model_id']):[];
  112. // $data[]=$value;
  113. // }
  114. // return app_show(0,"获取成功",$data);
  115. // }
  116. public function MenuAllList(){
  117. $company_type = isset($this->post['company_type']) && $this->post['company_type']!==""? trim($this->post['company_type']):"";
  118. if ($company_type== "") {
  119. return error_show(1002,"参数company_type不能为空");
  120. }
  121. $where=['company_type'=>$company_type,'pid'=>0,'is_del'=>0,"status"=>1];
  122. $level = isset($this->post['level']) && $this->post['level']!==""? trim($this->post['level']):"";
  123. if ($level== "") {
  124. $where['level'] = explode(",",$level);
  125. }
  126. $data = Db::name("model")->where($where)->order("weight desc")->select();
  127. $l=[];
  128. foreach ($data as $key=>$value){
  129. $temp = Db::name("model")->where(['pid'=>$value['id'],'is_del'=>0,"level"=>[2,3],"status"=>1])->order("weight desc")
  130. ->select()->toArray();
  131. $value['child']=$temp;
  132. if(empty($temp)) continue;
  133. $l[]=$value;
  134. }
  135. return app_show(0,"获取成功",$l);
  136. }
  137. // public function status(){
  138. // $id = isset($this->post['id']) ? intval($this->post['id']) : "";
  139. // if($id==""){
  140. // return error_show(1001,'参数id不能为空');
  141. // }
  142. // $info = Db::name("deal")->where(["id"=>$id,"is_del"=>0])->find();
  143. // if(empty($info)){
  144. // return error_show(1002,'未找到数据');
  145. // }
  146. // $status = isset($this->post['status'])&&$this->post['status']!=='' ? intval($this->post['status']) : "0";
  147. // if($status===""){
  148. // return error_show(1001,'参数status不能为空');
  149. // }
  150. // $level = isset($this->post['level']) && $this->post['level']!==""? trim($this->post['level']):"1";
  151. // if($level==""){
  152. // return error_show(1001,'参数level不能为空');
  153. // }
  154. // $type = isset($this->post['type'])&&$this->post['type']!=='' ? intval($this->post['type']) : "0";
  155. // if($type==""){
  156. // return error_show(1001,'参数type不能为空');
  157. // }
  158. // $deal_name= isset($this->post['deal_name'])&&$this->post['deal_name']!=='' ? intval($this->post['deal_name']) : "";
  159. // if($deal_name==""){
  160. // return error_show(1001,'参数deal_name不能为空');
  161. // }
  162. // $info['status']= $status;
  163. // $info['deal_name']= $deal_name;
  164. // $info['level']= $level;
  165. // $info['type']= $type;
  166. // $info['updatetime']=date("Y-m-d H:i:s");
  167. // $up = Db::name("deal")->update($info);
  168. // if($up){
  169. // return app_show(0,"更新成功");
  170. // }else{
  171. // return error_show(1005,"更新失败");
  172. // }
  173. // }
  174. }