RenewProjectController.php
6.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php
/**
* @remark :
* @name :RenewProjectController.php
* @author :lyh
* @method :post
* @time :2023/8/11 10:22
*/
namespace App\Http\Controllers\Aside\Project;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Manage\ManageLogic;
use App\Http\Logic\Aside\Project\ProjectLogic;
use App\Http\Logic\Aside\Project\RenewLogic;
use App\Models\ASide\APublicModel;
use App\Models\Channel\Channel;
use App\Models\HomeCount\Count;
use App\Models\Manage\Manage;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Project;
use App\Models\Task\Task;
use Carbon\Carbon;
class RenewProjectController extends BaseController
{
/**
* @remark :获取所有服务天数小于15天的项目
* @name :lists
* @author :lyh
* @method :post
* @time :2023/8/11 10:22
*/
public function lists(ProjectLogic $logic){
$count = new Count();
$yesterday = Carbon::yesterday()->toDateString();
$count_list = $count->list(['date'=>$yesterday,'service_day'=>['<=',15]],'id',['project_id']);
$arr = [];
foreach ($count_list as $v){
$arr[] = $v['project_id'];
}
$sort = ['id' => 'desc'];
//按类型搜索
$map[] = ['id', 'in', $arr];
if(!empty($this->param['search']) && !empty($this->param['search_type'])){
if($this->param['search_type'] == 'domain'){
//搜索域名
$map[] = ['id', 'in', DeployOptimize::where('domain', 'like', "%{$this->param['search']}%")->where('id','in',$arr)->pluck('project_id')->toArray()];
}else{
$map[] = [$this->param['search_type'], 'like', "%{$this->param['search']}%"];
}
}
$data = $logic->getList($map, $sort,['*'],$this->row);
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :续费记录单
* @name :renewLists
* @author :lyh
* @method :post
* @time :2023/8/11 17:28
*/
public function renewLists(RenewLogic $logic){
if(isset($this->map['company']) && !empty($this->map['company'])){
$this->map['company'] = ['like','%'.$this->map['company'].'%'];
}
$lists = $logic->renewListsLog($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :获取续费单详情
* @name :info
* @author :lyh
* @method :post
* @time :2023/8/14 9:08
*/
public function info(RenewLogic $logic){
$this->request->validate([
'id'=>'required',
],[
'id.required' => 'ID不能为空'
]);
$info = $logic->renewRead();
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :未续费项目列表
* @name :notHaveRenewItems
* @author :lyh
* @method :post
* @time :2023/8/18 14:33
*/
public function notHaveRenewItems(Project $project){
$lists = $project->with('payment')->with('deploy_build')
->with('deploy_optimize')->with('online_check')
->with('project_after')->paginate($this->row, ['*'], 'page', $this->page);
if(!empty($lists)){
$lists = $lists->toArray();
foreach ($lists['list'] as $k=>$item){
$item = $this->handleParam($item);
$lists['list'][$k] = $item;
}
}
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :参数处理
* @name :handleParam
* @author :lyh
* @method :post
* @time :2023/8/18 14:44
*/
public function handleParam(&$item){
$manageModel = new Manage();
$item = [
'id' => $item['id'],
'title' => $item['title'],
'channel' => Channel::getChannelText($item['channel']['user_id'] ?? 0),
'key' => $item['deploy_build']['keyword_num'] ?? 0,
'day' => $item['deploy_build']['service_duration'] ?? 0,
'amount' => $item['payment']['amount'] ?? 0,
'build_leader' => $manageModel->getName($item['deploy_build']['leader_mid']), //组长
'build_manager' => $manageModel->getName($item['deploy_build']['manager_mid']), //项目经理
'build_designer' => $manageModel->getName($item['deploy_build']['designer_mid']), //设计师
'build_tech' => $manageModel->getName($item['deploy_build']['tech_mid']), //技术助理
'optimize_manager' => $manageModel->getName($item['deploy_optimize']['manager_mid']), //优化服务经理
'optimize_optimist' => $manageModel->getName($item['deploy_optimize']['optimist_mid']), //优化师
'optimize_assist' => $manageModel->getName($item['deploy_optimize']['assist_mid']), //优化助理
'optimize_tech' => $manageModel->getName($item['deploy_optimize']['tech_mid']), //售后技术
'type' => $item['type'],
'test_domain' => $item['deploy_build']['test_domain'] ?? 0,
'plan' =>Project::planMap()[$item['deploy_build']['plan']],
'domain' => $item['deploy_optimize']['domain'] ?? 0,
'created_at' => date('Y年m月d日', strtotime($item['created_at'])),
'autologin_code' => $this->getAutoLoginCode($item['id']),
'product_num' => APublicModel::getProductNumByProjectId($item['id']),
'keyword_num' => $item['deploy_build']['keyword_num'] ?? 0,
'article_num' => APublicModel::getBlogNumByProjectId($item['id']) + APublicModel::getNewsNumByProjectId($item['id']),
'task_finish_num' => Task::getNumByProjectId($item['id'], Task::STATUS_DOWN),
'task_pending_num' => Task::getNumByProjectId($item['id'], [Task::STATUS_DONGING, Task::STATUS_WAIT]),
'optimist_status'=>$item['online_check']['optimist_status'] ?? 0,
'qa_status'=>$item['online_check']['qa_status'] ?? 0,
'service_day'=>$item['deploy_build']['service_duration'],
];
return $item;
}
}