作者 刘锟

update

... ... @@ -52,24 +52,23 @@ 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);
}
... ... @@ -77,8 +76,7 @@ class ProjectController extends BaseController
* 需要查询的字段
* @return array
*/
public function selectParam()
{
public function selectParam(){
$select = [
'gl_project.id AS id',
'gl_project.title AS title',
... ... @@ -130,8 +128,7 @@ 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;
}
... ... @@ -143,8 +140,7 @@ 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);
//根据查看权限获取项目搜索条件(必带)
... ... @@ -169,19 +165,18 @@ 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;
... ... @@ -194,9 +189,8 @@ 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;
... ... @@ -207,32 +201,31 @@ 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'].'%');
}
});
}
... ... @@ -246,16 +239,15 @@ 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;
}
... ... @@ -267,15 +259,14 @@ 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']);
});
}
}
... ... @@ -289,25 +280,24 @@ 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;
... ... @@ -320,12 +310,11 @@ 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默认显示
... ... @@ -390,25 +379,24 @@ 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();
... ... @@ -443,15 +431,14 @@ 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);
}
/**
... ... @@ -461,15 +448,14 @@ 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);
}
/**
... ... @@ -482,9 +468,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' => '请选择服务器'
]);
... ... @@ -497,24 +483,23 @@ 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);
}
... ... @@ -525,10 +510,9 @@ 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);
}
/**
... ... @@ -536,10 +520,9 @@ 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);
}
/**
... ... @@ -547,10 +530,9 @@ 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);
}
/**
... ... @@ -558,15 +540,14 @@ 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);
}
/**
... ... @@ -574,8 +555,7 @@ 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');
... ... @@ -586,16 +566,15 @@ 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() : []);
}
/**
... ... @@ -605,11 +584,10 @@ 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();
... ... @@ -623,13 +601,12 @@ 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' => '审核类型值无效',
... ... @@ -647,16 +624,15 @@ 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);
}
/**
... ... @@ -666,22 +642,21 @@ 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);
}
/**
... ... @@ -691,11 +666,10 @@ 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);
}
/**
... ... @@ -705,16 +679,15 @@ 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);
}
/**
... ... @@ -722,19 +695,18 @@ 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]);
}
/**
... ... @@ -744,11 +716,10 @@ 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();
... ... @@ -760,8 +731,7 @@ 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
... ... @@ -769,32 +739,32 @@ 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) {
->where(function ($query) use ($channel_id, $type, $company, $id, $notice_order_id){
if ($channel_id) {
$query->where('channel->channel_id', $channel_id);
}
... ... @@ -812,7 +782,7 @@ class ProjectController extends BaseController
}
})->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();
... ... @@ -859,7 +829,7 @@ class ProjectController extends BaseController
$list[] = $param;
}
$data['list'] = $list;
$this->response('success', Code::SUCCESS, $data);
$this->response('success',Code::SUCCESS, $data);
}
/**
... ... @@ -869,10 +839,9 @@ 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);
}
/**
... ... @@ -882,21 +851,20 @@ 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);
}
/**
... ... @@ -906,29 +874,28 @@ 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);
}
}
... ... @@ -943,15 +910,14 @@ 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);
}
/**
... ... @@ -959,15 +925,14 @@ 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]);
}
/**
... ... @@ -977,15 +942,14 @@ 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是否开启不能为空',
... ... @@ -1003,15 +967,14 @@ 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);
}
/**
... ... @@ -1021,21 +984,20 @@ 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);
}
/**
... ... @@ -1045,11 +1007,10 @@ 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);
}
/**
... ... @@ -1057,9 +1018,8 @@ 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());
}
/**
... ... @@ -1067,11 +1027,10 @@ 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);
... ... @@ -1083,11 +1042,10 @@ 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);
... ... @@ -1101,29 +1059,28 @@ 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');
}
... ... @@ -1134,17 +1091,16 @@ 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');
}
... ... @@ -1156,23 +1112,22 @@ 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');
}
... ...