作者 周海龙

合并分支 'develop' 到 'master'

Develop



查看合并请求 !11
正在显示 65 个修改的文件 包含 2450 行增加734 行删除

要显示太多修改。

为保证性能只显示 65 of 65+ 个文件。

@@ -4,4 +4,4 @@ @@ -4,4 +4,4 @@
4 <center><h1>404 Not Found</h1></center> 4 <center><h1>404 Not Found</h1></center>
5 <hr><center>nginx</center> 5 <hr><center>nginx</center>
6 </body> 6 </body>
7 -</html>  
  7 +</html>
@@ -4,12 +4,15 @@ namespace App\Console\Commands\DayCount; @@ -4,12 +4,15 @@ namespace App\Console\Commands\DayCount;
4 4
5 use App\Helper\Common; 5 use App\Helper\Common;
6 use App\Helper\FormGlobalsoApi; 6 use App\Helper\FormGlobalsoApi;
  7 +use App\Models\Domain\DomainInfo;
7 use App\Models\Project\DeployBuild; 8 use App\Models\Project\DeployBuild;
8 use App\Models\Project\DeployOptimize; 9 use App\Models\Project\DeployOptimize;
9 use App\Models\Project\Project; 10 use App\Models\Project\Project;
  11 +use App\Services\ProjectServer;
10 use Carbon\Carbon; 12 use Carbon\Carbon;
11 use Illuminate\Console\Command; 13 use Illuminate\Console\Command;
12 use Illuminate\Support\Facades\DB; 14 use Illuminate\Support\Facades\DB;
  15 +use Illuminate\Support\Facades\Log;
13 16
14 class Count extends Command 17 class Count extends Command
15 { 18 {
@@ -28,6 +31,7 @@ class Count extends Command @@ -28,6 +31,7 @@ class Count extends Command
28 * @var string 31 * @var string
29 */ 32 */
30 protected $description = '统计昨日数据'; 33 protected $description = '统计昨日数据';
  34 +
31 /** 35 /**
32 * @name :(定时执行生成昨日数据统计)handle 36 * @name :(定时执行生成昨日数据统计)handle
33 * @author :lyh 37 * @author :lyh
@@ -39,35 +43,51 @@ class Count extends Command @@ -39,35 +43,51 @@ class Count extends Command
39 $list = DB::table('gl_project')->where('gl_project.extend_type','!=',5) 43 $list = DB::table('gl_project')->where('gl_project.extend_type','!=',5)
40 ->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id') 44 ->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')
41 ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id') 45 ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
42 - ->select($this->selectParam())->get()->toArray();  
43 - $data = [];  
44 - $yesterday = Carbon::yesterday()->toDateString();  
45 - foreach ($list as $v){  
46 - $v = (array)$v;  
47 - if($v['domain'] != ''){  
48 - $v['test_domain'] = $v['domain']; 46 + ->select($this->selectParam())->get();
  47 + try {
  48 + if(!empty($list)){
  49 + $list = $list->toArray();
  50 + $data = [];
  51 + $yesterday = Carbon::yesterday()->toDateString();
  52 + $domainInfo = new DomainInfo();
  53 + foreach ($list as $v){
  54 + $v = (array)$v;
  55 + if($v['type'] == Project::TYPE_ZERO){
  56 + continue;
  57 + }
  58 + if(!empty($v['domain'])){
  59 + $info = $domainInfo->read(['id'=>$v['domain']]);
  60 + if($info !== false){
  61 + $v['test_domain'] = $info['domain'];
  62 + }
  63 + }
  64 + $arr = [];
  65 + //统计时间
  66 + $arr['date'] = $yesterday;
  67 + ProjectServer::useProject($v['id']);
  68 + //pv统计
  69 + $arr['pv_num'] = $this->pv_num($yesterday,$v['test_domain']);
  70 + //ip统计
  71 + $arr['ip_num'] = $this->ip_num($yesterday,$v['test_domain']);
  72 + DB::disconnect('custom_mysql');
  73 + //服务达标天数
  74 + $arr['compliance_day'] = $this->compliance_day($v['id']);
  75 + //剩余服务时常
  76 + $arr['service_day'] = $v['remain_day'];
  77 + //项目id
  78 + $arr['project_id'] = $v['project_id'];
  79 + $arr['created_at'] = date('Y-m-d H:i:s');
  80 + $arr['updated_at'] = date('Y-m-d H:i:s');
  81 + //询盘统计
  82 + $arr = $this->inquiry($arr,$v['test_domain']);
  83 + $data[] = $arr;
  84 + }
  85 + //判断数据是否存在
  86 + DB::table('gl_count')->insert($data);
49 } 87 }
50 - $arr = [];  
51 - //统计时间  
52 - $arr['date'] = $yesterday;  
53 - //pv统计  
54 - $arr['pv_num'] = $this->pv_num($yesterday,$v['test_domain']);  
55 - //ip统计  
56 - $arr['ip_num'] = $this->ip_num($yesterday,$v['test_domain']);  
57 - //服务达标天数  
58 - $arr['compliance_day'] = $this->compliance_day($v['test_domain']);  
59 - //剩余服务时常  
60 - $arr['service_day'] = ((int)$v['service_duration'] - (int)$arr['compliance_day']) > 0 ? ((int)$v['service_duration'] - (int)$arr['compliance_day']) : 0;  
61 - //项目id  
62 - $arr['project_id'] = $v['project_id'];  
63 - $arr['created_at'] = date('Y-m-d H:i:s');  
64 - $arr['updated_at'] = date('Y-m-d H:i:s');  
65 - //询盘统计  
66 - $arr = $this->inquiry($arr,$v['test_domain']);  
67 - $data[] = $arr; 88 + }catch (\Exception $e){
  89 + Log::error('同步数据执行失败');
68 } 90 }
69 - //判断数据是否存在  
70 - DB::table('gl_count')->insert($data);  
71 echo $this->error; 91 echo $this->error;
72 } 92 }
73 93
@@ -78,7 +98,7 @@ class Count extends Command @@ -78,7 +98,7 @@ class Count extends Command
78 * @time :2023/6/14 15:40 98 * @time :2023/6/14 15:40
79 */ 99 */
80 public function pv_num($yesterday,$domain){ 100 public function pv_num($yesterday,$domain){
81 - $pv = DB::table('gl_customer_visit_item')->whereDate('updated_date', $yesterday)->where('domain',$domain)->count(); 101 + $pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $yesterday)->where('domain',$domain)->count();
82 return $pv; 102 return $pv;
83 } 103 }
84 104
@@ -89,7 +109,7 @@ class Count extends Command @@ -89,7 +109,7 @@ class Count extends Command
89 * @time :2023/6/14 15:40 109 * @time :2023/6/14 15:40
90 */ 110 */
91 public function ip_num($yesterday,$domain){ 111 public function ip_num($yesterday,$domain){
92 - $ip = DB::table('gl_customer_visit')->whereDate('updated_date', $yesterday)->where('domain',$domain)->count(); 112 + $ip = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $yesterday)->where('domain',$domain)->count();
93 return $ip; 113 return $ip;
94 } 114 }
95 115
@@ -150,8 +170,10 @@ class Count extends Command @@ -150,8 +170,10 @@ class Count extends Command
150 */ 170 */
151 public function selectParam(){ 171 public function selectParam(){
152 $select = [ 172 $select = [
153 - 'gl_project.id AS user_id', 173 + 'gl_project.id AS id',
  174 + 'gl_project.type AS type',
154 'gl_project.extend_type AS extend_type', 175 'gl_project.extend_type AS extend_type',
  176 + 'gl_project.remain_day AS remain_day',
155 'gl_project_deploy_build.test_domain AS test_domain', 177 'gl_project_deploy_build.test_domain AS test_domain',
156 'gl_project_deploy_optimize.domain AS domain', 178 'gl_project_deploy_optimize.domain AS domain',
157 'gl_project_deploy_build.project_id AS project_id', 179 'gl_project_deploy_build.project_id AS project_id',
@@ -38,7 +38,7 @@ class InquiryDelay extends Command @@ -38,7 +38,7 @@ class InquiryDelay extends Command
38 { 38 {
39 $inquiryInfoModel = new InquiryInfo(); 39 $inquiryInfoModel = new InquiryInfo();
40 $param = $inquiryInfoModel->formatQuery(['status'=>$inquiryInfoModel::STATUS_FOUR])->orderBy('send_time','asc')->first(); 40 $param = $inquiryInfoModel->formatQuery(['status'=>$inquiryInfoModel::STATUS_FOUR])->orderBy('send_time','asc')->first();
41 - if($param !== false){ 41 + if(!empty($param)){
42 $time = date('Y-m-d H:i:s'); 42 $time = date('Y-m-d H:i:s');
43 if($time >= $param['send_time']){ 43 if($time >= $param['send_time']){
44 $data = []; 44 $data = [];
@@ -5,6 +5,7 @@ namespace App\Console\Commands; @@ -5,6 +5,7 @@ namespace App\Console\Commands;
5 5
6 use App\Models\Devops\DevopsTaskLog; 6 use App\Models\Devops\DevopsTaskLog;
7 use App\Models\Project\Project; 7 use App\Models\Project\Project;
  8 +use App\Utils\EncryptUtils;
8 use Illuminate\Console\Command; 9 use Illuminate\Console\Command;
9 use App\Models\Devops\DevopsTask as DevopsTaskModel; 10 use App\Models\Devops\DevopsTask as DevopsTaskModel;
10 11
@@ -45,16 +46,13 @@ class DevopsTask extends Command @@ -45,16 +46,13 @@ class DevopsTask extends Command
45 */ 46 */
46 public function handle() 47 public function handle()
47 { 48 {
48 - while (true){  
49 - $tasks = DevopsTaskModel::where('status', DevopsTaskModel::STATUS_PENDING)->get();  
50 - foreach ($tasks as $task){  
51 - echo "Start task " . $task->id . PHP_EOL;  
52 - if($task->type == DevopsTaskModel::TYPE_MYSQL){  
53 - $this->updateTable($task);  
54 - }  
55 - echo "End task " . $task->id . PHP_EOL; 49 + $tasks = DevopsTaskModel::where('status', DevopsTaskModel::STATUS_PENDING)->get();
  50 + foreach ($tasks as $task){
  51 + echo "Start task " . $task->id;
  52 + if($task->type == DevopsTaskModel::TYPE_MYSQL){
  53 + $this->updateTable($task);
56 } 54 }
57 - sleep(10); 55 + echo "End task " . $task->id . PHP_EOL;
58 } 56 }
59 } 57 }
60 58
@@ -64,6 +62,7 @@ class DevopsTask extends Command @@ -64,6 +62,7 @@ class DevopsTask extends Command
64 echo "project " . $project->id; 62 echo "project " . $project->id;
65 $log = DevopsTaskLog::addLog($task->id, $project->id); 63 $log = DevopsTaskLog::addLog($task->id, $project->id);
66 if($log->status == DevopsTaskModel::STATUS_ACTIVE){ 64 if($log->status == DevopsTaskModel::STATUS_ACTIVE){
  65 + echo 'continue' . PHP_EOL;
67 continue; 66 continue;
68 } 67 }
69 if(!$project->mysqlConfig){ 68 if(!$project->mysqlConfig){
@@ -73,13 +72,21 @@ class DevopsTask extends Command @@ -73,13 +72,21 @@ class DevopsTask extends Command
73 continue; 72 continue;
74 } 73 }
75 //DB类是单例模式,生命周期内修改配置不会生效 74 //DB类是单例模式,生命周期内修改配置不会生效
76 - $conn = new \mysqli(  
77 - $project->mysqlConfig->host,  
78 - $project->mysqlConfig->user,  
79 - $project->mysqlConfig->password,  
80 - $project->databaseName(),  
81 - $project->mysqlConfig->port,  
82 - ); 75 + try {
  76 + $conn = new \mysqli(
  77 + $project->mysqlConfig->host,
  78 + $project->mysqlConfig->user,
  79 + $project->mysqlConfig->password,
  80 + $project->databaseName(),
  81 + $project->mysqlConfig->port,
  82 + );
  83 + }catch (\Exception $e){
  84 + $log->remark = mb_substr('数据库连接失败:' . $e->getMessage(), 0, 500);
  85 + $log->status = DevopsTaskLog::STATUS_ERROR;
  86 + $log->save();
  87 + echo '-->' . $log->remark . PHP_EOL;
  88 + continue;
  89 + }
83 $res = $conn->query($task->sql); 90 $res = $conn->query($task->sql);
84 91
85 $log->status = $res ? DevopsTaskLog::STATUS_ACTIVE : DevopsTaskLog::STATUS_ERROR; 92 $log->status = $res ? DevopsTaskLog::STATUS_ACTIVE : DevopsTaskLog::STATUS_ERROR;
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :DomainInfo.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/9/11 14:37
  8 + */
  9 +
  10 +namespace App\Console\Commands\Domain;
  11 +
  12 +use Illuminate\Console\Command;
  13 +use App\Models\Domain\DomainInfo as DomainInfoModel;
  14 +
  15 +class DomainInfo extends Command
  16 +{
  17 + /**
  18 + * The name and signature of the console command.
  19 + *
  20 + * @var string
  21 + */
  22 + protected $signature = 'domain_info';
  23 +
  24 + /**
  25 + * The console command description.
  26 + *
  27 + * @var string
  28 + */
  29 + protected $description = '域名相关';
  30 +
  31 + /**
  32 + * @remark :更新证书+证书有效时间
  33 + * @name :handle
  34 + * @author :lyh
  35 + * @method :post
  36 + * @time :2023/9/11 15:09
  37 + */
  38 + public function handle(){
  39 + $domainModel = new DomainInfoModel();
  40 + $map = ['status'=>['!=',2]];
  41 + $list = $domainModel->list($map);
  42 + foreach ($list as $v){
  43 + $ssl = $this->updateDomainSsl($v['domain']);
  44 + $time = $this->updateDomain($v['domain']);
  45 + $data = [
  46 + 'certificate_start_time'=>$ssl['from'],
  47 + 'certificate_end_time'=>$ssl['to'],
  48 + 'domain_start_time'=>$time['start'],
  49 + 'domain_end_time'=>$time['end']
  50 + ];
  51 + $domainModel->edit($data,['id'=>$v['id']]);
  52 + }
  53 + return 1;
  54 + }
  55 +
  56 + /**
  57 + * @remark :更新域名证书
  58 + * @name :updateDomainSsl
  59 + * @author :lyh
  60 + * @method :post
  61 + * @time :2023/9/11 15:07
  62 + */
  63 + public function updateDomainSsl($domain){
  64 + try {
  65 + $context = stream_context_create([
  66 + 'ssl' => [
  67 + 'capture_peer_cert' => true,
  68 + 'capture_peer_cert_chain' => false,
  69 + ],
  70 + ]);
  71 + $stream = stream_socket_client('ssl://'.$domain.':443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);
  72 + if(!$stream) {
  73 + die("Failed to connect: $errno - $errstr");
  74 + }
  75 + $remote_cert = stream_context_get_params($stream)['options']['ssl']['peer_certificate'];
  76 + if(!$remote_cert) {
  77 + die("Failed to retrieve certificate");
  78 + }
  79 + $valid_from = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validFrom_time_t']);
  80 + $valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']);
  81 + fclose($stream);
  82 + }catch (\Exception $e){
  83 + $valid_from = date('Y-m-d H:i:s');
  84 + $valid_to = date('Y-m-d H:i:s');
  85 + }
  86 + return ['from'=>$valid_from,'to'=>$valid_to];
  87 + }
  88 +
  89 + /**
  90 + * @remark :更新域名有限时间
  91 + * @name :updateDomain
  92 + * @author :lyh
  93 + * @method :post
  94 + * @time :2023/9/11 15:11
  95 + */
  96 + public function updateDomain($domain){
  97 + $url = 'http://openai.waimaoq.com/v1/whois_api?domain='.$domain;
  98 + $response = http_get($url);
  99 + $start = '';
  100 + $end = '';
  101 + if($response['code'] == 200){
  102 + $start = $response['text']['creation_date'];
  103 + $end = $response['text']['expiration_date'];
  104 + }
  105 + return ['start'=>$start,'end'=>$end];
  106 + }
  107 +}
@@ -43,8 +43,13 @@ class ImportManager extends Command @@ -43,8 +43,13 @@ class ImportManager extends Command
43 $info = $model->read(['type'=>5]); 43 $info = $model->read(['type'=>5]);
44 $values = json_decode($info['values']); 44 $values = json_decode($info['values']);
45 $values = array_reverse($values); 45 $values = array_reverse($values);
  46 + $hrModel = new ManageHr();
46 foreach ($values as $k => $v){ 47 foreach ($values as $k => $v){
47 $v = (array)$v; 48 $v = (array)$v;
  49 + $info = $hrModel->read(['mobile'=>$v['mobile']]);
  50 + if($info !== false){
  51 + continue;
  52 + }
48 $data = [ 53 $data = [
49 'name'=>$v['name'], 54 'name'=>$v['name'],
50 'mobile'=>$v['mobile'], 55 'mobile'=>$v['mobile'],
@@ -97,22 +102,26 @@ class ImportManager extends Command @@ -97,22 +102,26 @@ class ImportManager extends Command
97 if($entry_position !== false){ 102 if($entry_position !== false){
98 $entry_position = $entry_position['id']; 103 $entry_position = $entry_position['id'];
99 }else{ 104 }else{
100 - $entry_position = ''; 105 + $entry_position = 0;
101 } 106 }
102 //获取级别 107 //获取级别
103 $jobLevelModel = new JobLevel(); 108 $jobLevelModel = new JobLevel();
104 - $p_level = $jobLevelModel->read(['name'=>$v['p_level']]);  
105 - if($entry_position !== false){  
106 - $p_level = $p_level['id']; 109 + if(!empty($v['p_level'])){
  110 + $p_level = $jobLevelModel->read(['name'=>$v['p_level']]);
  111 + if($p_level !== false){
  112 + $p_level = $p_level['id'];
  113 + }else{
  114 + $p_level = 0;
  115 + }
107 }else{ 116 }else{
108 - $p_level = ''; 117 + $p_level = 0;
109 } 118 }
110 $manager_data = [ 119 $manager_data = [
111 - 'manage_id'=>$manager_id ?? '', 120 + 'manage_id'=>$manager_id,
112 'name'=>$v['name'], 121 'name'=>$v['name'],
113 'id_card'=>$v['id_card'], 122 'id_card'=>$v['id_card'],
114 'mobile'=>$v['mobile'], 123 'mobile'=>$v['mobile'],
115 - 'birthday'=>$v['birthday'], 124 + 'birthday'=>!empty($v['birthday']) ? $v['birthday'] : date('Y-m-d'),
116 'address'=>$v['address'], 125 'address'=>$v['address'],
117 'sex'=>$v['sex'], 126 'sex'=>$v['sex'],
118 'nationality'=>$v['nationality'], 127 'nationality'=>$v['nationality'],
@@ -121,7 +130,7 @@ class ImportManager extends Command @@ -121,7 +130,7 @@ class ImportManager extends Command
121 'major'=>$v['major'], 130 'major'=>$v['major'],
122 'graduate_school'=>$v['graduate_school'], 131 'graduate_school'=>$v['graduate_school'],
123 'english_level'=>$v['english_level'], 132 'english_level'=>$v['english_level'],
124 - 'entry_position'=>$entry_position, 133 + 'entry_position'=>$entry_position ?? 0,
125 'p_level'=>$p_level, 134 'p_level'=>$p_level,
126 'residential_address'=>$v['residential_address'], 135 'residential_address'=>$v['residential_address'],
127 'emergency_contact'=>$v['emergency_contact'], 136 'emergency_contact'=>$v['emergency_contact'],
@@ -134,12 +143,11 @@ class ImportManager extends Command @@ -134,12 +143,11 @@ class ImportManager extends Command
134 'dangyuan'=>$v['dangyuan'], 143 'dangyuan'=>$v['dangyuan'],
135 'dangzhibu'=>$v['dangzhibu'], 144 'dangzhibu'=>$v['dangzhibu'],
136 'dang_address'=>$v['dang_address'], 145 'dang_address'=>$v['dang_address'],
137 - 'join_date'=>$v['join_date'],  
138 - 'status'=>($v['status'] == '在职') ? 1 : 2, 146 + 'join_date'=>!empty($v['join_date']) ? $v['join_date'] : date('Y-m-d'),
  147 + 'status'=> 1,
139 'computer_account'=>$v['computer_account'], 148 'computer_account'=>$v['computer_account'],
140 'qq_account'=>$v['qq_account'] 149 'qq_account'=>$v['qq_account']
141 ]; 150 ];
142 - $hrModel = new ManageHr();  
143 $hrModel->add($manager_data); 151 $hrModel->add($manager_data);
144 } 152 }
145 return 1; 153 return 1;
  1 +<?php
  2 +
  3 +namespace App\Console\Commands;
  4 +
  5 +use App\Helper\Arr;
  6 +use App\Helper\FormGlobalsoApi;
  7 +use App\Http\Logic\Bside\InquiryLogic;
  8 +use App\Models\Product\Category;
  9 +use App\Models\Product\Product;
  10 +use App\Models\Project\OnlineCheck;
  11 +use App\Models\Project\Project;
  12 +use App\Models\RankData\RankData as GoogleRankModel;
  13 +use App\Models\RouteMap\RouteMap;
  14 +use GuzzleHttp\Client;
  15 +use GuzzleHttp\Promise\Utils;
  16 +use Illuminate\Console\Command;
  17 +use Illuminate\Database\Eloquent\Model;
  18 +use Illuminate\Support\Facades\DB;
  19 +use Illuminate\Support\Str;
  20 +
  21 +/**
  22 + * 最近一次询盘
  23 + * Class InquiryList
  24 + * @package App\Console\Commands
  25 + * @author zbj
  26 + * @date 2023/9/11
  27 + */
  28 +class LastInquiry extends Command
  29 +{
  30 + /**
  31 + * The name and signature of the console command.
  32 + *
  33 + * @var string
  34 + */
  35 + protected $signature = 'last_inquiry';
  36 +
  37 + /**
  38 + * The console command description.
  39 + *
  40 + * @var string
  41 + */
  42 + protected $description = '询盘列表';
  43 +
  44 + /**
  45 + * Create a new command instance.
  46 + *
  47 + * @return void
  48 + */
  49 + public function __construct()
  50 + {
  51 + parent::__construct();
  52 + }
  53 +
  54 + /**
  55 + * @return bool
  56 + */
  57 + public function handle()
  58 + {
  59 + $list = Project::with('deploy_optimize')->whereIn('type', [2,3,4])->get();
  60 + foreach ($list as $item){
  61 + if(empty($item['deploy_optimize']['domain'])){
  62 + continue;
  63 + }
  64 + $api = new FormGlobalsoApi();
  65 + $res = $api->getInquiryList($item['deploy_optimize']['domain']);
  66 + if($res && $res['status'] == 200){
  67 + if(empty($res['data']['data'][0])){
  68 + continue;
  69 + }
  70 + $item->last_inquiry_time = $res['data']['data'][0]['submit_time'];
  71 + $item->save();
  72 + }
  73 + }
  74 + }
  75 +}
@@ -3,6 +3,9 @@ @@ -3,6 +3,9 @@
3 namespace App\Console\Commands\MonthlyCount; 3 namespace App\Console\Commands\MonthlyCount;
4 4
5 use App\Helper\FormGlobalsoApi; 5 use App\Helper\FormGlobalsoApi;
  6 +use App\Models\Domain\DomainInfo;
  7 +use App\Models\Project\Project;
  8 +use App\Services\ProjectServer;
6 use Carbon\Carbon; 9 use Carbon\Carbon;
7 use Illuminate\Console\Command; 10 use Illuminate\Console\Command;
8 use Illuminate\Support\Facades\DB; 11 use Illuminate\Support\Facades\DB;
@@ -41,16 +44,25 @@ class InquiryMonthlyCount extends Command @@ -41,16 +44,25 @@ class InquiryMonthlyCount extends Command
41 $startTime = Carbon::now()->subMonth()->startOfMonth()->toDateString(); 44 $startTime = Carbon::now()->subMonth()->startOfMonth()->toDateString();
42 // 获取上个月的结束时间 45 // 获取上个月的结束时间
43 $endTime = Carbon::now()->subMonth()->endOfMonth()->toDateString(); 46 $endTime = Carbon::now()->subMonth()->endOfMonth()->toDateString();
  47 + $domainInfo = new DomainInfo();
44 foreach ($list as $value){ 48 foreach ($list as $value){
45 $value = (array)$value; 49 $value = (array)$value;
46 - if($value['domain'] != ''){  
47 - $value['test_domain'] = $value['domain']; 50 + if($value['type'] == Project::TYPE_ZERO){
  51 + continue;
  52 + }
  53 + if(!empty($value['domain'])){
  54 + $info = $domainInfo->read(['id'=>$value['domain']]);
  55 + if($info !== false){
  56 + $value['test_domain'] = $value['domain'];
  57 + }
48 } 58 }
49 $arr = []; 59 $arr = [];
50 //按月统计询盘记录 60 //按月统计询盘记录
51 $arr = $this->inquiryCount($arr,$startTime,$endTime,$value['test_domain']); 61 $arr = $this->inquiryCount($arr,$startTime,$endTime,$value['test_domain']);
52 $arr = $this->flowCount($arr,$startTime,$endTime,$value['project_id']); 62 $arr = $this->flowCount($arr,$startTime,$endTime,$value['project_id']);
  63 + ProjectServer::useProject($value['project_id']);
53 $arr = $this->sourceCount($arr,$value['test_domain'],$startTime,$endTime); 64 $arr = $this->sourceCount($arr,$value['test_domain'],$startTime,$endTime);
  65 + DB::disconnect('custom_mysql');
54 $arr['created_at'] = date('Y-m-d H:i:s'); 66 $arr['created_at'] = date('Y-m-d H:i:s');
55 $arr['updated_at'] = date('Y-m-d H:i:s'); 67 $arr['updated_at'] = date('Y-m-d H:i:s');
56 $arr['project_id'] = $value['project_id']; 68 $arr['project_id'] = $value['project_id'];
@@ -128,21 +140,21 @@ class InquiryMonthlyCount extends Command @@ -128,21 +140,21 @@ class InquiryMonthlyCount extends Command
128 */ 140 */
129 public function sourceCount(&$arr,$domain,$startTime,$endTime){ 141 public function sourceCount(&$arr,$domain,$startTime,$endTime){
130 //访问来源前10 142 //访问来源前10
131 - $source = DB::table('gl_customer_visit') 143 + $source = DB::connection('custom_mysql')->table('gl_customer_visit')
132 ->select('referrer_url', DB::raw('COUNT(*) as count')) 144 ->select('referrer_url', DB::raw('COUNT(*) as count'))
133 ->groupBy('referrer_url')->where(['domain'=>$domain]) 145 ->groupBy('referrer_url')->where(['domain'=>$domain])
134 ->whereBetween('updated_date', [$startTime,$endTime]) 146 ->whereBetween('updated_date', [$startTime,$endTime])
135 ->orderByDesc('count')->limit(10)->get()->toArray(); 147 ->orderByDesc('count')->limit(10)->get()->toArray();
136 $arr['source'] = json_encode($source); 148 $arr['source'] = json_encode($source);
137 //访问国家前15 149 //访问国家前15
138 - $source_country = DB::table('gl_customer_visit') 150 + $source_country = DB::connection('custom_mysql')->table('gl_customer_visit')
139 ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv')) 151 ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
140 ->groupBy('country')->where(['domain'=>$domain]) 152 ->groupBy('country')->where(['domain'=>$domain])
141 ->whereBetween('updated_date', [$startTime,$endTime]) 153 ->whereBetween('updated_date', [$startTime,$endTime])
142 ->orderBy('ip','desc')->limit(15)->get()->toArray(); 154 ->orderBy('ip','desc')->limit(15)->get()->toArray();
143 $arr['source_country'] = json_encode($source_country); 155 $arr['source_country'] = json_encode($source_country);
144 //受访界面前15 156 //受访界面前15
145 - $referrer_url = DB::table('gl_customer_visit') 157 + $referrer_url = DB::connection('custom_mysql')->table('gl_customer_visit')
146 ->select('url',DB::raw('COUNT(*) as num')) 158 ->select('url',DB::raw('COUNT(*) as num'))
147 ->orderBy('num','desc')->where(['domain'=>$domain]) 159 ->orderBy('num','desc')->where(['domain'=>$domain])
148 ->whereBetween('updated_date', [$startTime,$endTime]) 160 ->whereBetween('updated_date', [$startTime,$endTime])
@@ -150,7 +162,7 @@ class InquiryMonthlyCount extends Command @@ -150,7 +162,7 @@ class InquiryMonthlyCount extends Command
150 ->limit(15)->get()->toArray(); 162 ->limit(15)->get()->toArray();
151 $arr['referrer_url'] = json_encode($referrer_url); 163 $arr['referrer_url'] = json_encode($referrer_url);
152 //访问端口 164 //访问端口
153 - $referrer_port = DB::table('gl_customer_visit') 165 + $referrer_port = DB::connection('custom_mysql')->table('gl_customer_visit')
154 ->select('device_port',DB::raw('COUNT(*) as num')) 166 ->select('device_port',DB::raw('COUNT(*) as num'))
155 ->orderBy('num','desc')->where(['domain'=>$domain]) 167 ->orderBy('num','desc')->where(['domain'=>$domain])
156 ->whereBetween('updated_date', [$startTime,$endTime]) 168 ->whereBetween('updated_date', [$startTime,$endTime])
@@ -168,7 +180,8 @@ class InquiryMonthlyCount extends Command @@ -168,7 +180,8 @@ class InquiryMonthlyCount extends Command
168 */ 180 */
169 public function selectParam(){ 181 public function selectParam(){
170 $select = [ 182 $select = [
171 - 'gl_project.id AS user_id', 183 + 'gl_project.id AS id',
  184 + 'gl_project.type AS type',
172 'gl_project.extend_type AS extend_type', 185 'gl_project.extend_type AS extend_type',
173 'gl_project_deploy_build.test_domain AS test_domain', 186 'gl_project_deploy_build.test_domain AS test_domain',
174 'gl_project_deploy_optimize.domain AS domain', 187 'gl_project_deploy_optimize.domain AS domain',
@@ -6,6 +6,7 @@ use App\Helper\Arr; @@ -6,6 +6,7 @@ use App\Helper\Arr;
6 use App\Helper\SemrushApi; 6 use App\Helper\SemrushApi;
7 use App\Models\RankData\ExternalLinks as ExternalLinksModel; 7 use App\Models\RankData\ExternalLinks as ExternalLinksModel;
8 use App\Models\Project\DeployOptimize; 8 use App\Models\Project\DeployOptimize;
  9 +use App\Utils\LogUtils;
9 10
10 /** 11 /**
11 * Class ExternalLinks 12 * Class ExternalLinks
@@ -39,7 +40,7 @@ class ExternalLinks extends BaseCommands @@ -39,7 +40,7 @@ class ExternalLinks extends BaseCommands
39 $semrushApi = new SemrushApi(); 40 $semrushApi = new SemrushApi();
40 //有排名api编号的项目 41 //有排名api编号的项目
41 $list = DeployOptimize::where('api_no', '>', 0)->pluck('domain', 'project_id')->toArray(); 42 $list = DeployOptimize::where('api_no', '>', 0)->pluck('domain', 'project_id')->toArray();
42 - 43 + LogUtils::info('start rank_data_external_links:' . count($list));
43 foreach ($list as $project_id => $domain) { 44 foreach ($list as $project_id => $domain) {
44 if(!$domain){ 45 if(!$domain){
45 continue; 46 continue;
@@ -5,6 +5,7 @@ namespace App\Console\Commands\RankData; @@ -5,6 +5,7 @@ namespace App\Console\Commands\RankData;
5 use App\Helper\QuanqiusouApi; 5 use App\Helper\QuanqiusouApi;
6 use App\Models\Project\DeployOptimize; 6 use App\Models\Project\DeployOptimize;
7 use App\Models\RankData\IndexedPages as IndexedPagesModel; 7 use App\Models\RankData\IndexedPages as IndexedPagesModel;
  8 +use App\Utils\LogUtils;
8 9
9 /** 10 /**
10 * Class IndexedPages 11 * Class IndexedPages
@@ -38,7 +39,7 @@ class IndexedPages extends BaseCommands @@ -38,7 +39,7 @@ class IndexedPages extends BaseCommands
38 $api = new QuanqiusouApi(); 39 $api = new QuanqiusouApi();
39 //有排名api编号的项目 40 //有排名api编号的项目
40 $list = DeployOptimize::where('api_no', '>', 0)->pluck('api_no', 'project_id')->toArray(); 41 $list = DeployOptimize::where('api_no', '>', 0)->pluck('api_no', 'project_id')->toArray();
41 - 42 + LogUtils::info('start rank_data_indexed_pages:' . count($list));
42 foreach ($list as $project_id => $api_no) { 43 foreach ($list as $project_id => $api_no) {
43 $model = IndexedPagesModel::where('project_id', $project_id)->first(); 44 $model = IndexedPagesModel::where('project_id', $project_id)->first();
44 if($model && $model->updated_date == getThisWeekStarDate()){ 45 if($model && $model->updated_date == getThisWeekStarDate()){
@@ -6,7 +6,9 @@ use App\Helper\Arr; @@ -6,7 +6,9 @@ use App\Helper\Arr;
6 use App\Helper\QuanqiusouApi; 6 use App\Helper\QuanqiusouApi;
7 use App\Models\Project\DeployBuild; 7 use App\Models\Project\DeployBuild;
8 use App\Models\Project\DeployOptimize; 8 use App\Models\Project\DeployOptimize;
  9 +use App\Models\Project\Project;
9 use App\Models\RankData\RankData as GoogleRankModel; 10 use App\Models\RankData\RankData as GoogleRankModel;
  11 +use App\Utils\LogUtils;
10 12
11 /** 13 /**
12 * Class GoogleRank 14 * Class GoogleRank
@@ -41,6 +43,7 @@ class RankData extends BaseCommands @@ -41,6 +43,7 @@ class RankData extends BaseCommands
41 $api = new QuanqiusouApi(); 43 $api = new QuanqiusouApi();
42 //有排名api编号的项目 44 //有排名api编号的项目
43 $list = DeployOptimize::where('api_no', '>' , 0)->select('api_no','minor_languages','project_id')->get(); 45 $list = DeployOptimize::where('api_no', '>' , 0)->select('api_no','minor_languages','project_id')->get();
  46 + LogUtils::info('start rank_data:' . count($list));
44 //当日所有站点谷歌收录数据 47 //当日所有站点谷歌收录数据
45 $site_res = $api->getSiteRes(); 48 $site_res = $api->getSiteRes();
46 if(!$site_res){ 49 if(!$site_res){
@@ -141,11 +144,14 @@ class RankData extends BaseCommands @@ -141,11 +144,14 @@ class RankData extends BaseCommands
141 } 144 }
142 145
143 //关键词达标天数 146 //关键词达标天数
  147 + $model->is_compliance = 0;
144 if($model->updated_date != date('Y-m-d')){ 148 if($model->updated_date != date('Y-m-d')){
145 //保证关键词数 149 //保证关键词数
146 $keyword_num = DeployBuild::where('project_id', $project_id)->value('keyword_num'); 150 $keyword_num = DeployBuild::where('project_id', $project_id)->value('keyword_num');
147 - if($first_page_num >= $keyword_num){ 151 + $type = Project::where('id', $project_id)->value('type');
  152 + if($keyword_num && $type == 2 && $first_page_num >= $keyword_num){
148 $model->compliance_day = $model->compliance_day + 1; 153 $model->compliance_day = $model->compliance_day + 1;
  154 + $model->is_compliance = 1;
149 } 155 }
150 } 156 }
151 157
@@ -7,6 +7,7 @@ use App\Helper\Arr; @@ -7,6 +7,7 @@ use App\Helper\Arr;
7 use App\Helper\QuanqiusouApi; 7 use App\Helper\QuanqiusouApi;
8 use App\Models\Project\DeployOptimize; 8 use App\Models\Project\DeployOptimize;
9 use App\Models\RankData\RankWeek as RankWeekModel; 9 use App\Models\RankData\RankWeek as RankWeekModel;
  10 +use App\Utils\LogUtils;
10 11
11 /** 12 /**
12 * Class WeekRank 13 * Class WeekRank
@@ -49,7 +50,7 @@ class RankWeek extends BaseCommands @@ -49,7 +50,7 @@ class RankWeek extends BaseCommands
49 $res = Arr::s2a($res); 50 $res = Arr::s2a($res);
50 //有排名api编号的项目 51 //有排名api编号的项目
51 $list = DeployOptimize::where('api_no', '>', 0)->pluck('api_no', 'project_id')->toArray(); 52 $list = DeployOptimize::where('api_no', '>', 0)->pluck('api_no', 'project_id')->toArray();
52 - 53 + LogUtils::info('start rank_data_week:' . count($list));
53 foreach ($list as $project_id => $api_no) { 54 foreach ($list as $project_id => $api_no) {
54 $rank_week = RankWeekModel::where('project_id', $project_id)->first(); 55 $rank_week = RankWeekModel::where('project_id', $project_id)->first();
55 if ($rank_week && $rank_week->updated_date == getThisWeekStarDate()) { 56 if ($rank_week && $rank_week->updated_date == getThisWeekStarDate()) {
@@ -5,6 +5,7 @@ namespace App\Console\Commands\RankData; @@ -5,6 +5,7 @@ namespace App\Console\Commands\RankData;
5 use App\Helper\SemrushApi; 5 use App\Helper\SemrushApi;
6 use App\Models\RankData\RecommDomain as RecommDomainModel; 6 use App\Models\RankData\RecommDomain as RecommDomainModel;
7 use App\Models\Project\DeployOptimize; 7 use App\Models\Project\DeployOptimize;
  8 +use App\Utils\LogUtils;
8 9
9 /** 10 /**
10 * Class RecommDomain 11 * Class RecommDomain
@@ -38,7 +39,7 @@ class RecommDomain extends BaseCommands @@ -38,7 +39,7 @@ class RecommDomain extends BaseCommands
38 $semrushApi = new SemrushApi(); 39 $semrushApi = new SemrushApi();
39 //有排名api编号的项目 40 //有排名api编号的项目
40 $list = DeployOptimize::where('api_no', '>', 0)->pluck('domain', 'project_id')->toArray(); 41 $list = DeployOptimize::where('api_no', '>', 0)->pluck('domain', 'project_id')->toArray();
41 - 42 + LogUtils::info('start rank_data_recomm_domain:' . count($list));
42 foreach ($list as $project_id => $domain) { 43 foreach ($list as $project_id => $domain) {
43 if(!$domain){ 44 if(!$domain){
44 continue; 45 continue;
@@ -6,6 +6,7 @@ use App\Helper\Arr; @@ -6,6 +6,7 @@ use App\Helper\Arr;
6 use App\Helper\GoogleSpeedApi; 6 use App\Helper\GoogleSpeedApi;
7 use App\Models\Project\DeployOptimize; 7 use App\Models\Project\DeployOptimize;
8 use App\Models\RankData\Speed as GoogleSpeedModel; 8 use App\Models\RankData\Speed as GoogleSpeedModel;
  9 +use App\Utils\LogUtils;
9 10
10 /** 11 /**
11 * Class GoogleSpeed 12 * Class GoogleSpeed
@@ -42,7 +43,7 @@ class Speed extends BaseCommands @@ -42,7 +43,7 @@ class Speed extends BaseCommands
42 43
43 //有排名api编号的项目 44 //有排名api编号的项目
44 $list = DeployOptimize::where('api_no', '>', 0)->pluck('domain', 'project_id')->toArray(); 45 $list = DeployOptimize::where('api_no', '>', 0)->pluck('domain', 'project_id')->toArray();
45 - 46 + LogUtils::info('start rank_data_speed:' . count($list));
46 foreach ($list as $project_id => $domain) { 47 foreach ($list as $project_id => $domain) {
47 $model = GoogleSpeedModel::where('project_id', $project_id)->first(); 48 $model = GoogleSpeedModel::where('project_id', $project_id)->first();
48 if ($model && $model->updated_date == getThisWeekStarDate()) { 49 if ($model && $model->updated_date == getThisWeekStarDate()) {
  1 +<?php
  2 +
  3 +namespace App\Console\Commands;
  4 +
  5 +use App\Helper\Arr;
  6 +use App\Models\Product\Category;
  7 +use App\Models\Product\Product;
  8 +use App\Models\Project\OnlineCheck;
  9 +use App\Models\Project\Project;
  10 +use App\Models\RankData\RankData as GoogleRankModel;
  11 +use App\Models\RouteMap\RouteMap;
  12 +use GuzzleHttp\Client;
  13 +use GuzzleHttp\Promise\Utils;
  14 +use Illuminate\Console\Command;
  15 +use Illuminate\Support\Facades\DB;
  16 +use Illuminate\Support\Str;
  17 +
  18 +/**
  19 + * 剩余服务时长
  20 + * Class Traffic
  21 + * @package App\Console\Commands
  22 + * @author zbj
  23 + * @date 2023/5/18
  24 + */
  25 +class RemainDay extends Command
  26 +{
  27 + /**
  28 + * The name and signature of the console command.
  29 + *
  30 + * @var string
  31 + */
  32 + protected $signature = 'remain_day';
  33 +
  34 + /**
  35 + * The console command description.
  36 + *
  37 + * @var string
  38 + */
  39 + protected $description = '网站服务剩余时长';
  40 +
  41 + /**
  42 + * Create a new command instance.
  43 + *
  44 + * @return void
  45 + */
  46 + public function __construct()
  47 + {
  48 + parent::__construct();
  49 + }
  50 +
  51 + /**
  52 + * @return bool
  53 + */
  54 + public function handle()
  55 + {
  56 + $list = Project::whereIn('type', [2,3,4])->get();
  57 + foreach ($list as $item){
  58 + if($item['type'] == 3){
  59 + //排名达标天数
  60 + $compliance_day = GoogleRankModel::where(['project_id' => $item['id'], 'lang' => ''])->value('compliance_day') ?: 0;
  61 + $remain_day = $item['deploy_build']['service_duration'] - $compliance_day;
  62 + }else{
  63 + //审核上线后开始
  64 + $check_time = OnlineCheck::where('project_id', $item['id'])->where('status', 1)->value('created_at') ?: '';
  65 + if(!$check_time){
  66 + $remain_day = $item['deploy_build']['service_duration'];
  67 + }else{
  68 + $diff = time() - strtotime($check_time);
  69 + $remain_day = floor($diff / (60 * 60 * 24));
  70 + }
  71 + }
  72 + $item->remain_day = $remain_day > 0 ? $remain_day : 0;
  73 + $item->save();
  74 + }
  75 + }
  76 +}
@@ -16,6 +16,7 @@ use App\Models\Project\ProjectRenew; @@ -16,6 +16,7 @@ use App\Models\Project\ProjectRenew;
16 use App\Utils\LogUtils; 16 use App\Utils\LogUtils;
17 use Hashids\Hashids; 17 use Hashids\Hashids;
18 use Illuminate\Console\Command; 18 use Illuminate\Console\Command;
  19 +use Illuminate\Database\Eloquent\Model;
19 use Illuminate\Support\Facades\DB; 20 use Illuminate\Support\Facades\DB;
20 use Illuminate\Support\Facades\Http; 21 use Illuminate\Support\Facades\Http;
21 22
@@ -57,37 +58,41 @@ class SyncProject extends Command @@ -57,37 +58,41 @@ class SyncProject extends Command
57 */ 58 */
58 public function handle() 59 public function handle()
59 { 60 {
60 - $list = NoticeLog::where('type', NoticeLog::TYPE_PROJECT)->where('status', NoticeLog::STATUS_PENDING)->get();  
61 - foreach ($list as $item){  
62 - try {  
63 - $api = new OaGlobalsoApi();  
64 - $data = $api->order_info($item['data']['order_id']);  
65 - if(!$data || empty($data['data'])){  
66 - LogUtils::error('OaGlobalsoApi order_info error', $data);  
67 - $this->retry($item);  
68 - }  
69 - if($data['data']['order_type'] == '首次'){  
70 - $this->sync($data['data']); 61 + while (true){
  62 + $list = NoticeLog::where('type', NoticeLog::TYPE_PROJECT)->where('status', NoticeLog::STATUS_PENDING)->get();
  63 + foreach ($list as $item){
  64 + try {
  65 + $api = new OaGlobalsoApi();
  66 + $data = $api->order_info($item['data']['order_id']);
  67 + if(!$data || empty($data['data'])){
  68 + LogUtils::error('OaGlobalsoApi order_info error', $data);
  69 + $this->retry($item);
  70 + }
  71 + if($data['data']['order_type'] == '首次'){
  72 + $this->sync($data['data']);
71 73
72 - //同步aicc  
73 - if($data['data']['exclusive_aicc']){  
74 - $this->toAicc($data['data']); 74 + //同步aicc
  75 + if($data['data']['exclusive_aicc']){
  76 + $this->toAicc($data['data']);
  77 + }
  78 + //同步hagro
  79 + if($data['data']['exclusive_hagro']){
  80 + $this->toHagro($data['data']);
  81 + }
75 } 82 }
76 - //同步hagro  
77 - if($data['data']['exclusive_hagro']){  
78 - $this->toHagro($data['data']); 83 + if($data['data']['order_type'] == '续费'){
  84 + $this->renewSync($data['data']);
79 } 85 }
  86 + $item->status = NoticeLog::STATUS_SUCCESS;
  87 + $item->save();
  88 + }catch (\Exception $e){
  89 + errorLog('项目同步失败', $item, $e);
  90 + $this->retry($item);
80 } 91 }
81 - if($data['data']['order_type'] == '续费'){  
82 - $this->renewSync($data['data']);  
83 - }  
84 - $item->status = NoticeLog::STATUS_SUCCESS;  
85 - $item->save();  
86 - }catch (\Exception $e){  
87 - errorLog('项目同步失败', $item, $e);  
88 - $this->retry($item);  
89 } 92 }
  93 + sleep(2);
90 } 94 }
  95 +
91 } 96 }
92 97
93 /** 98 /**
@@ -190,14 +195,10 @@ class SyncProject extends Command @@ -190,14 +195,10 @@ class SyncProject extends Command
190 'project_after' => [], 195 'project_after' => [],
191 'payment' => [ 196 'payment' => [
192 'amount' => $param['plan_price'], 197 'amount' => $param['plan_price'],
  198 + 'contract'=>$param['files'],
  199 + 'bill'=>$param['images']
193 ], 200 ],
194 ]; 201 ];
195 - if(!empty($param['files'])){  
196 - $data['payment']['contract'] = json_encode($param['files']);  
197 - }  
198 - if(!empty($param['images'])){  
199 - $data['payment']['bill'] = json_encode($param['images']);  
200 - }  
201 DB::beginTransaction(); 202 DB::beginTransaction();
202 try { 203 try {
203 $id = $this->saveProject($data['project']); 204 $id = $this->saveProject($data['project']);
@@ -209,7 +210,7 @@ class SyncProject extends Command @@ -209,7 +210,7 @@ class SyncProject extends Command
209 DB::commit(); 210 DB::commit();
210 }catch (\Exception $e){ 211 }catch (\Exception $e){
211 DB::rollBack(); 212 DB::rollBack();
212 - errorLog('项目同步失败', $data, $e); 213 + throw new \Exception($e->getMessage());
213 } 214 }
214 } 215 }
215 216
@@ -242,7 +243,13 @@ class SyncProject extends Command @@ -242,7 +243,13 @@ class SyncProject extends Command
242 $param['channel'] = Arr::a2s($param['channel']); 243 $param['channel'] = Arr::a2s($param['channel']);
243 } 244 }
244 $projectModel = new Project(); 245 $projectModel = new Project();
245 - return $projectModel->addReturnId($param); 246 + $info = $projectModel->read(['from_order_id'=>$param['from_order_id'],'delete_status'=>0]);
  247 + if($info !== false){
  248 + $projectModel->edit($param, ['id' => $info['id']]);
  249 + return $info['id'];
  250 + }else{
  251 + return $projectModel->addReturnId($param);
  252 + }
246 } 253 }
247 254
248 /** 255 /**
@@ -254,7 +261,12 @@ class SyncProject extends Command @@ -254,7 +261,12 @@ class SyncProject extends Command
254 $param['project_id'] = $id; 261 $param['project_id'] = $id;
255 //查询数据是否存在 262 //查询数据是否存在
256 $afterModel = new After(); 263 $afterModel = new After();
257 - return $afterModel->add($param); 264 + $info = $afterModel->read(['project_id'=>$id]);
  265 + if($info !== false){
  266 + $afterModel->edit($param,['id'=>$info['id']]);
  267 + }else{
  268 + $afterModel->add($param);
  269 + }
258 } 270 }
259 271
260 /** 272 /**
@@ -267,13 +279,18 @@ class SyncProject extends Command @@ -267,13 +279,18 @@ class SyncProject extends Command
267 protected function savePayment($param,$id){ 279 protected function savePayment($param,$id){
268 $param['project_id'] = $id; 280 $param['project_id'] = $id;
269 $paymentModel= new Payment(); 281 $paymentModel= new Payment();
270 - if(isset($param['contract']) && !empty($param['contract'])){ 282 +// if(isset($param['contract']) && !empty($param['contract'])){
271 $param['contract'] = Arr::a2s($param['contract']); 283 $param['contract'] = Arr::a2s($param['contract']);
272 - }  
273 - if(isset($param['bill']) && !empty($param['bill'])){ 284 +// }
  285 +// if(isset($param['bill']) && !empty($param['bill'])){
274 $param['bill'] = Arr::a2s($param['bill']); 286 $param['bill'] = Arr::a2s($param['bill']);
  287 +// }
  288 + $info = $paymentModel->read(['project_id'=>$id]);
  289 + if($info !== false){
  290 + $paymentModel->edit($param,['id'=>$info['id']]);
  291 + }else{
  292 + $paymentModel->add($param);
275 } 293 }
276 - return $paymentModel->add($param);  
277 } 294 }
278 295
279 /** 296 /**
@@ -289,7 +306,12 @@ class SyncProject extends Command @@ -289,7 +306,12 @@ class SyncProject extends Command
289 $code = $hashids->encode($id); 306 $code = $hashids->encode($id);
290 $param['test_domain'] = 'https://v6-' . $code . '.globalso.site/'; 307 $param['test_domain'] = 'https://v6-' . $code . '.globalso.site/';
291 $deployBuildModel = new DeployBuild(); 308 $deployBuildModel = new DeployBuild();
292 - return $deployBuildModel->add($param); 309 + $info = $deployBuildModel->read(['project_id'=>$id]);
  310 + if($info !== false){
  311 + $deployBuildModel->edit($param,['id'=>$info['id']]);
  312 + }else{
  313 + $deployBuildModel->add($param);
  314 + }
293 } 315 }
294 316
295 /** 317 /**
@@ -302,7 +324,12 @@ class SyncProject extends Command @@ -302,7 +324,12 @@ class SyncProject extends Command
302 protected function saveDeployOptimize($param,$id){ 324 protected function saveDeployOptimize($param,$id){
303 $param['project_id'] = $id; 325 $param['project_id'] = $id;
304 $deployOptimizeModel = new DeployOptimize(); 326 $deployOptimizeModel = new DeployOptimize();
305 - return $deployOptimizeModel->add($param); 327 + $info = $deployOptimizeModel->read(['project_id'=>$id]);
  328 + if($info !== false){
  329 + $deployOptimizeModel->edit($param,['id'=>$info['id']]);
  330 + }else{
  331 + $deployOptimizeModel->add($param);
  332 + }
306 } 333 }
307 334
308 /** 335 /**
@@ -346,7 +373,7 @@ class SyncProject extends Command @@ -346,7 +373,7 @@ class SyncProject extends Command
346 * @date 2023/9/1 373 * @date 2023/9/1
347 */ 374 */
348 protected function toHagro($data){ 375 protected function toHagro($data){
349 - $url = 'https://beta.hagro.cn/globalso/create_project'; 376 + $url = 'https://admin.hagro.cn/globalso/create_project';
350 $param = [ 377 $param = [
351 'company' => $data['company_name'], 378 'company' => $data['company_name'],
352 'phone' => $data['principal_mobile'], 379 'phone' => $data['principal_mobile'],
@@ -10,10 +10,15 @@ namespace App\Console\Commands\Test; @@ -10,10 +10,15 @@ namespace App\Console\Commands\Test;
10 use App\Models\Blog\Blog; 10 use App\Models\Blog\Blog;
11 use App\Models\Devops\ServerConfig; 11 use App\Models\Devops\ServerConfig;
12 use App\Models\File\Image; 12 use App\Models\File\Image;
  13 +use App\Models\Manage\BelongingGroup;
  14 +use App\Models\Manage\Dept;
  15 +use App\Models\Manage\EntryPosition;
  16 +use App\Models\Manage\ManageHr;
13 use App\Services\ProjectServer; 17 use App\Services\ProjectServer;
14 use GuzzleHttp\Client; 18 use GuzzleHttp\Client;
15 use Illuminate\Console\Command; 19 use Illuminate\Console\Command;
16 use Illuminate\Support\Facades\DB; 20 use Illuminate\Support\Facades\DB;
  21 +use Illuminate\Support\Facades\Log;
17 22
18 class Demo extends Command 23 class Demo extends Command
19 { 24 {
@@ -41,11 +46,187 @@ class Demo extends Command @@ -41,11 +46,187 @@ class Demo extends Command
41 parent::__construct(); 46 parent::__construct();
42 } 47 }
43 48
  49 + public function curlRequest($url, $data, $method = 'POST', $header = [], $time_out = 60)
  50 + {
  51 +
  52 + $ch = curl_init();
  53 + curl_setopt($ch, CURLOPT_TIMEOUT, $time_out);
  54 + curl_setopt($ch, CURLOPT_URL, $url);
  55 + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  56 + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  57 + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  58 + if ($data)
  59 + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
  60 + curl_setopt($ch, CURLOPT_HTTPHEADER, array_merge([
  61 + 'Expect:',
  62 + 'Content-type: application/json',
  63 + 'Accept: application/json',
  64 + ], $header)
  65 + );
  66 + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
  67 + $response = curl_exec($ch);
  68 + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  69 + curl_close($ch);
  70 + return [$code, $response];
  71 + }
  72 +
44 /** 73 /**
45 * @return bool 74 * @return bool
46 */ 75 */
47 public function handle() 76 public function handle()
48 { 77 {
  78 + $data = [];
  79 + dd(isset($data['a']['b']));
  80 + $url = 'https://demo.globalso.site/';
  81 + $action = 'api/updateHtmlNotify/';
  82 + $data = [
  83 + 'project_id' => 1,
  84 + 'type' => 1,
  85 + 'route' => 1
  86 + ];;
  87 + $method = 'GET';
  88 + $result = $this->curlRequest($url . $action, $data, $method);
  89 + dd($result);
  90 +
  91 + $context = stream_context_create([
  92 + 'ssl' => [
  93 + 'capture_peer_cert' => true,
  94 + 'capture_peer_cert_chain' => false,
  95 + ],
  96 + ]);
  97 +
  98 + $stream = stream_socket_client('ssl://oa.quanqiusou.cn:443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);
  99 +
  100 + if(!$stream) {
  101 + die("Failed to connect: $errno - $errstr");
  102 + }
  103 +
  104 + $remote_cert = stream_context_get_params($stream)['options']['ssl']['peer_certificate'];
  105 +
  106 + if(!$remote_cert) {
  107 + die("Failed to retrieve certificate");
  108 + }
  109 +
  110 + $valid_from = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validFrom_time_t']);
  111 + $valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']);
  112 +
  113 + fclose($stream);
  114 +
  115 + echo "Certificate Valid From: $valid_from<br>";
  116 + echo "Certificate Valid To: $valid_to<br>";
  117 +
  118 + dd('end');
  119 + $dept_array = [
  120 + '品牌部',
  121 + '综合部',
  122 + '渠道部',
  123 + '广告推广部',
  124 + 'AICC运营部',
  125 + '黑格运营部',
  126 + '直营运营部',
  127 + '直营销售部',
  128 + '深圳跨境部',
  129 + '外贸部',
  130 + '研发部',
  131 + '技术部',
  132 + '售后部',
  133 + ];
  134 + foreach ($dept_array as $v) {
  135 + $dept = Dept::where(['title' => $v])->first();
  136 + if (FALSE == empty($dept))
  137 + continue;
  138 + $dept = new Dept();
  139 + $dept->title = $v;
  140 + $dept->save();
  141 + }
  142 +// dd('dept end');
  143 + $dept_map = Dept::pluck('title', 'id')->toArray();
  144 + $belonging_map = BelongingGroup::pluck('name', 'id')->toArray();
  145 +// dd($belonging_map);
  146 +
  147 + $filename = storage_path('logs/oa_hr.txt');
  148 + $string = file_get_contents($filename);
  149 + $data = explode("\r\n", $string);
  150 + $data = array_filter($data);
  151 + $dept = '';
  152 + foreach ($data as $k=>$v) {
  153 +// var_dump($v) . PHP_EOL;
  154 + if ($k == 1)
  155 + continue;
  156 + $tmp = explode("\t", $v);
  157 + if (count($tmp) == 3) {
  158 + $dept = $tmp[0] ? : $dept;
  159 + $position = $tmp[1];
  160 + $name = $tmp[2];
  161 + } else if (count($tmp) == 2) {
  162 + $position = $tmp[0];
  163 + $name = $tmp[1];
  164 + } else {
  165 + Log::info($v . PHP_EOL);
  166 + continue;
  167 + }
  168 +
  169 +
  170 +// Log::info($dept . '---' . $position . '---' . $name . PHP_EOL);
  171 +// continue;
  172 +
  173 + $dept_id = array_search($dept, $dept_map);
  174 + $belonging_id = 17;
  175 + if (FALSE !== strpos($dept,'技术部')) {
  176 + $belonging_string = str_replace('技术部', '', $dept);
  177 + if ($belonging_string) {
  178 + $belonging_string = $belonging_string . '组';
  179 + $belonging_id = array_search($belonging_string, $belonging_map);
  180 + }
  181 +
  182 + $dept_tmp = '技术部';
  183 + $dept_id = array_search($dept_tmp, $dept_map);
  184 + }
  185 + if (FALSE !== strpos($dept,'售后')) {
  186 + $belonging_string = str_replace('售后', '', $dept);
  187 + if ($belonging_string)
  188 + $belonging_id = array_search($belonging_string, $belonging_map);
  189 + $dept_tmp = '售后部';
  190 + $dept_id = array_search($dept_tmp, $dept_map);
  191 + }
  192 +
  193 + $position_log = EntryPosition::where(['name' => $position])->first();
  194 + if (empty($position_log)) {
  195 + $position_log = new EntryPosition();
  196 + $position_log->name = $position;
  197 + $position_log->save();
  198 + }
  199 + $position_id = $position_log->id;
  200 +
  201 + $hr = ManageHr::where(['name' => $name])->first();
  202 + if (empty($hr)) {
  203 + Log::info($k . '-' . $name . '-' . $dept . '-' . $dept_id . '-' . $position . '-' . $position_id);
  204 + continue;
  205 + }
  206 +
  207 + $hr->belong_group = $belonging_id;
  208 + $hr->dept_id = $dept_id;
  209 + $hr->entry_position = $position_id;
  210 + $hr->save();
  211 + echo $k . '-' . $name . '-' . $dept . '-' . $dept_id . '-' . $position . '-' . $position_id . '-' . '组' . '-' . $belonging_id . PHP_EOL;
  212 +
  213 + }
  214 + dd('end');
  215 + exit;
  216 +
  217 + if (($handle = fopen($filename, 'r')) !== false) {
  218 + while (($data = fgetcsv($handle, 1000, ',')) !== false) {
  219 + // 处理每行数据
  220 + Log::info(var_export($data, true));
  221 + }
  222 + fclose($handle);
  223 + }
  224 + exit;
  225 +
  226 + $group = BelongingGroup::get();
  227 + dd($group->toArray());
  228 + $domain = parse_url('https//:dev.golbalso.site/');
  229 + dd($domain);
49 echo time() . PHP_EOL; 230 echo time() . PHP_EOL;
50 $blogModel = new Image(); 231 $blogModel = new Image();
51 $list = $blogModel->list(); 232 $list = $blogModel->list();
@@ -6,6 +6,7 @@ use App\Helper\Arr; @@ -6,6 +6,7 @@ use App\Helper\Arr;
6 use App\Models\Product\Category; 6 use App\Models\Product\Category;
7 use App\Models\Product\Product; 7 use App\Models\Product\Product;
8 use App\Models\RouteMap\RouteMap; 8 use App\Models\RouteMap\RouteMap;
  9 +use App\Services\ProjectServer;
9 use GuzzleHttp\Client; 10 use GuzzleHttp\Client;
10 use GuzzleHttp\Promise\Utils; 11 use GuzzleHttp\Promise\Utils;
11 use Illuminate\Console\Command; 12 use Illuminate\Console\Command;
@@ -230,20 +231,26 @@ class WebTraffic extends Command @@ -230,20 +231,26 @@ class WebTraffic extends Command
230 */ 231 */
231 protected function getProductUrls($project_id){ 232 protected function getProductUrls($project_id){
232 //产品分类页面 233 //产品分类页面
233 - $product_cate_ids = Category::where('project_id', $project_id)->where('status', Category::STATUS_ACTIVE)->pluck('id')->toArray();  
234 - $data['urls_cats'] = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PRODUCT_CATE)->whereIn('source_id', $product_cate_ids)->get()->toArray(); 234 + ProjectServer::useProject($project_id);
  235 + $product_cate_ids = DB::connection('custom_mysql')->table('gl_product_category')
  236 + ->where('project_id', $project_id)->where('status', 1)->pluck('id')->toArray();
  237 + $data['urls_cats'] = DB::connection('custom_mysql')->table('gl_route_map')
  238 + ->where('project_id', $project_id)->where('source', 'product_category')->whereIn('source_id', $product_cate_ids)->get()->toArray();
235 //单页面 239 //单页面
236 //todo 发布状态的单页面id 240 //todo 发布状态的单页面id
237 - $data['urls_page'] = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PAGE)->get()->toArray(); 241 + $data['urls_page'] = DB::connection('custom_mysql')->table('gl_route_map')
  242 + ->where('project_id', $project_id)->where('source', 'page')->get()->toArray();
238 //产品详情页 243 //产品详情页
239 - $product_ids = Product::where('project_id', $project_id)->where('status', Product::STATUS_ON)->pluck('id')->toArray();  
240 - $data['urls_details'] = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PRODUCT)->whereIn('source_id', $product_ids)->get()->toArray(); 244 + $product_ids = DB::connection('custom_mysql')->table('gl_product_category')
  245 + ->where('project_id', $project_id)->where('status', 1)->pluck('id')->toArray();
  246 + $data['urls_details'] = DB::connection('custom_mysql')->table('gl_route_map')
  247 + ->where('project_id', $project_id)->where('source', 'product')->whereIn('source_id', $product_ids)->get()->toArray();
241 248
242 $data['urls_cats'] = array_merge($data['urls_cats'], $data['urls_page']); 249 $data['urls_cats'] = array_merge($data['urls_cats'], $data['urls_page']);
243 if(empty($data['urls_cats'])){ 250 if(empty($data['urls_cats'])){
244 $data['urls_cats'] = $data['urls_details']; 251 $data['urls_cats'] = $data['urls_details'];
245 } 252 }
246 - 253 + DB::disconnect('custom_mysql');
247 return $data; 254 return $data;
248 } 255 }
249 256
@@ -312,10 +319,10 @@ class WebTraffic extends Command @@ -312,10 +319,10 @@ class WebTraffic extends Command
312 319
313 $url = []; 320 $url = [];
314 if($res_sdzb == 0){//深度一页 321 if($res_sdzb == 0){//深度一页
315 - $url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb])['route'] : ''; 322 + $url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb])->route : '';
316 }elseif($res_sdzb == 1){//深度两页 323 }elseif($res_sdzb == 1){//深度两页
317 $url[] = $project_urls['home']; 324 $url[] = $project_urls['home'];
318 - $url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb])['route'] : ''; 325 + $url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb])->route : '';
319 }elseif($res_sdzb == 2){//深度3-6页 326 }elseif($res_sdzb == 2){//深度3-6页
320 $yms = rand(2,5); //随机页面数 327 $yms = rand(2,5); //随机页面数
321 $url = Arr::pluck(Arr::random($all_url, $yms), 'route'); 328 $url = Arr::pluck(Arr::random($all_url, $yms), 'route');
@@ -16,6 +16,7 @@ class Kernel extends ConsoleKernel @@ -16,6 +16,7 @@ class Kernel extends ConsoleKernel
16 protected function schedule(Schedule $schedule) 16 protected function schedule(Schedule $schedule)
17 { 17 {
18 // $schedule->command('inspire')->hourly(); 18 // $schedule->command('inspire')->hourly();
  19 + $schedule->command('remain_day')->dailyAt('03:00')->withoutOverlapping(1); // 项目剩余服务时长
19 $schedule->command('rank_data')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据,每天凌晨执行一次 20 $schedule->command('rank_data')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据,每天凌晨执行一次
20 $schedule->command('rank_data_speed')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-测速数据,每周一凌晨执行一次 21 $schedule->command('rank_data_speed')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-测速数据,每周一凌晨执行一次
21 $schedule->command('rank_data_external_links')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-外链,每周一凌晨执行一次 22 $schedule->command('rank_data_external_links')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-外链,每周一凌晨执行一次
@@ -27,14 +28,13 @@ class Kernel extends ConsoleKernel @@ -27,14 +28,13 @@ class Kernel extends ConsoleKernel
27 $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次 28 $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次
28 $schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次 29 $schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次
29 $schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次 30 $schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次
30 - $schedule->command('sync_channel')->dailyAt('06:00')->withoutOverlapping(1); // 渠道信息,每周执行一次  
31 - $schedule->command('sync_project')->everyMinute()->withoutOverlapping(1); //同步项目 31 + $schedule->command('sync_channel')->dailyAt('06:00')->withoutOverlapping(1); // 渠道信息,每天执行一次
32 $schedule->command('month_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计记录 32 $schedule->command('month_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计记录
33 $schedule->command('forward_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计转发询盘记录 33 $schedule->command('forward_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计转发询盘记录
34 $schedule->command('inquiry_delay')->everyMinute()->withoutOverlapping(1);//TODO::上线放开,转发询盘,每分钟执行一次 34 $schedule->command('inquiry_delay')->everyMinute()->withoutOverlapping(1);//TODO::上线放开,转发询盘,每分钟执行一次
35 $schedule->command('inquiry_count')->dailyAt('01:00')->withoutOverlapping(1); // 询盘统计数据,每天凌晨执行一次 35 $schedule->command('inquiry_count')->dailyAt('01:00')->withoutOverlapping(1); // 询盘统计数据,每天凌晨执行一次
36 -// // 更新域名|证书结束时间,每天凌晨1点执行一次  
37 -// $schedule->command('domain_time')->dailyAt('01:00')->withoutOverlapping(1); 36 + $schedule->command('domain_info')->dailyAt('01:00')->withoutOverlapping(1);// 更新域名|证书结束时间,每天凌晨1点执行一次
  37 + $schedule->command('last_inquiry')->dailyAt('04:00')->withoutOverlapping(1);// 最近一次询盘信息
38 } 38 }
39 39
40 /** 40 /**
@@ -88,16 +88,16 @@ if (!function_exists('http_get')) { @@ -88,16 +88,16 @@ if (!function_exists('http_get')) {
88 function http_get($url, $header = []) 88 function http_get($url, $header = [])
89 { 89 {
90 if (empty($header)) { 90 if (empty($header)) {
91 - $header[] = "content-type: application/json;  
92 - charset = UTF-8"; 91 + $header[] = "content-type: application/json";
93 } 92 }
94 $ch1 = curl_init(); 93 $ch1 = curl_init();
95 $timeout = 0; 94 $timeout = 0;
96 curl_setopt($ch1, CURLOPT_URL, $url); 95 curl_setopt($ch1, CURLOPT_URL, $url);
97 curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true); 96 curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
  97 + curl_setopt($ch1, CURLOPT_ENCODING, '');
  98 + curl_setopt($ch1, CURLOPT_MAXREDIRS, 10);
98 curl_setopt($ch1, CURLOPT_HTTPHEADER, $header); 99 curl_setopt($ch1, CURLOPT_HTTPHEADER, $header);
99 curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, $timeout); 100 curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, $timeout);
100 - curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, false);  
101 curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, true); 101 curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, true);
102 curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, 'GET'); 102 curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, 'GET');
103 curl_setopt($ch1, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); 103 curl_setopt($ch1, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
@@ -419,28 +419,21 @@ if (!function_exists('getImageUrl')) { @@ -419,28 +419,21 @@ if (!function_exists('getImageUrl')) {
419 * @method :post 419 * @method :post
420 * @time :2023/7/20 16:46 420 * @time :2023/7/20 16:46
421 */ 421 */
422 - function getImageUrl($hash){  
423 - if(is_array($hash)){  
424 - foreach ($hash as $v){ 422 + function getImageUrl($path,$location = 1){
  423 + if(empty($path)){
  424 + return '';
  425 + }
  426 + if(is_array($path)){
  427 + foreach ($path as $v){
425 $url[] = getImageUrl($v); 428 $url[] = getImageUrl($v);
426 } 429 }
427 }else{ 430 }else{
428 - $imageModel = new Image();  
429 - if (strpos($hash, '.') !== false) {  
430 - $info = $imageModel->read(['path'=>['like','%'.$hash.'%']]); 431 + if($location == 1){
  432 + $cos = config('filesystems.disks.cos');
  433 + $cosCdn = $cos['cdn'];
  434 + $url = $cosCdn.$path;
431 }else{ 435 }else{
432 - $info = $imageModel->read(['hash'=>$hash]);  
433 - }  
434 - if(!empty($info)){  
435 - if($info['is_cos'] == 1){  
436 - $cos = config('filesystems.disks.cos');  
437 - $cosCdn = $cos['cdn'];  
438 - $url = $cosCdn.$info['path'];  
439 - }else{  
440 - $url = url($info['path']);  
441 - }  
442 - }else{  
443 - $url = $hash; 436 + $url = url($path);
444 } 437 }
445 } 438 }
446 return $url; 439 return $url;
@@ -454,33 +447,27 @@ if (!function_exists('getFileUrl')) { @@ -454,33 +447,27 @@ if (!function_exists('getFileUrl')) {
454 * @method :post 447 * @method :post
455 * @time :2023/7/20 16:46 448 * @time :2023/7/20 16:46
456 */ 449 */
457 - function getFileUrl($hash){  
458 - if(is_array($hash)){  
459 - foreach ($hash as $v){ 450 + function getFileUrl($path,$location = 1){
  451 + if(empty($path)){
  452 + return '';
  453 + }
  454 + if(is_array($path)){
  455 + foreach ($path as $v){
460 $url[] = getFileUrl($v); 456 $url[] = getFileUrl($v);
461 } 457 }
462 }else{ 458 }else{
463 - $fileModel = new File();  
464 - if (strpos($hash, '.') !== false) {  
465 - $info = $fileModel->read(['path'=>['like','%'.$hash.'%']]); 459 + if($location == 1){
  460 + $cos = config('filesystems.disks.cos');
  461 + $cosCdn = $cos['cdn'];
  462 + $url = $cosCdn.$path;
466 }else{ 463 }else{
467 - $info = $fileModel->read(['hash'=>$hash]);  
468 - }  
469 - if(!empty($info)){  
470 - if($info['is_cos'] == 1){  
471 - $cos = config('filesystems.disks.cos');  
472 - $cosCdn = $cos['cdn'];  
473 - $url = $cosCdn.'/upload'.$info['path'];  
474 - }else{  
475 - $url = url('upload'.$info['path']);  
476 - }  
477 - }else{  
478 - $url = $hash; 464 + $url = url($path);
479 } 465 }
480 } 466 }
481 return $url; 467 return $url;
482 } 468 }
483 } 469 }
  470 +
484 /** 471 /**
485 * @remark :字符串截取 472 * @remark :字符串截取
486 * @name :characterTruncation 473 * @name :characterTruncation
@@ -7,8 +7,6 @@ use App\Http\Controllers\Aside\BaseController; @@ -7,8 +7,6 @@ use App\Http\Controllers\Aside\BaseController;
7 use App\Http\Logic\Aside\Ai\AiCommandLogic; 7 use App\Http\Logic\Aside\Ai\AiCommandLogic;
8 use App\Http\Requests\Aside\Ai\AiCommandRequest; 8 use App\Http\Requests\Aside\Ai\AiCommandRequest;
9 use App\Models\Ai\AiCommand as AiCommandModel; 9 use App\Models\Ai\AiCommand as AiCommandModel;
10 -use Illuminate\Http\Request;  
11 -use function App\Helper\send_openai_msg;  
12 10
13 /** 11 /**
14 * @remark :ai指令 12 * @remark :ai指令
@@ -39,6 +39,7 @@ class BaseController extends Controller @@ -39,6 +39,7 @@ class BaseController extends Controller
39 $info = Cache::get(Common::MANAGE_TOKEN . $this->token); 39 $info = Cache::get(Common::MANAGE_TOKEN . $this->token);
40 if(!empty($this->token) && !empty($info)){ 40 if(!empty($this->token) && !empty($info)){
41 $this->manage = $info; 41 $this->manage = $info;
  42 + Cache::put($this->token, $info, 3600 * 6);//更新缓存时间
42 $this->uid = $info['id']; 43 $this->uid = $info['id'];
43 } 44 }
44 } 45 }
@@ -54,7 +55,7 @@ class BaseController extends Controller @@ -54,7 +55,7 @@ class BaseController extends Controller
54 public function getParam(){ 55 public function getParam(){
55 foreach ($this->param as $k => $v){ 56 foreach ($this->param as $k => $v){
56 if(is_array($v)){ 57 if(is_array($v)){
57 - continue; 58 + $this->map[$k] = $v;
58 }else{ 59 }else{
59 if(empty($v) && ($v == null)){ 60 if(empty($v) && ($v == null)){
60 unset($this->param[$k]); 61 unset($this->param[$k]);
@@ -3,8 +3,12 @@ @@ -3,8 +3,12 @@
3 namespace App\Http\Controllers\Aside\Com; 3 namespace App\Http\Controllers\Aside\Com;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
  6 +use App\Enums\Common\Common;
6 use App\Http\Controllers\Aside\BaseController; 7 use App\Http\Controllers\Aside\BaseController;
7 use App\Http\Logic\Aside\Manage\MenuLogic; 8 use App\Http\Logic\Aside\Manage\MenuLogic;
  9 +use App\Models\Manage\Manage;
  10 +use Illuminate\Support\Facades\Cache;
  11 +use Illuminate\Support\Facades\Hash;
8 12
9 /** 13 /**
10 * Class IndexController 14 * Class IndexController
@@ -33,4 +37,38 @@ class IndexController extends BaseController @@ -33,4 +37,38 @@ class IndexController extends BaseController
33 $this->response('success',Code::SUCCESS,$menus); 37 $this->response('success',Code::SUCCESS,$menus);
34 } 38 }
35 39
  40 + /**
  41 + * @remark :修改密码
  42 + * @name :editPassword
  43 + * @author :lyh
  44 + * @method :post
  45 + * @time :2023/9/11 9:10
  46 + */
  47 + public function editPassword(){
  48 + $this->request->validate([
  49 + 'oldPassword'=>'required',
  50 + 'password' => 'required',
  51 + 'confirm'=>'required',
  52 + ], [
  53 + 'oldPassword.required' => '请输入原密码',
  54 + 'password.required' => '请输入新密码',
  55 + 'confirm.required' => '请再次输入新密码',
  56 + ]);
  57 + //查询员密码是否正确
  58 + $managerModel = new Manage();
  59 + $info = $managerModel->read(['id'=>$this->manage['id']]);
  60 + if(!Hash::check($this->param['oldPassword'], $info['password'])){
  61 + $this->response('原密码错误',Code::USER_REGISTER_ERROE);
  62 + }
  63 + if($this->param['password'] != $this->param['confirm']){
  64 + $this->response('两次密码不一致');
  65 + }
  66 + $rs = $managerModel->edit(['password'=>Hash::make($this->param['password'])],['id'=>$this->manage['id']]);
  67 + if($rs === false){
  68 + $this->response('系统错误',Code::SYSTEM_ERROR);
  69 + }
  70 + Cache::pull(Common::MANAGE_TOKEN . $info['token']);
  71 + $this->response('success');
  72 + }
  73 +
36 } 74 }
@@ -31,15 +31,6 @@ class DomainInfoController extends BaseController @@ -31,15 +31,6 @@ class DomainInfoController extends BaseController
31 $this->map['domain'] = ['like','%'.$this->map['domain'],'%']; 31 $this->map['domain'] = ['like','%'.$this->map['domain'],'%'];
32 } 32 }
33 $lists = $domainModel->lists($this->map,$this->page,$this->row,$this->order); 33 $lists = $domainModel->lists($this->map,$this->page,$this->row,$this->order);
34 - $projectModel = new Project();  
35 - if(!empty($lists)){  
36 - foreach ($lists['list'] as $k => $v){  
37 - if(!empty($info['project_id'])){  
38 - $v['company'] = $projectModel->read(['id'=>$info['project_id']],['title'])['title'];  
39 - }  
40 - $lists['list'][$k] = $v;  
41 - }  
42 - }  
43 return $this->response('success', Code::SUCCESS, $lists); 34 return $this->response('success', Code::SUCCESS, $lists);
44 } 35 }
45 36
@@ -41,6 +41,13 @@ class LoginController extends BaseController @@ -41,6 +41,13 @@ class LoginController extends BaseController
41 $this->response('success',Code::SUCCESS,$data); 41 $this->response('success',Code::SUCCESS,$data);
42 } 42 }
43 43
  44 + /**
  45 + * @remark :退出登录
  46 + * @name :logout
  47 + * @author :lyh
  48 + * @method :post
  49 + * @time :2023/9/7 16:29
  50 + */
44 public function logout(LoginLogic $logic) 51 public function logout(LoginLogic $logic)
45 { 52 {
46 $logic->logout(); 53 $logic->logout();
@@ -91,4 +98,5 @@ class LoginController extends BaseController @@ -91,4 +98,5 @@ class LoginController extends BaseController
91 SmsLog::createLog($mobile, $code['code'],SmsLog::TYPE_MANAGER_LOGIN); 98 SmsLog::createLog($mobile, $code['code'],SmsLog::TYPE_MANAGER_LOGIN);
92 $this->response('success'); 99 $this->response('success');
93 } 100 }
  101 +
94 } 102 }
@@ -3,6 +3,8 @@ @@ -3,6 +3,8 @@
3 namespace App\Http\Controllers\Aside\Manage; 3 namespace App\Http\Controllers\Aside\Manage;
4 use App\Enums\Common\Code; 4 use App\Enums\Common\Code;
5 use App\Http\Controllers\Aside\BaseController; 5 use App\Http\Controllers\Aside\BaseController;
  6 +use App\Models\Manage\ManageHr;
  7 +use App\Models\Manage\Menu;
6 use Illuminate\Http\Request; 8 use Illuminate\Http\Request;
7 use App\Http\Logic\Aside\Manage\HrLogic; 9 use App\Http\Logic\Aside\Manage\HrLogic;
8 10
@@ -15,10 +17,10 @@ class HrController extends BaseController @@ -15,10 +17,10 @@ class HrController extends BaseController
15 * @method :post 17 * @method :post
16 * @time :2023/7/24 11:56 18 * @time :2023/7/24 11:56
17 */ 19 */
18 - public function list(HrLogic $logic) 20 + public function list(ManageHr $manageHr)
19 { 21 {
20 - $lists = $logic->getHrList($this->map,$this->page,$this->row,$this->order);  
21 - if(!empty($lists['list'])){ 22 + $lists = $manageHr->lists($this->map,$this->page,$this->row,$this->order);
  23 + if(!empty($lists) && !empty($lists['list'])){
22 foreach ($lists['list'] as $k => $v){ 24 foreach ($lists['list'] as $k => $v){
23 $v['photo_gallery_link'] = json_decode($v['photo_gallery']); 25 $v['photo_gallery_link'] = json_decode($v['photo_gallery']);
24 $v['id_card_gallery_link'] = json_decode($v['id_card_gallery']); 26 $v['id_card_gallery_link'] = json_decode($v['id_card_gallery']);
@@ -29,8 +31,15 @@ class HrController extends BaseController @@ -29,8 +31,15 @@ class HrController extends BaseController
29 return $this->response('success', Code::SUCCESS, $lists); 31 return $this->response('success', Code::SUCCESS, $lists);
30 } 32 }
31 33
32 - public function info(Request $request, HrLogic $logic){  
33 - $request->validate([ 34 + /**
  35 + * @remark :获取详情
  36 + * @name :info
  37 + * @author :lyh
  38 + * @method :post
  39 + * @time :2023/9/6 10:04
  40 + */
  41 + public function info(HrLogic $logic){
  42 + $this->request->validate([
34 'id'=>'required' 43 'id'=>'required'
35 ],[ 44 ],[
36 'id.required' => 'ID不能为空' 45 'id.required' => 'ID不能为空'
@@ -42,6 +51,13 @@ class HrController extends BaseController @@ -42,6 +51,13 @@ class HrController extends BaseController
42 $this->response('success',Code::SUCCESS,$info); 51 $this->response('success',Code::SUCCESS,$info);
43 } 52 }
44 53
  54 + /**
  55 + * @remark :保存数据
  56 + * @name :save
  57 + * @author :lyh
  58 + * @method :post
  59 + * @time :2023/9/6 10:05
  60 + */
45 public function save(HrLogic $logic){ 61 public function save(HrLogic $logic){
46 $logic->hrSave(); 62 $logic->hrSave();
47 return $this->response('success'); 63 return $this->response('success');
@@ -59,4 +75,26 @@ class HrController extends BaseController @@ -59,4 +75,26 @@ class HrController extends BaseController
59 $this->response('success',Code::SUCCESS,$list); 75 $this->response('success',Code::SUCCESS,$list);
60 } 76 }
61 77
  78 + /**
  79 + * @param HrLogic $hrLogic
  80 + * @return \Illuminate\Http\JsonResponse
  81 + */
  82 + public function getHrList(HrLogic $hrLogic)
  83 + {
  84 + $page_size = intval(request()->input('page_size', 15));
  85 + $list = $hrLogic->getHrListForV5($page_size);
  86 + $result = [];
  87 + foreach ($list as $v) {
  88 + $result[] = [
  89 + 'name' => $v->name,
  90 + 'id_card' => $v->id_card,
  91 + 'mobile' => $v->mobile,
  92 + 'dept_title' => $v->dept_title = $v->dept ? $v->dept->title : '',
  93 + 'position_title' => $v->position = $v->position ? $v->position->name : '',
  94 + 'status' => $v->status,
  95 + ];
  96 + }
  97 + return $this->response('success',Code::SUCCESS, $result);
  98 + }
  99 +
62 } 100 }
@@ -6,6 +6,7 @@ use App\Enums\Common\Code; @@ -6,6 +6,7 @@ use App\Enums\Common\Code;
6 use App\Http\Controllers\Aside\BaseController; 6 use App\Http\Controllers\Aside\BaseController;
7 use App\Http\Logic\Aside\Manage\ManageLogic; 7 use App\Http\Logic\Aside\Manage\ManageLogic;
8 use App\Http\Requests\Aside\Manage\ManageRequest; 8 use App\Http\Requests\Aside\Manage\ManageRequest;
  9 +use App\Models\Manage\Manage;
9 use App\Models\Manage\MenuSpecial; 10 use App\Models\Manage\MenuSpecial;
10 use App\Models\User\ProjectRole; 11 use App\Models\User\ProjectRole;
11 use App\Rules\Ids; 12 use App\Rules\Ids;
@@ -28,19 +29,10 @@ class ManageController extends BaseController @@ -28,19 +29,10 @@ class ManageController extends BaseController
28 * @method :post 29 * @method :post
29 * @time :2023/8/28 10:04 30 * @time :2023/8/28 10:04
30 */ 31 */
31 - public function list(Request $request, ManageLogic $logic) 32 + public function list()
32 { 33 {
33 - $map = [];  
34 - if(!empty($this->param['search'])){  
35 - $map[] = ['name|mobile', 'like', "%{$this->param['search']}%"];  
36 - }  
37 - if(!empty($this->param['dept_id'])){  
38 - $map[] = ['dept_id', $this->param['dept_id']];  
39 - }  
40 - if(!empty($this->param['gid'])){  
41 - $map[] = ['gid', $this->param['gid']];  
42 - }  
43 - $list = $logic->getList($map,['sort' => 'desc'],['*'],$this->row); 34 + $managerModel = new Manage();
  35 + $list = $managerModel->lists($this->map,$this->page,$this->row,$this->order);
44 $this->response('success',Code::SUCCESS,$list); 36 $this->response('success',Code::SUCCESS,$list);
45 } 37 }
46 38
@@ -90,8 +82,8 @@ class ManageController extends BaseController @@ -90,8 +82,8 @@ class ManageController extends BaseController
90 ],[ 82 ],[
91 'ids.required' => 'ID不能为空' 83 'ids.required' => 'ID不能为空'
92 ]); 84 ]);
93 - $logic->delete($this->param['ids']);  
94 - $this->response('success'); 85 + $logic->managerDelete();
  86 + $this->response('删除成功');
95 } 87 }
96 88
97 /** 89 /**
@@ -104,8 +96,10 @@ class ManageController extends BaseController @@ -104,8 +96,10 @@ class ManageController extends BaseController
104 public function setSort(ManageLogic $logic){ 96 public function setSort(ManageLogic $logic){
105 $this->request->validate([ 97 $this->request->validate([
106 'id'=>'required', 98 'id'=>'required',
  99 + 'sort'=>'required',
107 ],[ 100 ],[
108 'id.required' => 'ID不能为空', 101 'id.required' => 'ID不能为空',
  102 + 'sort.required' => 'sort不能为空',
109 ]); 103 ]);
110 $logic->setParamStatus(); 104 $logic->setParamStatus();
111 $this->response('success'); 105 $this->response('success');
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ManagerLogController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/9/5 16:09
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Aside\Manage;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Aside\BaseController;
  14 +use App\Models\Manage\LoginLog;
  15 +use App\Models\Manage\Manage;
  16 +
  17 +class ManagerLogController extends BaseController
  18 +{
  19 + /**
  20 + * @remark :管理员日志列表
  21 + * @name :lists
  22 + * @author :lyh
  23 + * @method :post
  24 + * @time :2023/9/5 16:10
  25 + */
  26 + public function lists(LoginLog $manageLogin){
  27 + $map = $this->searchParam();
  28 + $lists = $manageLogin->lists($map,$this->page,$this->row,$this->order);
  29 + if(!empty($lists) && !empty($lists['list'])){
  30 + $managerModel = new Manage();
  31 + foreach ($lists['list'] as $k => $v){
  32 + $info = $managerModel->read(['id'=>$v['manage_id']]);
  33 + $v['mobile'] = $info['mobile'] ?? '';
  34 + $v['name'] = $info['name'] ?? '';
  35 + $v['type'] = (isset($v['type']) && $v['type'] == 1) ? '账号密码登录' : '验证码登录';
  36 + $lists['list'][$k] = $v;
  37 + }
  38 + }
  39 + $this->response('success',Code::SUCCESS,$lists);
  40 + }
  41 +
  42 + /**
  43 + * @remark :搜索参数
  44 + * @name :searchParam
  45 + * @author :lyh
  46 + * @method :post
  47 + * @time :2023/9/5 16:56
  48 + */
  49 + public function searchParam(){
  50 + $map = [];
  51 + $managerModel = new Manage();
  52 + if(isset($this->map['mobile']) && !empty($this->map['mobile'])){
  53 + $ids = $managerModel->where('mobile', 'like', '%' . $this->map['mobile'] . '%')->pluck('id')->toArray();
  54 + $map['manage_id'] = ['in',$ids];
  55 + }elseif (isset($this->map['name']) && !empty($this->map['name'])){
  56 + $ids = $managerModel->where('name', 'like', '%' . $this->param['name'] . '%')->pluck('id')->toArray();
  57 + $map['manage_id'] = ['in',$ids];
  58 + }
  59 + if(isset($this->map['created_at'])){
  60 + $map['created_at'] = $this->map['created_at'];
  61 + }
  62 + return $map;
  63 + }
  64 +
  65 +}
@@ -12,6 +12,7 @@ namespace App\Http\Controllers\Aside\Manage; @@ -12,6 +12,7 @@ namespace App\Http\Controllers\Aside\Manage;
12 use App\Enums\Common\Code; 12 use App\Enums\Common\Code;
13 use App\Http\Controllers\Aside\BaseController; 13 use App\Http\Controllers\Aside\BaseController;
14 use App\Http\Logic\Aside\Manage\MenuSpecialLogic; 14 use App\Http\Logic\Aside\Manage\MenuSpecialLogic;
  15 +use App\Models\Manage\MenuSpecial;
15 16
16 /** 17 /**
17 * @remark :特殊模块设置 18 * @remark :特殊模块设置
@@ -29,8 +30,11 @@ class MenuSpecialController extends BaseController @@ -29,8 +30,11 @@ class MenuSpecialController extends BaseController
29 * @method :post 30 * @method :post
30 * @time :2023/8/7 11:52 31 * @time :2023/8/7 11:52
31 */ 32 */
32 - public function lists(MenuSpecialLogic $logic){  
33 - $lists = $logic->specialLists($this->map,$this->page,$this->row,$this->order); 33 + public function lists(MenuSpecial $menuSpecial){
  34 + if(isset($this->map['remark']) && !empty($this->map['remark'])){
  35 + $this->map['remark'] = ['like','%'.$this->map['remark'].'%'];
  36 + }
  37 + $lists = $menuSpecial->lists($this->map,$this->page,$this->row,$this->order);
34 $this->response('success',Code::SUCCESS,$lists); 38 $this->response('success',Code::SUCCESS,$lists);
35 } 39 }
36 40
@@ -73,11 +77,11 @@ class MenuSpecialController extends BaseController @@ -73,11 +77,11 @@ class MenuSpecialController extends BaseController
73 public function save(MenuSpecialLogic $logic){ 77 public function save(MenuSpecialLogic $logic){
74 $this->request->validate([ 78 $this->request->validate([
75 'name'=>'required', 79 'name'=>'required',
76 - 'user_list'=>'required', 80 +// 'user_list'=>'required',
77 'remark'=>'required' 81 'remark'=>'required'
78 ],[ 82 ],[
79 'name.required' => 'name不能为空', 83 'name.required' => 'name不能为空',
80 - 'user_list.required' => 'user_list不能为空', 84 +// 'user_list.required' => 'user_list不能为空',
81 'remark.required' => 'remark不能为空' 85 'remark.required' => 'remark不能为空'
82 ]); 86 ]);
83 $logic->specialSave(); 87 $logic->specialSave();
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :KeywordsController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/9/4 10:12
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Aside\Optimize;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Aside\BaseController;
  14 +use App\Models\Project\DeployOptimize;
  15 +use App\Models\Project\Project;
  16 +
  17 +class KeywordsController extends BaseController
  18 +{
  19 + /**
  20 + * @remark :关键字查案例
  21 + * @name :lists
  22 + * @author :lyh
  23 + * @method :post
  24 + * @time :2023/9/4 10:13
  25 + */
  26 + public function lists(){
  27 + $projectDeployOptimizeModel = new DeployOptimize();
  28 + $ids = $projectDeployOptimizeModel->where('customer_keywords','like','%'.$this->map['search'].'%')
  29 + ->orWhere('main_keywords', 'like' , '%'.$this->map['search'].'%')->pluck('project_id')->toArray();
  30 + $projectModel = new Project();
  31 + $lists = $projectModel->formatQuery(['id'=>['in',$ids]])->with('payment')->with('deploy_build')
  32 + ->with('deploy_optimize')->get()->toArray();
  33 + $this->response('success',Code::SUCCESS,$lists);
  34 + }
  35 +}
@@ -95,7 +95,9 @@ class OnlineController extends BaseController @@ -95,7 +95,9 @@ class OnlineController extends BaseController
95 * @time :2023/8/18 14:44 95 * @time :2023/8/18 14:44
96 */ 96 */
97 public function handleParam(&$item){ 97 public function handleParam(&$item){
98 - $data = APublicModel::getNumByProjectId($item['id']); 98 + if($item['type'] != Project::TYPE_ZERO){
  99 + $data = APublicModel::getNumByProjectId($item['id']);
  100 + }
99 $manageModel = new Manage(); 101 $manageModel = new Manage();
100 $item['channel'] = Channel::getChannelText($item['channel']['user_id'] ?? 0); 102 $item['channel'] = Channel::getChannelText($item['channel']['user_id'] ?? 0);
101 $item['build_leader'] = $manageModel->getName($item['leader_mid']); 103 $item['build_leader'] = $manageModel->getName($item['leader_mid']);
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Aside\Optimize; @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Aside\Optimize;
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 use App\Http\Controllers\Aside\BaseController; 6 use App\Http\Controllers\Aside\BaseController;
7 use App\Http\Logic\Aside\Optimize\OptimizeLogic; 7 use App\Http\Logic\Aside\Optimize\OptimizeLogic;
  8 +use App\Models\Domain\DomainInfo;
8 use App\Models\Manage\Manage; 9 use App\Models\Manage\Manage;
9 use App\Models\Project\Project; 10 use App\Models\Project\Project;
10 use Illuminate\Support\Facades\DB; 11 use Illuminate\Support\Facades\DB;
@@ -32,11 +33,13 @@ class OptimizeController extends BaseController @@ -32,11 +33,13 @@ class OptimizeController extends BaseController
32 $lists = $query->paginate($this->row, $this->selectParam(), 'page', $this->page)->toArray(); 33 $lists = $query->paginate($this->row, $this->selectParam(), 'page', $this->page)->toArray();
33 if(!empty($lists['list'])){ 34 if(!empty($lists['list'])){
34 $manager = new Manage(); 35 $manager = new Manage();
  36 + $domainModel = new DomainInfo();
35 foreach ($lists['list'] as $k => $v){ 37 foreach ($lists['list'] as $k => $v){
36 $v['plan'] = $project::planMap()[$v['plan']]; 38 $v['plan'] = $project::planMap()[$v['plan']];
37 $v['optimist_mid_name'] = $manager->getName($v['optimist_mid']); 39 $v['optimist_mid_name'] = $manager->getName($v['optimist_mid']);
38 $v['tech_mid_name'] = $manager->getName($v['tech_mid']); 40 $v['tech_mid_name'] = $manager->getName($v['tech_mid']);
39 $v['autologin_code'] = getAutoLoginCode($v['id']); 41 $v['autologin_code'] = getAutoLoginCode($v['id']);
  42 + $v['domain'] = $domainModel->getDomain($v['domain']);
40 $lists['list'][$k] = $v; 43 $lists['list'][$k] = $v;
41 } 44 }
42 } 45 }
@@ -11,6 +11,7 @@ namespace App\Http\Controllers\Aside\Project; @@ -11,6 +11,7 @@ namespace App\Http\Controllers\Aside\Project;
11 11
12 use App\Enums\Common\Code; 12 use App\Enums\Common\Code;
13 use App\Http\Controllers\Aside\BaseController; 13 use App\Http\Controllers\Aside\BaseController;
  14 +use App\Http\Logic\Aside\Project\KeywordPrefixLogic;
14 use App\Models\Project\KeywordPrefix; 15 use App\Models\Project\KeywordPrefix;
15 16
16 class KeywordPrefixController extends BaseController 17 class KeywordPrefixController extends BaseController
@@ -27,4 +28,23 @@ class KeywordPrefixController extends BaseController @@ -27,4 +28,23 @@ class KeywordPrefixController extends BaseController
27 $list = $keywordPrefixModel->list($this->map); 28 $list = $keywordPrefixModel->list($this->map);
28 $this->response('success',Code::SUCCESS,$list); 29 $this->response('success',Code::SUCCESS,$list);
29 } 30 }
  31 +
  32 + /**
  33 + * @remark :保存关键字
  34 + * @name :save
  35 + * @author :lyh
  36 + * @method :post
  37 + * @time :2023/9/6 14:47
  38 + */
  39 + public function save(KeywordPrefixLogic $keywordPrefixLogic){
  40 + $this->request->validate([
  41 + 'keyword'=>'required',
  42 + 'type'=>'required'
  43 + ],[
  44 + 'keyword.required' => 'keyword不能为空',
  45 + 'type.required' => 'type不能为空',
  46 + ]);
  47 + $keywordPrefixLogic->prefixSave();
  48 + $this->response('success');
  49 + }
30 } 50 }
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 namespace App\Http\Controllers\Aside\Project; 3 namespace App\Http\Controllers\Aside\Project;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
  6 +use App\Helper\QuanqiusouApi;
6 use App\Http\Controllers\Aside\BaseController; 7 use App\Http\Controllers\Aside\BaseController;
7 use App\Http\Logic\Aside\Manage\ManageLogic; 8 use App\Http\Logic\Aside\Manage\ManageLogic;
8 use App\Http\Logic\Aside\Project\OnlineCheckLogic; 9 use App\Http\Logic\Aside\Project\OnlineCheckLogic;
@@ -15,6 +16,7 @@ use App\Models\Channel\Channel; @@ -15,6 +16,7 @@ use App\Models\Channel\Channel;
15 use App\Models\Com\City; 16 use App\Models\Com\City;
16 use App\Models\Devops\ServerConfig; 17 use App\Models\Devops\ServerConfig;
17 use App\Models\Domain\DomainInfo; 18 use App\Models\Domain\DomainInfo;
  19 +use App\Models\HomeCount\Count;
18 use App\Models\Inquiry\InquirySet; 20 use App\Models\Inquiry\InquirySet;
19 use App\Models\Manage\BelongingGroup; 21 use App\Models\Manage\BelongingGroup;
20 use App\Models\Manage\Manage; 22 use App\Models\Manage\Manage;
@@ -25,6 +27,7 @@ use App\Models\Project\Payment; @@ -25,6 +27,7 @@ use App\Models\Project\Payment;
25 use App\Models\Project\Project; 27 use App\Models\Project\Project;
26 use App\Models\RankData\RankData; 28 use App\Models\RankData\RankData;
27 use App\Models\Task\Task; 29 use App\Models\Task\Task;
  30 +use App\Models\Visit\Visit;
28 use Illuminate\Http\Request; 31 use Illuminate\Http\Request;
29 use Illuminate\Support\Facades\DB; 32 use Illuminate\Support\Facades\DB;
30 33
@@ -47,144 +50,239 @@ class ProjectController extends BaseController @@ -47,144 +50,239 @@ class ProjectController extends BaseController
47 * @time :2023/8/30 10:11 50 * @time :2023/8/30 10:11
48 */ 51 */
49 public function lists(Project $project){ 52 public function lists(Project $project){
50 - $map = [];  
51 - //搜索参数处理  
52 - $map = $this->searchParam($map,$this->map);  
53 - //类型  
54 - if(isset($this->map['type'])){  
55 - $map['type'] = $this->searchType($this->map['type']);  
56 - $map['extend_type'] = 0;//排除未续费项目  
57 - }  
58 - $filed = ['id', 'title', 'mysql_id' ,'channel','cooperate_date' ,'type', 'created_at'];  
59 - $lists = $project->formatQuery($map)->select($filed)->with('payment')->with('deploy_build')  
60 - ->with('deploy_optimize')->with('online_check')->paginate($this->row, ['*'], 'page', $this->page);  
61 - if(!empty($lists)){  
62 - $lists = $lists->toArray();  
63 - foreach ($lists['list'] as $k=>$item){  
64 - $item = $this->handleParam($item);  
65 - $lists['list'][$k] = $item; 53 + $query = $project->leftJoin('gl_project_payment', 'gl_project.id', '=', 'gl_project_payment.project_id')
  54 + ->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')
  55 + ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
  56 + ->leftJoin('gl_project_online_check', 'gl_project.id', '=', 'gl_project_online_check.project_id');
  57 + $query = $this->searchParam($query);
  58 + $lists = $query->orderBy('gl_project.id', 'desc')->paginate($this->row, $this->selectParam(), 'page', $this->page)->toArray();
  59 + if(!empty($lists) && !empty($lists['list'])){
  60 + foreach ($lists['list'] as $k => $v){
  61 + $v = $this->handleParam($v);
  62 + $lists['list'][$k] = $v;
66 } 63 }
67 } 64 }
68 $this->response('success',Code::SUCCESS,$lists); 65 $this->response('success',Code::SUCCESS,$lists);
69 } 66 }
70 67
71 /** 68 /**
72 - * @remark :返回参数过滤  
73 - * @name :returnParamItem 69 + * @remark :搜索参数处理
  70 + * @name :searchParam
74 * @author :lyh 71 * @author :lyh
75 * @method :post 72 * @method :post
76 - * @time :2023/8/30 11:07 73 + * @time :2023/8/18 10:58
77 */ 74 */
78 - public function handleParam(&$item){  
79 - $manageModel = new Manage();  
80 - if($item['mysql_id'] != 0 && $item['type'] != 0){  
81 - $data = APublicModel::getNumByProjectId($item['id']);  
82 - }  
83 - $item = [  
84 - 'id' => $item['id'],  
85 - 'title' => $item['title'],  
86 - 'channel' => Channel::getChannelText($item['channel']['user_id'] ?? 0),  
87 - 'key' => $item['deploy_build']['keyword_num'] ?? 0,  
88 - 'day' => $item['deploy_build']['service_duration'] ?? 0,  
89 - 'amount' => $item['payment']['amount'] ?? 0,  
90 - 'build_leader' => $manageModel->getName($item['deploy_build']['leader_mid']), //组长  
91 - 'build_manager' => $manageModel->getName($item['deploy_build']['manager_mid']), //项目经理  
92 - 'build_designer' => $manageModel->getName($item['deploy_build']['designer_mid']), //设计师  
93 - 'build_tech' => $manageModel->getName($item['deploy_build']['tech_mid']), //技术助理  
94 - 'optimize_manager' => $manageModel->getName($item['deploy_optimize']['manager_mid']), //优化服务经理  
95 - 'optimize_optimist' => $manageModel->getName($item['deploy_optimize']['optimist_mid']), //优化师  
96 - 'optimize_assist' => $manageModel->getName($item['deploy_optimize']['assist_mid']), //优化助理  
97 - 'optimize_tech' => $manageModel->getName($item['deploy_optimize']['tech_mid']), //售后技术  
98 - 'type' => $item['type'],  
99 - 'test_domain' => $item['deploy_build']['test_domain'] ?? 0,  
100 - 'plan' =>Project::planMap()[$item['deploy_build']['plan']],  
101 - 'domain' => $item['deploy_optimize']['domain'] ?? 0,  
102 - 'created_at' => date('Y年m月d日', strtotime($item['created_at'])),  
103 - 'product_num' => $data['product'] ?? 0,  
104 - 'keyword_num' => $item['deploy_build']['keyword_num'] ?? 0,  
105 - 'article_num' => ($data['blog'] ?? 0) + ($data['news'] ?? 0),  
106 - 'task_finish_num' => Task::getNumByProjectId($item['id'], Task::STATUS_DOWN),  
107 - 'task_pending_num' => Task::getNumByProjectId($item['id'], [Task::STATUS_DONGING, Task::STATUS_WAIT]),  
108 - 'optimist_status'=>$item['online_check']['optimist_status'] ?? 0,  
109 - 'qa_status'=>$item['online_check']['qa_status'] ?? 0,  
110 - 'service_day'=>$item['deploy_build']['service_duration'] - $this->compliance_day($item['id']),  
111 - ];  
112 - return $item; 75 + public function searchParam(&$query){
  76 + //参数type
  77 + $query = $this->searchType($query);
  78 + //根据查看权限获取项目搜索条件(必带)
  79 + $query = $this->getManagerRole($query);
  80 + //搜索技术组
  81 + $query = $this->searchDept($query);
  82 + //搜索技术人员
  83 + $query = $this->searchManager($query);
  84 + //按类型搜索
  85 + $query = $this->searchContent($query);
  86 + return $query;
113 } 87 }
114 88
115 /** 89 /**
116 - * @param $yesterday  
117 - * @name :(服务达标天数)compliance_day 90 + * @remark :type类型
  91 + * @name :searchType
118 * @author :lyh 92 * @author :lyh
119 * @method :post 93 * @method :post
120 - * @time :2023/6/14 15:48 94 + * @time :2023/8/30 10:14
121 */ 95 */
122 - public function compliance_day($project_id){  
123 - //服务达标天数  
124 - $rankDataModel = new RankData();  
125 - $rank_info = $rankDataModel->where(['project_id'=>$project_id,'lang'=>''])->select(['compliance_day'])->first();  
126 - if(empty($rank_info)){  
127 - $compliance_day = 0; 96 + public function searchType(&$query){
  97 + $query->where('gl_project.delete_status',Project::TYPE_ZERO);
  98 + if(!isset($this->map['type'])){
  99 + $this->map['type'] = Project::TYPE_ZERO;
  100 + }
  101 + if($this->map['type'] == Project::TYPE_ZERO){
  102 + $query->where('gl_project.type',Project::TYPE_ZERO);
  103 + }elseif ($this->map['type'] == Project::TYPE_ONE){
  104 + $query->where('gl_project.type',Project::TYPE_ONE);
  105 + }elseif ($this->map['type'] == Project::TYPE_TWO){
  106 + $query->whereIn('gl_project.type', [Project::TYPE_TWO,Project::TYPE_THREE]);
128 }else{ 107 }else{
129 - $compliance_day = $rank_info->compliance_day; 108 + $query->whereIn('gl_project.type', [Project::TYPE_FOUR,Project::TYPE_SIX]);
130 } 109 }
131 - return $compliance_day; 110 + return $query;
132 } 111 }
133 112
134 /** 113 /**
135 - * @remark :type类型  
136 - * @name :searchType 114 + * @remark :查询字段处理
  115 + * @name :selectParam
137 * @author :lyh 116 * @author :lyh
138 * @method :post 117 * @method :post
139 - * @time :2023/8/30 10:14 118 + * @time :2023/8/18 10:59
140 */ 119 */
141 - public function searchType($type){  
142 - //初始项目  
143 - if($type == Project::TYPE_ZERO){  
144 - $type = Project::TYPE_ZERO;  
145 - }  
146 - //建站中  
147 - if($type == Project::TYPE_ONE){  
148 - $type = Project::TYPE_ONE;  
149 - }  
150 - //建站完成  
151 - if($type == Project::TYPE_TWO){  
152 - $type = ['in',[Project::TYPE_TWO,Project::TYPE_THREE]]; 120 + public function selectParam(){
  121 + $select = [
  122 + 'gl_project.id AS id',
  123 + 'gl_project.title AS title',
  124 + 'gl_project.channel AS channel',
  125 + 'gl_project.company AS company',
  126 + 'gl_project.type AS type',
  127 + 'gl_project.created_at AS created_at',
  128 + 'gl_project.cooperate_date AS cooperate_date',
  129 + 'gl_project_online_check.id AS online_check_id',
  130 + 'gl_project_online_check.question AS question',
  131 + 'gl_project_online_check.optimist_status AS optimist_status',
  132 + 'gl_project_online_check.qa_status AS qa_status',
  133 + 'gl_project_payment.amount AS amount',
  134 + 'gl_project_deploy_build.dept_id AS dept_id',
  135 + 'gl_project_deploy_build.keyword_num AS key',
  136 + 'gl_project_deploy_build.service_duration AS day',
  137 + 'gl_project_deploy_build.leader_mid AS leader_mid',
  138 + 'gl_project_deploy_build.manager_mid AS manager_mid',
  139 + 'gl_project_deploy_build.designer_mid AS designer_mid',
  140 + 'gl_project_deploy_build.tech_mid AS tech_mid',
  141 + 'gl_project_deploy_build.test_domain AS test_domain',
  142 + 'gl_project_deploy_build.plan AS plan',
  143 + 'gl_project_deploy_optimize.dept_id AS optimize_dept_id',
  144 + 'gl_project_deploy_optimize.manager_mid AS optimize_manager_mid',
  145 + 'gl_project_deploy_optimize.optimist_mid AS optimize_optimist_mid',
  146 + 'gl_project_deploy_optimize.assist_mid AS optimize_assist_mid',
  147 + 'gl_project_deploy_optimize.tech_mid AS optimize_tech_mid',
  148 + 'gl_project_deploy_optimize.design_mid AS design_mid',
  149 + 'gl_project_deploy_optimize.tech_leader AS tech_leader',
  150 + 'gl_project_deploy_optimize.domain AS domain',
  151 + 'gl_project_deploy_optimize.quality_mid AS quality_mid',
  152 + 'gl_project_deploy_optimize.design_mid AS design_mid',
  153 + 'gl_project_payment.amount AS amount',
  154 + ];
  155 + return $select;
  156 + }
  157 +
  158 + /**
  159 + * @remark :按需搜索
  160 + * @name :searchDomainTitle
  161 + * @author :lyh
  162 + * @method :post
  163 + * @time :2023/9/7 18:39
  164 + */
  165 + public function searchContent(&$query){
  166 + if(!empty($this->map['search']) && !empty($this->map['search_type'])){
  167 + //搜索域名
  168 + $query->where(function ($subQuery) {
  169 + $subQuery->orwhere('gl_project_deploy_optimize.domain','like','%'.$this->map['search'].'%')
  170 + ->orwhere('gl_project.company','like','%'.$this->map['search'].'%')
  171 + ->orwhere('gl_project.title','like','%'.$this->map['search'].'%');
  172 + });
153 } 173 }
154 - if($this->param['type'] == Project::TYPE_THREE){  
155 - $type = ['in',[Project::TYPE_FOUR,Project::TYPE_SIX]]; 174 + return $query;
  175 + }
  176 +
  177 + /**
  178 + * @remark :搜索技术组
  179 + * @name :searchDept
  180 + * @author :lyh
  181 + * @method :post
  182 + * @time :2023/9/7 18:40
  183 + */
  184 + public function searchDept(&$query){
  185 + if(!empty($this->map['dept_id'])){
  186 + $query->where(function ($subQuery) {
  187 + $subQuery->orwhere('gl_project_deploy_build.dept_id',$this->map['dept_id'])
  188 + ->orwhere('gl_project_deploy_optimize.dept_id',$this->map['dept_id']);
  189 + });
156 } 190 }
157 - return $type; 191 + return $query;
158 } 192 }
159 193
160 /** 194 /**
161 - * @remark :搜索参数处理  
162 - * @name :searchParam 195 + * @remark :访问权限
  196 + * @name :getManagerRole
163 * @author :lyh 197 * @author :lyh
164 * @method :post 198 * @method :post
165 - * @time :2023/8/30 10:30 199 + * @time :2023/9/7 17:28
166 */ 200 */
167 - public function searchParam(&$map,$param){  
168 - //搜索技术组  
169 - if(!empty($param['dep_id'])){  
170 - $map['id'] = ['in', DeployBuild::where('dept_id', $param['dep_id'])->pluck('project_id')->toArray()]; 201 + public function getManagerRole(&$query){
  202 + if($this->manage['role'] != 1){//1代表查看所有
  203 + //获取用户所在组
  204 + $managerHr = new ManageHr();
  205 + $info = $managerHr->read(['manage_id'=>$this->manage['id']]);
  206 + //获取当前用户自己的项目
  207 + $query->where(function ($subQuery) use ($info) {
  208 + $subQuery->where('gl_project_deploy_build.leader_mid', $this->manage['id'])
  209 + ->orWhere('gl_project_deploy_build.manager_mid', $this->manage['id'])
  210 + ->orWhere('gl_project_deploy_build.designer_mid', $this->manage['id'])
  211 + ->orWhere('gl_project_deploy_build.tech_mid', $this->manage['id'])
  212 + ->orWhere('gl_project_deploy_optimize.manager_mid', $this->manage['id'])
  213 + ->orWhere('gl_project_deploy_optimize.optimist_mid', $this->manage['id'])
  214 + ->orWhere('gl_project_deploy_optimize.assist_mid', $this->manage['id'])
  215 + ->orWhere('gl_project_deploy_optimize.tech_mid', $this->manage['id'])
  216 + ->orWhere('gl_project_deploy_optimize.tech_leader', $this->manage['id'])
  217 + ->orWhere('gl_project_deploy_optimize.quality_mid', $this->manage['id'])
  218 + ->orWhere('gl_project_deploy_optimize.design_mid', $this->manage['id'])
  219 + ->orWhere('gl_project_deploy_build.dept_id', $info['belong_group'])
  220 + ->orWhere('gl_project_deploy_optimize.dept_id', $info['belong_group']);
  221 + });
171 } 222 }
172 - //搜索技术人员  
173 - if(!empty($param['manage_id'])){  
174 - $map['id'] = ['in', DeployBuild::where('leader_mid', $param['manage_id'])  
175 - ->orwhere('manager_mid', $param['manage_id'])->orwhere('designer_mid', $param['manage_id'])  
176 - ->orwhere('tech_mid', $param['manage_id'])->pluck('project_id')->toArray()]; 223 + return $query;
  224 + }
  225 +
  226 + /**
  227 + * @remark :搜索技术人员
  228 + * @name :searchManager
  229 + * @author :lyh
  230 + * @method :post
  231 + * @time :2023/9/7 17:16
  232 + */
  233 + public function searchManager(&$query)
  234 + {
  235 + if (!empty($this->map['manage_id'])) {
  236 + $query->where(function ($subQuery) {
  237 + $subQuery->orWhere('gl_project_deploy_build.leader_mid', $this->map['manage_id'])
  238 + ->orWhere('gl_project_deploy_build.manager_mid', $this->map['manage_id'])
  239 + ->orWhere('gl_project_deploy_build.designer_mid', $this->map['manage_id'])
  240 + ->orWhere('gl_project_deploy_build.tech_mid', $this->map['manage_id'])
  241 + ->orWhere('gl_project_deploy_optimize.manager_mid', $this->map['manage_id'])
  242 + ->orWhere('gl_project_deploy_optimize.optimist_mid', $this->map['manage_id'])
  243 + ->orWhere('gl_project_deploy_optimize.assist_mid', $this->map['manage_id'])
  244 + ->orWhere('gl_project_deploy_optimize.tech_mid', $this->map['manage_id'])
  245 + ->orWhere('gl_project_deploy_optimize.tech_leader', $this->map['manage_id'])
  246 + ->orWhere('gl_project_deploy_optimize.quality_mid', $this->map['manage_id'])
  247 + ->orWhere('gl_project_deploy_optimize.design_mid', $this->map['manage_id']);
  248 + });
177 } 249 }
178 - //按类型搜索  
179 - if(!empty($param['search']) && !empty($param['search_type'])){  
180 - if($this->param['search_type'] == 'domain'){  
181 - //搜索域名  
182 - $map['id'] = ['id', 'in', DeployOptimize::where('domain', 'like', "%{$this->param['search']}%")->pluck('project_id')->toArray()];  
183 - }else{  
184 - $map[$param['search_type']] = ['like', "%{$param['search']}%"];  
185 - } 250 + return $query;
  251 + }
  252 +
  253 + /**
  254 + * @remark :参数处理
  255 + * @name :handleParam
  256 + * @author :lyh
  257 + * @method :post
  258 + * @time :2023/8/18 14:44
  259 + */
  260 + public function handleParam(&$item){
  261 + if($item['type'] != Project::TYPE_ZERO){
  262 + $data = APublicModel::getNumByProjectId($item['id']);
186 } 263 }
187 - return $map; 264 + $manageModel = new Manage();
  265 + $item['channel'] = Channel::getChannelText($item['channel']['user_id'] ?? 0);
  266 + $item['build_leader'] = $manageModel->getName($item['leader_mid']);
  267 + $item['build_manager'] = $manageModel->getName($item['manager_mid']);
  268 + $item['build_designer'] = $manageModel->getName($item['designer_mid']);
  269 + $item['build_tech'] = $manageModel->getName($item['tech_mid']);
  270 + $item['optimize_manager'] = $manageModel->getName($item['optimize_manager_mid']);
  271 + $item['optimize_optimist'] = $manageModel->getName($item['optimize_optimist_mid']);
  272 + $item['optimize_assist'] = $manageModel->getName($item['optimize_assist_mid']);
  273 + $item['optimize_tech'] = $manageModel->getName($item['optimize_tech_mid']);
  274 + $item['plan'] = Project::planMap()[$item['plan']];
  275 + $item['created_at'] = date('Y年m月d日', strtotime($item['cooperate_date']));
  276 + $item['autologin_code'] = getAutoLoginCode($item['id']);
  277 + $domainModel = new DomainInfo();
  278 + $item['domain'] = !empty($item['domain']) ? $domainModel->getDomain($item['domain']) : '';
  279 + $item['product_num'] = $data['product'] ?? 0;
  280 + $item['keyword_num'] = $item['key'] ?? 0;
  281 + $item['autologin_code'] = getAutoLoginCode($item['id']);
  282 + $item['article_num'] = ($data['blog'] ?? 0) + ($data['news'] ?? 0);
  283 + $item['task_finish_num'] = Task::getNumByProjectId($item['id'], Task::STATUS_DOWN);
  284 + $item['task_pending_num'] = Task::getNumByProjectId($item['id'], [Task::STATUS_DONGING, Task::STATUS_WAIT]);
  285 + return $item;
188 } 286 }
189 287
190 /** 288 /**
@@ -354,8 +452,8 @@ class ProjectController extends BaseController @@ -354,8 +452,8 @@ class ProjectController extends BaseController
354 * @method :post 452 * @method :post
355 * @time :2023/8/30 19:01 453 * @time :2023/8/30 19:01
356 */ 454 */
357 - public function online_check(Request $request, OnlineCheckLogic $logic){  
358 - $request->validate([ 455 + public function online_check(OnlineCheckLogic $logic){
  456 + $this->request->validate([
359 'id'=>'required', 457 'id'=>'required',
360 'type'=>'required|in:optimist,qa', 458 'type'=>'required|in:optimist,qa',
361 'status'=>'required|in:0,1' 459 'status'=>'required|in:0,1'
@@ -384,7 +482,7 @@ class ProjectController extends BaseController @@ -384,7 +482,7 @@ class ProjectController extends BaseController
384 'type.required' => '请选择审核类型' 482 'type.required' => '请选择审核类型'
385 ]); 483 ]);
386 $belongGroupModel = new BelongingGroup(); 484 $belongGroupModel = new BelongingGroup();
387 - $lists = $belongGroupModel->list($this->map); 485 + $lists = $belongGroupModel->list($this->map,'name',['id','name','type'],'asc');
388 $this->response('success',Code::SUCCESS,$lists); 486 $this->response('success',Code::SUCCESS,$lists);
389 } 487 }
390 488
@@ -397,6 +495,10 @@ class ProjectController extends BaseController @@ -397,6 +495,10 @@ class ProjectController extends BaseController
397 */ 495 */
398 public function getManagerList(){ 496 public function getManagerList(){
399 $hrManagerModel = new ManageHr(); 497 $hrManagerModel = new ManageHr();
  498 + $this->map['status'] = $hrManagerModel::STATUS_ONE;
  499 + if(isset($this->map['entry_position']) && is_array($this->map['entry_position'])){
  500 + $this->map['entry_position'] = ['in',$this->map['entry_position']];
  501 + }
400 $lists = $hrManagerModel->list($this->map,'id',['id','manage_id','name','entry_position','is_leader']); 502 $lists = $hrManagerModel->list($this->map,'id',['id','manage_id','name','entry_position','is_leader']);
401 $this->response('success',Code::SUCCESS,$lists); 503 $this->response('success',Code::SUCCESS,$lists);
402 } 504 }
@@ -410,7 +512,7 @@ class ProjectController extends BaseController @@ -410,7 +512,7 @@ class ProjectController extends BaseController
410 */ 512 */
411 public function getServiceConfig(){ 513 public function getServiceConfig(){
412 $serviceConfigModel = new ServerConfig(); 514 $serviceConfigModel = new ServerConfig();
413 - $list = $serviceConfigModel->list($this->param); 515 + $list = $serviceConfigModel->list($this->param,'id',['id','type','title']);
414 $this->response('success',Code::SUCCESS,$list); 516 $this->response('success',Code::SUCCESS,$list);
415 } 517 }
416 518
@@ -422,8 +524,112 @@ class ProjectController extends BaseController @@ -422,8 +524,112 @@ class ProjectController extends BaseController
422 * @time :2023/8/14 10:29 524 * @time :2023/8/14 10:29
423 */ 525 */
424 public function getDomain(){ 526 public function getDomain(){
  527 + $this->request->validate([
  528 + 'project_id'=>'required',
  529 + ],[
  530 + 'project_id.required' => 'project_id不能为空',
  531 + ]);
425 $domainModel = new DomainInfo(); 532 $domainModel = new DomainInfo();
426 - $list = $domainModel->list(['status'=>0]); 533 + $list = $domainModel->list(['status'=>0,'project_id'=>['or',$this->param['project_id']]]);
427 $this->response('success',Code::SUCCESS,$list); 534 $this->response('success',Code::SUCCESS,$list);
428 } 535 }
  536 +
  537 + /**
  538 + * 通过企业名称查询项目是否在服务中, 有项目并且在服务中的返回1, 其他的返回0
  539 + * @author zbj
  540 + * @date 2023/9/4
  541 + */
  542 + public function getProjectInService(){
  543 + $company = $this->param['company'];
  544 + if(!$company){
  545 + $this->response('企业名称必传',Code::SYSTEM_ERROR);
  546 + }
  547 + $project = Project::where('company', $company)->first();
  548 + if($project && ($project['remain_day'] > 0 || in_array($project['type'], [0, 1,6]))){
  549 + $in_service = 1;
  550 + }else{
  551 + $in_service = 0;
  552 + }
  553 + $this->response('success',Code::SUCCESS, ['in_service' => $in_service]);
  554 + }
  555 +
  556 + /**
  557 + * @remark :逻辑删除项目
  558 + * @name :del
  559 + * @author :lyh
  560 + * @method :post
  561 + * @time :2023/9/8 15:21
  562 + */
  563 + public function del(ProjectLogic $logic){
  564 + $this->request->validate([
  565 + 'id'=>'required',
  566 + ],[
  567 + 'id.required' => 'id不能为空',
  568 + ]);
  569 + $logic->projectDel();
  570 + $this->response('success');
  571 + }
  572 +
  573 + /**
  574 + * 根据渠道商查询项目
  575 + * @author zbj
  576 + * @date 2023/9/11
  577 + */
  578 + public function getProjectByChannel(){
  579 + $source_id = $this->param['channel_id']; //原系统渠道id
  580 + $size = $this->param['page_size'] ?? 20;
  581 + $type = $this->param['type'] ?? '';
  582 + $company = $this->param['company'] ?? '';
  583 + $channel = Channel::where('source_id', $source_id)->first();
  584 + if(!$channel){
  585 + $this->response('渠道不存在',Code::SYSTEM_ERROR);
  586 + }
  587 +
  588 + $data = Project::with(['deploy_build', 'deploy_optimize', 'online_check'])->where('channel->channel_id', $channel->id)->where(function ($query) use ($type, $company){
  589 + if ($type) {
  590 + $query->where('type', $type);
  591 + }
  592 + if ($company) {
  593 + $query->where('company', 'like', '%' . $company . '%');
  594 + }
  595 + })->orderBy('id', 'desc')->paginate($size)->toArray();
  596 + $list = [];
  597 + foreach ($data['list'] as $item){
  598 + $param = [
  599 + "id" => $item['id'],
  600 + "title" => $item['title'],
  601 + "company" => $item['company'],
  602 + "type" => $item['type'],
  603 + "type_text" => Project::typeMap()[$item['type']] ?? '',
  604 + "channel" => $item['channel'],
  605 + "created_at" => $item['created_at'],
  606 + "updated_at" => $item['updated_at'],
  607 + "post_id" => $item['post_id'],
  608 + "from_order_id" => $item['from_order_id'],
  609 + "remain_day" => $item['remain_day'],
  610 + "last_inquiry_time" => $item['last_inquiry_time'],
  611 + "plan" => $item['deploy_build']['plan'] ?: 0,
  612 + "plan_text" => Project::planMap()[$item['deploy_build']['plan']] ?? '',
  613 + "start_date" => $item['deploy_optimize']['start_date'] ?? '',
  614 + "domain" => $item['deploy_optimize']['domain'] ?? '',
  615 + "test_domain" => $item['deploy_build']['test_domain'] ?? '',
  616 + "online_time" => $item['online_check']['qa_check_time'] ?? '',
  617 + "cooperate_date" => $item['cooperate_date'],
  618 + ];
  619 + if ($item['type'] == 3) {
  620 + $param['is_compliance'] = RankData::where('project_id', $item['id'])->where('lang', '')->value('is_compliance') ?: 0;
  621 + } else {
  622 + $param['is_compliance'] = 1;
  623 + }
  624 + $yesterday_count = Count::where('project_id', $item['id'])->where('date', date('Y-m-d', strtotime('-1 day')))->first();
  625 + $today_count = Count::where('project_id', $item['id'])->where('date', date('Y-m-d'))->first();
  626 + $param['yesterday_ip_count'] = $yesterday_count['ip_num'] ?? 0;
  627 + $param['today_ip_count'] = $today_count['ip_num'] ?? 0;
  628 + $param['inquiry_num'] = $today_count['inquiry_num'] ?? 0;
  629 +
  630 + $list[] = $param;
  631 + }
  632 + $data['list'] = $list;
  633 + $this->response('success',Code::SUCCESS, $data);
  634 + }
429 } 635 }
@@ -16,6 +16,7 @@ use App\Http\Logic\Aside\Project\ProjectLogic; @@ -16,6 +16,7 @@ use App\Http\Logic\Aside\Project\ProjectLogic;
16 use App\Http\Logic\Aside\Project\RenewLogic; 16 use App\Http\Logic\Aside\Project\RenewLogic;
17 use App\Models\ASide\APublicModel; 17 use App\Models\ASide\APublicModel;
18 use App\Models\Channel\Channel; 18 use App\Models\Channel\Channel;
  19 +use App\Models\Domain\DomainInfo;
19 use App\Models\HomeCount\Count; 20 use App\Models\HomeCount\Count;
20 use App\Models\Manage\Manage; 21 use App\Models\Manage\Manage;
21 use App\Models\Project\DeployBuild; 22 use App\Models\Project\DeployBuild;
@@ -34,43 +35,22 @@ class RenewProjectController extends BaseController @@ -34,43 +35,22 @@ class RenewProjectController extends BaseController
34 * @time :2023/8/11 10:22 35 * @time :2023/8/11 10:22
35 */ 36 */
36 public function lists(Project $project){ 37 public function lists(Project $project){
37 - $arr = $this->getLessThanFifteenProjectId();  
38 - $map = [];  
39 - $this->searchParam($map,$this->map,$arr);  
40 - //按类型搜索  
41 - $map['id'] = ['in', $arr];  
42 - $filed = ['id', 'title', 'mysql_id' ,'channel','cooperate_date' ,'type', 'created_at']; 38 + $map = $this->searchParam($this->map);
  39 + $filed = ['id', 'title', 'type' ,'mysql_id' ,'channel','cooperate_date' ,'type', 'remain_day' ,'created_at','delete_status'];
43 $lists = $project->formatQuery($map)->select($filed)->with('payment')->with('deploy_build') 40 $lists = $project->formatQuery($map)->select($filed)->with('payment')->with('deploy_build')
44 ->with('deploy_optimize')->with('online_check')->paginate($this->row, ['*'], 'page', $this->page); 41 ->with('deploy_optimize')->with('online_check')->paginate($this->row, ['*'], 'page', $this->page);
45 if(!empty($lists)){ 42 if(!empty($lists)){
46 $lists = $lists->toArray(); 43 $lists = $lists->toArray();
  44 + $manageModel = new Manage();
  45 + $domainModel = new DomainInfo();
47 foreach ($lists['list'] as $k=>$item){ 46 foreach ($lists['list'] as $k=>$item){
48 - $item = $this->handleParam($item); 47 + $item = $this->handleParam($item,$manageModel,$domainModel);
49 $lists['list'][$k] = $item; 48 $lists['list'][$k] = $item;
50 } 49 }
51 } 50 }
52 $this->response('success',Code::SUCCESS,$lists); 51 $this->response('success',Code::SUCCESS,$lists);
53 } 52 }
54 53
55 - /**  
56 - * @remark :获取小于15天的项目id  
57 - * @name :getlessThanFifteenProjectId  
58 - * @author :lyh  
59 - * @method :post  
60 - * @time :2023/8/30 11:49  
61 - */  
62 - public function getLessThanFifteenProjectId(){  
63 - $count = new Count();  
64 - $yesterday = Carbon::yesterday()->toDateString();  
65 - $count_list = $count->list(['date'=>$yesterday,'service_day'=>['<=',15]],'id',['project_id']);  
66 - $arr = [];  
67 - if(!empty($count_list)){  
68 - foreach ($count_list as $v){  
69 - $arr[] = $v['project_id'];  
70 - }  
71 - }  
72 - return $arr;  
73 - }  
74 54
75 /** 55 /**
76 * @remark :搜索参数处理 56 * @remark :搜索参数处理
@@ -79,16 +59,16 @@ class RenewProjectController extends BaseController @@ -79,16 +59,16 @@ class RenewProjectController extends BaseController
79 * @method :post 59 * @method :post
80 * @time :2023/8/30 10:30 60 * @time :2023/8/30 10:30
81 */ 61 */
82 - public function searchParam(&$map,$param,&$arr){ 62 + public function searchParam($param){
  63 + $map = [];
83 //按类型搜索 64 //按类型搜索
84 if(!empty($param['search']) && !empty($param['search_type'])){ 65 if(!empty($param['search']) && !empty($param['search_type'])){
85 - if($this->param['search_type'] == 'domain'){  
86 - //搜索域名  
87 - $map['id'] = ['id', 'in', DeployOptimize::where('domain', 'like', "%{$param['search']}%")->where('id','in',$arr)->pluck('project_id')->toArray()];  
88 - }else{  
89 - $map[$this->param['search_type']] = ['like', "%{$this->param['search']}%"];  
90 - } 66 + $map[$this->param['search_type']] = ['like', "%{$this->param['search']}%"];
91 } 67 }
  68 + //按类型搜索
  69 + $map['delete_status'] = 0;
  70 + $map['type'] = ['in',[2,3,4]];
  71 + $map['remain_day'] = ['<=',15];
92 return $map; 72 return $map;
93 } 73 }
94 74
@@ -138,8 +118,10 @@ class RenewProjectController extends BaseController @@ -138,8 +118,10 @@ class RenewProjectController extends BaseController
138 ->with('project_after')->paginate($this->row, ['*'], 'page', $this->page); 118 ->with('project_after')->paginate($this->row, ['*'], 'page', $this->page);
139 if(!empty($lists)){ 119 if(!empty($lists)){
140 $lists = $lists->toArray(); 120 $lists = $lists->toArray();
  121 + $manageModel = new Manage();
  122 + $domainModel = new DomainInfo();
141 foreach ($lists['list'] as $k=>$item){ 123 foreach ($lists['list'] as $k=>$item){
142 - $item = $this->handleParam($item); 124 + $item = $this->handleParam($item,$manageModel,$domainModel);
143 $lists['list'][$k] = $item; 125 $lists['list'][$k] = $item;
144 } 126 }
145 } 127 }
@@ -153,9 +135,10 @@ class RenewProjectController extends BaseController @@ -153,9 +135,10 @@ class RenewProjectController extends BaseController
153 * @method :post 135 * @method :post
154 * @time :2023/8/18 14:44 136 * @time :2023/8/18 14:44
155 */ 137 */
156 - public function handleParam(&$item){  
157 - $manageModel = new Manage();  
158 - $data = APublicModel::getNumByProjectId($item['id']); 138 + public function handleParam(&$item,&$manageModel,&$domainModel){
  139 + if($item['type'] != Project::TYPE_ZERO){
  140 + $data = APublicModel::getNumByProjectId($item['id']);
  141 + }
159 $item = [ 142 $item = [
160 'id' => $item['id'], 143 'id' => $item['id'],
161 'title' => $item['title'], 144 'title' => $item['title'],
@@ -174,7 +157,7 @@ class RenewProjectController extends BaseController @@ -174,7 +157,7 @@ class RenewProjectController extends BaseController
174 'type' => $item['type'], 157 'type' => $item['type'],
175 'test_domain' => $item['deploy_build']['test_domain'] ?? 0, 158 'test_domain' => $item['deploy_build']['test_domain'] ?? 0,
176 'plan' =>Project::planMap()[$item['deploy_build']['plan']], 159 'plan' =>Project::planMap()[$item['deploy_build']['plan']],
177 - 'domain' => $item['deploy_optimize']['domain'] ?? 0, 160 + 'domain' => !empty($item['deploy_optimize']['domain']) ? $domainModel->getDomain($item['deploy_optimize']['domain']) : '',
178 'created_at' => date('Y年m月d日', strtotime($item['created_at'])), 161 'created_at' => date('Y年m月d日', strtotime($item['created_at'])),
179 'autologin_code' => getAutoLoginCode($item['id']), 162 'autologin_code' => getAutoLoginCode($item['id']),
180 'product_num' => $data['product'] ?? 0, 163 'product_num' => $data['product'] ?? 0,
@@ -184,6 +167,7 @@ class RenewProjectController extends BaseController @@ -184,6 +167,7 @@ class RenewProjectController extends BaseController
184 'task_pending_num' => Task::getNumByProjectId($item['id'], [Task::STATUS_DONGING, Task::STATUS_WAIT]), 167 'task_pending_num' => Task::getNumByProjectId($item['id'], [Task::STATUS_DONGING, Task::STATUS_WAIT]),
185 'optimist_status'=>$item['online_check']['optimist_status'] ?? 0, 168 'optimist_status'=>$item['online_check']['optimist_status'] ?? 0,
186 'qa_status'=>$item['online_check']['qa_status'] ?? 0, 169 'qa_status'=>$item['online_check']['qa_status'] ?? 0,
  170 + 'service_day'=>$item['remain_day'] ?? 0,
187 ]; 171 ];
188 return $item; 172 return $item;
189 } 173 }
@@ -44,6 +44,7 @@ class TaskController extends BaseController @@ -44,6 +44,7 @@ class TaskController extends BaseController
44 $map = $this->searchParam($task,$taskOwnerModel); 44 $map = $this->searchParam($task,$taskOwnerModel);
45 $manager_list = $taskOwnerModel->formatQuery($map)->select('manage_id', DB::raw('COUNT(*) as count')) 45 $manager_list = $taskOwnerModel->formatQuery($map)->select('manage_id', DB::raw('COUNT(*) as count'))
46 ->groupBy('manage_id')->get()->toArray(); 46 ->groupBy('manage_id')->get()->toArray();
  47 +
47 $managerModel = new Manage(); 48 $managerModel = new Manage();
48 foreach ($manager_list as $k => $v){ 49 foreach ($manager_list as $k => $v){
49 $ids = $taskOwnerModel->where('manage_id', $v['manage_id'])->pluck('task_id')->toArray(); 50 $ids = $taskOwnerModel->where('manage_id', $v['manage_id'])->pluck('task_id')->toArray();
@@ -74,19 +75,23 @@ class TaskController extends BaseController @@ -74,19 +75,23 @@ class TaskController extends BaseController
74 $map['manage_id'] = $this->map['manage_id']; 75 $map['manage_id'] = $this->map['manage_id'];
75 } 76 }
76 } 77 }
77 - }elseif (isset($this->map['content']) && !empty($this->map['content'])){  
78 - $ids = $task->where('content', 'like','%'.$this->map['content'].'%')->pluck('id')->toArray();  
79 - $manage_ids = $taskOwnerModel->formatQuery(['task_id'=>['in',$ids]])->pluck('manage_id')->toArray();  
80 - $map['manage_id'] = ['in',$manage_ids];  
81 }elseif (isset($this->map['search_type']) && !empty($this->map['search_type'])){ 78 }elseif (isset($this->map['search_type']) && !empty($this->map['search_type'])){
82 if(isset($this->map['search']) && !empty($this->map['search'])) { 79 if(isset($this->map['search']) && !empty($this->map['search'])) {
83 $projectModel = new Project(); 80 $projectModel = new Project();
84 - $ids = $projectModel->where('title', 'like', '%' . $this->map['search'] . '%')->pluck('id')->toArray();  
85 - $manage_ids = $taskOwnerModel->formatQuery(['project'=>['in',$ids]])->pluck('manage_id')->toArray();  
86 - $map['manage_id'] = ['in',$manage_ids]; 81 + if($this->map['search_type'] == 'project'){
  82 + $ids = $projectModel->where('title', 'like', '%' . $this->map['search'] . '%')->pluck('id')->toArray();
  83 + $manage_ids = $taskOwnerModel->formatQuery(['project'=>['in',$ids]])->pluck('manage_id')->toArray();
  84 + $map['manage_id'] = ['in',$manage_ids];
  85 + }else{
  86 + $ids = $task->where('content', 'like','%'.$this->map['search'].'%')->pluck('id')->toArray();
  87 + $manage_ids = $taskOwnerModel->formatQuery(['task_id'=>['in',$ids]])->pluck('manage_id')->toArray();
  88 + $map['manage_id'] = ['in',$manage_ids];
  89 + }
87 } 90 }
88 }else{ 91 }else{
89 - $map['manage_id'] = $this->map['manage_id']; 92 + if(isset($this->map['search_type']) && !empty($this->map['search_type'])){
  93 + $map['manage_id'] = $this->map['manage_id'];
  94 + }
90 } 95 }
91 96
92 return $map; 97 return $map;
@@ -210,10 +215,11 @@ class TaskController extends BaseController @@ -210,10 +215,11 @@ class TaskController extends BaseController
210 */ 215 */
211 public function getUserTaskList(){ 216 public function getUserTaskList(){
212 $taskOwnerModel = new TaskOwner(); 217 $taskOwnerModel = new TaskOwner();
213 - $this->map['manage_id'] = $this->manage['id'];  
214 - $lists = $taskOwnerModel->lists($this->map,$this->page,$this->row,$this->order); 218 +
  219 + $taskModel = new Task();
  220 + $map = $this->searchUserParam($taskOwnerModel,$taskModel);
  221 + $lists = $taskOwnerModel->lists($map,$this->page,$this->row,$this->order);
215 if(!empty($lists) && !empty($lists['list'])){ 222 if(!empty($lists) && !empty($lists['list'])){
216 - $taskModel = new Task();  
217 $managerModel = new Manage(); 223 $managerModel = new Manage();
218 foreach ($lists['list'] as $k => $v){ 224 foreach ($lists['list'] as $k => $v){
219 $taskInfo = $taskModel->read(['id'=>$v['task_id']]); 225 $taskInfo = $taskModel->read(['id'=>$v['task_id']]);
@@ -225,4 +231,34 @@ class TaskController extends BaseController @@ -225,4 +231,34 @@ class TaskController extends BaseController
225 } 231 }
226 $this->response('success',Code::SUCCESS,$lists); 232 $this->response('success',Code::SUCCESS,$lists);
227 } 233 }
  234 +
  235 + /**
  236 + * @remark :我的任务搜索参数
  237 + * @name :searchUserParam
  238 + * @author :lyh
  239 + * @method :post
  240 + * @time :2023/9/5 15:00
  241 + */
  242 + public function searchUserParam(&$taskOwnerModel,&$taskModel){
  243 + $map = [];
  244 + if (isset($this->map['search_type']) && !empty($this->map['search_type'])){
  245 + if(isset($this->map['search']) && !empty($this->map['search'])) {
  246 + $projectModel = new Project();
  247 + if($this->map['search_type'] == 'project'){
  248 + $ids = $projectModel->where('title', 'like', '%' . $this->map['search'] . '%')->pluck('id')->toArray();
  249 + $manage_ids = $taskOwnerModel->formatQuery(['project'=>['in',$ids],'manage_id'=>$this->manage['id']])->pluck('manage_id')->toArray();
  250 + $map['manage_id'] = ['in',$manage_ids];
  251 + }else{
  252 + $ids = $taskModel->where('content', 'like','%'.$this->map['search'].'%')->pluck('id')->toArray();
  253 + $manage_ids = $taskOwnerModel->formatQuery(['task_id'=>['in',$ids],'manage_id'=>$this->manage['id']])->pluck('manage_id')->toArray();
  254 + $map['manage_id'] = ['in',$manage_ids];
  255 + }
  256 + }else{
  257 + $map['manage_id'] = $this->manage['id'];
  258 + }
  259 + }else{
  260 + $map['manage_id'] = $this->manage['id'];
  261 + }
  262 + return $map;
  263 + }
228 } 264 }
@@ -36,13 +36,6 @@ class ATemplateModuleController extends BaseController @@ -36,13 +36,6 @@ class ATemplateModuleController extends BaseController
36 * @time :2023/6/28 16:55 36 * @time :2023/6/28 16:55
37 */ 37 */
38 public function save(ATemplateModuleRequest $ATemplateModuleRequest,ATemplateModuleLogic $ATemplateModuleLogic){ 38 public function save(ATemplateModuleRequest $ATemplateModuleRequest,ATemplateModuleLogic $ATemplateModuleLogic){
39 - if(isset($this->param['id'])){  
40 - $this->request->validate([  
41 - 'id'=>'required'  
42 - ],[  
43 - 'id.required' => 'ID不能为空'  
44 - ]);  
45 - }  
46 $ATemplateModuleRequest->validated(); 39 $ATemplateModuleRequest->validated();
47 $ATemplateModuleLogic->aTemplateModuleSave(); 40 $ATemplateModuleLogic->aTemplateModuleSave();
48 $this->response('success'); 41 $this->response('success');
@@ -30,6 +30,7 @@ class ProjectMenuController extends BaseController @@ -30,6 +30,7 @@ class ProjectMenuController extends BaseController
30 * @time :2023/6/21 17:24 30 * @time :2023/6/21 17:24
31 */ 31 */
32 public function lists(ProjectMenuLogic $projectMenuLogic){ 32 public function lists(ProjectMenuLogic $projectMenuLogic){
  33 +
33 $lists = $projectMenuLogic->MenuList($this->map); 34 $lists = $projectMenuLogic->MenuList($this->map);
34 $this->response('success',Code::SUCCESS,$lists); 35 $this->response('success',Code::SUCCESS,$lists);
35 } 36 }
@@ -137,4 +138,21 @@ class ProjectMenuController extends BaseController @@ -137,4 +138,21 @@ class ProjectMenuController extends BaseController
137 $list = $projectMenuLogic->roleMenuInfo(); 138 $list = $projectMenuLogic->roleMenuInfo();
138 $this->response('success',Code::SUCCESS,$list); 139 $this->response('success',Code::SUCCESS,$list);
139 } 140 }
  141 +
  142 + /**
  143 + * @remark :排序
  144 + * @name :setSort
  145 + * @author :lyh
  146 + * @method :post
  147 + * @time :2023/8/10 16:40
  148 + */
  149 + public function sort(ProjectMenuLogic $projectMenuLogic){
  150 + $this->request->validate([
  151 + 'id'=>'required',
  152 + ],[
  153 + 'id.required' => 'ID不能为空',
  154 + ]);
  155 + $projectMenuLogic->setParamStatus();
  156 + $this->response('success');
  157 + }
140 } 158 }
@@ -6,6 +6,7 @@ use App\Enums\Common\Code; @@ -6,6 +6,7 @@ use App\Enums\Common\Code;
6 use App\Http\Controllers\Aside\BaseController; 6 use App\Http\Controllers\Aside\BaseController;
7 use App\Http\Logic\Aside\User\UserLogic; 7 use App\Http\Logic\Aside\User\UserLogic;
8 use App\Http\Requests\Aside\User\UserRequest; 8 use App\Http\Requests\Aside\User\UserRequest;
  9 +use App\Models\Project\Project;
9 use App\Models\User\ProjectRole; 10 use App\Models\User\ProjectRole;
10 use App\Models\User\User; 11 use App\Models\User\User;
11 use App\Models\User\User as UserModel; 12 use App\Models\User\User as UserModel;
@@ -145,4 +146,33 @@ class ProjectUserController extends BaseController @@ -145,4 +146,33 @@ class ProjectUserController extends BaseController
145 $list = $roleModel->list($this->map); 146 $list = $roleModel->list($this->map);
146 $this->response('success',Code::SUCCESS,$list); 147 $this->response('success',Code::SUCCESS,$list);
147 } 148 }
  149 +
  150 + /**
  151 + * @remark :排序
  152 + * @name :setSort
  153 + * @author :lyh
  154 + * @method :post
  155 + * @time :2023/8/10 16:40
  156 + */
  157 + public function sort(UserLogic $userLogic){
  158 + $this->request->validate([
  159 + 'id'=>'required',
  160 + ],[
  161 + 'id.required' => 'ID不能为空',
  162 + ]);
  163 + $userLogic->setParamStatus();
  164 + $this->response('success');
  165 + }
  166 +
  167 + /**
  168 + * @remark :保存用户获取项目列表
  169 + * @name :getProjectList
  170 + * @author :lyh
  171 + * @method :post
  172 + * @time :2023/9/6 9:06
  173 + */
  174 + public function getProjectList(Project $project){
  175 + $lists = $project->list(['type'=>['!=',$project::TYPE_ZERO]],'id',['id','title']);
  176 + $this->response('success',Code::SUCCESS,$lists);
  177 + }
148 } 178 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :UserLogController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/9/5 16:07
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Aside\User;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Aside\BaseController;
  14 +use App\Models\Manage\Manage;
  15 +use App\Models\User\User;
  16 +use App\Models\User\UserLogin;
  17 +
  18 +class UserLogController extends BaseController
  19 +{
  20 + /**
  21 + * @remark :用户日志
  22 + * @name :lists
  23 + * @author :lyh
  24 + * @method :post
  25 + * @time :2023/9/5 16:10
  26 + */
  27 + public function lists(UserLogin $user){
  28 + $userModel = new User();
  29 + $map = $this->searchParam($userModel);
  30 + $lists = $user->lists($map,$this->page,$this->row,$this->order);
  31 + if(!empty($lists) && !empty($lists['list'])){
  32 + foreach ($lists['list'] as $k => $v){
  33 + $info = $userModel->read(['id'=>$v['user_id']]);
  34 + $v['mobile'] = $info['mobile'] ?? '';
  35 + $v['name'] = $info['name'] ?? '';
  36 + $v['type'] = ($v['type'] == 0) ? '用户登录' : '管理员登录';
  37 + if(!empty($v['remark'])){
  38 + $v['remark'] = $this->handleRemark($userModel,$v['remark']);
  39 + }
  40 + $lists['list'][$k] = $v;
  41 + }
  42 + }
  43 + $this->response('success',Code::SUCCESS,$lists);
  44 + }
  45 +
  46 + /**
  47 + * @remark :搜索参数
  48 + * @name :searchParam
  49 + * @author :lyh
  50 + * @method :post
  51 + * @time :2023/9/5 16:56
  52 + */
  53 + public function searchParam(&$userModel){
  54 + $map = [];
  55 + if(isset($this->map['mobile']) && !empty($this->map['mobile'])){
  56 + $ids = $userModel->where('mobile', 'like', '%' . $this->map['mobile'] . '%')->pluck('id')->toArray();
  57 + $map['user_id'] = ['in',$ids];
  58 + }elseif (isset($this->map['name']) && !empty($this->map['name'])){
  59 + $ids = $userModel->where('name', 'like', '%' . $this->param['name'] . '%')->pluck('id')->toArray();
  60 + $map['user_id'] = ['in',$ids];
  61 + }
  62 + if(isset($this->map['created_at'])){
  63 + $map['created_at'] = $this->map['created_at'];
  64 + }
  65 + return $map;
  66 + }
  67 +
  68 + /**
  69 + * @remark :处理备注
  70 + * @name :handleRemark
  71 + * @author :lyh
  72 + * @method :post
  73 + * @time :2023/9/5 17:21
  74 + */
  75 + public function handleRemark(&$managerModel,$remark){
  76 + $arr = explode(':',$remark);
  77 + $managerInfo = $managerModel->read(['id'=>$arr[1]]);
  78 + if($managerInfo !== false){
  79 + $remark = $arr[0].':'.$managerInfo['name'];
  80 + }
  81 + return $remark;
  82 + }
  83 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :CNoticeController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/9/12 10:04
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\BCom;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Bside\BaseController;
  14 +use App\Http\Logic\Bside\Setting\WebSettingLogic;
  15 +use App\Models\Com\UpdateNotify;
  16 +use App\Models\Com\UpdateProgress;
  17 +use App\Models\Project\Country as CountryModel;
  18 +use App\Models\RouteMap\RouteMap;
  19 +use App\Models\WebSetting\WebSettingCountry;
  20 +use Illuminate\Http\Request;
  21 +
  22 +/**
  23 + * @remark :通知C端
  24 + * @name :CNoticeController
  25 + * @author :lyh
  26 + * @method :post
  27 + * @time :2023/9/12 10:38
  28 + */
  29 +class CNoticeController extends BaseController
  30 +{
  31 + /**
  32 + * 更新通知C端
  33 + * @param Request $request
  34 + * @param WebSettingLogic $webSettingLogic
  35 + */
  36 + public function sendNotify(){
  37 + $updateProgressModel = new UpdateProgress();
  38 + $progressInfo = $updateProgressModel->formatQuery(['project_id'=>$this->user['project_id'],'type'=>$this->param['type']])->orderBy('id','desc')->first();
  39 + if((!empty($progressInfo))){
  40 + $progressInfo = $progressInfo->toArray();
  41 + if(($progressInfo['total_num'] > $progressInfo['current_num'])){
  42 + $this->response('当前页面正在生成了,请完成后再点击',Code::SUCCESS,$progressInfo);
  43 + }
  44 + }
  45 + //通知更新
  46 + if($this->param['type'] == UpdateNotify::TYPE_MASTER){
  47 + $this->updateMaster();
  48 + }else{
  49 + $this->updateMinorLanguages();
  50 + }
  51 + $urlStr = $this->getString($this->param['type'],$this->param['page']);
  52 + @file_put_contents(storage_path('logs/lyh_error.log'), var_export($urlStr, true) . PHP_EOL, FILE_APPEND);
  53 + $this->curlGet($urlStr);
  54 + $this->response('更新成功');
  55 + }
  56 +
  57 + /**
  58 + * @remark :主站通知
  59 + * @name :updateMaster
  60 + * @author :lyh
  61 + * @method :post
  62 + * @time :2023/9/12 14:46
  63 + */
  64 + public function updateMaster(){
  65 + try {
  66 + $updateNotifyModel = new UpdateNotify();
  67 + if($this->param['page'] == UpdateNotify::PAGE_ALL){
  68 + //如果是更新所有
  69 + $routeMapModel = new RouteMap();
  70 + $count = $routeMapModel->formatQuery(['project_id'=>$this->user['project_id']])->count();
  71 + $updateNotifyModel->edit(['status' => 1], ['project_id' => $this->user['project_id'], 'status' => 0]);
  72 + $this->addProgress($count,$this->param['type'],$this->param['page']);
  73 + }elseif($this->param['page'] == UpdateNotify::PAGE_SINGLE){
  74 + //更新所有已修改的更新
  75 + $count = $updateNotifyModel->formatQuery(['project_id' => $this->user['project_id'], 'status' => 0])->count();
  76 + $updateNotifyModel->edit(['status' => 1], ['project_id' => $this->user['project_id'], 'status' => 0]);
  77 + $this->addProgress($count,$this->param['type'],$this->param['page']);
  78 + }else{
  79 + //根据传递的参数更新
  80 + $count = count($this->param['url']);
  81 + $extent = json_encode(['url'=>$this->param['url']]);
  82 + $this->addProgress($count,$this->param['type'],$this->param['page'],$extent);
  83 + }
  84 + }catch (\Exception $e){
  85 + $this->response('error',Code::USER_ERROR);
  86 + }
  87 + return true;
  88 + }
  89 +
  90 + /**
  91 + * @remark :更新小语种
  92 + * @name :updateMinorLanguages
  93 + * @author :lyh
  94 + * @method :post
  95 + * @time :2023/9/12 14:48
  96 + */
  97 + public function updateMinorLanguages(){
  98 + $updateNotifyModel = new UpdateNotify();
  99 + try {
  100 + if($this->param['page'] == UpdateNotify::PAGE_ALL){
  101 + //如果是更新所有
  102 + $routeMapModel = new RouteMap();
  103 + $count = $routeMapModel->formatQuery(['project_id'=>$this->user['project_id']])->count();
  104 + $updateNotifyModel->edit(['minor_languages_status' => 1], ['project_id' => $this->user['project_id'], 'minor_languages_status' => 0]);
  105 + $extent = json_encode(['language'=>$this->param['language']]);
  106 + $this->addProgress($count,$this->param['type'],$this->param['page'],$extent);
  107 + }else{
  108 + //根据传递的参数更新
  109 + $count = count($this->param['url']);
  110 + $extent = json_encode(['url'=>$this->param['url'],'language'=>$this->param['language']]);
  111 + $this->addProgress($count,$this->param['type'],$this->param['page'],$extent);
  112 + }
  113 + }catch (\Exception $e){
  114 + $this->response('error',Code::USER_ERROR);
  115 + }
  116 + return true;
  117 + }
  118 +
  119 + /**
  120 + * @remark :curl请求
  121 + * @name :curlGet
  122 + * @author :lyh
  123 + * @method :post
  124 + * @time :2023/9/12 10:10
  125 + */
  126 + public function curlGet($url){
  127 + $ch1 = curl_init();
  128 + $timeout = 0;
  129 + curl_setopt($ch1, CURLOPT_URL, $url);
  130 + curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
  131 + curl_setopt($ch1, CURLOPT_ENCODING, '');
  132 + curl_setopt($ch1, CURLOPT_MAXREDIRS, 10);
  133 + curl_setopt($ch1, CURLOPT_HTTPHEADER, array());
  134 + curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, $timeout);
  135 + curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, FALSE);
  136 + curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, FALSE);
  137 + curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, true);
  138 + curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, 'GET');
  139 + curl_setopt($ch1, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
  140 + $access_txt = curl_exec($ch1);
  141 + curl_close($ch1);
  142 + return json_decode($access_txt, true);
  143 + }
  144 +
  145 + /**
  146 + * @remark :生成一条更新记录
  147 + * @name :addProgress
  148 + * @author :lyh
  149 + * @method :post
  150 + * @time :2023/9/6 17:01
  151 + */
  152 + public function addProgress($count,$type,$page,$extend = ''){
  153 + $data = [
  154 + 'total_num'=>$count,
  155 + 'current_num'=>0,
  156 + 'type'=>$type,
  157 + 'page'=>$page,
  158 + 'extends'=>!empty($extend) ? $extend : json_encode([]),
  159 + 'project_id'=>$this->user['project_id'],
  160 + 'created_at'=>date('Y-m-d H;i:s')
  161 + ];
  162 + $updateProgressModel = new UpdateProgress();
  163 + return $updateProgressModel->insert($data);
  164 + }
  165 +
  166 + /**
  167 + * @remark :通知参数处理
  168 + * @name :getString
  169 + * @author :lyh
  170 + * @method :post
  171 + * @time :2023/9/6 17:03
  172 + */
  173 + public function getString($type,$page){
  174 + $param = [
  175 + 'project_id' => $this->user['project_id'],
  176 + 'type' => $type,
  177 + 'route' => $page
  178 + ];
  179 + $string = http_build_query($param);
  180 + return $this->user['domain'].'api/updateHtmlNotify/?' . $string;
  181 + }
  182 +
  183 + /**
  184 + * @remark :获取当前项目选中的语种
  185 + * @name :getCountry
  186 + * @author :lyh
  187 + * @method :post
  188 + * @time :2023/9/12 15:20
  189 + */
  190 + public function getCountry(){
  191 + $countryModel = new CountryModel();
  192 + $info = $countryModel->read(['project_id'=>$this->user['project_id']],['id','country_lists']);
  193 + $ids = [];
  194 + if($info !== false){
  195 + $ids = explode(',',$info['country_lists']);
  196 + }
  197 + $webSettingCountryModel = new WebSettingCountry();
  198 + $lists = $webSettingCountryModel->list(['id'=>['in',$ids]],'id',['id','name','country_img']);
  199 + if (!empty($lists)){
  200 + foreach ($lists as $k => $v){
  201 + $lists[$k]['image_link'] = url('upload/country/' . $v['country_img']);
  202 + }
  203 + }
  204 + $this->response('success',Code::SUCCESS,$lists);
  205 + }
  206 +}
@@ -3,9 +3,11 @@ @@ -3,9 +3,11 @@
3 namespace App\Http\Controllers\Bside\BCom; 3 namespace App\Http\Controllers\Bside\BCom;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
  6 +use App\Helper\Arr;
6 use App\Helper\Common; 7 use App\Helper\Common;
7 use App\Http\Controllers\Bside\BaseController; 8 use App\Http\Controllers\Bside\BaseController;
8 use App\Http\Logic\Bside\User\UserLogic; 9 use App\Http\Logic\Bside\User\UserLogic;
  10 +use App\Models\Project\DeployBuild;
9 use App\Models\Project\Project; 11 use App\Models\Project\Project;
10 use App\Models\User\ProjectMenu as ProjectMenuModel; 12 use App\Models\User\ProjectMenu as ProjectMenuModel;
11 use App\Models\User\ProjectRole as ProjectRoleModel; 13 use App\Models\User\ProjectRole as ProjectRoleModel;
@@ -26,14 +28,11 @@ class ComController extends BaseController @@ -26,14 +28,11 @@ class ComController extends BaseController
26 //根据当前登录用户角色返回用户菜单列表 28 //根据当前登录用户角色返回用户菜单列表
27 $projectMenuModel = new ProjectMenuModel(); 29 $projectMenuModel = new ProjectMenuModel();
28 if($this->user['role_id'] != 0){ 30 if($this->user['role_id'] != 0){
29 - $projectRoleModel = new ProjectRoleModel();  
30 - $info = $projectRoleModel->read(['id'=>$this->user['role_id']]);  
31 - $info['role_menu'] = trim($info['role_menu'],',');  
32 - $lists = $projectMenuModel->where(['status'=>0,'is_role'=>0])->whereIn('id',explode(',',$info['role_menu']))->get(); 31 + $this->map = $this->getNoAdminMenuCondition();
33 }else{ 32 }else{
34 - $lists = $projectMenuModel->where(['is_role'=>0])->get(); 33 + $this->map = $this->getAdminMenuCondition();
35 } 34 }
36 - $lists = $lists->toArray(); 35 + $lists = $projectMenuModel->list($this->map,'sort');
37 $menu = array(); 36 $menu = array();
38 foreach ($lists as $k => $v){ 37 foreach ($lists as $k => $v){
39 $v = (array)$v; 38 $v = (array)$v;
@@ -45,6 +44,7 @@ class ComController extends BaseController @@ -45,6 +44,7 @@ class ComController extends BaseController
45 $this->response('当前用户菜单列表',Code::SUCCESS,$menu); 44 $this->response('当前用户菜单列表',Code::SUCCESS,$menu);
46 } 45 }
47 46
  47 +
48 /** 48 /**
49 * @name :获取当前项目详情 49 * @name :获取当前项目详情
50 * @author :liyuhang 50 * @author :liyuhang
@@ -59,22 +59,96 @@ class ComController extends BaseController @@ -59,22 +59,96 @@ class ComController extends BaseController
59 } 59 }
60 60
61 /** 61 /**
  62 + * @remark :非超级管理员菜单列表
  63 + * @name :getRoleMenuLis
  64 + * @author :lyh
  65 + * @method :post
  66 + * @time :2023/9/6 11:47
  67 + */
  68 + public function getNoAdminMenuCondition(){
  69 + $code = $this->getIsHome();
  70 + $projectRoleModel = new ProjectRoleModel();
  71 + $info = $projectRoleModel->read(['id'=>$this->user['role_id']]);
  72 + if($code != 1){
  73 + $info['role_menu'] = trim(str_replace(',11,',',',','.$info['role_menu'].','),',');
  74 + }
  75 + $this->map = [
  76 + 'status'=>0,
  77 + 'is_role'=>0,
  78 + 'id'=>['in',explode(',',$info['role_menu'])]
  79 + ];
  80 + return $this->map;
  81 + }
  82 +
  83 + /**
  84 + * @remark :超级管理员菜单列表
  85 + * @name :getAdminMenuCondition
  86 + * @author :lyh
  87 + * @method :post
  88 + * @time :2023/9/6 13:53
  89 + */
  90 + public function getAdminMenuCondition(){
  91 + $this->map['status'] = 0;
  92 + $code = $this->getIsHome();
  93 + if($code != 1){
  94 + $this->map['id'] = ['!=',11];//排除菜单网站装修
  95 + }
  96 + return $this->map;
  97 + }
  98 +
  99 +
  100 + /**
  101 + * @remark :查看是否显示网站装饰
  102 + * @name :getIsHome
  103 + * @author :lyh
  104 + * @method :post
  105 + * @time :2023/9/6 11:30
  106 + */
  107 + public function getIsHome(){
  108 + if(isset($this->user['manager_id'])){
  109 + return 1;
  110 + }
  111 + $deployBuild = new DeployBuild();
  112 + $info = $deployBuild->read(['project_id'=>$this->user['project_id']]);
  113 + if(!empty($info['configuration'])){
  114 + $configuration = Arr::s2a($info['configuration']);
  115 + if(isset($configuration['is_home']) && ((int)$configuration['is_home'] != 0)){
  116 + return 1;
  117 + }
  118 + }
  119 + return 0;
  120 + }
  121 +
  122 + /**
62 * @name :登录用户编辑资料/修改密码 123 * @name :登录用户编辑资料/修改密码
63 * @author :liyuhang 124 * @author :liyuhang
64 * @method 125 * @method
65 */ 126 */
66 public function edit_info(){ 127 public function edit_info(){
67 - $this->request->validate([  
68 - 'password'=>['required'],  
69 - 'name'=>['required'],  
70 - ],[  
71 - 'password.required'=>'密码必须填写',  
72 - 'name.required'=>'名称必须填写',  
73 - ]);  
74 - $userLogic = new UserLogic();  
75 - $this->param['id'] = $this->uid;  
76 - $userLogic->edits($this->param);  
77 - $this->response('编辑成功'); 128 + $this->request->validate([
  129 + 'oldPassword'=>'required',
  130 + 'password' => 'required',
  131 + 'confirm'=>'required',
  132 + ], [
  133 + 'oldPassword.required' => '请输入原密码',
  134 + 'password.required' => '请输入新密码',
  135 + 'confirm.required' => '请再次输入新密码',
  136 + ]);
  137 + //查询员密码是否正确
  138 + $userModel = new User();
  139 + $info = $userModel->read(['id'=>$this->user['id']]);
  140 + if($info['password'] != base64_encode(md5($this->param['oldPassword']))){
  141 + $this->response('原密码错误',Code::USER_ERROR);
  142 + }
  143 + if($this->param['password'] != $this->param['confirm']){
  144 + $this->response('两次密码不一致');
  145 + }
  146 + $rs = $userModel->edit(['password'=>base64_encode(md5($this->param['password']))],['id'=>$this->user['id']]);
  147 + if($rs === false){
  148 + $this->response('系统错误',Code::SYSTEM_ERROR);
  149 + }
  150 + Cache::pull($info['token']);
  151 + $this->response('success');
78 } 152 }
79 153
80 /** 154 /**
@@ -5,12 +5,7 @@ namespace App\Http\Controllers\Bside; @@ -5,12 +5,7 @@ namespace App\Http\Controllers\Bside;
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 use App\Helper\Common; 6 use App\Helper\Common;
7 use App\Http\Controllers\Controller; 7 use App\Http\Controllers\Controller;
8 -use App\Http\Logic\Aside\Project\ProjectLogic;  
9 use App\Http\Requests\Scene; 8 use App\Http\Requests\Scene;
10 -use App\Models\File\File;  
11 -use App\Models\File\Image;  
12 -use App\Models\User\User as UserModel;  
13 -use App\Services\CosService;  
14 use Illuminate\Http\JsonResponse; 9 use Illuminate\Http\JsonResponse;
15 use Illuminate\Http\Request; 10 use Illuminate\Http\Request;
16 use Illuminate\Http\Exceptions\HttpResponseException; 11 use Illuminate\Http\Exceptions\HttpResponseException;
@@ -58,7 +53,7 @@ class BaseController extends Controller @@ -58,7 +53,7 @@ class BaseController extends Controller
58 public function getParam(){ 53 public function getParam(){
59 foreach ($this->param as $k => $v){ 54 foreach ($this->param as $k => $v){
60 if(is_array($v)){ 55 if(is_array($v)){
61 - continue; 56 + $this->map[$k] = $v;
62 }else{ 57 }else{
63 if(empty($v) && ($v == null)){ 58 if(empty($v) && ($v == null)){
64 unset($this->param[$k]); 59 unset($this->param[$k]);
@@ -90,13 +85,13 @@ class BaseController extends Controller @@ -90,13 +85,13 @@ class BaseController extends Controller
90 $this->map['name'] = ['like','%'.$v.'%']; 85 $this->map['name'] = ['like','%'.$v.'%'];
91 break; 86 break;
92 case "start_at": 87 case "start_at":
93 - $this->_btw[0] = $v;  
94 - $this->_btw[1] = date('Y-m-d H:i:s',time()); 88 + $this->_btw[0] = $v;
  89 + $this->_btw[1] = date('Y-m-d H:i:s',time());
95 $this->map['created_at'] = ['between', $this->_btw]; 90 $this->map['created_at'] = ['between', $this->_btw];
96 break; 91 break;
97 case "end_at": 92 case "end_at":
98 - $this->_btw[1] = $v;  
99 - $this->map['updated_at'] = ['between', $this->_btw]; 93 + $this->_btw[1] = $v;
  94 + $this->map['created_at'] = ['between', $this->_btw];
100 break; 95 break;
101 default: 96 default:
102 if (!empty($v) || $v == 0) { 97 if (!empty($v) || $v == 0) {
@@ -58,36 +58,23 @@ class BlogCategoryController extends BaseController @@ -58,36 +58,23 @@ class BlogCategoryController extends BaseController
58 'id.required' => 'ID不能为空' 58 'id.required' => 'ID不能为空'
59 ]); 59 ]);
60 $info = $blogCategoryLogic->info_blog_category(); 60 $info = $blogCategoryLogic->info_blog_category();
61 - $info['alias'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG_CATE, $info['id'], $this->user['project_id']);  
62 - $info['url'] = $this->user['domain'] . RouteMap::PATH_BLOG_CATE . '/' . $info['alias']; 61 + $info['url'] = $this->user['domain'] . $info['alias'];
63 $this->response('success',Code::SUCCESS,$info); 62 $this->response('success',Code::SUCCESS,$info);
64 } 63 }
  64 +
65 /** 65 /**
66 - * @name :添加分类  
67 - * @author :liyuhang  
68 - * @method 66 + * @remark :保存数据
  67 + * @name :save
  68 + * @author :lyh
  69 + * @method :post
  70 + * @time :2023/9/7 14:04
69 */ 71 */
70 - public function add(BlogCategoryRequest $request,BlogCategoryLogic $blogCategoryLogic){ 72 + public function save(BlogCategoryRequest $request,BlogCategoryLogic $blogCategoryLogic){
71 $request->validated(); 73 $request->validated();
72 - //添加时,验证分类上级分类是否有,有则更新到当前分类中,没有时直接添加  
73 - $blogCategoryLogic->add_blog_category(); 74 + $blogCategoryLogic->categorySave();
74 $this->response('success'); 75 $this->response('success');
75 } 76 }
76 77
77 - /**  
78 - * @name :编辑分类  
79 - * @author :liyuhang  
80 - * @method  
81 - */  
82 - public function edit(BlogCategoryRequest $request,BlogCategoryLogic $blogCategoryLogic){  
83 - $request->validate([  
84 - 'id'=>['required']  
85 - ],[  
86 - 'id.required' => 'ID不能为空'  
87 - ]);  
88 - $blogCategoryLogic->edit_blog_category();  
89 - $this->response('success');  
90 - }  
91 78
92 /** 79 /**
93 * @name :编辑状态/与排序 80 * @name :编辑状态/与排序
@@ -116,7 +103,7 @@ class BlogCategoryController extends BaseController @@ -116,7 +103,7 @@ class BlogCategoryController extends BaseController
116 'id.required' => 'ID不能为空', 103 'id.required' => 'ID不能为空',
117 'id.array' => 'ID为数组', 104 'id.array' => 'ID为数组',
118 ]); 105 ]);
119 - $blogCategoryLogic->del_blog_category(); 106 + $blogCategoryLogic->delBlogCategory();
120 //TODO::写入操作日志 107 //TODO::写入操作日志
121 $this->response('success'); 108 $this->response('success');
122 } 109 }
@@ -9,33 +9,32 @@ use App\Http\Logic\Bside\Blog\BlogLabelLogic; @@ -9,33 +9,32 @@ use App\Http\Logic\Bside\Blog\BlogLabelLogic;
9 use App\Http\Logic\Bside\Blog\BlogLogic; 9 use App\Http\Logic\Bside\Blog\BlogLogic;
10 use App\Http\Requests\Bside\Blog\BlogRequest; 10 use App\Http\Requests\Bside\Blog\BlogRequest;
11 use App\Models\Blog\Blog as BlogModel; 11 use App\Models\Blog\Blog as BlogModel;
  12 +use App\Models\Blog\BlogCategory;
12 use App\Models\RouteMap\RouteMap; 13 use App\Models\RouteMap\RouteMap;
13 use App\Models\User\User; 14 use App\Models\User\User;
14 15
15 class BlogController extends BaseController 16 class BlogController extends BaseController
16 { 17 {
17 - //通知别名  
18 - public $updateModelView = 'blog';  
19 18
20 /** 19 /**
21 - * @name :博客列表  
22 - * @author :liyuhang  
23 - * @method 20 + * @remark :博客列表
  21 + * @name :lists
  22 + * @author :lyh
  23 + * @method :post
  24 + * @time :2023/9/14 10:45
24 */ 25 */
25 public function lists(BlogModel $blogModel,BlogCategoryLogic $blogCategoryLogic,BlogLabelLogic $blogLabelLogic){ 26 public function lists(BlogModel $blogModel,BlogCategoryLogic $blogCategoryLogic,BlogLabelLogic $blogLabelLogic){
26 - //搜索条件  
27 - $this->map['project_id'] = $this->user['project_id'];  
28 - $lists = $blogModel->lists($this->map,$this->page,$this->row,$this->order = 'sort',  
29 - ['id','category_id','operator_id','status','created_at','label_id','image','updated_at','name','sort','url']);  
30 - if(!empty($lists['list'])){ 27 + $this->map = $this->searchParam();
  28 + $lists = $blogModel->lists($this->map,$this->page,$this->row,$this->order = 'sort', ['id','category_id','operator_id','status','created_at','label_id','image','updated_at','name','sort','url']);
  29 + if(!empty($lists) && !empty($lists['list'])){
  30 + //获取当前项目的所有分类
  31 + $data = $this->getCategoryList();
  32 + $user = new User();
31 foreach ($lists['list'] as $k => $v){ 33 foreach ($lists['list'] as $k => $v){
32 - //获取分类名称  
33 - $v = $blogCategoryLogic->get_category_name($v);  
34 - //获取标签名称  
35 - $v = $blogLabelLogic->get_label_name($v);  
36 - $v['url'] = $this->user['domain'] . RouteMap::getRoute(RouteMap::SOURCE_BLOG, $v['id'], $this->user['project_id']); 34 + $v['category_name'] = $this->categoryName($v['category_id'],$data);
  35 + $v['url'] = $this->user['domain'] .$v['url'];
37 $v['image_link'] = getImageUrl($v['image']); 36 $v['image_link'] = getImageUrl($v['image']);
38 - $v['operator_name'] = (new User())->getName($v['operator_id']); 37 + $v['operator_name'] = $user->getName($v['operator_id']);
39 $lists['list'][$k] = $v; 38 $lists['list'][$k] = $v;
40 } 39 }
41 } 40 }
@@ -43,6 +42,61 @@ class BlogController extends BaseController @@ -43,6 +42,61 @@ class BlogController extends BaseController
43 } 42 }
44 43
45 /** 44 /**
  45 + * @remark :处理列表返回参数
  46 + * @name :handleReturnParam
  47 + * @author :lyh
  48 + * @method :post
  49 + * @time :2023/9/14 10:01
  50 + */
  51 + public function searchParam(){
  52 + $this->map['project_id'] = $this->user['project_id'];
  53 + if(isset($this->map['category_id']) && !empty($this->map['category_id'])){
  54 + $this->map['category_id'] = ['like','%,'.$this->map['category_id'].',%'];
  55 + }
  56 + return $this->map;
  57 + }
  58 +
  59 + /**
  60 + * @remark :获取所有分类
  61 + * @name :getCategoryList
  62 + * @author :lyh
  63 + * @method :post
  64 + * @time :2023/9/14 13:56
  65 + */
  66 + public function getCategoryList(){
  67 + $categoryModel = new BlogCategory();
  68 + $data = [];
  69 + $cateList = $categoryModel->list(['project_id'=>$this->user['project_id']],['id','name']);
  70 + if(!empty($cateList)){
  71 + foreach ($cateList as $value){
  72 + $data[$value['id']] = $value['name'];
  73 + }
  74 + }
  75 + return $data;
  76 + }
  77 +
  78 + /**
  79 + * @remark :获取分类名称
  80 + * @name :categoryName
  81 + * @author :lyh
  82 + * @method :post
  83 + * @time :2023/9/14 13:58
  84 + */
  85 + public function categoryName($category_id,$data){
  86 + $category_name = '';
  87 + if(!empty($category_id) && !empty($data)){
  88 + $arr = explode(',',trim($category_id,','));
  89 + foreach ($arr as $v){
  90 + if(isset($data[$v])){
  91 + $category_name .= $data[$v].',';
  92 + }
  93 + }
  94 + $category_name = trim($category_name,',');
  95 + }
  96 + return $category_name;
  97 + }
  98 +
  99 + /**
46 * @remark :根据状态数量 100 * @remark :根据状态数量
47 * @name :getStatusNumber 101 * @name :getStatusNumber
48 * @author :lyh 102 * @author :lyh
@@ -76,34 +130,20 @@ class BlogController extends BaseController @@ -76,34 +130,20 @@ class BlogController extends BaseController
76 ],[ 130 ],[
77 'id.required' => 'ID不能为空' 131 'id.required' => 'ID不能为空'
78 ]); 132 ]);
79 - $info = $blogLogic->blog_info(); 133 + $info = $blogLogic->blogInfo();
80 $this->response('success',Code::SUCCESS,$info); 134 $this->response('success',Code::SUCCESS,$info);
81 } 135 }
82 136
83 -  
84 /** 137 /**
85 - * @name :添加博客  
86 - * @author :liyuhang  
87 - * @method 138 + * @remark :保存数据
  139 + * @name :save
  140 + * @author :lyh
  141 + * @method :post
  142 + * @time :2023/9/7 13:40
88 */ 143 */
89 - public function add(BlogRequest $request,BlogLogic $blogLogic){ 144 + public function save(BlogRequest $request,BlogLogic $blogLogic){
90 $request->validated(); 145 $request->validated();
91 - $blogLogic->blogAdd();  
92 - $this->response('success');  
93 - }  
94 -  
95 - /**  
96 - * @name :编辑博客  
97 - * @author :liyuhang  
98 - * @method  
99 - */  
100 - public function edit(BlogRequest $request,BlogLogic $blogLogic){  
101 - $request->validate([  
102 - 'id'=>['required']  
103 - ],[  
104 - 'id.required' => 'ID不能为空'  
105 - ]);  
106 - $blogLogic->blogEdit(); 146 + $blogLogic->blogSave();
107 $this->response('success'); 147 $this->response('success');
108 } 148 }
109 149
@@ -140,7 +180,7 @@ class BlogController extends BaseController @@ -140,7 +180,7 @@ class BlogController extends BaseController
140 'id.required' => 'ID不能为空', 180 'id.required' => 'ID不能为空',
141 'id.array' => 'ID为数组', 181 'id.array' => 'ID为数组',
142 ]); 182 ]);
143 - $blogLogic->blog_status(); 183 + $blogLogic->blogStatus();
144 //TODO::写入日志 184 //TODO::写入日志
145 $this->response('success'); 185 $this->response('success');
146 } 186 }
@@ -157,7 +197,7 @@ class BlogController extends BaseController @@ -157,7 +197,7 @@ class BlogController extends BaseController
157 'id.required' => 'ID不能为空', 197 'id.required' => 'ID不能为空',
158 'id.array' => 'ID为数组', 198 'id.array' => 'ID为数组',
159 ]); 199 ]);
160 - $blogLogic->blog_del(); 200 + $blogLogic->blogDel();
161 $this->response('success'); 201 $this->response('success');
162 } 202 }
163 203
@@ -23,6 +23,8 @@ use App\Models\Service\Service; @@ -23,6 +23,8 @@ use App\Models\Service\Service;
23 use App\Models\Sms\SmsLog; 23 use App\Models\Sms\SmsLog;
24 use App\Models\Template\Template; 24 use App\Models\Template\Template;
25 use App\Models\Template\TemplateModule; 25 use App\Models\Template\TemplateModule;
  26 +use App\Models\User\DeptUser;
  27 +use App\Models\User\ProjectRole;
26 use App\Models\User\User; 28 use App\Models\User\User;
27 use App\Models\User\User as UserModel; 29 use App\Models\User\User as UserModel;
28 use App\Utils\EncryptUtils; 30 use App\Utils\EncryptUtils;
@@ -182,7 +184,8 @@ class LoginController extends BaseController @@ -182,7 +184,8 @@ class LoginController extends BaseController
182 $message = simplexml_load_string($message, 'SimpleXMLElement', LIBXML_NOCDATA | LIBXML_NOERROR); 184 $message = simplexml_load_string($message, 'SimpleXMLElement', LIBXML_NOCDATA | LIBXML_NOERROR);
183 $jsonData = json_encode($message); 185 $jsonData = json_encode($message);
184 $arrayData = json_decode($jsonData, true); 186 $arrayData = json_decode($jsonData, true);
185 - $data = $this->setWechat($arrayData['ToUserName'],$arrayData['EventKey']); 187 + //gh_27174ac5c9d8,gh_27174ac5c9d8
  188 + $data = $this->setWechat($arrayData['FromUserName'],$arrayData['EventKey']);
186 if($data['code'] == 0){//登录失败,请先绑定 189 if($data['code'] == 0){//登录失败,请先绑定
187 $resMessage = $data['message']; 190 $resMessage = $data['message'];
188 }elseif($data['code'] == 1){ 191 }elseif($data['code'] == 1){
@@ -228,22 +231,32 @@ class LoginController extends BaseController @@ -228,22 +231,32 @@ class LoginController extends BaseController
228 */ 231 */
229 public function globalSo_v6_login(UserLoginLogic $logic){ 232 public function globalSo_v6_login(UserLoginLogic $logic){
230 $common = new Common(); 233 $common = new Common();
231 - $arr = $common->decrypt($this->param['token']); 234 + $arr = $common->decrypt(urldecode($this->param['token']));
232 if(empty($arr)){ 235 if(empty($arr)){
233 - $this->response('登录失败',Code::USER_ERROR); 236 + $this->response('非法请求!',Code::USER_ERROR);
  237 + }
  238 + if (empty($arr['timestamp']) || time() - $arr['timestamp'] > 60) {
  239 + $this->response('授权已过期,请重新获取授权码!',Code::USER_ERROR);
234 } 240 }
235 //没有from_order_id的项目 进入演示版 运营中心 241 //没有from_order_id的项目 进入演示版 运营中心
236 - $arr['from_order_id'] = 0; 242 + $arr['from_order_id'] = $arr['from_order_id'] ?? 0;
237 if(!$arr['from_order_id']){ 243 if(!$arr['from_order_id']){
238 //有账号就直接登录, 没有账号创建账号登录 244 //有账号就直接登录, 没有账号创建账号登录
239 $user = (new User())->where('project_id', Project::DEMO_PROJECT_ID)->where('mobile', $arr['phone'])->first(); 245 $user = (new User())->where('project_id', Project::DEMO_PROJECT_ID)->where('mobile', $arr['phone'])->first();
240 if(!$user){ 246 if(!$user){
241 $user = new User(); 247 $user = new User();
242 $user->project_id = Project::DEMO_PROJECT_ID; 248 $user->project_id = Project::DEMO_PROJECT_ID;
  249 + $user->role_id = ProjectRole::OPERATION_CENTER_ID;
243 $user->mobile = $arr['phone']; 250 $user->mobile = $arr['phone'];
244 $user->password = base64_encode(md5('v6.' . substr($arr['phone'], -6))); 251 $user->password = base64_encode(md5('v6.' . substr($arr['phone'], -6)));
245 - $user->name = $arr['phone']; 252 + $user->name = $arr['name'] ?? $arr['phone'];
246 $user->save(); 253 $user->save();
  254 + //运营中心组织
  255 + $dept_user = new DeptUser();
  256 + $dept_user->dept_id = DeptUser::OPERATION_CENTER_ID;
  257 + $dept_user->project_id = Project::DEMO_PROJECT_ID;
  258 + $dept_user->user_id = $user->id;
  259 + $dept_user->save();
247 } 260 }
248 $data = [ 261 $data = [
249 'user_id'=>$user['id'], 262 'user_id'=>$user['id'],
@@ -287,21 +300,4 @@ class LoginController extends BaseController @@ -287,21 +300,4 @@ class LoginController extends BaseController
287 return $data; 300 return $data;
288 } 301 }
289 302
290 - public function ceshi(){  
291 - $templateModel = new TemplateModule();  
292 - $list = $templateModel->list();  
293 - $imageModel = new ImageModel();  
294 - foreach ($list as $k=>$v){  
295 - if (strpos($v['image'], '.') !== false) {  
296 - $v['image'] = '/upload'.$v['image'];  
297 - }else{  
298 - $info = $imageModel->read(['hash'=>$v['image']]);  
299 - if($info !== false){  
300 - $v['image'] = $info['path'];  
301 - }  
302 - }  
303 - $templateModel->edit(['image'=>$v['image']],['id'=>$v['id']]);  
304 - }  
305 - $this->response('success');  
306 - }  
307 } 303 }
@@ -82,28 +82,14 @@ class NavController extends BaseController @@ -82,28 +82,14 @@ class NavController extends BaseController
82 */ 82 */
83 public function urls(){ 83 public function urls(){
84 // todo::需要配合 c端来 84 // todo::需要配合 c端来
85 - return $this->success([  
86 - [  
87 - 'url' => 'index',  
88 - 'name' => '首页'  
89 - ],  
90 - [  
91 - 'url' => 'news',  
92 - 'name' => '新闻'  
93 - ],  
94 - [  
95 - 'url' => 'products',  
96 - 'name' => '产品'  
97 - ],  
98 - [  
99 - 'url' => 'search',  
100 - 'name' => '搜索页'  
101 - ],  
102 - [  
103 - 'url' => 'blog',  
104 - 'name' => '博客'  
105 - ]  
106 - ]); 85 + $data = [
  86 + ['url'=>'index', 'name'=>'首页'],
  87 + ['url'=>'news', 'name'=>'新闻'],
  88 + ['url'=>'products', 'name'=>'产品'],
  89 + ['url'=>'search', 'name'=>'搜索页'],
  90 + ['url'=>'blog', 'name'=>'博客']
  91 + ];
  92 + $this->response('success',Code::SUCCESS,$data);
107 } 93 }
108 94
109 /** 95 /**
@@ -58,34 +58,20 @@ class NewsCategoryController extends BaseController @@ -58,34 +58,20 @@ class NewsCategoryController extends BaseController
58 'id.required' => 'ID不能为空' 58 'id.required' => 'ID不能为空'
59 ]); 59 ]);
60 $info = $newsCategoryLogic->info_news_category(); 60 $info = $newsCategoryLogic->info_news_category();
61 - $info['alias'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS_CATE, $info['id'], $this->user['project_id']);  
62 - $info['url'] = $this->user['domain'] . RouteMap::PATH_NEWS_CATE . '/' . $info['alias']; 61 + $info['url'] = $this->user['domain'] . $info['alias'];
63 $this->response('success',Code::SUCCESS,$info); 62 $this->response('success',Code::SUCCESS,$info);
64 } 63 }
65 - /**  
66 - * @name :添加分类  
67 - * @author :liyuhang  
68 - * @method  
69 - */  
70 - public function add(NewsCategoryRequest $request,NewsCategoryLogic $newsCategoryLogic){  
71 - $request->validated();  
72 - //添加时,验证分类上级分类是否有,有则更新到当前分类中,没有时直接添加  
73 - $newsCategoryLogic->add_news_category();  
74 - $this->response('success');  
75 - }  
76 64
77 /** 65 /**
78 - * @name :编辑分类  
79 - * @author :liyuhang  
80 - * @method 66 + * @remark :保存数据
  67 + * @name :save
  68 + * @author :lyh
  69 + * @method :post
  70 + * @time :2023/9/7 14:51
81 */ 71 */
82 - public function edit(NewsCategoryRequest $request,NewsCategoryLogic $newsCategoryLogic){  
83 - $request->validate([  
84 - 'id'=>['required']  
85 - ],[  
86 - 'id.required' => 'ID不能为空'  
87 - ]);  
88 - $newsCategoryLogic->edit_news_category(); 72 + public function save(NewsCategoryRequest $request,NewsCategoryLogic $newsCategoryLogic){
  73 + $request->validated();
  74 + $newsCategoryLogic->newsCategorySave();
89 $this->response('success'); 75 $this->response('success');
90 } 76 }
91 77
@@ -8,6 +8,7 @@ use App\Http\Logic\Bside\News\NewsCategoryLogic; @@ -8,6 +8,7 @@ use App\Http\Logic\Bside\News\NewsCategoryLogic;
8 use App\Http\Logic\Bside\News\NewsLogic; 8 use App\Http\Logic\Bside\News\NewsLogic;
9 use App\Http\Requests\Bside\News\NewsRequest; 9 use App\Http\Requests\Bside\News\NewsRequest;
10 use App\Models\News\News as NewsModel; 10 use App\Models\News\News as NewsModel;
  11 +use App\Models\News\NewsCategory;
11 use App\Models\RouteMap\RouteMap; 12 use App\Models\RouteMap\RouteMap;
12 use App\Models\User\User; 13 use App\Models\User\User;
13 14
@@ -24,21 +25,18 @@ class NewsController extends BaseController @@ -24,21 +25,18 @@ class NewsController extends BaseController
24 * @method 25 * @method
25 */ 26 */
26 public function lists(NewsModel $news,NewsCategoryLogic $newsCategoryLogic){ 27 public function lists(NewsModel $news,NewsCategoryLogic $newsCategoryLogic){
27 - $this->map['project_id'] = $this->user['project_id']; 28 + $this->map = $this->searchParam();
28 $lists = $news->lists($this->map,$this->page,$this->row,$this->order = 'sort', 29 $lists = $news->lists($this->map,$this->page,$this->row,$this->order = 'sort',
29 ['id','category_id','operator_id','status','created_at','updated_at','image','name','sort','url']); 30 ['id','category_id','operator_id','status','created_at','updated_at','image','name','sort','url']);
30 - if(!empty($lists['list'])){ 31 + if(!empty($lists) && !empty($lists['list'])){
  32 + //获取当前项目的所有分类
  33 + $data = $this->getCategoryList();
  34 + $user = new User();
31 foreach ($lists['list'] as $k => $v){ 35 foreach ($lists['list'] as $k => $v){
32 - if(!empty($v['category_id'])){  
33 - $v = $newsCategoryLogic->get_category_name($v);  
34 - }  
35 - $v['url'] = $this->user['domain'] . RouteMap::getRoute(RouteMap::SOURCE_NEWS, $v['id'], $this->user['project_id']);  
36 - if(!empty($v['image'])){  
37 - $v['image_link'] = getImageUrl($v['image']);  
38 - }  
39 - if(!empty($v['operator_id'])){  
40 - $v['operator_name'] = (new User())->getName($v['operator_id']);  
41 - } 36 + $v['category_name'] = $this->categoryName($v['category_id'],$data);
  37 + $v['url'] = $this->user['domain'] . $v['url'];
  38 + $v['image_link'] = getImageUrl($v['image']);
  39 + $v['operator_name'] = $user->getName($v['operator_id']);
42 $lists['list'][$k] = $v; 40 $lists['list'][$k] = $v;
43 } 41 }
44 } 42 }
@@ -46,6 +44,61 @@ class NewsController extends BaseController @@ -46,6 +44,61 @@ class NewsController extends BaseController
46 } 44 }
47 45
48 /** 46 /**
  47 + * @remark :处理列表返回参数
  48 + * @name :handleReturnParam
  49 + * @author :lyh
  50 + * @method :post
  51 + * @time :2023/9/14 10:01
  52 + */
  53 + public function searchParam(){
  54 + $this->map['project_id'] = $this->user['project_id'];
  55 + if(isset($this->map['category_id']) && !empty($this->map['category_id'])){
  56 + $this->map['category_id'] = ['like','%,'.$this->map['category_id'].',%'];
  57 + }
  58 + return $this->map;
  59 + }
  60 +
  61 + /**
  62 + * @remark :获取所有分类
  63 + * @name :getCategoryList
  64 + * @author :lyh
  65 + * @method :post
  66 + * @time :2023/9/14 13:56
  67 + */
  68 + public function getCategoryList(){
  69 + $categoryModel = new NewsCategory();
  70 + $data = [];
  71 + $cateList = $categoryModel->list(['project_id'=>$this->user['project_id']],['id','name']);
  72 + if(!empty($cateList)){
  73 + foreach ($cateList as $value){
  74 + $data[$value['id']] = $value['name'];
  75 + }
  76 + }
  77 + return $data;
  78 + }
  79 +
  80 + /**
  81 + * @remark :获取分类名称
  82 + * @name :categoryName
  83 + * @author :lyh
  84 + * @method :post
  85 + * @time :2023/9/14 13:58
  86 + */
  87 + public function categoryName($category_id,$data){
  88 + $category_name = '';
  89 + if(!empty($category_id) && !empty($data)){
  90 + $arr = explode(',',trim($category_id,','));
  91 + foreach ($arr as $v){
  92 + if(isset($data[$v])){
  93 + $category_name .= $data[$v].',';
  94 + }
  95 + }
  96 + $category_name = trim($category_name,',');
  97 + }
  98 + return $category_name;
  99 + }
  100 +
  101 + /**
49 * @remark :根据状态数量 102 * @remark :根据状态数量
50 * @name :getStatusNumber 103 * @name :getStatusNumber
51 * @author :lyh 104 * @author :lyh
@@ -78,38 +131,24 @@ class NewsController extends BaseController @@ -78,38 +131,24 @@ class NewsController extends BaseController
78 ],[ 131 ],[
79 'id.required' => 'ID不能为空', 132 'id.required' => 'ID不能为空',
80 ]); 133 ]);
81 - $info = $newsLogic->news_info();  
82 - $info['route'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS, $info['id'], $this->user['project_id']);  
83 - $info['url'] = $this->user['domain'] . $info['route'];  
84 - $info['image_link'] = getImageUrl($info['image']); 134 + $info = $newsLogic->newsInfo();
  135 +
85 $this->response('success',Code::SUCCESS,$info); 136 $this->response('success',Code::SUCCESS,$info);
86 } 137 }
  138 +
87 /** 139 /**
88 - * @name :添加新闻  
89 - * @return json  
90 - * @author :liyuhang  
91 - * @method 140 + * @remark :保存数据
  141 + * @name :save
  142 + * @author :lyh
  143 + * @method :post
  144 + * @time :2023/9/7 11:22
92 */ 145 */
93 - public function add(NewsRequest $newsRequest,NewsLogic $newsLogic){ 146 + public function save(NewsRequest $newsRequest,NewsLogic $newsLogic){
94 $newsRequest->validated(); 147 $newsRequest->validated();
95 - $newsLogic->news_add(); 148 + $newsLogic->newsSave();
96 $this->response('success'); 149 $this->response('success');
97 } 150 }
98 151
99 - /**  
100 - * @name :编辑  
101 - * @author :liyuhang  
102 - * @method  
103 - */  
104 - public function edit(NewsRequest $newsRequest,NewsLogic $newsLogic){  
105 - $newsRequest->validate([  
106 - 'id'=>['required'],  
107 - ],[  
108 - 'id.required' => 'ID不能为空',  
109 - ]);  
110 - $newsLogic->news_edit();  
111 - $this->response('success');  
112 - }  
113 152
114 /** 153 /**
115 * @name :编辑新闻seo 154 * @name :编辑新闻seo
@@ -160,8 +199,7 @@ class NewsController extends BaseController @@ -160,8 +199,7 @@ class NewsController extends BaseController
160 'id.required' => 'ID不能为空', 199 'id.required' => 'ID不能为空',
161 'id.array' => 'ID为数组', 200 'id.array' => 'ID为数组',
162 ]); 201 ]);
163 - $newsLogic->news_del();  
164 - //TODO::清空相关资源/写入日志 202 + $newsLogic->newsDel();
165 $this->response('success'); 203 $this->response('success');
166 } 204 }
167 205
@@ -31,16 +31,15 @@ class CategoryController extends BaseController @@ -31,16 +31,15 @@ class CategoryController extends BaseController
31 */ 31 */
32 public function index(Category $category) 32 public function index(Category $category)
33 { 33 {
34 - if(!empty($this->map['title'])){  
35 - $this->map['title'] = ['like','%'.$this->map['title'].'%'];  
36 - }  
37 - $this->map['project_id'] = $this->user['project_id']; 34 + $this->map = $this->searchParam();
38 $filed = ['id', 'project_id', 'pid', 'title', 'image', 'route','keywords', 'describe', 'status','created_at']; 35 $filed = ['id', 'project_id', 'pid', 'title', 'image', 'route','keywords', 'describe', 'status','created_at'];
39 $list = $category->list($this->map,'id',$filed); 36 $list = $category->list($this->map,'id',$filed);
40 $data = []; 37 $data = [];
41 if(!empty($list)){ 38 if(!empty($list)){
42 foreach ($list as $k =>$v){ 39 foreach ($list as $k =>$v){
43 - $v = $this->handleParam($v); 40 + $v['url'] = $this->user['domain'] . $v['route'];
  41 + $v['product_num'] = Product::where('category_id','like' ,'%,'.$v['id'].',%')->count();;
  42 + $v['image_link'] = getImageUrl($v['image']);
44 $list[$k] = $v; 43 $list[$k] = $v;
45 } 44 }
46 $data = $this->getListSon($list); 45 $data = $this->getListSon($list);
@@ -49,17 +48,18 @@ class CategoryController extends BaseController @@ -49,17 +48,18 @@ class CategoryController extends BaseController
49 } 48 }
50 49
51 /** 50 /**
52 - * @remark :分类处理参数  
53 - * @name :handleParam 51 + * @remark :搜索参数处理
  52 + * @name :searchParam
54 * @author :lyh 53 * @author :lyh
55 * @method :post 54 * @method :post
56 - * @time :2023/8/17 11:10 55 + * @time :2023/9/14 14:57
57 */ 56 */
58 - public function handleParam($v){  
59 - $v['url'] = $this->user['domain'] . RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_CATE, $v['id'], $v['project_id']);  
60 - $v['product_num'] = Product::where('category_id','like' ,'%,'.$v['id'].',%')->count();;  
61 - $v['image_link'] = getImageUrl($v['image']);  
62 - return $v; 57 + public function searchParam(){
  58 + if(!empty($this->map['title'])){
  59 + $this->map['title'] = ['like','%'.$this->map['title'].'%'];
  60 + }
  61 + $this->map['project_id'] = $this->user['project_id'];
  62 + return $this->map;
63 } 63 }
64 64
65 /** 65 /**
@@ -126,7 +126,6 @@ class CategoryController extends BaseController @@ -126,7 +126,6 @@ class CategoryController extends BaseController
126 ],[ 126 ],[
127 'ids.required' => 'ID不能为空' 127 'ids.required' => 'ID不能为空'
128 ]); 128 ]);
129 -  
130 $data = $logic->categoryDelete(); 129 $data = $logic->categoryDelete();
131 return $this->success($data); 130 return $this->success($data);
132 } 131 }
@@ -36,13 +36,13 @@ class KeywordController extends BaseController @@ -36,13 +36,13 @@ class KeywordController extends BaseController
36 $this->map['title'] = ['like','%'.$this->map['title'].'%']; 36 $this->map['title'] = ['like','%'.$this->map['title'].'%'];
37 } 37 }
38 $this->map['project_id'] = $this->user['project_id']; 38 $this->map['project_id'] = $this->user['project_id'];
39 - $filed = ['id', 'project_id', 'title', 'seo_title', 'seo_keywords', 'seo_description', 'status', 'created_at']; 39 + $filed = ['id', 'project_id', 'title', 'seo_title', 'seo_keywords', 'seo_description', 'status', 'created_at','route'];
40 $data = $keyword->lists($this->map,$this->page,$this->row,$this->order,$filed); 40 $data = $keyword->lists($this->map,$this->page,$this->row,$this->order,$filed);
41 if(!empty($data)){ 41 if(!empty($data)){
42 foreach ($data['list'] as &$v){ 42 foreach ($data['list'] as &$v){
43 $v['product_num'] = Product::where('keyword_id','like' ,'%,'.$v['id'].',%')->count(); 43 $v['product_num'] = Product::where('keyword_id','like' ,'%,'.$v['id'].',%')->count();
44 $v['tdk'] = boolval($v['seo_title']) * boolval($v['seo_keywords']) * boolval($v['seo_description']); 44 $v['tdk'] = boolval($v['seo_title']) * boolval($v['seo_keywords']) * boolval($v['seo_description']);
45 - $v['url'] = $this->user['domain'] . RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']); 45 + $v['url'] = $this->user['domain'] . $v['route'];
46 } 46 }
47 } 47 }
48 return $this->response('success',Code::SUCCESS,$data); 48 return $this->response('success',Code::SUCCESS,$data);
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Bside\Product; @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Bside\Product;
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 use App\Exceptions\BsideGlobalException; 6 use App\Exceptions\BsideGlobalException;
7 use App\Helper\Arr; 7 use App\Helper\Arr;
  8 +use App\Helper\Common;
8 use App\Http\Controllers\Bside\BaseController; 9 use App\Http\Controllers\Bside\BaseController;
9 use App\Http\Logic\Bside\Product\ProductLogic; 10 use App\Http\Logic\Bside\Product\ProductLogic;
10 use App\Http\Requests\Bside\Product\ProductRequest; 11 use App\Http\Requests\Bside\Product\ProductRequest;
@@ -13,9 +14,12 @@ use App\Models\Product\CategoryRelated; @@ -13,9 +14,12 @@ use App\Models\Product\CategoryRelated;
13 use App\Models\Product\Keyword; 14 use App\Models\Product\Keyword;
14 use App\Models\Product\KeywordRelated; 15 use App\Models\Product\KeywordRelated;
15 use App\Models\Product\Product; 16 use App\Models\Product\Product;
  17 +use App\Models\Template\BSetting;
  18 +use App\Models\Template\BTemplate;
16 use App\Models\User\User; 19 use App\Models\User\User;
17 use App\Rules\Ids; 20 use App\Rules\Ids;
18 use Illuminate\Http\Request; 21 use Illuminate\Http\Request;
  22 +use Illuminate\Support\Facades\Cache;
19 use Illuminate\Support\Facades\DB; 23 use Illuminate\Support\Facades\DB;
20 24
21 /** 25 /**
@@ -36,7 +40,36 @@ class ProductController extends BaseController @@ -36,7 +40,36 @@ class ProductController extends BaseController
36 */ 40 */
37 public function index(Product $product) 41 public function index(Product $product)
38 { 42 {
39 - $this->order = 'sort'; 43 + $this->map = $this->searchParam();
  44 + $filed = ['id', 'project_id', 'title', 'sort' ,'thumb', 'gallery' ,'product_type' , 'route' ,
  45 + 'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at'];
  46 + $lists = $product->lists($this->map,$this->page,$this->row,$this->order = ['sort','id'],$filed);
  47 + if(!empty($lists) && !empty($lists['list'])){
  48 + $cate_data = $this->getCategoryList();//分类
  49 + $key_data = $this->getKeywordsList();//关键字
  50 + //获取当前用户选择的模版
  51 + $templateSettingModel = new BSetting();
  52 + $info = $templateSettingModel->read(['project_id'=>$this->user['project_id']]);
  53 + $userModel = new User();
  54 + foreach ($lists['list'] as $k=>$v){
  55 + $v['category_id_text'] = $this->categoryName($v['category_id'],$cate_data);
  56 + $v['keyword_id_text'] = $this->keywordName($v['keyword_id'],$key_data);
  57 + $v['created_uid_text'] = $userModel->getName($v['created_uid']);
  58 + $v['is_renovation'] = $this->getProductIsRenovation($info,$v['id']);
  59 + $lists['list'][$k] = $v;
  60 + }
  61 + }
  62 + return $this->response('success',Code::SUCCESS,$lists);
  63 + }
  64 +
  65 + /**
  66 + * @remark :搜索参数处理
  67 + * @name :searchParam
  68 + * @author :lyh
  69 + * @method :post
  70 + * @time :2023/9/14 14:32
  71 + */
  72 + public function searchParam(){
40 if(isset($this->map['title']) && !empty($this->map['title'])){ 73 if(isset($this->map['title']) && !empty($this->map['title'])){
41 $this->map['title'] = ['like','%'.$this->map['title'].'%']; 74 $this->map['title'] = ['like','%'.$this->map['title'].'%'];
42 } 75 }
@@ -44,17 +77,135 @@ class ProductController extends BaseController @@ -44,17 +77,135 @@ class ProductController extends BaseController
44 $this->map['category_id'] = ['like','%'.$this->map['category_id'].'%']; 77 $this->map['category_id'] = ['like','%'.$this->map['category_id'].'%'];
45 } 78 }
46 $this->map['project_id'] = $this->user['project_id']; 79 $this->map['project_id'] = $this->user['project_id'];
47 - $filed = ['id', 'project_id', 'title', 'sort' ,'thumb', 'gallery' ,'product_type' , 'route' ,  
48 - 'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at'];  
49 - $lists = $product->lists($this->map,$this->page,$this->row,$this->order,$filed);  
50 - if(!empty($lists['list'])){  
51 - foreach ($lists['list'] as $k=>$v){  
52 - //处理参数  
53 - $v = $this->handleParam($v);  
54 - $lists['list'][$k] = $v; 80 + return $this->map;
  81 + }
  82 +
  83 + /**
  84 + * @remark :查看产品是否已装修
  85 + * @name :getProductIsRenovation
  86 + * @author :lyh
  87 + * @method :post
  88 + * @time :2023/9/13 14:02
  89 + */
  90 + public function getProductIsRenovation($info,$id){
  91 + if($info !== false){
  92 + $webTemplateModel = new BTemplate();
  93 + $param = [
  94 + 'source'=>2,
  95 + 'project_id'=>$this->user['project_id'],
  96 + 'source_id'=>$id,
  97 + 'template_id'=>$info['template_id']
  98 + ];
  99 + $templateInfo = $webTemplateModel->read($param);
  100 + if($templateInfo !== false){
  101 + return 1;
55 } 102 }
56 } 103 }
57 - return $this->response('success',Code::SUCCESS,$lists); 104 + return 0;
  105 + }
  106 +
  107 + /**
  108 + * @remark :获取所有分类
  109 + * @name :getCategoryList
  110 + * @author :lyh
  111 + * @method :post
  112 + * @time :2023/9/14 13:56
  113 + */
  114 + public function getCategoryList(){
  115 + $data = Common::get_user_cache('product_category',$this->user['project_id']);
  116 + if(empty($data)){
  117 + $categoryModel = new Category();
  118 + $data = [];
  119 + $cateList = $categoryModel->list(['project_id'=>$this->user['project_id']],['id','title']);
  120 + if(!empty($cateList)){
  121 + foreach ($cateList as $value){
  122 + $data[$value['id']] = $value['title'];
  123 + }
  124 + }
  125 + Common::set_user_cache($data,'product_category',$this->user['project_id']);
  126 + }
  127 + return $data;
  128 + }
  129 +
  130 + /**
  131 + * @remark :获取所有关键词
  132 + * @name :getCategoryList
  133 + * @author :lyh
  134 + * @method :post
  135 + * @time :2023/9/14 13:56
  136 + */
  137 + public function getKeywordsList(){
  138 + $data = Common::get_user_cache('product_keyword',$this->user['project_id']);
  139 + if(empty($data)) {
  140 + $keywordModel = new Keyword();
  141 + $data = [];
  142 + $cateList = $keywordModel->list(['project_id' => $this->user['project_id']], ['id', 'title']);
  143 + if (!empty($cateList)) {
  144 + foreach ($cateList as $value) {
  145 + $data[$value['id']] = $value['title'];
  146 + }
  147 + }
  148 + Common::set_user_cache($data,'product_keyword',$this->user['project_id']);
  149 + }
  150 + return $data;
  151 + }
  152 +
  153 + /**
  154 + * @remark :获取分类名称
  155 + * @name :categoryName
  156 + * @author :lyh
  157 + * @method :post
  158 + * @time :2023/9/14 13:58
  159 + */
  160 + public function categoryName($category_id,$data){
  161 + $category_name = '';
  162 + if(!empty($category_id) && !empty($data)){
  163 + foreach ($category_id as $v){
  164 + if(isset($data[$v])){
  165 + $category_name .= $data[$v].',';
  166 + }
  167 + }
  168 + $category_name = trim($category_name,',');
  169 + }
  170 + return $category_name;
  171 + }
  172 +
  173 + /**
  174 + * @remark :获取关键词名称
  175 + * @name :categoryName
  176 + * @author :lyh
  177 + * @method :post
  178 + * @time :2023/9/14 13:58
  179 + */
  180 + public function keywordName($keyword_id,$data){
  181 + $keyword_name = '';
  182 + if(!empty($keyword_id) && !empty($data)){
  183 + foreach ($keyword_id as $v){
  184 + if(isset($data[$v])){
  185 + $keyword_name .= $data[$v].',';
  186 + }
  187 + }
  188 + $keyword_name = trim($keyword_name,',');
  189 + }
  190 + return $keyword_name;
  191 + }
  192 +
  193 + /**
  194 + * @remark :详情
  195 + * @name :info
  196 + * @author :lyh
  197 + * @method :post
  198 + * @time :2023/8/21 18:12
  199 + */
  200 + public function info(Product $product){
  201 + $this->request->validate([
  202 + 'id'=>'required'
  203 + ],[
  204 + 'id.required' => 'ID不能为空'
  205 + ]);
  206 + $info = $product->read(['id'=>$this->param['id']]);
  207 + $info = $this->handleParam($info);
  208 + return $this->response('success',Code::SUCCESS,$info);
58 } 209 }
59 210
60 /** 211 /**
@@ -84,28 +235,13 @@ class ProductController extends BaseController @@ -84,28 +235,13 @@ class ProductController extends BaseController
84 $v['keyword_id_text'] = trim($v['keyword_id_text'],','); 235 $v['keyword_id_text'] = trim($v['keyword_id_text'],',');
85 } 236 }
86 $v['status_text'] = Product::statusMap()[$v['status']] ?? ''; 237 $v['status_text'] = Product::statusMap()[$v['status']] ?? '';
87 - $v['created_uid_text'] = (new User())->read(['id'=>$v['created_uid']])['name'] ?? ''; 238 + //获取当前用户选择的模版
  239 + $templateSettingModel = new BSetting();
  240 + $templateInfo = $templateSettingModel->read(['project_id'=>$this->user['project_id']]);
  241 + $v['is_renovation'] = $this->getProductIsRenovation($templateInfo,$v['id']);
88 $v['url'] = $this->user['domain'].$v['route']; 242 $v['url'] = $this->user['domain'].$v['route'];
89 return $v; 243 return $v;
90 } 244 }
91 - /**  
92 - * @remark :详情  
93 - * @name :info  
94 - * @author :lyh  
95 - * @method :post  
96 - * @time :2023/8/21 18:12  
97 - */  
98 - public function info(Product $product){  
99 - $this->request->validate([  
100 - 'id'=>'required'  
101 - ],[  
102 - 'id.required' => 'ID不能为空'  
103 - ]);  
104 - $info = $product->read(['id'=>$this->param['id']]);  
105 - $info = $this->handleParam($info);  
106 - return $this->response('success',Code::SUCCESS,$info);  
107 - }  
108 -  
109 245
110 246
111 /** 247 /**
@@ -118,8 +254,8 @@ class ProductController extends BaseController @@ -118,8 +254,8 @@ class ProductController extends BaseController
118 public function save(ProductRequest $request, ProductLogic $logic) 254 public function save(ProductRequest $request, ProductLogic $logic)
119 { 255 {
120 $request->validated(); 256 $request->validated();
121 - $data = $logic->productSave();  
122 - return $this->success($data); 257 + $logic->productSave();
  258 + $this->response('success');
123 } 259 }
124 260
125 /** 261 /**
@@ -35,20 +35,4 @@ class WebSettingController extends BaseController @@ -35,20 +35,4 @@ class WebSettingController extends BaseController
35 $this->response('success'); 35 $this->response('success');
36 } 36 }
37 37
38 - /**  
39 - * 更新通知C端  
40 - * @param Request $request  
41 - * @param WebSettingLogic $webSettingLogic  
42 - */  
43 - public function sendNotify(Request $request, WebSettingLogic $webSettingLogic){  
44 - $type = $request->input('type', UpdateNotify::TYPE_MASTER);  
45 - if (FALSE == in_array($type, [UpdateNotify::TYPE_MASTER, UpdateNotify::TYPE_MINOR]))  
46 - $this->response('非法参数!', Code::USER_ERROR);  
47 -  
48 - $list = $webSettingLogic->sendNotifyMessage($type);  
49 - if(!empty($list)){  
50 - $this->response('当前页面正在生成了,请完成后再点击',Code::USER_ERROR,$list);  
51 - }  
52 - $this->response('success');  
53 - }  
54 } 38 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :WebSettingSeoController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/9/11 16:31
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\Setting;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Bside\BaseController;
  14 +use App\Http\Logic\Bside\Setting\WebSettingSeoLogic;
  15 +
  16 +class WebSettingSeoController extends BaseController
  17 +{
  18 + /**
  19 + * @remark :获取当前项目seo详情
  20 + * @name :info
  21 + * @author :lyh
  22 + * @method :post
  23 + * @time :2023/9/11 16:31
  24 + */
  25 + public function info(WebSettingSeoLogic $logic){
  26 + $info = $logic->seoInfo();
  27 + $this->response('success',Code::SUCCESS,$info);
  28 + }
  29 +
  30 + /**
  31 + * @remark :保存数据
  32 + * @name :save
  33 + * @author :lyh
  34 + * @method :post
  35 + * @time :2023/9/11 16:32
  36 + */
  37 + public function save(WebSettingSeoLogic $logic){
  38 + $logic->seoSave();
  39 + $this->response('success');
  40 + }
  41 +}
@@ -71,6 +71,10 @@ class BTemplateController extends BaseController @@ -71,6 +71,10 @@ class BTemplateController extends BaseController
71 * @time :2023/6/29 10:02 71 * @time :2023/6/29 10:02
72 */ 72 */
73 public function save(TemplateRequest $templateRequest,BTemplateLogic $BTemplateLogic){ 73 public function save(TemplateRequest $templateRequest,BTemplateLogic $BTemplateLogic){
  74 + //演示项目,不允许其他号码编辑$this->user['mobile'] != '15928018676' ||
  75 + if(($this->user['project_id'] == 1) && ($this->user['mobile'] != '15680871314') && ($this->param['source'] == 1)){
  76 + $this->response('演示项目仅支持演示功能,无法更改首页',Code::USER_ERROR);
  77 + }
74 $templateRequest->validated(); 78 $templateRequest->validated();
75 $BTemplateLogic->templateSave(); 79 $BTemplateLogic->templateSave();
76 $this->response('success'); 80 $this->response('success');
@@ -87,4 +91,36 @@ class BTemplateController extends BaseController @@ -87,4 +91,36 @@ class BTemplateController extends BaseController
87 $list = $BTemplateLogic->getModuleType(); 91 $list = $BTemplateLogic->getModuleType();
88 $this->response('success',Code::SUCCESS,$list); 92 $this->response('success',Code::SUCCESS,$list);
89 } 93 }
  94 +
  95 + /**
  96 + * @remark :公共主题设置公共head
  97 + * @name :setHead
  98 + * @author :lyh
  99 + * @method :post
  100 + * @time :2023/7/10 15:30
  101 + */
  102 + public function setHeadFooter(BTemplateLogic $BTemplateLogic){
  103 + $this->request->validate([
  104 + 'head'=>'required',
  105 + 'footer'=>'required'
  106 + ],[
  107 + 'head.required' => 'head不能为空',
  108 + 'footer.required' => 'footer不能为空'
  109 + ]);
  110 + $BTemplateLogic->setHeadFooterSave();
  111 + $this->response('success');
  112 + }
  113 +
  114 + /**
  115 + * @remark :获取公共主题head
  116 + * @name :getHead
  117 + * @author :lyh
  118 + * @method :post
  119 + * @time :2023/7/10 15:30
  120 + */
  121 + public function getHeadFooter(BTemplateLogic $BTemplateLogic){
  122 + $info = $BTemplateLogic->getHeadFooterList();
  123 + $this->response('success',Code::SUCCESS,$info);
  124 + }
  125 +
90 } 126 }
@@ -54,7 +54,7 @@ class UserController extends BaseController @@ -54,7 +54,7 @@ class UserController extends BaseController
54 * @author :liyuhang 54 * @author :liyuhang
55 * @method 55 * @method
56 */ 56 */
57 - public function edit(UserRequest $request,UserLogic $userLogic){ 57 + public function edit(Request $request,UserLogic $userLogic){
58 $request->validate([ 58 $request->validate([
59 'id'=>['required'] 59 'id'=>['required']
60 ],[ 60 ],[
@@ -35,6 +35,9 @@ class FileController @@ -35,6 +35,9 @@ class FileController
35 $this->param = $this->request->all(); 35 $this->param = $this->request->all();
36 $this->config = config('filesystems.disks.upload'); 36 $this->config = config('filesystems.disks.upload');
37 $this->uploads = config('upload.default_file'); 37 $this->uploads = config('upload.default_file');
  38 + //获取当前登录用户详情
  39 + $this->token = $this->request->header('token');
  40 + $this->cache = Cache::get($this->token);
38 } 41 }
39 42
40 /** 43 /**
@@ -94,7 +97,7 @@ class FileController @@ -94,7 +97,7 @@ class FileController
94 $size = $files->getSize(); 97 $size = $files->getSize();
95 $file_type = $files->getClientOriginalExtension(); 98 $file_type = $files->getClientOriginalExtension();
96 $mime = $files->getMimeType(); 99 $mime = $files->getMimeType();
97 - return $this->single($files,$size,$file_type,$mime); 100 + return $this->single($files);
98 } 101 }
99 } 102 }
100 103
@@ -105,7 +108,7 @@ class FileController @@ -105,7 +108,7 @@ class FileController
105 * @method :post 108 * @method :post
106 * @time :2023/6/17 16:32 109 * @time :2023/6/17 16:32
107 */ 110 */
108 - public function single(&$files,$size,$file_type,$mime = ''){ 111 + public function single(&$files){
109 $hash = hash_file('md5', $files->getPathname()); 112 $hash = hash_file('md5', $files->getPathname());
110 //查看文件是否存在 113 //查看文件是否存在
111 $fileModel = new File(); 114 $fileModel = new File();
@@ -114,7 +117,7 @@ class FileController @@ -114,7 +117,7 @@ class FileController
114 return $this->response('资源',Code::SUCCESS,$this->responseData($file_hash['path'])); 117 return $this->response('资源',Code::SUCCESS,$this->responseData($file_hash['path']));
115 } 118 }
116 $url = $this->config['root'].$this->path; 119 $url = $this->config['root'].$this->path;
117 - $fileName = uniqid().rand(10000,99999).'.'.$file_type; 120 + $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
118 //同步数据到cos 121 //同步数据到cos
119 if($this->upload_location == 1){ 122 if($this->upload_location == 1){
120 $cosService = new CosService(); 123 $cosService = new CosService();
@@ -125,7 +128,7 @@ class FileController @@ -125,7 +128,7 @@ class FileController
125 return $this->response($files->getError(), Code::USER_ERROR); 128 return $this->response($files->getError(), Code::USER_ERROR);
126 } 129 }
127 } 130 }
128 - $this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime); 131 + $this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType());
129 return $this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName)); 132 return $this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName));
130 } 133 }
131 134
@@ -222,11 +225,10 @@ class FileController @@ -222,11 +225,10 @@ class FileController
222 */ 225 */
223 public function downLoad(){ 226 public function downLoad(){
224 $file_model = new File(); 227 $file_model = new File();
225 - $info = $file_model->read(['path' => $this->param['path']]); 228 + $info = $file_model->read(['path' => str_replace_url($this->param['path'])]);
226 if ($info === false) { 229 if ($info === false) {
227 $this->response('指定文件不存在!', Code::USER_ERROR); 230 $this->response('指定文件不存在!', Code::USER_ERROR);
228 } 231 }
229 -  
230 if($info['is_cos'] == 1){ 232 if($info['is_cos'] == 1){
231 $cos = new CosService(); 233 $cos = new CosService();
232 $fileUrl = $cos->getImageUrl($info['path']); 234 $fileUrl = $cos->getImageUrl($info['path']);
@@ -257,9 +259,6 @@ class FileController @@ -257,9 +259,6 @@ class FileController
257 if(isset($this->param['refer_type']) && $this->param['refer_type'] == 1){ 259 if(isset($this->param['refer_type']) && $this->param['refer_type'] == 1){
258 $this->path = $this->uploads['path_a'].'/'.$this->file_type[$this->param['refer']].'/'.date('Y-m'); 260 $this->path = $this->uploads['path_a'].'/'.$this->file_type[$this->param['refer']].'/'.date('Y-m');
259 }else{ 261 }else{
260 - //获取当前登录用户详情  
261 - $this->token = $this->request->header('token');  
262 - $this->cache = Cache::get($this->token);  
263 //B端上传,upload_method 为 1时 强制上传到本地 262 //B端上传,upload_method 为 1时 强制上传到本地
264 if(!isset($this->param['upload_method'])) { 263 if(!isset($this->param['upload_method'])) {
265 //根据项目上传标识区分上传到cos/本地 264 //根据项目上传标识区分上传到cos/本地
@@ -281,10 +280,14 @@ class FileController @@ -281,10 +280,14 @@ class FileController
281 * @time :2023/6/29 11:48 280 * @time :2023/6/29 11:48
282 */ 281 */
283 public function getFileList(){ 282 public function getFileList(){
  283 + if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){
  284 + $this->map['project_id'] = $this->cache['project_id'];
  285 + }
  286 + $this->map['refer'] = 1;
284 $fileModel = new File(); 287 $fileModel = new File();
285 - $lists = $fileModel->list(['refer'=>1],$order = 'id',['id','hash','type','path','created_at']); 288 + $lists = $fileModel->list($this->map,'id',['id','hash','type','path','created_at']);
286 foreach ($lists as $k => $v){ 289 foreach ($lists as $k => $v){
287 - $v['file_link'] = getFileUrl($v['hash']); 290 + $v['file_link'] = getFileUrl($v['path']);
288 $lists[$k] = $v; 291 $lists[$k] = $v;
289 } 292 }
290 $this->response('success',Code::SUCCESS,$lists); 293 $this->response('success',Code::SUCCESS,$lists);
@@ -300,7 +303,7 @@ class FileController @@ -300,7 +303,7 @@ class FileController
300 public function responseData($path){ 303 public function responseData($path){
301 $data = [ 304 $data = [
302 'file'=>$path, 305 'file'=>$path,
303 - 'file_link'=>getFileUrl($path), 306 + 'file_link'=>getFileUrl($path,$this->upload_location),
304 ]; 307 ];
305 return $data; 308 return $data;
306 } 309 }
@@ -314,11 +317,11 @@ class FileController @@ -314,11 +317,11 @@ class FileController
314 */ 317 */
315 public function getDownloadUrl(){ 318 public function getDownloadUrl(){
316 $fileModel = new File(); 319 $fileModel = new File();
317 - $info = $fileModel->read(['path' => $this->param['path']]); 320 + $info = $fileModel->read(['path' => str_replace_url($this->param['path'])]);
318 if ($info === false) { 321 if ($info === false) {
319 $this->response('指定文件不存在!', Code::USER_ERROR); 322 $this->response('指定文件不存在!', Code::USER_ERROR);
320 } 323 }
321 - $data = ['file_download'=>url('a/downLoad/files?path='.$this->param['path'])]; 324 + $data = ['file_download'=>url('a/download_files?path='.$info['path'])];
322 $this->response('success',Code::SUCCESS,$data); 325 $this->response('success',Code::SUCCESS,$data);
323 } 326 }
324 } 327 }
@@ -16,7 +16,7 @@ use Intervention\Image\Facades\Image; @@ -16,7 +16,7 @@ use Intervention\Image\Facades\Image;
16 16
17 class ImageController extends Controller 17 class ImageController extends Controller
18 { 18 {
19 - public $path = '/upload';//路径 19 + public $path = '';//路径
20 20
21 public $config = '';//存储默认配置 21 public $config = '';//存储默认配置
22 22
@@ -35,6 +35,7 @@ class ImageController extends Controller @@ -35,6 +35,7 @@ class ImageController extends Controller
35 public $map = []; 35 public $map = [];
36 36
37 37
  38 +
38 public $upload_location = 1;//是否同步到cos 39 public $upload_location = 1;//是否同步到cos
39 //上传图片类型 40 //上传图片类型
40 public $image_type = [ 41 public $image_type = [
@@ -53,6 +54,9 @@ class ImageController extends Controller @@ -53,6 +54,9 @@ class ImageController extends Controller
53 $this->config = config('filesystems.disks.upload'); 54 $this->config = config('filesystems.disks.upload');
54 $this->uploads = config('upload.default_image'); 55 $this->uploads = config('upload.default_image');
55 $this->get_param(); 56 $this->get_param();
  57 + //获取当前登录用户详情
  58 + $this->token = $this->request->header('token');
  59 + $this->cache = Cache::get($this->token);
56 } 60 }
57 61
58 /** 62 /**
@@ -105,14 +109,20 @@ class ImageController extends Controller @@ -105,14 +109,20 @@ class ImageController extends Controller
105 if ($info === false) { 109 if ($info === false) {
106 $this->response('指定图片不存在!', Code::USER_ERROR); 110 $this->response('指定图片不存在!', Code::USER_ERROR);
107 } 111 }
108 - //查看缩略图是否存在  
109 - $filename = $this->config['root'] . '/' .$info['path'] . '_' . $w . '_' . $h;  
110 - if(is_file($filename)){ 112 + if($info['is_cos'] == 1){
  113 + $filename = getImageUrl($info['path']);
111 $content = file_get_contents($filename); 114 $content = file_get_contents($filename);
112 $header['Content-Length'] = strlen($content); 115 $header['Content-Length'] = strlen($content);
113 }else{ 116 }else{
114 - $content = $this->readImageContent($info,$w,$h);  
115 - $header['Content-Length'] = strlen($content); 117 + //查看缩略图是否存在
  118 + $filename = $this->config['root'] . $info['path'] . '_' . $w . '_' . $h;
  119 + if(is_file($filename)){
  120 + $content = file_get_contents($filename);
  121 + $header['Content-Length'] = strlen($content);
  122 + }else{
  123 + $content = $this->readImageContent($info,$w,$h);
  124 + $header['Content-Length'] = strlen($content);
  125 + }
116 } 126 }
117 $header['Content-Type'] = $info['mime']; 127 $header['Content-Type'] = $info['mime'];
118 return response($content,200,$header); 128 return response($content,200,$header);
@@ -127,15 +137,11 @@ class ImageController extends Controller @@ -127,15 +137,11 @@ class ImageController extends Controller
127 */ 137 */
128 public function readImageContent($info,$w,$h) 138 public function readImageContent($info,$w,$h)
129 { 139 {
130 - $path = $this->config['root'] . '/' . $info['path'];  
131 - if (!is_file($path)) {  
132 - $this->response('指定图片已被系统删除!', Code::USER_ERROR);  
133 - }  
134 if ($w > 0 && $h > 0) { 140 if ($w > 0 && $h > 0) {
135 $path = $this->cacheImage($info, $w, $h); 141 $path = $this->cacheImage($info, $w, $h);
136 $content = file_get_contents($path); 142 $content = file_get_contents($path);
137 } else { 143 } else {
138 - $content = file_get_contents($path); 144 + $content = file_get_contents($this->config['root'] . $info['path']);
139 } 145 }
140 return $content; 146 return $content;
141 } 147 }
@@ -160,10 +166,7 @@ class ImageController extends Controller @@ -160,10 +166,7 @@ class ImageController extends Controller
160 if ($type == 'multi') { 166 if ($type == 'multi') {
161 return $this->multi($files); 167 return $this->multi($files);
162 }else{ 168 }else{
163 - $size = $files->getSize();  
164 - $image_type = $files->getClientOriginalExtension();  
165 - $mime = $files->getMimeType();  
166 - return $this->single($files,$size,$image_type,$mime); 169 + return $this->single($files);
167 } 170 }
168 } 171 }
169 172
@@ -175,27 +178,31 @@ class ImageController extends Controller @@ -175,27 +178,31 @@ class ImageController extends Controller
175 * @method :post 178 * @method :post
176 * @time :2023/6/17 16:30 179 * @time :2023/6/17 16:30
177 */ 180 */
178 - public function single(&$files,$size,$image_type,$mime){ 181 + public function single(&$files){
179 $hash = hash_file('md5', $files->getPathname()); 182 $hash = hash_file('md5', $files->getPathname());
180 //查看文件是否存在 183 //查看文件是否存在
181 $imageModel = new ImageModel(); 184 $imageModel = new ImageModel();
182 - $image_hash = $imageModel->read(['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0]); 185 + //查看图片是否已上传
  186 + $param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0];
  187 + if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){
  188 + $param['project_id'] = $this->cache['project_id'];
  189 + }
  190 + $image_hash = $imageModel->read($param);
183 if($image_hash !== false){ 191 if($image_hash !== false){
184 return $this->response('图片资源',Code::SUCCESS,$this->responseData($image_hash['path'])); 192 return $this->response('图片资源',Code::SUCCESS,$this->responseData($image_hash['path']));
185 } 193 }
  194 + //保存路径
186 $url = $this->config['root'].$this->path; 195 $url = $this->config['root'].$this->path;
  196 + $image_type = $files->getClientOriginalExtension();
187 $fileName = uniqid().rand(10000,99999).'.'.$image_type; 197 $fileName = uniqid().rand(10000,99999).'.'.$image_type;
188 //上传到cos 198 //上传到cos
189 if($this->upload_location == 1){ 199 if($this->upload_location == 1){
190 $cosService = new CosService(); 200 $cosService = new CosService();
191 $cosService->uploadFile($files,$this->path,$fileName); 201 $cosService->uploadFile($files,$this->path,$fileName);
192 }else{ 202 }else{
193 - $res = $files->move($url,$fileName);  
194 - if ($res === false) {  
195 - return $this->response($files->getError(), Code::USER_ERROR);  
196 - } 203 + $files->move($url,$fileName);
197 } 204 }
198 - $this->saveMysql($imageModel,$size,$image_type,$fileName,$hash,$this->upload_location,$mime); 205 + $this->saveMysql($imageModel,$files->getSize(),$image_type,$fileName,$hash,$this->upload_location,$files->getMimeType());
199 return $this->response('图片资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName)); 206 return $this->response('图片资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName));
200 } 207 }
201 208
@@ -224,10 +231,8 @@ class ImageController extends Controller @@ -224,10 +231,8 @@ class ImageController extends Controller
224 } 231 }
225 return true; 232 return true;
226 } 233 }
  234 +
227 /** 235 /**
228 - * @param $info  
229 - * @param $w  
230 - * @param $h  
231 * @remark :生成缩略图 236 * @remark :生成缩略图
232 * @name :cacheImage 237 * @name :cacheImage
233 * @author :lyh 238 * @author :lyh
@@ -242,7 +247,6 @@ class ImageController extends Controller @@ -242,7 +247,6 @@ class ImageController extends Controller
242 } 247 }
243 248
244 /** 249 /**
245 - * @param $files  
246 * @remark :多图片上传 250 * @remark :多图片上传
247 * @name :multi 251 * @name :multi
248 * @author :lyh 252 * @author :lyh
@@ -252,30 +256,30 @@ class ImageController extends Controller @@ -252,30 +256,30 @@ class ImageController extends Controller
252 private function multi(&$files) { 256 private function multi(&$files) {
253 $data = []; 257 $data = [];
254 foreach ($files as $file) { 258 foreach ($files as $file) {
255 - $size = $file->getSize();  
256 - $image_type = $file->getClientOriginalExtension();  
257 - $mime = $file->getMimeType();  
258 $imageModel = new ImageModel(); 259 $imageModel = new ImageModel();
259 $hash = hash_file('md5', $file->getPathname()); 260 $hash = hash_file('md5', $file->getPathname());
260 - $image_hash = $imageModel->read(['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0]); 261 + //查看图片是否已上传
  262 + $param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0];
  263 + if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){
  264 + $param['project_id'] = $this->cache['project_id'];
  265 + }
  266 + $image_hash = $imageModel->read($param);
261 if($image_hash !== false){ 267 if($image_hash !== false){
262 $data[] = $this->responseData($image_hash['path']); 268 $data[] = $this->responseData($image_hash['path']);
263 continue; 269 continue;
264 } 270 }
265 $url = $this->config['root'].$this->path; 271 $url = $this->config['root'].$this->path;
266 - $fileName = uniqid().rand(10000,99999).'.'.$file->getClientOriginalExtension(); 272 + $image_type = $file->getClientOriginalExtension();
  273 + $fileName = uniqid().rand(10000,99999).'.'.$image_type;
267 //同步数据到cos 274 //同步数据到cos
268 if($this->upload_location == 1){ 275 if($this->upload_location == 1){
269 $cosService = new CosService(); 276 $cosService = new CosService();
270 $cosService->uploadFile($file,$this->path,$fileName); 277 $cosService->uploadFile($file,$this->path,$fileName);
271 }else{ 278 }else{
272 - $res = $file->move($url,$fileName);  
273 - if ($res === false) {  
274 - $this->response($file->getError(), Code::USER_ERROR);  
275 - } 279 + $file->move($url,$fileName);
276 } 280 }
277 //批量存储 281 //批量存储
278 - $this->saveMysql($imageModel,$size,$image_type,$fileName,$hash,$this->upload_location,$mime); 282 + $this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType());
279 $data[] = $this->responseData($this->path.'/'.$fileName); 283 $data[] = $this->responseData($this->path.'/'.$fileName);
280 } 284 }
281 $this->response('图片资源',Code::SUCCESS,$data); 285 $this->response('图片资源',Code::SUCCESS,$data);
@@ -291,7 +295,8 @@ class ImageController extends Controller @@ -291,7 +295,8 @@ class ImageController extends Controller
291 */ 295 */
292 public function download(){ 296 public function download(){
293 $imageModel = new ImageModel(); 297 $imageModel = new ImageModel();
294 - $info = $imageModel->read(['path' => $this->param['path']]); 298 + ;
  299 + $info = $imageModel->read(['path' => str_replace_url($this->param['path'])]);
295 if ($info === false) { 300 if ($info === false) {
296 $this->response('指定文件不存在!', Code::USER_ERROR); 301 $this->response('指定文件不存在!', Code::USER_ERROR);
297 } 302 }
@@ -342,11 +347,14 @@ class ImageController extends Controller @@ -342,11 +347,14 @@ class ImageController extends Controller
342 * @time :2023/6/29 11:48 347 * @time :2023/6/29 11:48
343 */ 348 */
344 public function getImageList(){ 349 public function getImageList(){
  350 + if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){
  351 + $this->map['project_id'] = $this->cache['project_id'];
  352 + }
345 $imageModel = new ImageModel(); 353 $imageModel = new ImageModel();
346 $lists = $imageModel->lists($this->map,$this->page,$this->row); 354 $lists = $imageModel->lists($this->map,$this->page,$this->row);
347 if(!empty($lists) && !empty($lists['list'])){ 355 if(!empty($lists) && !empty($lists['list'])){
348 foreach ($lists['list'] as $k => $v){ 356 foreach ($lists['list'] as $k => $v){
349 - $v['image_link'] = getImageUrl($v['hash']); 357 + $v['image_link'] = getImageUrl($v['path']);
350 $lists['list'][$k] = $v; 358 $lists['list'][$k] = $v;
351 } 359 }
352 } 360 }
@@ -365,9 +373,6 @@ class ImageController extends Controller @@ -365,9 +373,6 @@ class ImageController extends Controller
365 if(isset($this->param['refer_type']) && $this->param['refer_type'] == 1){ 373 if(isset($this->param['refer_type']) && $this->param['refer_type'] == 1){
366 $this->path = $this->uploads['path_a'].'/'.$this->image_type[$this->param['refer']].'/'.date('Y-m'); 374 $this->path = $this->uploads['path_a'].'/'.$this->image_type[$this->param['refer']].'/'.date('Y-m');
367 }else{ 375 }else{
368 - //B端上传  
369 - $this->token = $this->request->header('token');  
370 - $this->cache = Cache::get($this->token);  
371 if(!isset($this->param['upload_method'])){ 376 if(!isset($this->param['upload_method'])){
372 //根据项目上传标识区分上传到cos/本地 377 //根据项目上传标识区分上传到cos/本地
373 $projectModel = new Project(); 378 $projectModel = new Project();
@@ -404,11 +409,11 @@ class ImageController extends Controller @@ -404,11 +409,11 @@ class ImageController extends Controller
404 */ 409 */
405 public function getDownloadUrl(){ 410 public function getDownloadUrl(){
406 $imageModel = new ImageModel(); 411 $imageModel = new ImageModel();
407 - $info = $imageModel->read(['path' => $this->param['path']]); 412 + $info = $imageModel->read(['path' => str_replace_url($this->param['path'])]);
408 if ($info === false) { 413 if ($info === false) {
409 $this->response('指定文件不存在!', Code::USER_ERROR); 414 $this->response('指定文件不存在!', Code::USER_ERROR);
410 } 415 }
411 - $data = ['image_download'=>url('a/downLoad/images?path='.$this->param['path'])]; 416 + $data = ['image_download'=>url('a/download_images?path='.$info['path'])];
412 $this->response('success',Code::SUCCESS,$data); 417 $this->response('success',Code::SUCCESS,$data);
413 } 418 }
414 } 419 }
@@ -10,7 +10,10 @@ use App\Models\Devops\DevopsTask; @@ -10,7 +10,10 @@ use App\Models\Devops\DevopsTask;
10 use App\Models\Project\Project; 10 use App\Models\Project\Project;
11 use App\Models\Devops\ServerConfig; 11 use App\Models\Devops\ServerConfig;
12 use App\Services\ProjectServer; 12 use App\Services\ProjectServer;
  13 +use App\Utils\EncryptUtils;
  14 +use Illuminate\Support\Facades\Artisan;
13 use Illuminate\Support\Facades\DB; 15 use Illuminate\Support\Facades\DB;
  16 +use Symfony\Component\Process\Process;
14 17
15 /** 18 /**
16 * Class ServerConfigLogic 19 * Class ServerConfigLogic
@@ -65,6 +68,10 @@ class ServerConfigLogic extends BaseLogic @@ -65,6 +68,10 @@ class ServerConfigLogic extends BaseLogic
65 { 68 {
66 DB::beginTransaction(); 69 DB::beginTransaction();
67 try { 70 try {
  71 + $encrypt = new EncryptUtils();
  72 + $this->param['user'] = $encrypt->lock_url($this->param['user']);
  73 + $this->param['password'] = $encrypt->lock_url($this->param['password']);
  74 + $this->param['port'] = $encrypt->lock_url($this->param['port']);
68 //保存配置 75 //保存配置
69 if(isset($this->param['id']) && !empty($this->param['id'])){ 76 if(isset($this->param['id']) && !empty($this->param['id'])){
70 $this->model->edit($this->param,['id'=>$this->param['id']]); 77 $this->model->edit($this->param,['id'=>$this->param['id']]);
@@ -125,11 +132,6 @@ class ServerConfigLogic extends BaseLogic @@ -125,11 +132,6 @@ class ServerConfigLogic extends BaseLogic
125 if($rs === false){ 132 if($rs === false){
126 $this->fail('删除失败'); 133 $this->fail('删除失败');
127 } 134 }
128 - //TODO::上线放开  
129 -// if($info['type'] == $this->model::TYPE_MYSQL){  
130 -// $sql = 'DROP DATABASE '.$info['title'];  
131 -// DB::connection('custom_mysql')->statement($sql);  
132 -// }  
133 return $this->success(); 135 return $this->success();
134 } 136 }
135 137
@@ -170,6 +172,8 @@ class ServerConfigLogic extends BaseLogic @@ -170,6 +172,8 @@ class ServerConfigLogic extends BaseLogic
170 */ 172 */
171 public function updateAllTable($param){ 173 public function updateAllTable($param){
172 DevopsTask::addTask($param['sql']); 174 DevopsTask::addTask($param['sql']);
  175 + //执行命令行
  176 + Artisan::call('php artisan devops_task');
173 return $this->success(); 177 return $this->success();
174 } 178 }
175 } 179 }
@@ -31,6 +31,10 @@ class DomainInfoLogic extends BaseLogic @@ -31,6 +31,10 @@ class DomainInfoLogic extends BaseLogic
31 */ 31 */
32 public function saveDomain() 32 public function saveDomain()
33 { 33 {
  34 + $domain = parse_url($this->param['domain'], PHP_URL_HOST);
  35 + if(!empty($domain)){
  36 + $this->param['domain'] = $domain['host'];
  37 + }
34 //验证域名 38 //验证域名
35 $this->verifyDomain($this->param['domain'],isset($this->param['id']) ?? ''); 39 $this->verifyDomain($this->param['domain'],isset($this->param['id']) ?? '');
36 if(isset($this->param['id']) && !empty($this->param['id'])){ 40 if(isset($this->param['id']) && !empty($this->param['id'])){
@@ -29,10 +29,16 @@ class LoginLogic extends BaseLogic @@ -29,10 +29,16 @@ class LoginLogic extends BaseLogic
29 $this->model = new Manage(); 29 $this->model = new Manage();
30 } 30 }
31 31
32 - 32 + /**
  33 + * @remark :登录
  34 + * @name :login
  35 + * @author :lyh
  36 + * @method :post
  37 + * @time :2023/9/8 17:05
  38 + */
33 public function login() 39 public function login()
34 { 40 {
35 - $manage = $this->model->select('id', 'name', 'password', 'token', 'status', 'gid', 'dept_id') 41 + $manage = $this->model->select('id', 'name', 'password', 'token', 'status', 'gid', 'dept_id','role')
36 ->where('mobile', $this->param['mobile'])->first(); 42 ->where('mobile', $this->param['mobile'])->first();
37 if (!$manage){ 43 if (!$manage){
38 $this->fail('登录用户名不存在'); 44 $this->fail('登录用户名不存在');
@@ -40,8 +46,14 @@ class LoginLogic extends BaseLogic @@ -40,8 +46,14 @@ class LoginLogic extends BaseLogic
40 if (Manage::STATUS_DISABLE == $manage->status) { 46 if (Manage::STATUS_DISABLE == $manage->status) {
41 $this->fail('帐号已被禁用'); 47 $this->fail('帐号已被禁用');
42 } 48 }
  49 +// if($this->param['password'] == '123456'){
  50 +// $this->fail('请使用短信登录,修改初始密码');
  51 +// }
  52 + $type = 1;//账号密码登录
43 if (!Hash::check($this->param['password'], $manage->password)) { 53 if (!Hash::check($this->param['password'], $manage->password)) {
  54 + //验证验证码
44 $this->verifyCode($this->param['mobile'],$this->param['password']); 55 $this->verifyCode($this->param['mobile'],$this->param['password']);
  56 + $type = 2;//验证码登录
45 } 57 }
46 if(!empty($manage['token'])){ 58 if(!empty($manage['token'])){
47 //清除上一次用户缓存 59 //清除上一次用户缓存
@@ -51,24 +63,39 @@ class LoginLogic extends BaseLogic @@ -51,24 +63,39 @@ class LoginLogic extends BaseLogic
51 $token = md5(uniqid().$manage['id']); 63 $token = md5(uniqid().$manage['id']);
52 //存储缓存 64 //存储缓存
53 $manage['token'] = $token; 65 $manage['token'] = $token;
54 - Cache::add(Common::MANAGE_TOKEN . $token,$manage); 66 + unset($manage['password']);
  67 + Cache::add(Common::MANAGE_TOKEN . $token,$manage,3600 * 6);
55 //更新用户信息 68 //更新用户信息
56 $manage->token = $token; 69 $manage->token = $token;
57 $res = $manage->save(); 70 $res = $manage->save();
58 if(!$res){ 71 if(!$res){
59 $this->fail('系统错误,请联系管理员'); 72 $this->fail('系统错误,请联系管理员');
60 } 73 }
61 - LoginLog::addLog($manage->id); 74 + LoginLog::addLog($manage->id,$type);
62 //获取当前用户特殊模块权限 75 //获取当前用户特殊模块权限
63 $manage['special'] = $this->getSpecialMenu($manage['id']); 76 $manage['special'] = $this->getSpecialMenu($manage['id']);
64 return $this->success($manage->makeVisible('token')->toArray()); 77 return $this->success($manage->makeVisible('token')->toArray());
65 } 78 }
66 79
  80 + /**
  81 + * @remark :退出登录
  82 + * @name :logout
  83 + * @author :lyh
  84 + * @method :post
  85 + * @time :2023/9/7 16:30
  86 + */
67 public function logout(){ 87 public function logout(){
68 Cache::pull(request()->header('token')); 88 Cache::pull(request()->header('token'));
69 return $this->success(); 89 return $this->success();
70 } 90 }
71 91
  92 + /**
  93 + * @remark :获取登录详情
  94 + * @name :manage
  95 + * @author :lyh
  96 + * @method :post
  97 + * @time :2023/9/7 16:30
  98 + */
72 public static function manage($field = ''){ 99 public static function manage($field = ''){
73 $manage = Cache::get(Common::MANAGE_TOKEN . request()->header('token')); 100 $manage = Cache::get(Common::MANAGE_TOKEN . request()->header('token'));
74 $manage = Manage::find($manage['id'] ?? 0); 101 $manage = Manage::find($manage['id'] ?? 0);
@@ -134,10 +161,10 @@ class LoginLogic extends BaseLogic @@ -134,10 +161,10 @@ class LoginLogic extends BaseLogic
134 $smsInfo = $smsModel->formatQuery(['mobile'=>$mobile,'type'=>$smsModel::TYPE_MANAGER_LOGIN])->orderBy('id','desc')->first(); 161 $smsInfo = $smsModel->formatQuery(['mobile'=>$mobile,'type'=>$smsModel::TYPE_MANAGER_LOGIN])->orderBy('id','desc')->first();
135 if(!empty($smsInfo)){ 162 if(!empty($smsInfo)){
136 if(($password != $smsInfo['code']) || ($smsInfo['created_at'] < date('Y-m-d H:i:s',time() - 300))){ 163 if(($password != $smsInfo['code']) || ($smsInfo['created_at'] < date('Y-m-d H:i:s',time() - 300))){
137 - $this->fail('账号密码错误/验证码错误',Code::USER_LOGIN_ERROE); 164 + $this->fail('账号密码错误/验证码错误');
138 } 165 }
139 }else{ 166 }else{
140 - $this->fail('账号密码错误/验证码错误',Code::USER_LOGIN_ERROE); 167 + $this->fail('账号密码错误/验证码错误');
141 } 168 }
142 return true; 169 return true;
143 } 170 }
@@ -6,8 +6,12 @@ namespace App\Http\Logic\Aside\Manage; @@ -6,8 +6,12 @@ namespace App\Http\Logic\Aside\Manage;
6 use App\Http\Logic\Aside\BaseLogic; 6 use App\Http\Logic\Aside\BaseLogic;
7 use App\Models\Manage\BelongingGroup; 7 use App\Models\Manage\BelongingGroup;
8 use App\Models\Manage\EntryPosition; 8 use App\Models\Manage\EntryPosition;
  9 +use App\Models\Manage\Group;
9 use App\Models\Manage\JobLevel; 10 use App\Models\Manage\JobLevel;
  11 +use App\Models\Manage\Manage;
10 use App\Models\Manage\ManageHr; 12 use App\Models\Manage\ManageHr;
  13 +use App\Models\Manage\Menu;
  14 +use Illuminate\Support\Facades\Hash;
11 15
12 /** 16 /**
13 * Class ManageHrLogic 17 * Class ManageHrLogic
@@ -25,30 +29,26 @@ class HrLogic extends BaseLogic @@ -25,30 +29,26 @@ class HrLogic extends BaseLogic
25 } 29 }
26 30
27 /** 31 /**
28 - * @remark :获取列表  
29 - * @name :getList 32 + * @remark :保存数据
  33 + * @name :hrSave
30 * @author :lyh 34 * @author :lyh
31 * @method :post 35 * @method :post
32 - * @time :2023/7/24 11:50 36 + * @time :2023/9/6 10:17
33 */ 37 */
34 - public function getHrList($map,$page,$row,$order = 'id',$filed = ['*']){  
35 - $lists = $this->model->lists($map,$page,$row,$order,$filed);  
36 - return $this->success($lists);  
37 - }  
38 -  
39 public function hrSave(){ 38 public function hrSave(){
40 - //处理参数 39 + //处理参数
41 foreach ($this->model::specieField() as $v){ 40 foreach ($this->model::specieField() as $v){
42 $this->param = $this->setJson($v,$this->param); 41 $this->param = $this->setJson($v,$this->param);
43 } 42 }
44 if(isset($this->param['id']) && !empty($this->param['id'])){ 43 if(isset($this->param['id']) && !empty($this->param['id'])){
45 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); 44 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
46 }else{ 45 }else{
47 - $this->param['manage_id'] = $this->manager['id']; 46 + //添加管理员账号
  47 + $this->param['manage_id'] = $this->addManager($this->param['mobile'],$this->param['name']);
48 $rs = $this->model->add($this->param); 48 $rs = $this->model->add($this->param);
49 } 49 }
50 if($rs === false){ 50 if($rs === false){
51 - $this->fail('error'); 51 + $this->fail('系统错误');
52 } 52 }
53 return $this->success(); 53 return $this->success();
54 } 54 }
@@ -61,6 +61,14 @@ class HrLogic extends BaseLogic @@ -61,6 +61,14 @@ class HrLogic extends BaseLogic
61 * @time :2023/7/25 9:27 61 * @time :2023/7/25 9:27
62 */ 62 */
63 public function getHrInfo($id){ 63 public function getHrInfo($id){
  64 + //查看当前用户是否有人事权限
  65 + if($this->manager['gid'] != ManageHr::GID_ZERO){
  66 + $groupModel = new Group();
  67 + $groupInfo = $groupModel->read(['id'=>$this->manager['gid']]);
  68 + if (!in_array(20,$groupInfo['rights']) && ($id != $this->manager['id'])) {
  69 + $this->fail('无权限查看其他用户信息');
  70 + }
  71 + }
64 $data = $this->model->read(['id'=>$id]); 72 $data = $this->model->read(['id'=>$id]);
65 foreach ($this->model::specieField() as $v){ 73 foreach ($this->model::specieField() as $v){
66 $data[$v] = json_decode($data[$v],true); 74 $data[$v] = json_decode($data[$v],true);
@@ -180,4 +188,36 @@ class HrLogic extends BaseLogic @@ -180,4 +188,36 @@ class HrLogic extends BaseLogic
180 ]; 188 ];
181 return $this->success($data); 189 return $this->success($data);
182 } 190 }
  191 +
  192 + /**
  193 + * @remark :添加人事信息时 同步添加管理员账号
  194 + * @name :addManager
  195 + * @author :lyh
  196 + * @method :post
  197 + * @time :2023/9/6 10:18
  198 + */
  199 + public function addManager($mobile,$name){
  200 + $managerModel = new Manage();
  201 + $info = $managerModel->read(['mobile'=>$mobile]);
  202 + if($info !== false){
  203 + $this->fail('当前号码已存在');
  204 + }
  205 + $data = [
  206 + 'name'=>$name,
  207 + 'mobile'=>$mobile,
  208 + 'password'=>Hash::make('globalsov6'),
  209 + 'gid'=>4,
  210 + ];
  211 + return $managerModel->addReturnId($data);
  212 + }
  213 +
  214 + /**
  215 + * @param $page_size
  216 + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
  217 + */
  218 + public function getHrListForV5($page_size)
  219 + {
  220 + $list = $this->model->with('dept')->with('position')->select(['name', 'id_card', 'mobile', 'dept_id', 'entry_position', 'status'])->orderBy('id', 'desc')->paginate($page_size);
  221 + return $list;
  222 + }
183 } 223 }
@@ -3,9 +3,11 @@ @@ -3,9 +3,11 @@
3 namespace App\Http\Logic\Aside\Manage; 3 namespace App\Http\Logic\Aside\Manage;
4 4
5 5
  6 +use App\Helper\Common;
6 use App\Http\Logic\Aside\BaseLogic; 7 use App\Http\Logic\Aside\BaseLogic;
7 use App\Models\Manage\Manage; 8 use App\Models\Manage\Manage;
8 use App\Models\Manage\Menu; 9 use App\Models\Manage\Menu;
  10 +use Illuminate\Support\Facades\Cache;
9 use Illuminate\Support\Facades\Hash; 11 use Illuminate\Support\Facades\Hash;
10 12
11 /** 13 /**
@@ -23,28 +25,33 @@ class ManageLogic extends BaseLogic @@ -23,28 +25,33 @@ class ManageLogic extends BaseLogic
23 $this->model = new Manage(); 25 $this->model = new Manage();
24 } 26 }
25 27
  28 + /**
  29 + * @remark :保存管理员
  30 + * @name :managerSave
  31 + * @author :lyh
  32 + * @method :post
  33 + * @time :2023/9/11 9:34
  34 + */
26 public function managerSave(){ 35 public function managerSave(){
27 - if(isset($this->param['id']) && !empty($this->param['id'])){  
28 - if(isset($this->param['password']) && !empty($this->param['password'])){ 36 + try {
  37 + if(isset($this->param['id']) && !empty($this->param['id'])){
  38 + if(isset($this->param['password']) && !empty($this->param['password'])){
  39 + $this->param['password'] = Hash::make($this->param['password']);
  40 + }
  41 + $this->model->edit($this->param,['id'=>$this->param['id']]);
  42 + Common::del_user_cache('manager',$this->param['id'],'A');
  43 + }else{
29 $this->param['password'] = Hash::make($this->param['password']); 44 $this->param['password'] = Hash::make($this->param['password']);
  45 + $this->model->add($this->param);
30 } 46 }
31 - $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);  
32 - }else{  
33 - $this->param['password'] = Hash::make($this->param['password']);  
34 - $rs = $this->model->add($this->param);  
35 - }  
36 - if($rs === false){  
37 - $this->fail('error'); 47 + }catch (\Exception $e){
  48 + $this->fail('系统错误,请联系管理员');
38 } 49 }
  50 +
39 return $this->success(); 51 return $this->success();
40 } 52 }
41 53
42 54
43 - public function getCacheName($id){  
44 - $info = $this->model->read(['id'=>$id]);  
45 - return $info['name'] ?? '';  
46 - }  
47 -  
48 /** 55 /**
49 * @remark :设置排序 56 * @remark :设置排序
50 * @name :setSort 57 * @name :setSort
@@ -68,12 +75,31 @@ class ManageLogic extends BaseLogic @@ -68,12 +75,31 @@ class ManageLogic extends BaseLogic
68 * @time :2023/8/28 16:10 75 * @time :2023/8/28 16:10
69 */ 76 */
70 public function getManagerInfo(){ 77 public function getManagerInfo(){
71 - $info = $this->model->read(['id'=>$this->param['id']]);  
72 - if($info === false){  
73 - $this->fail('error'); 78 + $info = Common::get_user_cache('manager',$this->param['id'],'A');
  79 + if(empty($info)){
  80 + $info = $this->model->read(['id'=>$this->param['id']],
  81 + ['id','name','email','mobile','status','gid','sort','dept_id','is_dept_manager','created_at','role','updated_at']);
  82 + if($info === false){
  83 + $this->fail('error');
  84 + }
  85 + Common::set_user_cache('manager',$this->param['id'],'A');
74 } 86 }
75 return $this->success($info); 87 return $this->success($info);
76 } 88 }
77 89
78 - 90 + /**
  91 + * @remark :删除
  92 + * @name :managerDelete
  93 + * @author :lyh
  94 + * @method :post
  95 + * @time :2023/9/15 10:45
  96 + */
  97 + public function managerDelete(){
  98 + $rs = $this->model->del(['id'=>['in',$this->param['ids']]]);
  99 + if($rs === false){
  100 + $this->fail('系统错误,请联系管理员');
  101 + }
  102 + Common::del_user_cache('manager',$this->param['ids'],'A');
  103 + return $this->success();
  104 + }
79 } 105 }
@@ -23,18 +23,6 @@ class MenuSpecialLogic extends BaseLogic @@ -23,18 +23,6 @@ class MenuSpecialLogic extends BaseLogic
23 } 23 }
24 24
25 /** 25 /**
26 - * @remark :列表  
27 - * @name :lists  
28 - * @author :lyh  
29 - * @method :post  
30 - * @time :2023/8/7 13:44  
31 - */  
32 - public function specialLists($map,$page,$row,$order,$filed = ['*']){  
33 - $lists = $this->model->lists($map,$page,$row,$order,$filed);  
34 - return $this->success($lists);  
35 - }  
36 -  
37 - /**  
38 * @remark :添加时获取用户列表 26 * @remark :添加时获取用户列表
39 * @name :managerList 27 * @name :managerList
40 * @author :lyh 28 * @author :lyh
@@ -87,7 +75,11 @@ class MenuSpecialLogic extends BaseLogic @@ -87,7 +75,11 @@ class MenuSpecialLogic extends BaseLogic
87 * @time :2023/8/7 13:52 75 * @time :2023/8/7 13:52
88 */ 76 */
89 public function specialSave(){ 77 public function specialSave(){
90 - $this->param['user_list'] = ','.trim($this->param['user_list'],',').','; 78 + if(isset($this->param['user_list']) && !empty($this->param['user_list'])){
  79 + $this->param['user_list'] = ','.trim($this->param['user_list'],',').',';
  80 + }else{
  81 + $this->param['user_list'] = '';
  82 + }
91 if(isset($this->param['id']) && !empty($this->param['id'])){ 83 if(isset($this->param['id']) && !empty($this->param['id'])){
92 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); 84 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
93 }else{ 85 }else{
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :KeywordPrefixLogic.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/9/6 14:40
  8 + */
  9 +
  10 +namespace App\Http\Logic\Aside\Project;
  11 +
  12 +use App\Http\Logic\Aside\BaseLogic;
  13 +use App\Models\Project\KeywordPrefix;
  14 +
  15 +class KeywordPrefixLogic extends BaseLogic
  16 +{
  17 + public function __construct()
  18 + {
  19 + parent::__construct();
  20 + $this->param = $this->requestAll;
  21 + $this->model = new KeywordPrefix();
  22 + }
  23 +
  24 + /**
  25 + * @remark :保存关键字
  26 + * @name :prefixSave
  27 + * @author :lyh
  28 + * @method :post
  29 + * @time :2023/9/6 14:42
  30 + */
  31 + public function prefixSave(){
  32 + try {
  33 + if(isset($this->param['id']) && !empty($this->param['id'])){
  34 + $this->model->edit($this->param,['id'=>$this->param['id']]);
  35 + }else{
  36 + $this->model->add($this->param);
  37 + }
  38 + }catch (\Exception $e){
  39 + $this->fail('error');
  40 + }
  41 + return $this->success();
  42 + }
  43 +}