作者 lyh

gx

@@ -39,49 +39,6 @@ use Illuminate\Support\Facades\DB; @@ -39,49 +39,6 @@ use Illuminate\Support\Facades\DB;
39 class ProjectController extends BaseController 39 class ProjectController extends BaseController
40 { 40 {
41 41
42 - public function list(ProjectLogic $logic)  
43 - {  
44 - $map = [];  
45 - //搜索类型  
46 - if(isset($this->param['type']) && $this->param['type'] == Project::TYPE_THREE){  
47 - $map[] = ['type', 'in' ,[Project::TYPE_FOUR,Project::TYPE_SIX]];  
48 - }  
49 - if(isset($this->param['type']) && $this->param['type'] == Project::TYPE_TWO){  
50 - $map[] = ['type', 'in', [Project::TYPE_TWO,Project::TYPE_THREE]];  
51 - }  
52 - if(isset($this->param['type']) && $this->param['type'] == Project::TYPE_ONE){  
53 - $map[] = ['type','in',[Project::TYPE_ONE]];  
54 - }  
55 - if(isset($this->param['type']) && $this->param['type'] == Project::TYPE_ZERO){  
56 - $map[] = ['type','in',[Project::TYPE_ZERO]];  
57 - }  
58 - //搜索技术组  
59 - if(!empty($this->param['dep_id'])){  
60 - $map[] = ['id', 'in', DeployBuild::where('dept_id', $this->param['dep_id'])->pluck('project_id')->toArray()];  
61 - }  
62 - //搜索技术人员  
63 - if(!empty($this->param['manage_id'])){  
64 - $map[] = ['id', 'in', DeployBuild::where('leader_mid', $this->param['manage_id'])  
65 - ->orwhere('manager_mid', $this->param['manage_id'])  
66 - ->orwhere('designer_mid', $this->param['manage_id'])  
67 - ->orwhere('tech_mid', $this->param['manage_id'])  
68 - ->pluck('project_id')  
69 - ->toArray()];  
70 - }  
71 - //按类型搜索  
72 - if(!empty($this->param['search']) && !empty($this->param['search_type'])){  
73 - if($this->param['search_type'] == 'domain'){  
74 - //搜索域名  
75 - $map[] = ['id', 'in', DeployOptimize::where('domain', 'like', "%{$this->param['search']}%")->pluck('project_id')->toArray()];  
76 - }else{  
77 - $map[] = [$this->param['search_type'], 'like', "%{$this->param['search']}%"];  
78 - }  
79 - }  
80 - $sort = ['id' => 'desc'];  
81 - $data = $logic->getList($map, $sort,['*'],$this->row);  
82 - $this->response('success',Code::SUCCESS,$data);  
83 - }  
84 -  
85 /** 42 /**
86 * @remark :项目列表 43 * @remark :项目列表
87 * @name :lists 44 * @name :lists
@@ -18,6 +18,7 @@ use App\Models\ASide\APublicModel; @@ -18,6 +18,7 @@ use App\Models\ASide\APublicModel;
18 use App\Models\Channel\Channel; 18 use App\Models\Channel\Channel;
19 use App\Models\HomeCount\Count; 19 use App\Models\HomeCount\Count;
20 use App\Models\Manage\Manage; 20 use App\Models\Manage\Manage;
  21 +use App\Models\Project\DeployBuild;
21 use App\Models\Project\DeployOptimize; 22 use App\Models\Project\DeployOptimize;
22 use App\Models\Project\Project; 23 use App\Models\Project\Project;
23 use App\Models\Task\Task; 24 use App\Models\Task\Task;
@@ -32,27 +33,65 @@ class RenewProjectController extends BaseController @@ -32,27 +33,65 @@ class RenewProjectController extends BaseController
32 * @method :post 33 * @method :post
33 * @time :2023/8/11 10:22 34 * @time :2023/8/11 10:22
34 */ 35 */
35 - public function lists(ProjectLogic $logic){ 36 + public function lists(Project $project){
  37 + $arr = $this->getLessThanFifteenProjectId();
  38 + $map = [];
  39 + if(!empty($arr)){
  40 + $this->searchParam($map,$this->map,$arr);
  41 + //按类型搜索
  42 + $map['id'] = ['in', $arr];
  43 + }
  44 + $filed = ['id', 'title', 'mysql_id' ,'channel','cooperate_date' ,'type', 'created_at'];
  45 + $lists = $project->formatQuery($map)->select($filed)->with('payment')->with('deploy_build')
  46 + ->with('deploy_optimize')->with('online_check')->paginate($this->row, ['*'], 'page', $this->page);
  47 + if(!empty($lists)){
  48 + $lists = $lists->toArray();
  49 + foreach ($lists['list'] as $k=>$item){
  50 + $item = $this->handleParam($item);
  51 + $lists['list'][$k] = $item;
  52 + }
  53 + }
  54 + $this->response('success',Code::SUCCESS,$lists);
  55 + }
  56 +
  57 + /**
  58 + * @remark :获取小于15天的项目id
  59 + * @name :getlessThanFifteenProjectId
  60 + * @author :lyh
  61 + * @method :post
  62 + * @time :2023/8/30 11:49
  63 + */
  64 + public function getLessThanFifteenProjectId(){
36 $count = new Count(); 65 $count = new Count();
37 $yesterday = Carbon::yesterday()->toDateString(); 66 $yesterday = Carbon::yesterday()->toDateString();
38 $count_list = $count->list(['date'=>$yesterday,'service_day'=>['<=',15]],'id',['project_id']); 67 $count_list = $count->list(['date'=>$yesterday,'service_day'=>['<=',15]],'id',['project_id']);
39 $arr = []; 68 $arr = [];
  69 + if(!empty($count_list)){
40 foreach ($count_list as $v){ 70 foreach ($count_list as $v){
41 $arr[] = $v['project_id']; 71 $arr[] = $v['project_id'];
42 } 72 }
43 - $sort = ['id' => 'desc']; 73 + }
  74 + return $arr;
  75 + }
  76 +
  77 + /**
  78 + * @remark :搜索参数处理
  79 + * @name :searchParam
  80 + * @author :lyh
  81 + * @method :post
  82 + * @time :2023/8/30 10:30
  83 + */
  84 + public function searchParam(&$map,$param,&$arr){
44 //按类型搜索 85 //按类型搜索
45 - $map[] = ['id', 'in', $arr];  
46 - if(!empty($this->param['search']) && !empty($this->param['search_type'])){ 86 + if(!empty($param['search']) && !empty($param['search_type'])){
47 if($this->param['search_type'] == 'domain'){ 87 if($this->param['search_type'] == 'domain'){
48 //搜索域名 88 //搜索域名
49 - $map[] = ['id', 'in', DeployOptimize::where('domain', 'like', "%{$this->param['search']}%")->where('id','in',$arr)->pluck('project_id')->toArray()]; 89 + $map['id'] = ['id', 'in', DeployOptimize::where('domain', 'like', "%{$param['search']}%")->where('id','in',$arr)->pluck('project_id')->toArray()];
50 }else{ 90 }else{
51 - $map[] = [$this->param['search_type'], 'like', "%{$this->param['search']}%"]; 91 + $map[$this->param['search_type']] = ['like', "%{$this->param['search']}%"];
52 } 92 }
53 } 93 }
54 - $data = $logic->getList($map, $sort,['*'],$this->row);  
55 - $this->response('success',Code::SUCCESS,$data); 94 + return $map;
56 } 95 }
57 96
58 /** 97 /**