作者 刘锟

update

... ... @@ -20,6 +20,7 @@ use App\Models\Devops\ServerConfig;
use App\Models\Domain\DomainInfo;
use App\Models\Domain\DomainInfo as DomainInfoModel;
use App\Models\HomeCount\Count;
use App\Models\Industry\ProjectIndustry;
use App\Models\Inquiry\InquirySet;
use App\Models\Manage\BelongingGroup;
use App\Models\Manage\ManageHr;
... ... @@ -51,23 +52,24 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/8/30 10:11
*/
public function lists(Project $project){
public function lists(Project $project)
{
$query = $project->leftJoin('gl_project_payment', 'gl_project.id', '=', 'gl_project_payment.project_id')
->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')
->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
->leftJoin('gl_project_online_check', 'gl_project.id', '=', 'gl_project_online_check.project_id')
->leftJoin('gl_web_setting_template', 'gl_project.id', '=', 'gl_web_setting_template.project_id')
->where('gl_project.delete_status',Project::TYPE_ZERO);
->where('gl_project.delete_status', Project::TYPE_ZERO);
$query = $this->searchParam($query);
$query = $this->orderByList($query);
$lists = $query->paginate($this->row, $this->selectParam(), 'page', $this->page)->toArray();
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
if (!empty($lists) && !empty($lists['list'])) {
foreach ($lists['list'] as $k => $v) {
$v = $this->handleParam($v);
$lists['list'][$k] = $v;
}
}
$this->response('success',Code::SUCCESS,$lists);
$this->response('success', Code::SUCCESS, $lists);
}
... ... @@ -75,7 +77,8 @@ class ProjectController extends BaseController
* 需要查询的字段
* @return array
*/
public function selectParam(){
public function selectParam()
{
$select = [
'gl_project.id AS id',
'gl_project.title AS title',
... ... @@ -127,7 +130,8 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/12/29 17:14
*/
public function orderByList($query){
public function orderByList($query)
{
$query = $query->orderBy('gl_project.uptime', 'desc')->orderBy('gl_project.id', 'desc');
return $query;
}
... ... @@ -139,7 +143,8 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/8/18 10:58
*/
public function searchParam(&$query){
public function searchParam(&$query)
{
//参数type
$query = $this->searchType($query);
//根据查看权限获取项目搜索条件(必带)
... ... @@ -164,18 +169,19 @@ class ProjectController extends BaseController
* @param $query
* @return mixed
*/
public function searchType(&$query){
if(isset($this->map['type'])){
$query->where('gl_project.extend_type', '!=' ,5);
if (in_array($this->map['type'], [Project::TYPE_ZERO, Project::TYPE_ONE, Project::TYPE_TWO, Project::TYPE_THREE])){
public function searchType(&$query)
{
if (isset($this->map['type'])) {
$query->where('gl_project.extend_type', '!=', 5);
if (in_array($this->map['type'], [Project::TYPE_ZERO, Project::TYPE_ONE, Project::TYPE_TWO, Project::TYPE_THREE])) {
$query->where('gl_project.type', $this->map['type']);
} elseif ($this->map['type'] == 8){
$query->where('gl_project_online_check.id', null)->where('gl_project.type',Project::TYPE_TWO);
}else{
$query->whereIn('gl_project.type', [Project::TYPE_FOUR,Project::TYPE_SIX]);
} elseif ($this->map['type'] == 8) {
$query->where('gl_project_online_check.id', null)->where('gl_project.type', Project::TYPE_TWO);
} else {
$query->whereIn('gl_project.type', [Project::TYPE_FOUR, Project::TYPE_SIX]);
}
}
if(isset($this->map['uptime']) && is_array($this->map['uptime'])){
if (isset($this->map['uptime']) && is_array($this->map['uptime'])) {
$query->whereBetween('gl_project.uptime', $this->map['uptime']);
}
return $query;
... ... @@ -188,8 +194,9 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/11/6 16:27
*/
public function searchUpgrade(&$query){
if(isset($this->map['is_upgrade'])){
public function searchUpgrade(&$query)
{
if (isset($this->map['is_upgrade'])) {
$query->where('gl_project.is_upgrade', $this->map['is_upgrade']);
}
return $query;
... ... @@ -200,31 +207,32 @@ class ProjectController extends BaseController
* @param $query
* @return mixed
*/
public function searchContent(&$query){
if(!empty($this->map['domain_type']) && !empty($this->map['domain_search'])){
if($this->map['domain_type'] == 'domain'){
public function searchContent(&$query)
{
if (!empty($this->map['domain_type']) && !empty($this->map['domain_search'])) {
if ($this->map['domain_type'] == 'domain') {
$parsedUrl = parse_url($this->map['domain_search']);
$this->map['domain_search'] = $parsedUrl['host'] ?? $this->map['domain_search'];
$ids = DomainInfo::where('domain', 'like', '%'.$this->map['domain_search'].'%')->pluck('id')->toArray();
$ids = DomainInfo::where('domain', 'like', '%' . $this->map['domain_search'] . '%')->pluck('id')->toArray();
$query->whereIn('gl_project_deploy_optimize.domain', $ids);
}else{
$query->where('gl_project_deploy_build.test_domain','like','%'.$this->map['domain_search'].'%');
} else {
$query->where('gl_project_deploy_build.test_domain', 'like', '%' . $this->map['domain_search'] . '%');
}
}
if(!empty($this->map['search']) && !empty($this->map['search_type'])){
if (!empty($this->map['search']) && !empty($this->map['search_type'])) {
$query->where(function ($subQuery) {
// 搜索域名
if ($this->map['search_type'] == 'domain') {
$parsedUrl = parse_url($this->map['search']);
$this->map['search'] = $parsedUrl['host'] ?? $this->map['search'];
$ids = DomainInfo::where('domain', 'like', '%'.$this->map['search'].'%')->pluck('id')->toArray();
$ids = DomainInfo::where('domain', 'like', '%' . $this->map['search'] . '%')->pluck('id')->toArray();
$subQuery->whereIn('gl_project_deploy_optimize.domain', $ids);
} else if($this->map['search_type'] == 'test_domain'){
$subQuery->where('gl_project_deploy_build.test_domain','like','%'.$this->map['search'].'%');
} else if ($this->map['search_type'] == 'test_domain') {
$subQuery->where('gl_project_deploy_build.test_domain', 'like', '%' . $this->map['search'] . '%');
} else {
// 搜索名称
$subQuery->orwhere('gl_project.company','like','%'.$this->map['search'].'%')
->orwhere('gl_project.title','like','%'.$this->map['search'].'%');
$subQuery->orwhere('gl_project.company', 'like', '%' . $this->map['search'] . '%')
->orwhere('gl_project.title', 'like', '%' . $this->map['search'] . '%');
}
});
}
... ... @@ -238,15 +246,16 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/11/9 10:16
*/
public function searchChannel(&$query){
if(isset($this->map['zone_id']) && !empty($this->map['zone_id'])){
$query->where('gl_project.channel','like','%"zone_id": "'.$this->map['zone_id'].'"%');
public function searchChannel(&$query)
{
if (isset($this->map['zone_id']) && !empty($this->map['zone_id'])) {
$query->where('gl_project.channel', 'like', '%"zone_id": "' . $this->map['zone_id'] . '"%');
}
if(isset($this->map['channel_id']) && !empty($this->map['channel_id'])){
$query->where('gl_project.channel','like','%"channel_id": "'.$this->map['channel_id'].'"%');
if (isset($this->map['channel_id']) && !empty($this->map['channel_id'])) {
$query->where('gl_project.channel', 'like', '%"channel_id": "' . $this->map['channel_id'] . '"%');
}
if(isset($this->map['user_id']) && !empty($this->map['user_id'])){
$query->where('gl_project.channel','like','%"user_id": "'.$this->map['user_id'].'"%');
if (isset($this->map['user_id']) && !empty($this->map['user_id'])) {
$query->where('gl_project.channel', 'like', '%"user_id": "' . $this->map['user_id'] . '"%');
}
return $query;
}
... ... @@ -258,14 +267,15 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/9/7 18:40
*/
public function searchDept(&$query){
if(!empty($this->map['dept_id'])){
if($this->map['dept_id'] == 7 || $this->map['dept_id'] == 9){//7,9代表合并组H+F组
$query->whereIn('gl_project_deploy_build.dept_id', [7,9]);
}else{
public function searchDept(&$query)
{
if (!empty($this->map['dept_id'])) {
if ($this->map['dept_id'] == 7 || $this->map['dept_id'] == 9) {//7,9代表合并组H+F组
$query->whereIn('gl_project_deploy_build.dept_id', [7, 9]);
} else {
$query->where(function ($subQuery) {
$subQuery->orwhere('gl_project_deploy_build.dept_id',$this->map['dept_id'])
->orwhere('gl_project_deploy_optimize.dept_id',$this->map['dept_id']);
$subQuery->orwhere('gl_project_deploy_build.dept_id', $this->map['dept_id'])
->orwhere('gl_project_deploy_optimize.dept_id', $this->map['dept_id']);
});
}
}
... ... @@ -279,24 +289,25 @@ class ProjectController extends BaseController
* @method :post
* @time :2024/3/4 14:58
*/
public function searchTechMid(&$query){
if(isset($this->map['tech_mid'])){
$query = $query->where('gl_project_deploy_optimize.tech_mid',$this->map['tech_mid']);
public function searchTechMid(&$query)
{
if (isset($this->map['tech_mid'])) {
$query = $query->where('gl_project_deploy_optimize.tech_mid', $this->map['tech_mid']);
}
if(isset($this->map['optimize_optimist_mid'])){
$query = $query->where('gl_project_deploy_optimize.optimist_mid',$this->map['optimize_optimist_mid']);
if (isset($this->map['optimize_optimist_mid'])) {
$query = $query->where('gl_project_deploy_optimize.optimist_mid', $this->map['optimize_optimist_mid']);
}
if(isset($this->map['plan'])){
$query = $query->where('gl_project_deploy_build.plan',$this->map['plan']);
if (isset($this->map['plan'])) {
$query = $query->where('gl_project_deploy_build.plan', $this->map['plan']);
}
if(isset($this->map['site_status'])){
$query = $query->where('gl_project.site_status',$this->map['site_status']);
if (isset($this->map['site_status'])) {
$query = $query->where('gl_project.site_status', $this->map['site_status']);
}
if(isset($this->map['domain'])){
if($this->map['domain'] == 0){
$query = $query->where('gl_project_deploy_optimize.domain',null);
}else{
$query = $query->where('gl_project_deploy_optimize.domain','!=',null);
if (isset($this->map['domain'])) {
if ($this->map['domain'] == 0) {
$query = $query->where('gl_project_deploy_optimize.domain', null);
} else {
$query = $query->where('gl_project_deploy_optimize.domain', '!=', null);
}
}
return $query;
... ... @@ -309,11 +320,12 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/9/7 17:28
*/
public function getManagerRole(&$query){
if(($this->manage['role'] != 1)){//1代表查看所有
public function getManagerRole(&$query)
{
if (($this->manage['role'] != 1)) {//1代表查看所有
//获取用户所在组
$managerHr = new ManageHr();
$info = $managerHr->read(['manage_id'=>$this->manage['id']]);
$info = $managerHr->read(['manage_id' => $this->manage['id']]);
//获取当前用户自己的项目
$query->where(function ($subQuery) use ($info) {
$subQuery->whereIn('gl_project.id', [1]) // 项目1 + 项目3默认显示
... ... @@ -378,24 +390,25 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/8/18 14:44
*/
public function handleParam(&$item){
if($item['type'] != Project::TYPE_ZERO){
public function handleParam(&$item)
{
if ($item['type'] != Project::TYPE_ZERO) {
$data = APublicModel::getNumByProjectId($item['id']);
}
if($item['type'] == Project::TYPE_ONE){//建站中
if ($item['type'] == Project::TYPE_ONE) {//建站中
$processModel = new ProcessRecords();
$item['sign_project'] = 1;
$count = $processModel->counts(['project_id'=>$item['id']]);
if($count < 1){
$count = $processModel->counts(['project_id' => $item['id']]);
if ($count < 1) {
$item['sign_project'] = 0;
}else{
$proInfo = $processModel->read(['project_id'=>$item['id'],'date'=>['>=',date('Y-m-d', strtotime('-3 days'))]],['id']);
if($proInfo !== false){
} else {
$proInfo = $processModel->read(['project_id' => $item['id'], 'date' => ['>=', date('Y-m-d', strtotime('-3 days'))]], ['id']);
if ($proInfo !== false) {
$item['sign_project'] = 0;
}
}
}
if(!empty($item['extend_type'])){
if (!empty($item['extend_type'])) {
$item['type'] = $item['extend_type'];
}
$manageModel = new ManageHr();
... ... @@ -413,7 +426,7 @@ class ProjectController extends BaseController
$item['created_at'] = date('Y年m月d日', strtotime($item['cooperate_date']));
$item['autologin_code'] = getAutoLoginCode($item['id']);
$domainModel = new DomainInfo();
$item['domain'] = !empty($item['domain']) ? $domainModel->getDomain($item['domain']) : '';
$item['domain'] = !empty($item['domain']) ? $domainModel->getDomain($item['domain']) : '';
$item['product_num'] = $data['product'] ?? 0;
$item['keyword_num'] = $data['key'] ?? 0;
$item['article_num'] = ($data['blog'] ?? 0) + ($data['news'] ?? 0);
... ... @@ -430,14 +443,15 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/8/17 16:42
*/
public function info(ProjectLogic $logic){
public function info(ProjectLogic $logic)
{
$this->request->validate([
'id'=>'required'
],[
'id' => 'required'
], [
'id.required' => 'ID不能为空'
]);
$data = $logic->getProjectInfo($this->param['id']);
$this->response('success',Code::SUCCESS,$data);
$this->response('success', Code::SUCCESS, $data);
}
/**
... ... @@ -447,14 +461,15 @@ class ProjectController extends BaseController
* @method :post
* @time :2024/6/18 11:53
*/
public function deleteMinorLanguages(ProjectLogic $logic){
public function deleteMinorLanguages(ProjectLogic $logic)
{
$this->request->validate([
'id'=>'required'
],[
'id' => 'required'
], [
'id.required' => 'ID不能为空'
]);
$data = $logic->deleteMinorLanguages();
$this->response('success',Code::SUCCESS,$data);
$this->response('success', Code::SUCCESS, $data);
}
/**
... ... @@ -467,9 +482,9 @@ class ProjectController extends BaseController
public function save(ProjectLogic $logic)
{
$this->request->validate([
'type'=>'required',
'serve_id'=>'required',
],[
'type' => 'required',
'serve_id' => 'required',
], [
'type.required' => '类型不能为空',
'serve_id.required' => '请选择服务器'
]);
... ... @@ -482,23 +497,24 @@ class ProjectController extends BaseController
* @author zbj
* @date 2023/5/17
*/
public function inquiry_set(Request $request, ProjectLogic $logic){
public function inquiry_set(Request $request, ProjectLogic $logic)
{
$request->validate([
'project_id'=>'required'
],[
'project_id' => 'required'
], [
'project_id.required' => '项目ID不能为空'
]);
if($request->isMethod('get')){
if ($request->isMethod('get')) {
$data = InquirySet::where('project_id', $request->project_id)->first();
if(!$data){
if (!$data) {
$data = ['emails' => '', 'phones' => ''];
}else{
} else {
$data = $data->toArray();
}
$this->response('success',Code::SUCCESS,$data);
$this->response('success', Code::SUCCESS, $data);
}
$data = $logic->saveInquirySet($this->param);
$this->response('success',Code::SUCCESS,$data);
$this->response('success', Code::SUCCESS, $data);
}
... ... @@ -509,9 +525,10 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/12/7 10:41
*/
public function data_source(ProjectLogic $logic){
public function data_source(ProjectLogic $logic)
{
$data = $logic->dataSource();
$this->response('success',Code::SUCCESS,$data);
$this->response('success', Code::SUCCESS, $data);
}
/**
... ... @@ -519,9 +536,10 @@ class ProjectController extends BaseController
* @author zbj
* @date 2023/6/27
*/
public function city_source(){
public function city_source()
{
$data = City::source($this->param['id'] ?? 0);
$this->response('success',Code::SUCCESS,$data);
$this->response('success', Code::SUCCESS, $data);
}
/**
... ... @@ -529,9 +547,10 @@ class ProjectController extends BaseController
* @author zbj
* @date 2023/6/27
*/
public function channel_source(ProjectLogic $logic){
public function channel_source(ProjectLogic $logic)
{
$data = $logic->channelSource($this->param);
$this->response('success',Code::SUCCESS,$data);
$this->response('success', Code::SUCCESS, $data);
}
/**
... ... @@ -539,14 +558,15 @@ class ProjectController extends BaseController
* @author zbj
* @date 2023/6/25
*/
public function get_process_records(Request $request, ProcessRecordsLogic $logic){
public function get_process_records(Request $request, ProcessRecordsLogic $logic)
{
$request->validate([
'project_id'=>'required'
],[
'project_id' => 'required'
], [
'project_id.required' => '项目ID不能为空'
]);
$data = $logic->getInfo($this->param['project_id']);
$this->response('success',Code::SUCCESS,$data);
$this->response('success', Code::SUCCESS, $data);
}
/**
... ... @@ -554,7 +574,8 @@ class ProjectController extends BaseController
* @author zbj
* @date 2023/6/25
*/
public function save_process_records(ProcessRecordsRequest $request, ProcessRecordsLogic $logic){
public function save_process_records(ProcessRecordsRequest $request, ProcessRecordsLogic $logic)
{
$request->validated();
$logic->recordSave();
$this->response('success');
... ... @@ -565,15 +586,16 @@ class ProjectController extends BaseController
* @author zbj
* @date 2023/6/27
*/
public function get_contract_bill(Request $request){
public function get_contract_bill(Request $request)
{
$request->validate([
'id'=>'required'
],[
'id' => 'required'
], [
'id.required' => 'ID不能为空'
]);
$payment = Payment::where('project_id', $this->param['id'])->select(['contract', 'bill'])->first();
$data = $payment->makeVisible(['contract', 'bill']);
$this->response('success',Code::SUCCESS,$data ? $data->toArray() : []);
$this->response('success', Code::SUCCESS, $data ? $data->toArray() : []);
}
/**
... ... @@ -583,10 +605,11 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/12/2 9:59
*/
public function submit_check(OnlineCheckLogic $logic){
public function submit_check(OnlineCheckLogic $logic)
{
$this->request->validate([
'id'=>'required'
],[
'id' => 'required'
], [
'id.required' => 'ID不能为空'
]);
$logic->saveOnlineCheck();
... ... @@ -600,12 +623,13 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/8/30 19:01
*/
public function online_check(OnlineCheckLogic $logic){
public function online_check(OnlineCheckLogic $logic)
{
$this->request->validate([
'id'=>'required',
'type'=>'required|in:optimist,qa',
'status'=>'required|in:0,1'
],[
'id' => 'required',
'type' => 'required|in:optimist,qa',
'status' => 'required|in:0,1'
], [
'id.required' => 'ID不能为空',
'type.required' => '请选择审核类型',
'type.in' => '审核类型值无效',
... ... @@ -623,15 +647,16 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/8/4 16:27
*/
public function getBelongingGroup(){
public function getBelongingGroup()
{
$this->request->validate([
'type'=>'required',
],[
'type' => 'required',
], [
'type.required' => '请选择审核类型'
]);
$belongGroupModel = new BelongingGroup();
$lists = $belongGroupModel->list($this->map,'name',['id','name','type'],'asc');
$this->response('success',Code::SUCCESS,$lists);
$lists = $belongGroupModel->list($this->map, 'name', ['id', 'name', 'type'], 'asc');
$this->response('success', Code::SUCCESS, $lists);
}
/**
... ... @@ -641,21 +666,22 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/8/8 10:29
*/
public function getManagerList(){
public function getManagerList()
{
$hrManagerModel = new ManageHr();
if(!isset($this->map['status'])){
if (!isset($this->map['status'])) {
$this->map['status'] = $hrManagerModel::STATUS_ONE;
}else{
if(!is_array($this->map['status'])){
} else {
if (!is_array($this->map['status'])) {
$this->map['status'] = [$this->map['status']];
}
$this->map['status'] = ['in',$this->map['status']];
$this->map['status'] = ['in', $this->map['status']];
}
if(isset($this->map['entry_position']) && !empty($this->map['entry_position'])){
$this->map['entry_position'] = ['in',$this->map['entry_position']];
if (isset($this->map['entry_position']) && !empty($this->map['entry_position'])) {
$this->map['entry_position'] = ['in', $this->map['entry_position']];
}
$lists = $hrManagerModel->list($this->map,['sort','id'],['id','manage_id','name','entry_position','is_leader']);
$this->response('success',Code::SUCCESS,$lists);
$lists = $hrManagerModel->list($this->map, ['sort', 'id'], ['id', 'manage_id', 'name', 'entry_position', 'is_leader']);
$this->response('success', Code::SUCCESS, $lists);
}
/**
... ... @@ -665,10 +691,11 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/8/14 10:23 todo::后面删除
*/
public function getServiceConfig(){
public function getServiceConfig()
{
$serviceConfigModel = new ServerConfig();
$list = $serviceConfigModel->list($this->param,'id',['id','type','title','count','init_domain','service_type']);
$this->response('success',Code::SUCCESS,$list);
$list = $serviceConfigModel->list($this->param, 'id', ['id', 'type', 'title', 'count', 'init_domain', 'service_type']);
$this->response('success', Code::SUCCESS, $list);
}
/**
... ... @@ -678,15 +705,16 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/8/14 10:29
*/
public function getDomain(){
public function getDomain()
{
$this->request->validate([
'project_id'=>'required',
],[
'project_id' => 'required',
], [
'project_id.required' => 'project_id不能为空',
]);
$domainModel = new DomainInfo();
$list = $domainModel->list(['status'=>0,'project_id'=>['or',$this->param['project_id']]]);
$this->response('success',Code::SUCCESS,$list);
$list = $domainModel->list(['status' => 0, 'project_id' => ['or', $this->param['project_id']]]);
$this->response('success', Code::SUCCESS, $list);
}
/**
... ... @@ -694,18 +722,19 @@ class ProjectController extends BaseController
* @author zbj
* @date 2023/9/4
*/
public function getProjectInService(){
public function getProjectInService()
{
$company = $this->param['company'];
if(!$company){
$this->response('企业名称必传',Code::SYSTEM_ERROR);
if (!$company) {
$this->response('企业名称必传', Code::SYSTEM_ERROR);
}
$project = Project::where('company', $company)->first();
if($project && ($project['remain_day'] > 0 || in_array($project['type'], [0, 1,6]))){
if ($project && ($project['remain_day'] > 0 || in_array($project['type'], [0, 1, 6]))) {
$in_service = 1;
}else{
} else {
$in_service = 0;
}
$this->response('success',Code::SUCCESS, ['in_service' => $in_service]);
$this->response('success', Code::SUCCESS, ['in_service' => $in_service]);
}
/**
... ... @@ -715,10 +744,11 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/9/8 15:21
*/
public function del(ProjectLogic $logic){
public function del(ProjectLogic $logic)
{
$this->request->validate([
'id'=>'required',
],[
'id' => 'required',
], [
'id.required' => 'id不能为空',
]);
$logic->projectDel();
... ... @@ -730,7 +760,8 @@ class ProjectController extends BaseController
* @author zbj
* @date 2023/9/11
*/
public function getProjectByChannel(){
public function getProjectByChannel()
{
$id = $this->param['id'] ?? '';
$notice_order_id = $this->param['notice_order_id'] ?? '';
$source_id = $this->param['channel_id'] ?? 0; //原系统渠道id
... ... @@ -738,50 +769,50 @@ class ProjectController extends BaseController
$type = $this->param['type'] ?? '';
$company = $this->param['company'] ?? '';
if(!$source_id && !$id){
$this->response('参数异常',Code::SYSTEM_ERROR);
if (!$source_id && !$id) {
$this->response('参数异常', Code::SYSTEM_ERROR);
}
$channel_id = 0;
if($source_id){
if ($source_id) {
$channel = Channel::where('source_id', $source_id)->first();
if(!$channel){
$this->response('渠道不存在',Code::SYSTEM_ERROR);
if (!$channel) {
$this->response('渠道不存在', Code::SYSTEM_ERROR);
}
$channel_id = $channel->id;
}
if ($id){
if(!is_array($id)){
if ($id) {
if (!is_array($id)) {
$id = explode(',', $id);
}
}
if ($notice_order_id){
if(!is_array($notice_order_id)){
if ($notice_order_id) {
if (!is_array($notice_order_id)) {
$notice_order_id = explode(',', $notice_order_id);
}
}
$data = Project::with(['deploy_build', 'deploy_optimize', 'online_check'])
->where('delete_status', 0)
->where(function ($query) use ($channel_id, $type, $company, $id, $notice_order_id){
if ($channel_id) {
$query->where('channel->channel_id', $channel_id);
}
if ($type) {
$query->where('type', $type);
}
if ($company) {
$query->where('company', 'like', '%' . $company . '%');
}
if ($id) {
$query->whereIn('id', $id);
}
if ($notice_order_id) {
$query->whereIn('notice_order_id', $notice_order_id);
}
})->orderBy('id', 'desc')->paginate($size)->toArray();
->where(function ($query) use ($channel_id, $type, $company, $id, $notice_order_id) {
if ($channel_id) {
$query->where('channel->channel_id', $channel_id);
}
if ($type) {
$query->where('type', $type);
}
if ($company) {
$query->where('company', 'like', '%' . $company . '%');
}
if ($id) {
$query->whereIn('id', $id);
}
if ($notice_order_id) {
$query->whereIn('notice_order_id', $notice_order_id);
}
})->orderBy('id', 'desc')->paginate($size)->toArray();
$list = [];
foreach ($data['list'] as $item){
foreach ($data['list'] as $item) {
$domain = '';
if ($item['deploy_optimize']['domain']) {
$domain_pro = DomainInfo::where('id', $item['deploy_optimize']['domain'])->first();
... ... @@ -790,29 +821,29 @@ class ProjectController extends BaseController
}
$manageHr = new ManageHr();
$param = [
"id" => $item['id'],
"title" => $item['title'],
"company" => $item['company'],
"type" => $item['type'],
"type_text" => Project::typeMap()[$item['type']] ?? '',
"channel" => $item['channel'],
"created_at" => $item['created_at'],
"updated_at" => $item['updated_at'],
"post_id" => $item['post_id'],
"from_order_id" => $item['from_order_id'],
"remain_day" => $item['remain_day'],
"last_inquiry_time" => $item['last_inquiry_time'],
"plan" => $item['deploy_build']['plan'] ?: 0,
"plan_text" => Project::planMap()[$item['deploy_build']['plan']] ?? '',
"start_date" => $item['deploy_optimize']['start_date'] ?? '',
"domain" => $domain ? 'https://' . $domain : $domain,
"test_domain" => $item['deploy_build']['test_domain'] ?? '',
"id" => $item['id'],
"title" => $item['title'],
"company" => $item['company'],
"type" => $item['type'],
"type_text" => Project::typeMap()[$item['type']] ?? '',
"channel" => $item['channel'],
"created_at" => $item['created_at'],
"updated_at" => $item['updated_at'],
"post_id" => $item['post_id'],
"from_order_id" => $item['from_order_id'],
"remain_day" => $item['remain_day'],
"last_inquiry_time" => $item['last_inquiry_time'],
"plan" => $item['deploy_build']['plan'] ?: 0,
"plan_text" => Project::planMap()[$item['deploy_build']['plan']] ?? '',
"start_date" => $item['deploy_optimize']['start_date'] ?? '',
"domain" => $domain ? 'https://' . $domain : $domain,
"test_domain" => $item['deploy_build']['test_domain'] ?? '',
// "online_time" => $item['online_check']['qa_check_time'] ?? '',
"online_time" => $item['uptime'] ?? '',
"cooperate_date" => $item['cooperate_date'],
"project_manager_name" => $manageHr->getName($item['deploy_build']['manager_mid']), //项目经理
"after_sales_manager_name" => $manageHr->getName($item['deploy_optimize']['manager_mid']), //售后服务经理
"leader_name" => $manageHr->getName($item['deploy_build']['leader_mid']), //组长
"online_time" => $item['uptime'] ?? '',
"cooperate_date" => $item['cooperate_date'],
"project_manager_name" => $manageHr->getName($item['deploy_build']['manager_mid']), //项目经理
"after_sales_manager_name" => $manageHr->getName($item['deploy_optimize']['manager_mid']), //售后服务经理
"leader_name" => $manageHr->getName($item['deploy_build']['leader_mid']), //组长
];
if ($item['type'] == Project::TYPE_TWO) {
$param['is_compliance'] = RankData::where('project_id', $item['id'])->where('lang', '')->value('is_compliance') ?: 0;
... ... @@ -828,7 +859,7 @@ class ProjectController extends BaseController
$list[] = $param;
}
$data['list'] = $list;
$this->response('success',Code::SUCCESS, $data);
$this->response('success', Code::SUCCESS, $data);
}
/**
... ... @@ -838,9 +869,10 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/9/28 9:09
*/
public function getRenewLog(RenewLog $renewLog){
$lists = $renewLog->lists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
public function getRenewLog(RenewLog $renewLog)
{
$lists = $renewLog->lists($this->map, $this->page, $this->row, $this->order);
$this->response('success', Code::SUCCESS, $lists);
}
/**
... ... @@ -850,20 +882,21 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/11/8 11:17
*/
public function tdkList(){
public function tdkList()
{
$this->request->validate([
'project_id'=>'required',
],[
'project_id' => 'required',
], [
'project_id.required' => '项目ID不能为空',
]);
$tdkModel = new ProjectUpdateTdk();
$list = $tdkModel->list(['project_id'=>$this->map['project_id']],'id',['*'],'desc',5);
if(!empty($list)){
foreach ($list as $k => $v){
$list = $tdkModel->list(['project_id' => $this->map['project_id']], 'id', ['*'], 'desc', 5);
if (!empty($list)) {
foreach ($list as $k => $v) {
$list[$k] = $this->handleTdk($v);
}
}
$this->response('success',Code::SUCCESS,$list);
$this->response('success', Code::SUCCESS, $list);
}
/**
... ... @@ -873,28 +906,29 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/12/29 11:16
*/
public function handleTdk($item){
public function handleTdk($item)
{
$data = [
'gl_product'=>'产品',
'gl_product_category'=>'产品分类',
'gl_product_keyword'=>'产品关键字',
'gl_news'=>'新闻',
'gl_news_category'=>'新闻分类',
'gl_blog'=>'博客',
'gl_blog_category'=>'博客分类',
'gl_web_custom_template'=>'自定义页面',
'gl_product' => '产品',
'gl_product_category' => '产品分类',
'gl_product_keyword' => '产品关键字',
'gl_news' => '新闻',
'gl_news_category' => '新闻分类',
'gl_blog' => '博客',
'gl_blog_category' => '博客分类',
'gl_web_custom_template' => '自定义页面',
];
foreach ($data as $k => $v){
if(isset($item[$k])){
foreach ($data as $k => $v) {
if (isset($item[$k])) {
$data = Arr::s2a($item[$k]);
//{"des": 3500, "title": 0, "keyword": 3501, "total_page": 8458, "keyword_title": 3500, "keyword_content": 3500}
$item[$k] = $v.'总条数:'.$data['total_page'].
', title更新数:'.$data['title'].
',keyword更新数:'.$data['keyword'].
',des更新数:'.$data['des'];
if($k == 'gl_product_keyword'){
$item[$k] .= ',keyword_title更新数:'.($data['keyword_title']??0);
$item[$k] .= ',keyword_content更新数:'.($data['keyword_content']??0);
$item[$k] = $v . '总条数:' . $data['total_page'] .
', title更新数:' . $data['title'] .
',keyword更新数:' . $data['keyword'] .
',des更新数:' . $data['des'];
if ($k == 'gl_product_keyword') {
$item[$k] .= ',keyword_title更新数:' . ($data['keyword_title'] ?? 0);
$item[$k] .= ',keyword_content更新数:' . ($data['keyword_content'] ?? 0);
}
}
... ... @@ -909,14 +943,15 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/11/8 14:17
*/
public function copyProject(ProjectLogic $logic){
public function copyProject(ProjectLogic $logic)
{
$this->request->validate([
'project_id'=>'required',
],[
'project_id' => 'required',
], [
'project_id.required' => 'project_id不能为空',
]);
$data = $logic->copyProject();
$this->response('success',Code::SUCCESS,$data);
$this->response('success', Code::SUCCESS, $data);
}
/**
... ... @@ -924,14 +959,15 @@ class ProjectController extends BaseController
* @author zbj
* @date 2023/11/10
*/
public function site_token(ProjectLogic $logic){
public function site_token(ProjectLogic $logic)
{
$this->request->validate([
'project_id'=>'required',
],[
'project_id' => 'required',
], [
'project_id.required' => 'project_id不能为空',
]);
$token = $logic->getSiteToken($this->map);
$this->response('success',Code::SUCCESS,['site_token' => $token]);
$this->response('success', Code::SUCCESS, ['site_token' => $token]);
}
/**
... ... @@ -941,14 +977,15 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/11/17 15:23
*/
public function saveOtherProject(ProjectLogic $logic){
public function saveOtherProject(ProjectLogic $logic)
{
$this->request->validate([
'id'=>'required',
'aicc'=>'required',
'hagro'=>'required',
'id' => 'required',
'aicc' => 'required',
'hagro' => 'required',
// 'exclusive_aicc_day'=>'required',
// 'exclusive_hagro_day'=>'required',
],[
], [
'id.required' => 'id不能为空',
'aicc.required' => 'aicc是否开启不能为空',
'hagro.required' => 'hagro是否开启不能为空',
... ... @@ -966,14 +1003,15 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/11/17 15:23
*/
public function getOtherProject(ProjectLogic $logic){
public function getOtherProject(ProjectLogic $logic)
{
$this->request->validate([
'id'=>'required',
],[
'id' => 'required',
], [
'id.required' => 'id不能为空',
]);
$info = $logic->getOtherProject();
$this->response('success',Code::SUCCESS,$info);
$this->response('success', Code::SUCCESS, $info);
}
/**
... ... @@ -983,20 +1021,21 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/11/17 16:08
*/
public function getChannel(){
public function getChannel()
{
$zoneModel = new Zone();
$zone_list = $zoneModel->list();
$channelModel = new Channel();
$channelUserModel = new User();
foreach ($zone_list as $k => $v){
$channel_list = $channelModel->list(['zone_id'=>$v['id']]);
foreach ($channel_list as $k1 => $v1){
$user_list = $channelUserModel->list(['channel_id'=>$v1['id']]);
foreach ($zone_list as $k => $v) {
$channel_list = $channelModel->list(['zone_id' => $v['id']]);
foreach ($channel_list as $k1 => $v1) {
$user_list = $channelUserModel->list(['channel_id' => $v1['id']]);
$channel_list[$k1]['sub'] = $user_list;
}
$zone_list[$k]['sub'] = $channel_list;
}
$this->response('success',Code::SUCCESS,$zone_list);
$this->response('success', Code::SUCCESS, $zone_list);
}
/**
... ... @@ -1006,10 +1045,11 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/11/30 10:59
*/
public function languageLists(){
public function languageLists()
{
$webLanguageModel = new WebLanguage();
$lists = $webLanguageModel->list();
$this->response('success',Code::SUCCESS,$lists);
$this->response('success', Code::SUCCESS, $lists);
}
/**
... ... @@ -1017,8 +1057,9 @@ class ProjectController extends BaseController
* @author zbj
* @date 2024/1/19
*/
public function countryLists(){
$this->response('success',Code::SUCCESS, Country::getCountryList());
public function countryLists()
{
$this->response('success', Code::SUCCESS, Country::getCountryList());
}
/**
... ... @@ -1026,10 +1067,11 @@ class ProjectController extends BaseController
* @author zbj
* @date 2024/1/19
*/
public function saveInquiryFilterConfig(ProjectLogic $logic){
public function saveInquiryFilterConfig(ProjectLogic $logic)
{
$this->request->validate([
'project_id'=>'required',
],[
'project_id' => 'required',
], [
'project_id.required' => '项目id不能为空',
]);
$logic->saveInquiryFilterConfig($this->param);
... ... @@ -1041,10 +1083,11 @@ class ProjectController extends BaseController
* @author zbj
* @date 2024/3/29
*/
public function saveWebTrafficConfig(ProjectLogic $logic){
public function saveWebTrafficConfig(ProjectLogic $logic)
{
$this->request->validate([
'project_id'=>'required',
],[
'project_id' => 'required',
], [
'project_id.required' => '项目id不能为空',
]);
$logic->saveWebTrafficConfig($this->param);
... ... @@ -1058,28 +1101,29 @@ class ProjectController extends BaseController
* @method :post
* @time :2024/4/7 10:41
*/
public function updateProjectManager(ProjectLogic $logic){
public function updateProjectManager(ProjectLogic $logic)
{
$this->request->validate([
'old_id'=>'required',
'new_id'=>'required'
],[
'old_id' => 'required',
'new_id' => 'required'
], [
'old_id.required' => '参数不能为空',
'new_id.required' => '参数不能为空',
]);
//查看当前用户是否存在
$hrModel = new ManageHr();
$oldHrInfo = $hrModel->read(['id'=>$this->param['old_id']]);
if($oldHrInfo === false){
$this->response('当前用户不存在',Code::SYSTEM_ERROR);
$oldHrInfo = $hrModel->read(['id' => $this->param['old_id']]);
if ($oldHrInfo === false) {
$this->response('当前用户不存在', Code::SYSTEM_ERROR);
}
$newHrInfo = $hrModel->read(['id'=>$this->param['new_id'],'status'=>1]);
if($newHrInfo === false){
$this->response('变更的用户不存在',Code::SYSTEM_ERROR);
$newHrInfo = $hrModel->read(['id' => $this->param['new_id'], 'status' => 1]);
if ($newHrInfo === false) {
$this->response('变更的用户不存在', Code::SYSTEM_ERROR);
}
if($oldHrInfo['entry_position'] != $newHrInfo['entry_position']){
$this->response('不同岗位不允许变更',Code::SYSTEM_ERROR);
if ($oldHrInfo['entry_position'] != $newHrInfo['entry_position']) {
$this->response('不同岗位不允许变更', Code::SYSTEM_ERROR);
}
$logic->getManagerFiled($newHrInfo['entry_position'],$this->param['old_id'],$this->param['new_id'],$this->param['project_id'] ?? []);
$logic->getManagerFiled($newHrInfo['entry_position'], $this->param['old_id'], $this->param['new_id'], $this->param['project_id'] ?? []);
$this->response('success');
}
... ... @@ -1090,16 +1134,17 @@ class ProjectController extends BaseController
* @method :post
* @time :2024/6/19 10:07
*/
public function setIsParticiple(){
public function setIsParticiple()
{
$this->request->validate([
'project_id'=>'required',
'is_participle'=>'required'
],[
'project_id' => 'required',
'is_participle' => 'required'
], [
'project_id.required' => '项目id不能为空',
'is_participle.required' => '项目id不能为空',
]);
$deployBuildModel = new DeployBuild();
$deployBuildModel->edit(['is_participle'=>$this->param['is_participle']],['project_id'=>$this->param['project_id']]);
$deployBuildModel->edit(['is_participle' => $this->param['is_participle']], ['project_id' => $this->param['project_id']]);
$this->response('success');
}
... ... @@ -1111,23 +1156,36 @@ class ProjectController extends BaseController
* @method :post
* @time :2024/7/29 17:12
*/
public function saveSiteStatus(){
public function saveSiteStatus()
{
$projectModel = new Project();
$this->request->validate([
'project_id'=>'required',
'site_status'=>'required'
],[
'project_id' => 'required',
'site_status' => 'required'
], [
'project_id.required' => '项目id不能为空',
'site_status.required' => '状态不能为空',
]);
$projectModel->edit(['site_status'=>$this->map['site_status']],['id'=>$this->param['project_id']]);
$projectModel->edit(['site_status' => $this->map['site_status']], ['id' => $this->param['project_id']]);
//TODO::通知C端
$domainModel = new DomainInfoModel();
$domainInfo = $domainModel->read(['project_id'=>$this->param['project_id']]);
if($domainInfo !== false){
$rs = curl_get('https://'.$domainInfo['domain'].'/api/stop_or_start_website/');
@file_put_contents(storage_path('logs/site_status.log'), var_export('通知C端on/off'.$domainInfo['domain'].'.返回结果:'.json_encode($rs), true) . PHP_EOL, FILE_APPEND);
$domainInfo = $domainModel->read(['project_id' => $this->param['project_id']]);
if ($domainInfo !== false) {
$rs = curl_get('https://' . $domainInfo['domain'] . '/api/stop_or_start_website/');
@file_put_contents(storage_path('logs/site_status.log'), var_export('通知C端on/off' . $domainInfo['domain'] . '.返回结果:' . json_encode($rs), true) . PHP_EOL, FILE_APPEND);
}
$this->response('success');
}
/**
* 获取项目所有行业列表
* @author Akun
* @date 2025/03/05 11:40
*/
public function industryList()
{
$model = new ProjectIndustry();
$lists = $model->list(['status' => 1], 'id', ['id', 'industry_name'], 'asc');
$this->response('success', Code::SUCCESS, $lists);
}
}
... ...
... ... @@ -21,6 +21,7 @@ use App\Models\Com\UpdateLog;
use App\Models\Devops\Servers;
use App\Models\Devops\ServersIp;
use App\Models\Domain\DomainInfo;
use App\Models\Industry\ProjectIndustryRelated;
use App\Models\Inquiry\InquiryIP;
use App\Models\Inquiry\InquirySet;
use App\Models\Manage\Manage;
... ... @@ -109,6 +110,8 @@ class ProjectLogic extends BaseLogic
$info['minor_languages'] = $this->getProjectMinorLanguages($id);
//升级项目采集完成时间
$info['collect_time'] = $info['is_upgrade'] ? UpdateLog::getProjectUpdate($id) : '';
//获取项目所属行业
$info['industry'] = ProjectIndustryRelated::where('project_id', $id)->pluck('industry_id')->toArray();
return $this->success($info);
}
... ...
... ... @@ -528,6 +528,10 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/', [Aside\Project\AllProjectController::class, 'lists'])->name('admin.all_project_lists');
});
//项目行业相关
Route::prefix('industry')->group(function () {
Route::any('/', [Aside\Project\ProjectController::class, 'industryList'])->name('admin.industryList');
});
});
//无需登录验证的路由组
... ...