Merge remote-tracking branch 'origin/develop' into akun
正在显示
81 个修改的文件
包含
2327 行增加
和
686 行删除
| @@ -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,25 +43,37 @@ class Count extends Command | @@ -39,25 +43,37 @@ 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(); | 46 | + ->select($this->selectParam())->get(); |
| 47 | + try { | ||
| 48 | + if(!empty($list)){ | ||
| 49 | + $list = $list->toArray(); | ||
| 43 | $data = []; | 50 | $data = []; |
| 44 | $yesterday = Carbon::yesterday()->toDateString(); | 51 | $yesterday = Carbon::yesterday()->toDateString(); |
| 52 | + $domainInfo = new DomainInfo(); | ||
| 45 | foreach ($list as $v){ | 53 | foreach ($list as $v){ |
| 46 | $v = (array)$v; | 54 | $v = (array)$v; |
| 47 | - if($v['domain'] != ''){ | ||
| 48 | - $v['test_domain'] = $v['domain']; | 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 | + } | ||
| 49 | } | 63 | } |
| 50 | $arr = []; | 64 | $arr = []; |
| 51 | //统计时间 | 65 | //统计时间 |
| 52 | $arr['date'] = $yesterday; | 66 | $arr['date'] = $yesterday; |
| 67 | + ProjectServer::useProject($v['id']); | ||
| 53 | //pv统计 | 68 | //pv统计 |
| 54 | $arr['pv_num'] = $this->pv_num($yesterday,$v['test_domain']); | 69 | $arr['pv_num'] = $this->pv_num($yesterday,$v['test_domain']); |
| 55 | //ip统计 | 70 | //ip统计 |
| 56 | $arr['ip_num'] = $this->ip_num($yesterday,$v['test_domain']); | 71 | $arr['ip_num'] = $this->ip_num($yesterday,$v['test_domain']); |
| 72 | + DB::disconnect('custom_mysql'); | ||
| 57 | //服务达标天数 | 73 | //服务达标天数 |
| 58 | - $arr['compliance_day'] = $this->compliance_day($v['test_domain']); | 74 | + $arr['compliance_day'] = $this->compliance_day($v['id']); |
| 59 | //剩余服务时常 | 75 | //剩余服务时常 |
| 60 | - $arr['service_day'] = ((int)$v['service_duration'] - (int)$arr['compliance_day']) > 0 ? ((int)$v['service_duration'] - (int)$arr['compliance_day']) : 0; | 76 | + $arr['service_day'] = $v['remain_day']; |
| 61 | //项目id | 77 | //项目id |
| 62 | $arr['project_id'] = $v['project_id']; | 78 | $arr['project_id'] = $v['project_id']; |
| 63 | $arr['created_at'] = date('Y-m-d H:i:s'); | 79 | $arr['created_at'] = date('Y-m-d H:i:s'); |
| @@ -68,6 +84,10 @@ class Count extends Command | @@ -68,6 +84,10 @@ class Count extends Command | ||
| 68 | } | 84 | } |
| 69 | //判断数据是否存在 | 85 | //判断数据是否存在 |
| 70 | DB::table('gl_count')->insert($data); | 86 | DB::table('gl_count')->insert($data); |
| 87 | + } | ||
| 88 | + }catch (\Exception $e){ | ||
| 89 | + Log::error('同步数据执行失败'); | ||
| 90 | + } | ||
| 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 = []; |
app/Console/Commands/Domain/DomainInfo.php
0 → 100644
| 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(); |
| 109 | + if(!empty($v['p_level'])){ | ||
| 104 | $p_level = $jobLevelModel->read(['name'=>$v['p_level']]); | 110 | $p_level = $jobLevelModel->read(['name'=>$v['p_level']]); |
| 105 | - if($entry_position !== false){ | 111 | + if($p_level !== false){ |
| 106 | $p_level = $p_level['id']; | 112 | $p_level = $p_level['id']; |
| 107 | }else{ | 113 | }else{ |
| 108 | - $p_level = ''; | 114 | + $p_level = 0; |
| 115 | + } | ||
| 116 | + }else{ | ||
| 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; |
app/Console/Commands/LastInquiry.php
0 → 100644
| 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'] != ''){ | 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){ | ||
| 47 | $value['test_domain'] = $value['domain']; | 56 | $value['test_domain'] = $value['domain']; |
| 48 | } | 57 | } |
| 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,13 @@ class RankData extends BaseCommands | @@ -141,11 +144,13 @@ 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 | if($first_page_num >= $keyword_num){ |
| 148 | $model->compliance_day = $model->compliance_day + 1; | 152 | $model->compliance_day = $model->compliance_day + 1; |
| 153 | + $model->is_compliance = 1; | ||
| 149 | } | 154 | } |
| 150 | } | 155 | } |
| 151 | 156 |
| @@ -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()) { |
app/Console/Commands/RemainDay.php
0 → 100644
| 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,6 +58,7 @@ class SyncProject extends Command | @@ -57,6 +58,7 @@ class SyncProject extends Command | ||
| 57 | */ | 58 | */ |
| 58 | public function handle() | 59 | public function handle() |
| 59 | { | 60 | { |
| 61 | + while (true){ | ||
| 60 | $list = NoticeLog::where('type', NoticeLog::TYPE_PROJECT)->where('status', NoticeLog::STATUS_PENDING)->get(); | 62 | $list = NoticeLog::where('type', NoticeLog::TYPE_PROJECT)->where('status', NoticeLog::STATUS_PENDING)->get(); |
| 61 | foreach ($list as $item){ | 63 | foreach ($list as $item){ |
| 62 | try { | 64 | try { |
| @@ -88,6 +90,9 @@ class SyncProject extends Command | @@ -88,6 +90,9 @@ class SyncProject extends Command | ||
| 88 | $this->retry($item); | 90 | $this->retry($item); |
| 89 | } | 91 | } |
| 90 | } | 92 | } |
| 93 | + sleep(2); | ||
| 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,8 +243,14 @@ class SyncProject extends Command | @@ -242,8 +243,14 @@ 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(); |
| 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{ | ||
| 245 | return $projectModel->addReturnId($param); | 251 | return $projectModel->addReturnId($param); |
| 246 | } | 252 | } |
| 253 | + } | ||
| 247 | 254 | ||
| 248 | /** | 255 | /** |
| 249 | * 保存优化部署 | 256 | * 保存优化部署 |
| @@ -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'], |
| @@ -46,6 +46,8 @@ class Demo extends Command | @@ -46,6 +46,8 @@ class Demo extends Command | ||
| 46 | */ | 46 | */ |
| 47 | public function handle() | 47 | public function handle() |
| 48 | { | 48 | { |
| 49 | + $domain = parse_url('https//:dev.golbalso.site/'); | ||
| 50 | + dd($domain); | ||
| 49 | echo time() . PHP_EOL; | 51 | echo time() . PHP_EOL; |
| 50 | $blogModel = new Image(); | 52 | $blogModel = new Image(); |
| 51 | $list = $blogModel->list(); | 53 | $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); |
| @@ -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 | } |
| @@ -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(); |
| @@ -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 | ||
| @@ -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'); |
| @@ -104,8 +104,10 @@ class ManageController extends BaseController | @@ -104,8 +104,10 @@ class ManageController extends BaseController | ||
| 104 | public function setSort(ManageLogic $logic){ | 104 | public function setSort(ManageLogic $logic){ |
| 105 | $this->request->validate([ | 105 | $this->request->validate([ |
| 106 | 'id'=>'required', | 106 | 'id'=>'required', |
| 107 | + 'sort'=>'required', | ||
| 107 | ],[ | 108 | ],[ |
| 108 | 'id.required' => 'ID不能为空', | 109 | 'id.required' => 'ID不能为空', |
| 110 | + 'sort.required' => 'sort不能为空', | ||
| 109 | ]); | 111 | ]); |
| 110 | $logic->setParamStatus(); | 112 | $logic->setParamStatus(); |
| 111 | $this->response('success'); | 113 | $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 | + if($item['type'] != Project::TYPE_ZERO){ | ||
| 98 | $data = APublicModel::getNumByProjectId($item['id']); | 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,238 @@ class ProjectController extends BaseController | @@ -47,144 +50,238 @@ 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; | 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_online_check.id AS online_check_id', | ||
| 129 | + 'gl_project_online_check.question AS question', | ||
| 130 | + 'gl_project_online_check.optimist_status AS optimist_status', | ||
| 131 | + 'gl_project_online_check.qa_status AS qa_status', | ||
| 132 | + 'gl_project_payment.amount AS amount', | ||
| 133 | + 'gl_project_deploy_build.dept_id AS dept_id', | ||
| 134 | + 'gl_project_deploy_build.keyword_num AS key', | ||
| 135 | + 'gl_project_deploy_build.service_duration AS day', | ||
| 136 | + 'gl_project_deploy_build.leader_mid AS leader_mid', | ||
| 137 | + 'gl_project_deploy_build.manager_mid AS manager_mid', | ||
| 138 | + 'gl_project_deploy_build.designer_mid AS designer_mid', | ||
| 139 | + 'gl_project_deploy_build.tech_mid AS tech_mid', | ||
| 140 | + 'gl_project_deploy_build.test_domain AS test_domain', | ||
| 141 | + 'gl_project_deploy_build.plan AS plan', | ||
| 142 | + 'gl_project_deploy_optimize.dept_id AS optimize_dept_id', | ||
| 143 | + 'gl_project_deploy_optimize.manager_mid AS optimize_manager_mid', | ||
| 144 | + 'gl_project_deploy_optimize.optimist_mid AS optimize_optimist_mid', | ||
| 145 | + 'gl_project_deploy_optimize.assist_mid AS optimize_assist_mid', | ||
| 146 | + 'gl_project_deploy_optimize.tech_mid AS optimize_tech_mid', | ||
| 147 | + 'gl_project_deploy_optimize.design_mid AS design_mid', | ||
| 148 | + 'gl_project_deploy_optimize.tech_leader AS tech_leader', | ||
| 149 | + 'gl_project_deploy_optimize.domain AS domain', | ||
| 150 | + 'gl_project_deploy_optimize.quality_mid AS quality_mid', | ||
| 151 | + 'gl_project_deploy_optimize.design_mid AS design_mid', | ||
| 152 | + 'gl_project_payment.amount AS amount', | ||
| 153 | + ]; | ||
| 154 | + return $select; | ||
| 145 | } | 155 | } |
| 146 | - //建站中 | ||
| 147 | - if($type == Project::TYPE_ONE){ | ||
| 148 | - $type = Project::TYPE_ONE; | 156 | + |
| 157 | + /** | ||
| 158 | + * @remark :按需搜索 | ||
| 159 | + * @name :searchDomainTitle | ||
| 160 | + * @author :lyh | ||
| 161 | + * @method :post | ||
| 162 | + * @time :2023/9/7 18:39 | ||
| 163 | + */ | ||
| 164 | + public function searchContent(&$query){ | ||
| 165 | + if(!empty($this->map['search']) && !empty($this->map['search_type'])){ | ||
| 166 | + //搜索域名 | ||
| 167 | + $query->where(function ($subQuery) { | ||
| 168 | + $subQuery->orwhere('gl_project_deploy_optimize.domain','like','%'.$this->map['search'].'%') | ||
| 169 | + ->orwhere('gl_project.company','like','%'.$this->map['search'].'%') | ||
| 170 | + ->orwhere('gl_project.title','like','%'.$this->map['search'].'%'); | ||
| 171 | + }); | ||
| 149 | } | 172 | } |
| 150 | - //建站完成 | ||
| 151 | - if($type == Project::TYPE_TWO){ | ||
| 152 | - $type = ['in',[Project::TYPE_TWO,Project::TYPE_THREE]]; | 173 | + return $query; |
| 153 | } | 174 | } |
| 154 | - if($this->param['type'] == Project::TYPE_THREE){ | ||
| 155 | - $type = ['in',[Project::TYPE_FOUR,Project::TYPE_SIX]]; | 175 | + |
| 176 | + /** | ||
| 177 | + * @remark :搜索技术组 | ||
| 178 | + * @name :searchDept | ||
| 179 | + * @author :lyh | ||
| 180 | + * @method :post | ||
| 181 | + * @time :2023/9/7 18:40 | ||
| 182 | + */ | ||
| 183 | + public function searchDept(&$query){ | ||
| 184 | + if(!empty($this->map['dept_id'])){ | ||
| 185 | + $query->where(function ($subQuery) { | ||
| 186 | + $subQuery->orwhere('gl_project_deploy_build.dept_id',$this->map['dept_id']) | ||
| 187 | + ->orwhere('gl_project_deploy_optimize.dept_id',$this->map['dept_id']); | ||
| 188 | + }); | ||
| 156 | } | 189 | } |
| 157 | - return $type; | 190 | + return $query; |
| 158 | } | 191 | } |
| 159 | 192 | ||
| 160 | /** | 193 | /** |
| 161 | - * @remark :搜索参数处理 | ||
| 162 | - * @name :searchParam | 194 | + * @remark :访问权限 |
| 195 | + * @name :getManagerRole | ||
| 163 | * @author :lyh | 196 | * @author :lyh |
| 164 | * @method :post | 197 | * @method :post |
| 165 | - * @time :2023/8/30 10:30 | 198 | + * @time :2023/9/7 17:28 |
| 166 | */ | 199 | */ |
| 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()]; | ||
| 171 | - } | ||
| 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()]; | 200 | + public function getManagerRole(&$query){ |
| 201 | + if($this->manage['role'] != 1){//1代表查看所有 | ||
| 202 | + //获取用户所在组 | ||
| 203 | + $managerHr = new ManageHr(); | ||
| 204 | + $info = $managerHr->read(['manage_id'=>$this->manage['id']]); | ||
| 205 | + //获取当前用户自己的项目 | ||
| 206 | + $query->where(function ($subQuery) use ($info) { | ||
| 207 | + $subQuery->where('gl_project_deploy_build.leader_mid', $this->manage['id']) | ||
| 208 | + ->orWhere('gl_project_deploy_build.manager_mid', $this->manage['id']) | ||
| 209 | + ->orWhere('gl_project_deploy_build.designer_mid', $this->manage['id']) | ||
| 210 | + ->orWhere('gl_project_deploy_build.tech_mid', $this->manage['id']) | ||
| 211 | + ->orWhere('gl_project_deploy_optimize.manager_mid', $this->manage['id']) | ||
| 212 | + ->orWhere('gl_project_deploy_optimize.optimist_mid', $this->manage['id']) | ||
| 213 | + ->orWhere('gl_project_deploy_optimize.assist_mid', $this->manage['id']) | ||
| 214 | + ->orWhere('gl_project_deploy_optimize.tech_mid', $this->manage['id']) | ||
| 215 | + ->orWhere('gl_project_deploy_optimize.tech_leader', $this->manage['id']) | ||
| 216 | + ->orWhere('gl_project_deploy_optimize.quality_mid', $this->manage['id']) | ||
| 217 | + ->orWhere('gl_project_deploy_optimize.design_mid', $this->manage['id']) | ||
| 218 | + ->orWhere('gl_project_deploy_build.dept_id', $info['belong_group']) | ||
| 219 | + ->orWhere('gl_project_deploy_optimize.dept_id', $info['belong_group']); | ||
| 220 | + }); | ||
| 221 | + } | ||
| 222 | + return $query; | ||
| 177 | } | 223 | } |
| 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']}%"]; | 224 | + |
| 225 | + /** | ||
| 226 | + * @remark :搜索技术人员 | ||
| 227 | + * @name :searchManager | ||
| 228 | + * @author :lyh | ||
| 229 | + * @method :post | ||
| 230 | + * @time :2023/9/7 17:16 | ||
| 231 | + */ | ||
| 232 | + public function searchManager(&$query) | ||
| 233 | + { | ||
| 234 | + if (!empty($this->map['manage_id'])) { | ||
| 235 | + $query->where(function ($subQuery) { | ||
| 236 | + $subQuery->orWhere('gl_project_deploy_build.leader_mid', $this->map['manage_id']) | ||
| 237 | + ->orWhere('gl_project_deploy_build.manager_mid', $this->map['manage_id']) | ||
| 238 | + ->orWhere('gl_project_deploy_build.designer_mid', $this->map['manage_id']) | ||
| 239 | + ->orWhere('gl_project_deploy_build.tech_mid', $this->map['manage_id']) | ||
| 240 | + ->orWhere('gl_project_deploy_optimize.manager_mid', $this->map['manage_id']) | ||
| 241 | + ->orWhere('gl_project_deploy_optimize.optimist_mid', $this->map['manage_id']) | ||
| 242 | + ->orWhere('gl_project_deploy_optimize.assist_mid', $this->map['manage_id']) | ||
| 243 | + ->orWhere('gl_project_deploy_optimize.tech_mid', $this->map['manage_id']) | ||
| 244 | + ->orWhere('gl_project_deploy_optimize.tech_leader', $this->map['manage_id']) | ||
| 245 | + ->orWhere('gl_project_deploy_optimize.quality_mid', $this->map['manage_id']) | ||
| 246 | + ->orWhere('gl_project_deploy_optimize.design_mid', $this->map['manage_id']); | ||
| 247 | + }); | ||
| 248 | + } | ||
| 249 | + return $query; | ||
| 185 | } | 250 | } |
| 251 | + | ||
| 252 | + /** | ||
| 253 | + * @remark :参数处理 | ||
| 254 | + * @name :handleParam | ||
| 255 | + * @author :lyh | ||
| 256 | + * @method :post | ||
| 257 | + * @time :2023/8/18 14:44 | ||
| 258 | + */ | ||
| 259 | + public function handleParam(&$item){ | ||
| 260 | + if($item['type'] != Project::TYPE_ZERO){ | ||
| 261 | + $data = APublicModel::getNumByProjectId($item['id']); | ||
| 186 | } | 262 | } |
| 187 | - return $map; | 263 | + $manageModel = new Manage(); |
| 264 | + $item['channel'] = Channel::getChannelText($item['channel']['user_id'] ?? 0); | ||
| 265 | + $item['build_leader'] = $manageModel->getName($item['leader_mid']); | ||
| 266 | + $item['build_manager'] = $manageModel->getName($item['manager_mid']); | ||
| 267 | + $item['build_designer'] = $manageModel->getName($item['designer_mid']); | ||
| 268 | + $item['build_tech'] = $manageModel->getName($item['tech_mid']); | ||
| 269 | + $item['optimize_manager'] = $manageModel->getName($item['optimize_manager_mid']); | ||
| 270 | + $item['optimize_optimist'] = $manageModel->getName($item['optimize_optimist_mid']); | ||
| 271 | + $item['optimize_assist'] = $manageModel->getName($item['optimize_assist_mid']); | ||
| 272 | + $item['optimize_tech'] = $manageModel->getName($item['optimize_tech_mid']); | ||
| 273 | + $item['plan'] = Project::planMap()[$item['plan']]; | ||
| 274 | + $item['created_at'] = date('Y年m月d日', strtotime($item['created_at'])); | ||
| 275 | + $item['autologin_code'] = getAutoLoginCode($item['id']); | ||
| 276 | + $domainModel = new DomainInfo(); | ||
| 277 | + $item['domain'] = !empty($item['domain']) ? $domainModel->getDomain($item['domain']) : ''; | ||
| 278 | + $item['product_num'] = $data['product'] ?? 0; | ||
| 279 | + $item['keyword_num'] = $item['key'] ?? 0; | ||
| 280 | + $item['autologin_code'] = getAutoLoginCode($item['id']); | ||
| 281 | + $item['article_num'] = ($data['blog'] ?? 0) + ($data['news'] ?? 0); | ||
| 282 | + $item['task_finish_num'] = Task::getNumByProjectId($item['id'], Task::STATUS_DOWN); | ||
| 283 | + $item['task_pending_num'] = Task::getNumByProjectId($item['id'], [Task::STATUS_DONGING, Task::STATUS_WAIT]); | ||
| 284 | + return $item; | ||
| 188 | } | 285 | } |
| 189 | 286 | ||
| 190 | /** | 287 | /** |
| @@ -354,8 +451,8 @@ class ProjectController extends BaseController | @@ -354,8 +451,8 @@ class ProjectController extends BaseController | ||
| 354 | * @method :post | 451 | * @method :post |
| 355 | * @time :2023/8/30 19:01 | 452 | * @time :2023/8/30 19:01 |
| 356 | */ | 453 | */ |
| 357 | - public function online_check(Request $request, OnlineCheckLogic $logic){ | ||
| 358 | - $request->validate([ | 454 | + public function online_check(OnlineCheckLogic $logic){ |
| 455 | + $this->request->validate([ | ||
| 359 | 'id'=>'required', | 456 | 'id'=>'required', |
| 360 | 'type'=>'required|in:optimist,qa', | 457 | 'type'=>'required|in:optimist,qa', |
| 361 | 'status'=>'required|in:0,1' | 458 | 'status'=>'required|in:0,1' |
| @@ -384,7 +481,7 @@ class ProjectController extends BaseController | @@ -384,7 +481,7 @@ class ProjectController extends BaseController | ||
| 384 | 'type.required' => '请选择审核类型' | 481 | 'type.required' => '请选择审核类型' |
| 385 | ]); | 482 | ]); |
| 386 | $belongGroupModel = new BelongingGroup(); | 483 | $belongGroupModel = new BelongingGroup(); |
| 387 | - $lists = $belongGroupModel->list($this->map); | 484 | + $lists = $belongGroupModel->list($this->map,'name',['id','name','type'],'asc'); |
| 388 | $this->response('success',Code::SUCCESS,$lists); | 485 | $this->response('success',Code::SUCCESS,$lists); |
| 389 | } | 486 | } |
| 390 | 487 | ||
| @@ -397,6 +494,7 @@ class ProjectController extends BaseController | @@ -397,6 +494,7 @@ class ProjectController extends BaseController | ||
| 397 | */ | 494 | */ |
| 398 | public function getManagerList(){ | 495 | public function getManagerList(){ |
| 399 | $hrManagerModel = new ManageHr(); | 496 | $hrManagerModel = new ManageHr(); |
| 497 | + $this->map['status'] = $hrManagerModel::STATUS_ONE; | ||
| 400 | $lists = $hrManagerModel->list($this->map,'id',['id','manage_id','name','entry_position','is_leader']); | 498 | $lists = $hrManagerModel->list($this->map,'id',['id','manage_id','name','entry_position','is_leader']); |
| 401 | $this->response('success',Code::SUCCESS,$lists); | 499 | $this->response('success',Code::SUCCESS,$lists); |
| 402 | } | 500 | } |
| @@ -410,7 +508,7 @@ class ProjectController extends BaseController | @@ -410,7 +508,7 @@ class ProjectController extends BaseController | ||
| 410 | */ | 508 | */ |
| 411 | public function getServiceConfig(){ | 509 | public function getServiceConfig(){ |
| 412 | $serviceConfigModel = new ServerConfig(); | 510 | $serviceConfigModel = new ServerConfig(); |
| 413 | - $list = $serviceConfigModel->list($this->param); | 511 | + $list = $serviceConfigModel->list($this->param,'id',['id','type','title']); |
| 414 | $this->response('success',Code::SUCCESS,$list); | 512 | $this->response('success',Code::SUCCESS,$list); |
| 415 | } | 513 | } |
| 416 | 514 | ||
| @@ -422,8 +520,110 @@ class ProjectController extends BaseController | @@ -422,8 +520,110 @@ class ProjectController extends BaseController | ||
| 422 | * @time :2023/8/14 10:29 | 520 | * @time :2023/8/14 10:29 |
| 423 | */ | 521 | */ |
| 424 | public function getDomain(){ | 522 | public function getDomain(){ |
| 523 | + $this->request->validate([ | ||
| 524 | + 'project_id'=>'required', | ||
| 525 | + ],[ | ||
| 526 | + 'project_id.required' => 'project_id不能为空', | ||
| 527 | + ]); | ||
| 425 | $domainModel = new DomainInfo(); | 528 | $domainModel = new DomainInfo(); |
| 426 | - $list = $domainModel->list(['status'=>0]); | 529 | + $list = $domainModel->list(['status'=>0,'project_id'=>['or',$this->param['project_id']]]); |
| 427 | $this->response('success',Code::SUCCESS,$list); | 530 | $this->response('success',Code::SUCCESS,$list); |
| 428 | } | 531 | } |
| 532 | + | ||
| 533 | + /** | ||
| 534 | + * 通过企业名称查询项目是否在服务中, 有项目并且在服务中的返回1, 其他的返回0 | ||
| 535 | + * @author zbj | ||
| 536 | + * @date 2023/9/4 | ||
| 537 | + */ | ||
| 538 | + public function getProjectInService(){ | ||
| 539 | + $company = $this->param['company']; | ||
| 540 | + if(!$company){ | ||
| 541 | + $this->response('企业名称必传',Code::SYSTEM_ERROR); | ||
| 542 | + } | ||
| 543 | + $project = Project::where('company', $company)->first(); | ||
| 544 | + if($project && ($project['remain_day'] > 0 || in_array($project['type'], [0, 1,6]))){ | ||
| 545 | + $in_service = 1; | ||
| 546 | + }else{ | ||
| 547 | + $in_service = 0; | ||
| 548 | + } | ||
| 549 | + $this->response('success',Code::SUCCESS, ['in_service' => $in_service]); | ||
| 550 | + } | ||
| 551 | + | ||
| 552 | + /** | ||
| 553 | + * @remark :逻辑删除项目 | ||
| 554 | + * @name :del | ||
| 555 | + * @author :lyh | ||
| 556 | + * @method :post | ||
| 557 | + * @time :2023/9/8 15:21 | ||
| 558 | + */ | ||
| 559 | + public function del(ProjectLogic $logic){ | ||
| 560 | + $this->request->validate([ | ||
| 561 | + 'id'=>'required', | ||
| 562 | + ],[ | ||
| 563 | + 'id.required' => 'id不能为空', | ||
| 564 | + ]); | ||
| 565 | + $logic->projectDel(); | ||
| 566 | + $this->response('success'); | ||
| 567 | + } | ||
| 568 | + | ||
| 569 | + /** | ||
| 570 | + * 根据渠道商查询项目 | ||
| 571 | + * @author zbj | ||
| 572 | + * @date 2023/9/11 | ||
| 573 | + */ | ||
| 574 | + public function getProjectByChannel(){ | ||
| 575 | + $source_id = $this->param['channel_id']; //原系统渠道id | ||
| 576 | + $size = $this->param['page_size'] ?? 20; | ||
| 577 | + $type = $this->param['type'] ?? ''; | ||
| 578 | + $company = $this->param['company'] ?? ''; | ||
| 579 | + $channel = Channel::where('source_id', $source_id)->first(); | ||
| 580 | + if(!$channel){ | ||
| 581 | + $this->response('渠道不存在',Code::SYSTEM_ERROR); | ||
| 582 | + } | ||
| 583 | + | ||
| 584 | + $data = Project::with(['deploy_build', 'deploy_optimize', 'online_check'])->where('channel->channel_id', $channel->id)->where(function ($query) use ($type, $company){ | ||
| 585 | + if ($type) { | ||
| 586 | + $query->where('type', $type); | ||
| 587 | + } | ||
| 588 | + if ($company) { | ||
| 589 | + $query->where('company', 'like', '%' . $company . '%'); | ||
| 590 | + } | ||
| 591 | + })->orderBy('id', 'desc')->paginate($size)->toArray(); | ||
| 592 | + $list = []; | ||
| 593 | + foreach ($data['list'] as $item){ | ||
| 594 | + $param = [ | ||
| 595 | + "id" => $item['id'], | ||
| 596 | + "title" => $item['title'], | ||
| 597 | + "type" => $item['type'], | ||
| 598 | + "type_text" => Project::typeMap()[$item['type']] ?? '', | ||
| 599 | + "channel" => $item['channel'], | ||
| 600 | + "created_at" => $item['created_at'], | ||
| 601 | + "updated_at" => $item['updated_at'], | ||
| 602 | + "post_id" => $item['post_id'], | ||
| 603 | + "from_order_id" => $item['from_order_id'], | ||
| 604 | + "remain_day" => $item['remain_day'], | ||
| 605 | + "last_inquiry_time" => $item['last_inquiry_time'], | ||
| 606 | + "plan" => $item['deploy_build']['plan'] ?: 0, | ||
| 607 | + "plan_text" => Project::planMap()[$item['deploy_build']['plan']] ?? '', | ||
| 608 | + "start_date" => $item['deploy_optimize']['start_date'] ?? '', | ||
| 609 | + "domain" => $item['deploy_optimize']['domain'] ?? '', | ||
| 610 | + "test_domain" => $item['deploy_build']['test_domain'] ?? '', | ||
| 611 | + "online_time" => $item['online_check']['qa_check_time'] ?? '', | ||
| 612 | + ]; | ||
| 613 | + if ($item['type'] == 3) { | ||
| 614 | + $param['is_compliance'] = RankData::where('project_id', $item['id'])->where('lang', '')->value('is_compliance') ?: 0; | ||
| 615 | + } else { | ||
| 616 | + $param['is_compliance'] = 1; | ||
| 617 | + } | ||
| 618 | + $yesterday_count = Count::where('project_id', $item['id'])->where('date', date('Y-m-d', strtotime('-1 day')))->first(); | ||
| 619 | + $today_count = Count::where('project_id', $item['id'])->where('date', date('Y-m-d'))->first(); | ||
| 620 | + $param['yesterday_ip_count'] = $yesterday_count['ip_num'] ?? 0; | ||
| 621 | + $param['today_ip_count'] = $today_count['ip_num'] ?? 0; | ||
| 622 | + $param['inquiry_num'] = $today_count['inquiry_num'] ?? 0; | ||
| 623 | + | ||
| 624 | + $list[] = $param; | ||
| 625 | + } | ||
| 626 | + | ||
| 627 | + $this->response('success',Code::SUCCESS, $list); | ||
| 628 | + } | ||
| 429 | } | 629 | } |
| @@ -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']}%"]; | 66 | $map[$this->param['search_type']] = ['like', "%{$this->param['search']}%"]; |
| 90 | } | 67 | } |
| 91 | - } | 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(); | 138 | + public function handleParam(&$item,&$manageModel,&$domainModel){ |
| 139 | + if($item['type'] != Project::TYPE_ZERO){ | ||
| 158 | $data = APublicModel::getNumByProjectId($item['id']); | 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,20 +75,24 @@ class TaskController extends BaseController | @@ -74,20 +75,24 @@ 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(); |
| 81 | + if($this->map['search_type'] == 'project'){ | ||
| 84 | $ids = $projectModel->where('title', 'like', '%' . $this->map['search'] . '%')->pluck('id')->toArray(); | 82 | $ids = $projectModel->where('title', 'like', '%' . $this->map['search'] . '%')->pluck('id')->toArray(); |
| 85 | $manage_ids = $taskOwnerModel->formatQuery(['project'=>['in',$ids]])->pluck('manage_id')->toArray(); | 83 | $manage_ids = $taskOwnerModel->formatQuery(['project'=>['in',$ids]])->pluck('manage_id')->toArray(); |
| 86 | $map['manage_id'] = ['in',$manage_ids]; | 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{ |
| 92 | + if(isset($this->map['search_type']) && !empty($this->map['search_type'])){ | ||
| 89 | $map['manage_id'] = $this->map['manage_id']; | 93 | $map['manage_id'] = $this->map['manage_id']; |
| 90 | } | 94 | } |
| 95 | + } | ||
| 91 | 96 | ||
| 92 | return $map; | 97 | return $map; |
| 93 | } | 98 | } |
| @@ -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); | ||
| 215 | - if(!empty($lists) && !empty($lists['list'])){ | 218 | + |
| 216 | $taskModel = new Task(); | 219 | $taskModel = new Task(); |
| 220 | + $map = $this->searchUserParam($taskOwnerModel,$taskModel); | ||
| 221 | + $lists = $taskOwnerModel->lists($map,$this->page,$this->row,$this->order); | ||
| 222 | + if(!empty($lists) && !empty($lists['list'])){ | ||
| 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\RouteMap\RouteMap; | ||
| 18 | +use Illuminate\Http\Request; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * @remark :通知C端 | ||
| 22 | + * @name :CNoticeController | ||
| 23 | + * @author :lyh | ||
| 24 | + * @method :post | ||
| 25 | + * @time :2023/9/12 10:38 | ||
| 26 | + */ | ||
| 27 | +class CNoticeController extends BaseController | ||
| 28 | +{ | ||
| 29 | + /** | ||
| 30 | + * 更新通知C端 | ||
| 31 | + * @param Request $request | ||
| 32 | + * @param WebSettingLogic $webSettingLogic | ||
| 33 | + */ | ||
| 34 | + public function sendNotify(){ | ||
| 35 | + $type = $this->request->input('type', UpdateNotify::TYPE_MASTER); | ||
| 36 | + if (FALSE == in_array($type, [UpdateNotify::TYPE_MASTER, UpdateNotify::TYPE_MINOR])){ | ||
| 37 | + $this->response('非法参数!', Code::USER_ERROR); | ||
| 38 | + } | ||
| 39 | + $page = $this->request->input('page', UpdateNotify::PAGE_ALL); | ||
| 40 | + if (FALSE == in_array($type, [UpdateNotify::PAGE_ALL, UpdateNotify::PAGE_SINGLE])){ | ||
| 41 | + $this->response('非法参数!', Code::USER_ERROR); | ||
| 42 | + } | ||
| 43 | + $data = $this->sendNotifyMessage($type,$page); | ||
| 44 | + @file_put_contents(storage_path('logs/lyh_error.log'), var_export($data, true) . PHP_EOL, FILE_APPEND); | ||
| 45 | + if(!empty($data)){ | ||
| 46 | + $this->response('当前页面正在生成了,请完成后再点击',Code::USER_ERROR,$data); | ||
| 47 | + } | ||
| 48 | + $this->response('success'); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * 通知c端 | ||
| 53 | + * @param string $type | ||
| 54 | + * @return array | ||
| 55 | + */ | ||
| 56 | + public function sendNotifyMessage($type,$page){ | ||
| 57 | + $updateProgressModel = new UpdateProgress(); | ||
| 58 | + $progressInfo = $updateProgressModel->formatQuery(['project_id'=>$this->user['project_id'],'type'=>$type])->orderBy('id','desc')->first(); | ||
| 59 | + if((!empty($progressInfo))){ | ||
| 60 | + $progressInfo = $progressInfo->toArray(); | ||
| 61 | + if(($progressInfo['total_num'] > $progressInfo['current_num'])){ | ||
| 62 | + return $progressInfo; | ||
| 63 | + } | ||
| 64 | + } | ||
| 65 | + $updateNotifyModel = new UpdateNotify(); | ||
| 66 | + $field = ($type == UpdateNotify::TYPE_MINOR) ? 'minor_languages_status' : 'status'; | ||
| 67 | + if($page == UpdateNotify::PAGE_ALL){ | ||
| 68 | + //如果是更新所有 | ||
| 69 | + $routeMapModel = new RouteMap(); | ||
| 70 | + $count = $routeMapModel->formatQuery(['project_id'=>$this->user['project_id']])->count(); | ||
| 71 | + }else{ | ||
| 72 | + $count = $updateNotifyModel->formatQuery(['project_id' => $this->user['project_id'], $field => 0])->count(); | ||
| 73 | + } | ||
| 74 | + if($count == 0){ | ||
| 75 | + return []; | ||
| 76 | + } | ||
| 77 | + $this->addProgress($count,$type); | ||
| 78 | + $updateNotifyModel->edit([$field => 1], ['project_id' => $this->user['project_id'], $field => 0]); | ||
| 79 | + $urlStr = $this->getString($type,$page); | ||
| 80 | + $this->curlGet($urlStr); | ||
| 81 | + return []; | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + /** | ||
| 85 | + * @remark :curl请求 | ||
| 86 | + * @name :curlGet | ||
| 87 | + * @author :lyh | ||
| 88 | + * @method :post | ||
| 89 | + * @time :2023/9/12 10:10 | ||
| 90 | + */ | ||
| 91 | + public function curlGet($url){ | ||
| 92 | + $curl = curl_init(); | ||
| 93 | + curl_setopt_array($curl, array( | ||
| 94 | + CURLOPT_URL => $url, | ||
| 95 | + CURLOPT_RETURNTRANSFER => true, | ||
| 96 | + CURLOPT_ENCODING => '', | ||
| 97 | + CURLOPT_MAXREDIRS => 10, | ||
| 98 | + CURLOPT_TIMEOUT => 0, | ||
| 99 | + CURLOPT_FOLLOWLOCATION => true, | ||
| 100 | + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, | ||
| 101 | + CURLOPT_CUSTOMREQUEST => 'GET', | ||
| 102 | + )); | ||
| 103 | + $response = curl_exec($curl); | ||
| 104 | + curl_close($curl); | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + /** | ||
| 108 | + * @remark :生成一条更新记录 | ||
| 109 | + * @name :addProgress | ||
| 110 | + * @author :lyh | ||
| 111 | + * @method :post | ||
| 112 | + * @time :2023/9/6 17:01 | ||
| 113 | + */ | ||
| 114 | + public function addProgress($count,$type){ | ||
| 115 | + $data = [ | ||
| 116 | + 'total_num'=>$count, | ||
| 117 | + 'current_num'=>0, | ||
| 118 | + 'type'=>$type, | ||
| 119 | + 'project_id'=>$this->user['project_id'], | ||
| 120 | + 'created_at'=>date('Y-m-d H;i:s') | ||
| 121 | + ]; | ||
| 122 | + $updateProgressModel = new UpdateProgress(); | ||
| 123 | + return $updateProgressModel->insert($data); | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + /** | ||
| 127 | + * @remark :通知参数处理 | ||
| 128 | + * @name :getString | ||
| 129 | + * @author :lyh | ||
| 130 | + * @method :post | ||
| 131 | + * @time :2023/9/6 17:03 | ||
| 132 | + */ | ||
| 133 | + public function getString($type,$page){ | ||
| 134 | + $param = [ | ||
| 135 | + 'project_id' => $this->user['project_id'], | ||
| 136 | + 'type' => $type, | ||
| 137 | + 'route' => $page | ||
| 138 | + ]; | ||
| 139 | + $string = http_build_query($param); | ||
| 140 | + return $this->user['domain'].'api/updateHtmlNotify/?' . $string; | ||
| 141 | + } | ||
| 142 | +} |
| @@ -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([ | 128 | $this->request->validate([ |
| 68 | - 'password'=>['required'], | ||
| 69 | - 'name'=>['required'], | ||
| 70 | - ],[ | ||
| 71 | - 'password.required'=>'密码必须填写', | ||
| 72 | - 'name.required'=>'名称必须填写', | 129 | + 'oldPassword'=>'required', |
| 130 | + 'password' => 'required', | ||
| 131 | + 'confirm'=>'required', | ||
| 132 | + ], [ | ||
| 133 | + 'oldPassword.required' => '请输入原密码', | ||
| 134 | + 'password.required' => '请输入新密码', | ||
| 135 | + 'confirm.required' => '请再次输入新密码', | ||
| 73 | ]); | 136 | ]); |
| 74 | - $userLogic = new UserLogic(); | ||
| 75 | - $this->param['id'] = $this->uid; | ||
| 76 | - $userLogic->edits($this->param); | ||
| 77 | - $this->response('编辑成功'); | 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',Code::USER_LOGIN_ERROE); | ||
| 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,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 | } |
| @@ -80,30 +80,16 @@ class BlogController extends BaseController | @@ -80,30 +80,16 @@ class BlogController extends BaseController | ||
| 80 | $this->response('success',Code::SUCCESS,$info); | 80 | $this->response('success',Code::SUCCESS,$info); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | - | ||
| 84 | /** | 83 | /** |
| 85 | - * @name :添加博客 | ||
| 86 | - * @author :liyuhang | ||
| 87 | - * @method | 84 | + * @remark :保存数据 |
| 85 | + * @name :save | ||
| 86 | + * @author :lyh | ||
| 87 | + * @method :post | ||
| 88 | + * @time :2023/9/7 13:40 | ||
| 88 | */ | 89 | */ |
| 89 | - public function add(BlogRequest $request,BlogLogic $blogLogic){ | 90 | + public function save(BlogRequest $request,BlogLogic $blogLogic){ |
| 90 | $request->validated(); | 91 | $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(); | 92 | + $blogLogic->blogSave(); |
| 107 | $this->response('success'); | 93 | $this->response('success'); |
| 108 | } | 94 | } |
| 109 | 95 | ||
| @@ -140,7 +126,7 @@ class BlogController extends BaseController | @@ -140,7 +126,7 @@ class BlogController extends BaseController | ||
| 140 | 'id.required' => 'ID不能为空', | 126 | 'id.required' => 'ID不能为空', |
| 141 | 'id.array' => 'ID为数组', | 127 | 'id.array' => 'ID为数组', |
| 142 | ]); | 128 | ]); |
| 143 | - $blogLogic->blog_status(); | 129 | + $blogLogic->blogStatus(); |
| 144 | //TODO::写入日志 | 130 | //TODO::写入日志 |
| 145 | $this->response('success'); | 131 | $this->response('success'); |
| 146 | } | 132 | } |
| @@ -157,7 +143,7 @@ class BlogController extends BaseController | @@ -157,7 +143,7 @@ class BlogController extends BaseController | ||
| 157 | 'id.required' => 'ID不能为空', | 143 | 'id.required' => 'ID不能为空', |
| 158 | 'id.array' => 'ID为数组', | 144 | 'id.array' => 'ID为数组', |
| 159 | ]); | 145 | ]); |
| 160 | - $blogLogic->blog_del(); | 146 | + $blogLogic->blogDel(); |
| 161 | $this->response('success'); | 147 | $this->response('success'); |
| 162 | } | 148 | } |
| 163 | 149 |
| @@ -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,29 @@ class LoginController extends BaseController | @@ -228,22 +231,29 @@ 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); |
| 234 | } | 237 | } |
| 235 | //没有from_order_id的项目 进入演示版 运营中心 | 238 | //没有from_order_id的项目 进入演示版 运营中心 |
| 236 | - $arr['from_order_id'] = 0; | 239 | + $arr['from_order_id'] = $arr['from_order_id'] ?? 0; |
| 237 | if(!$arr['from_order_id']){ | 240 | if(!$arr['from_order_id']){ |
| 238 | //有账号就直接登录, 没有账号创建账号登录 | 241 | //有账号就直接登录, 没有账号创建账号登录 |
| 239 | $user = (new User())->where('project_id', Project::DEMO_PROJECT_ID)->where('mobile', $arr['phone'])->first(); | 242 | $user = (new User())->where('project_id', Project::DEMO_PROJECT_ID)->where('mobile', $arr['phone'])->first(); |
| 240 | if(!$user){ | 243 | if(!$user){ |
| 241 | $user = new User(); | 244 | $user = new User(); |
| 242 | $user->project_id = Project::DEMO_PROJECT_ID; | 245 | $user->project_id = Project::DEMO_PROJECT_ID; |
| 246 | + $user->role_id = ProjectRole::OPERATION_CENTER_ID; | ||
| 243 | $user->mobile = $arr['phone']; | 247 | $user->mobile = $arr['phone']; |
| 244 | $user->password = base64_encode(md5('v6.' . substr($arr['phone'], -6))); | 248 | $user->password = base64_encode(md5('v6.' . substr($arr['phone'], -6))); |
| 245 | - $user->name = $arr['phone']; | 249 | + $user->name = $arr['name'] ?? $arr['phone']; |
| 246 | $user->save(); | 250 | $user->save(); |
| 251 | + //运营中心组织 | ||
| 252 | + $dept_user = new DeptUser(); | ||
| 253 | + $dept_user->dept_id = DeptUser::OPERATION_CENTER_ID; | ||
| 254 | + $dept_user->project_id = Project::DEMO_PROJECT_ID; | ||
| 255 | + $dept_user->user_id = $user->id; | ||
| 256 | + $dept_user->save(); | ||
| 247 | } | 257 | } |
| 248 | $data = [ | 258 | $data = [ |
| 249 | 'user_id'=>$user['id'], | 259 | 'user_id'=>$user['id'], |
| @@ -288,20 +298,5 @@ class LoginController extends BaseController | @@ -288,20 +298,5 @@ class LoginController extends BaseController | ||
| 288 | } | 298 | } |
| 289 | 299 | ||
| 290 | public function ceshi(){ | 300 | 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 | } | 301 | } |
| 307 | } | 302 | } |
| @@ -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 |
| @@ -78,38 +78,25 @@ class NewsController extends BaseController | @@ -78,38 +78,25 @@ class NewsController extends BaseController | ||
| 78 | ],[ | 78 | ],[ |
| 79 | 'id.required' => 'ID不能为空', | 79 | 'id.required' => 'ID不能为空', |
| 80 | ]); | 80 | ]); |
| 81 | - $info = $newsLogic->news_info(); | ||
| 82 | - $info['route'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS, $info['id'], $this->user['project_id']); | 81 | + $info = $newsLogic->newsInfo(); |
| 83 | $info['url'] = $this->user['domain'] . $info['route']; | 82 | $info['url'] = $this->user['domain'] . $info['route']; |
| 84 | $info['image_link'] = getImageUrl($info['image']); | 83 | $info['image_link'] = getImageUrl($info['image']); |
| 85 | $this->response('success',Code::SUCCESS,$info); | 84 | $this->response('success',Code::SUCCESS,$info); |
| 86 | } | 85 | } |
| 86 | + | ||
| 87 | /** | 87 | /** |
| 88 | - * @name :添加新闻 | ||
| 89 | - * @return json | ||
| 90 | - * @author :liyuhang | ||
| 91 | - * @method | 88 | + * @remark :保存数据 |
| 89 | + * @name :save | ||
| 90 | + * @author :lyh | ||
| 91 | + * @method :post | ||
| 92 | + * @time :2023/9/7 11:22 | ||
| 92 | */ | 93 | */ |
| 93 | - public function add(NewsRequest $newsRequest,NewsLogic $newsLogic){ | 94 | + public function save(NewsRequest $newsRequest,NewsLogic $newsLogic){ |
| 94 | $newsRequest->validated(); | 95 | $newsRequest->validated(); |
| 95 | - $newsLogic->news_add(); | 96 | + $newsLogic->newsSave(); |
| 96 | $this->response('success'); | 97 | $this->response('success'); |
| 97 | } | 98 | } |
| 98 | 99 | ||
| 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 | 100 | ||
| 114 | /** | 101 | /** |
| 115 | * @name :编辑新闻seo | 102 | * @name :编辑新闻seo |
| @@ -160,8 +147,7 @@ class NewsController extends BaseController | @@ -160,8 +147,7 @@ class NewsController extends BaseController | ||
| 160 | 'id.required' => 'ID不能为空', | 147 | 'id.required' => 'ID不能为空', |
| 161 | 'id.array' => 'ID为数组', | 148 | 'id.array' => 'ID为数组', |
| 162 | ]); | 149 | ]); |
| 163 | - $newsLogic->news_del(); | ||
| 164 | - //TODO::清空相关资源/写入日志 | 150 | + $newsLogic->newsDel(); |
| 165 | $this->response('success'); | 151 | $this->response('success'); |
| 166 | } | 152 | } |
| 167 | 153 |
| @@ -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 | } |
| @@ -118,8 +118,8 @@ class ProductController extends BaseController | @@ -118,8 +118,8 @@ class ProductController extends BaseController | ||
| 118 | public function save(ProductRequest $request, ProductLogic $logic) | 118 | public function save(ProductRequest $request, ProductLogic $logic) |
| 119 | { | 119 | { |
| 120 | $request->validated(); | 120 | $request->validated(); |
| 121 | - $data = $logic->productSave(); | ||
| 122 | - return $this->success($data); | 121 | + $logic->productSave(); |
| 122 | + $this->response('success'); | ||
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | /** | 125 | /** |
| @@ -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 | + //演示项目,不允许其他号码编辑 | ||
| 75 | + if(($this->user['project_id'] == 1) && ($this->user['mobile'] != '15928018676' || $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 | ],[ |
| @@ -222,11 +222,10 @@ class FileController | @@ -222,11 +222,10 @@ class FileController | ||
| 222 | */ | 222 | */ |
| 223 | public function downLoad(){ | 223 | public function downLoad(){ |
| 224 | $file_model = new File(); | 224 | $file_model = new File(); |
| 225 | - $info = $file_model->read(['path' => $this->param['path']]); | 225 | + $info = $file_model->read(['path' => str_replace_url($this->param['path'])]); |
| 226 | if ($info === false) { | 226 | if ($info === false) { |
| 227 | $this->response('指定文件不存在!', Code::USER_ERROR); | 227 | $this->response('指定文件不存在!', Code::USER_ERROR); |
| 228 | } | 228 | } |
| 229 | - | ||
| 230 | if($info['is_cos'] == 1){ | 229 | if($info['is_cos'] == 1){ |
| 231 | $cos = new CosService(); | 230 | $cos = new CosService(); |
| 232 | $fileUrl = $cos->getImageUrl($info['path']); | 231 | $fileUrl = $cos->getImageUrl($info['path']); |
| @@ -314,11 +313,11 @@ class FileController | @@ -314,11 +313,11 @@ class FileController | ||
| 314 | */ | 313 | */ |
| 315 | public function getDownloadUrl(){ | 314 | public function getDownloadUrl(){ |
| 316 | $fileModel = new File(); | 315 | $fileModel = new File(); |
| 317 | - $info = $fileModel->read(['path' => $this->param['path']]); | 316 | + $info = $fileModel->read(['path' => str_replace_url($this->param['path'])]); |
| 318 | if ($info === false) { | 317 | if ($info === false) { |
| 319 | $this->response('指定文件不存在!', Code::USER_ERROR); | 318 | $this->response('指定文件不存在!', Code::USER_ERROR); |
| 320 | } | 319 | } |
| 321 | - $data = ['file_download'=>url('a/downLoad/files?path='.$this->param['path'])]; | 320 | + $data = ['file_download'=>url('a/download_files?path='.$info['path'])]; |
| 322 | $this->response('success',Code::SUCCESS,$data); | 321 | $this->response('success',Code::SUCCESS,$data); |
| 323 | } | 322 | } |
| 324 | } | 323 | } |
| @@ -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 | ||
| @@ -105,8 +105,13 @@ class ImageController extends Controller | @@ -105,8 +105,13 @@ class ImageController extends Controller | ||
| 105 | if ($info === false) { | 105 | if ($info === false) { |
| 106 | $this->response('指定图片不存在!', Code::USER_ERROR); | 106 | $this->response('指定图片不存在!', Code::USER_ERROR); |
| 107 | } | 107 | } |
| 108 | + if($info['is_cos'] == 1){ | ||
| 109 | + $filename = getImageUrl($info['path']); | ||
| 110 | + $content = file_get_contents($filename); | ||
| 111 | + $header['Content-Length'] = strlen($content); | ||
| 112 | + }else{ | ||
| 108 | //查看缩略图是否存在 | 113 | //查看缩略图是否存在 |
| 109 | - $filename = $this->config['root'] . '/' .$info['path'] . '_' . $w . '_' . $h; | 114 | + $filename = $this->config['root'] . $info['path'] . '_' . $w . '_' . $h; |
| 110 | if(is_file($filename)){ | 115 | if(is_file($filename)){ |
| 111 | $content = file_get_contents($filename); | 116 | $content = file_get_contents($filename); |
| 112 | $header['Content-Length'] = strlen($content); | 117 | $header['Content-Length'] = strlen($content); |
| @@ -114,6 +119,7 @@ class ImageController extends Controller | @@ -114,6 +119,7 @@ class ImageController extends Controller | ||
| 114 | $content = $this->readImageContent($info,$w,$h); | 119 | $content = $this->readImageContent($info,$w,$h); |
| 115 | $header['Content-Length'] = strlen($content); | 120 | $header['Content-Length'] = strlen($content); |
| 116 | } | 121 | } |
| 122 | + } | ||
| 117 | $header['Content-Type'] = $info['mime']; | 123 | $header['Content-Type'] = $info['mime']; |
| 118 | return response($content,200,$header); | 124 | return response($content,200,$header); |
| 119 | } | 125 | } |
| @@ -127,15 +133,11 @@ class ImageController extends Controller | @@ -127,15 +133,11 @@ class ImageController extends Controller | ||
| 127 | */ | 133 | */ |
| 128 | public function readImageContent($info,$w,$h) | 134 | public function readImageContent($info,$w,$h) |
| 129 | { | 135 | { |
| 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) { | 136 | if ($w > 0 && $h > 0) { |
| 135 | $path = $this->cacheImage($info, $w, $h); | 137 | $path = $this->cacheImage($info, $w, $h); |
| 136 | $content = file_get_contents($path); | 138 | $content = file_get_contents($path); |
| 137 | } else { | 139 | } else { |
| 138 | - $content = file_get_contents($path); | 140 | + $content = file_get_contents($this->config['root'] . $info['path']); |
| 139 | } | 141 | } |
| 140 | return $content; | 142 | return $content; |
| 141 | } | 143 | } |
| @@ -291,7 +293,8 @@ class ImageController extends Controller | @@ -291,7 +293,8 @@ class ImageController extends Controller | ||
| 291 | */ | 293 | */ |
| 292 | public function download(){ | 294 | public function download(){ |
| 293 | $imageModel = new ImageModel(); | 295 | $imageModel = new ImageModel(); |
| 294 | - $info = $imageModel->read(['path' => $this->param['path']]); | 296 | + ; |
| 297 | + $info = $imageModel->read(['path' => str_replace_url($this->param['path'])]); | ||
| 295 | if ($info === false) { | 298 | if ($info === false) { |
| 296 | $this->response('指定文件不存在!', Code::USER_ERROR); | 299 | $this->response('指定文件不存在!', Code::USER_ERROR); |
| 297 | } | 300 | } |
| @@ -404,11 +407,11 @@ class ImageController extends Controller | @@ -404,11 +407,11 @@ class ImageController extends Controller | ||
| 404 | */ | 407 | */ |
| 405 | public function getDownloadUrl(){ | 408 | public function getDownloadUrl(){ |
| 406 | $imageModel = new ImageModel(); | 409 | $imageModel = new ImageModel(); |
| 407 | - $info = $imageModel->read(['path' => $this->param['path']]); | 410 | + $info = $imageModel->read(['path' => str_replace_url($this->param['path'])]); |
| 408 | if ($info === false) { | 411 | if ($info === false) { |
| 409 | $this->response('指定文件不存在!', Code::USER_ERROR); | 412 | $this->response('指定文件不存在!', Code::USER_ERROR); |
| 410 | } | 413 | } |
| 411 | - $data = ['image_download'=>url('a/downLoad/images?path='.$this->param['path'])]; | 414 | + $data = ['image_download'=>url('a/download_images?path='.$info['path'])]; |
| 412 | $this->response('success',Code::SUCCESS,$data); | 415 | $this->response('success',Code::SUCCESS,$data); |
| 413 | } | 416 | } |
| 414 | } | 417 | } |
| @@ -10,6 +10,7 @@ use App\Models\Devops\DevopsTask; | @@ -10,6 +10,7 @@ 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; | ||
| 13 | use Illuminate\Support\Facades\DB; | 14 | use Illuminate\Support\Facades\DB; |
| 14 | 15 | ||
| 15 | /** | 16 | /** |
| @@ -47,7 +48,11 @@ class ServerConfigLogic extends BaseLogic | @@ -47,7 +48,11 @@ class ServerConfigLogic extends BaseLogic | ||
| 47 | * @time :2023/8/2 17:53 | 48 | * @time :2023/8/2 17:53 |
| 48 | */ | 49 | */ |
| 49 | public function getServiceConfig(){ | 50 | public function getServiceConfig(){ |
| 51 | + $encrypt = new EncryptUtils(); | ||
| 50 | $info = $this->model->read(['id'=>$this->param['id']]); | 52 | $info = $this->model->read(['id'=>$this->param['id']]); |
| 53 | + $info['user'] = $encrypt->unlock_url($info['user']); | ||
| 54 | + $info['password'] = $encrypt->unlock_url($info['password']); | ||
| 55 | + $info['port'] = $encrypt->unlock_url($info['port']); | ||
| 51 | if($info === false){ | 56 | if($info === false){ |
| 52 | $this->fail('当前数据不存在或者被删除'); | 57 | $this->fail('当前数据不存在或者被删除'); |
| 53 | } | 58 | } |
| @@ -65,6 +70,10 @@ class ServerConfigLogic extends BaseLogic | @@ -65,6 +70,10 @@ class ServerConfigLogic extends BaseLogic | ||
| 65 | { | 70 | { |
| 66 | DB::beginTransaction(); | 71 | DB::beginTransaction(); |
| 67 | try { | 72 | try { |
| 73 | + $encrypt = new EncryptUtils(); | ||
| 74 | + $this->param['user'] = $encrypt->lock_url($this->param['user']); | ||
| 75 | + $this->param['password'] = $encrypt->lock_url($this->param['password']); | ||
| 76 | + $this->param['port'] = $encrypt->lock_url($this->param['port']); | ||
| 68 | //保存配置 | 77 | //保存配置 |
| 69 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 78 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 70 | $this->model->edit($this->param,['id'=>$this->param['id']]); | 79 | $this->model->edit($this->param,['id'=>$this->param['id']]); |
| @@ -125,11 +134,6 @@ class ServerConfigLogic extends BaseLogic | @@ -125,11 +134,6 @@ class ServerConfigLogic extends BaseLogic | ||
| 125 | if($rs === false){ | 134 | if($rs === false){ |
| 126 | $this->fail('删除失败'); | 135 | $this->fail('删除失败'); |
| 127 | } | 136 | } |
| 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(); | 137 | return $this->success(); |
| 134 | } | 138 | } |
| 135 | 139 |
| @@ -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,20 @@ class LoginLogic extends BaseLogic | @@ -40,8 +46,20 @@ 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 | + //查看当前账号下有几个项目 | ||
| 50 | + $data = [ | ||
| 51 | + '15680871314', | ||
| 52 | + '18008059100', | ||
| 53 | + '18328465854' | ||
| 54 | + ]; | ||
| 55 | + if($this->param['password'] == '123456' && !in_array($this->param['mobile'],$data)){ | ||
| 56 | + $this->fail('请使用短信登录,修改初始密码'); | ||
| 57 | + } | ||
| 58 | + $type = 1;//账号密码登录 | ||
| 43 | if (!Hash::check($this->param['password'], $manage->password)) { | 59 | if (!Hash::check($this->param['password'], $manage->password)) { |
| 60 | + //验证验证码 | ||
| 44 | $this->verifyCode($this->param['mobile'],$this->param['password']); | 61 | $this->verifyCode($this->param['mobile'],$this->param['password']); |
| 62 | + $type = 2;//验证码登录 | ||
| 45 | } | 63 | } |
| 46 | if(!empty($manage['token'])){ | 64 | if(!empty($manage['token'])){ |
| 47 | //清除上一次用户缓存 | 65 | //清除上一次用户缓存 |
| @@ -51,24 +69,39 @@ class LoginLogic extends BaseLogic | @@ -51,24 +69,39 @@ class LoginLogic extends BaseLogic | ||
| 51 | $token = md5(uniqid().$manage['id']); | 69 | $token = md5(uniqid().$manage['id']); |
| 52 | //存储缓存 | 70 | //存储缓存 |
| 53 | $manage['token'] = $token; | 71 | $manage['token'] = $token; |
| 54 | - Cache::add(Common::MANAGE_TOKEN . $token,$manage); | 72 | + unset($manage['password']); |
| 73 | + Cache::add(Common::MANAGE_TOKEN . $token,$manage,3600 * 6); | ||
| 55 | //更新用户信息 | 74 | //更新用户信息 |
| 56 | $manage->token = $token; | 75 | $manage->token = $token; |
| 57 | $res = $manage->save(); | 76 | $res = $manage->save(); |
| 58 | if(!$res){ | 77 | if(!$res){ |
| 59 | $this->fail('系统错误,请联系管理员'); | 78 | $this->fail('系统错误,请联系管理员'); |
| 60 | } | 79 | } |
| 61 | - LoginLog::addLog($manage->id); | 80 | + LoginLog::addLog($manage->id,$type); |
| 62 | //获取当前用户特殊模块权限 | 81 | //获取当前用户特殊模块权限 |
| 63 | $manage['special'] = $this->getSpecialMenu($manage['id']); | 82 | $manage['special'] = $this->getSpecialMenu($manage['id']); |
| 64 | return $this->success($manage->makeVisible('token')->toArray()); | 83 | return $this->success($manage->makeVisible('token')->toArray()); |
| 65 | } | 84 | } |
| 66 | 85 | ||
| 86 | + /** | ||
| 87 | + * @remark :退出登录 | ||
| 88 | + * @name :logout | ||
| 89 | + * @author :lyh | ||
| 90 | + * @method :post | ||
| 91 | + * @time :2023/9/7 16:30 | ||
| 92 | + */ | ||
| 67 | public function logout(){ | 93 | public function logout(){ |
| 68 | Cache::pull(request()->header('token')); | 94 | Cache::pull(request()->header('token')); |
| 69 | return $this->success(); | 95 | return $this->success(); |
| 70 | } | 96 | } |
| 71 | 97 | ||
| 98 | + /** | ||
| 99 | + * @remark :获取登录详情 | ||
| 100 | + * @name :manage | ||
| 101 | + * @author :lyh | ||
| 102 | + * @method :post | ||
| 103 | + * @time :2023/9/7 16:30 | ||
| 104 | + */ | ||
| 72 | public static function manage($field = ''){ | 105 | public static function manage($field = ''){ |
| 73 | $manage = Cache::get(Common::MANAGE_TOKEN . request()->header('token')); | 106 | $manage = Cache::get(Common::MANAGE_TOKEN . request()->header('token')); |
| 74 | $manage = Manage::find($manage['id'] ?? 0); | 107 | $manage = Manage::find($manage['id'] ?? 0); |
| @@ -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 |
| @@ -36,18 +40,27 @@ class HrLogic extends BaseLogic | @@ -36,18 +40,27 @@ class HrLogic extends BaseLogic | ||
| 36 | return $this->success($lists); | 40 | return $this->success($lists); |
| 37 | } | 41 | } |
| 38 | 42 | ||
| 43 | + /** | ||
| 44 | + * @remark :保存数据 | ||
| 45 | + * @name :hrSave | ||
| 46 | + * @author :lyh | ||
| 47 | + * @method :post | ||
| 48 | + * @time :2023/9/6 10:17 | ||
| 49 | + */ | ||
| 39 | public function hrSave(){ | 50 | public function hrSave(){ |
| 51 | + try { | ||
| 40 | //处理参数 | 52 | //处理参数 |
| 41 | foreach ($this->model::specieField() as $v){ | 53 | foreach ($this->model::specieField() as $v){ |
| 42 | $this->param = $this->setJson($v,$this->param); | 54 | $this->param = $this->setJson($v,$this->param); |
| 43 | } | 55 | } |
| 44 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 56 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 45 | - $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | 57 | + $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 46 | }else{ | 58 | }else{ |
| 47 | - $this->param['manage_id'] = $this->manager['id']; | ||
| 48 | - $rs = $this->model->add($this->param); | 59 | + //添加管理员账号 |
| 60 | + $this->param['manage_id'] = $this->addManager($this->param['mobile'],$this->param['name']); | ||
| 61 | + $this->model->add($this->param); | ||
| 49 | } | 62 | } |
| 50 | - if($rs === false){ | 63 | + }catch (\Exception $e){ |
| 51 | $this->fail('error'); | 64 | $this->fail('error'); |
| 52 | } | 65 | } |
| 53 | return $this->success(); | 66 | return $this->success(); |
| @@ -61,6 +74,14 @@ class HrLogic extends BaseLogic | @@ -61,6 +74,14 @@ class HrLogic extends BaseLogic | ||
| 61 | * @time :2023/7/25 9:27 | 74 | * @time :2023/7/25 9:27 |
| 62 | */ | 75 | */ |
| 63 | public function getHrInfo($id){ | 76 | public function getHrInfo($id){ |
| 77 | + //查看当前用户是否有人事权限 | ||
| 78 | + if($this->manager['gid'] != ManageHr::GID_ZERO){ | ||
| 79 | + $groupModel = new Group(); | ||
| 80 | + $groupInfo = $groupModel->read(['id'=>$this->manager['gid']]); | ||
| 81 | + if (!in_array(20,$groupInfo['rights']) && ($id != $this->manager['id'])) { | ||
| 82 | + $this->fail('无权限查看其他用户信息'); | ||
| 83 | + } | ||
| 84 | + } | ||
| 64 | $data = $this->model->read(['id'=>$id]); | 85 | $data = $this->model->read(['id'=>$id]); |
| 65 | foreach ($this->model::specieField() as $v){ | 86 | foreach ($this->model::specieField() as $v){ |
| 66 | $data[$v] = json_decode($data[$v],true); | 87 | $data[$v] = json_decode($data[$v],true); |
| @@ -180,4 +201,26 @@ class HrLogic extends BaseLogic | @@ -180,4 +201,26 @@ class HrLogic extends BaseLogic | ||
| 180 | ]; | 201 | ]; |
| 181 | return $this->success($data); | 202 | return $this->success($data); |
| 182 | } | 203 | } |
| 204 | + | ||
| 205 | + /** | ||
| 206 | + * @remark :添加人事信息时 同步添加管理员账号 | ||
| 207 | + * @name :addManager | ||
| 208 | + * @author :lyh | ||
| 209 | + * @method :post | ||
| 210 | + * @time :2023/9/6 10:18 | ||
| 211 | + */ | ||
| 212 | + public function addManager($mobile,$name){ | ||
| 213 | + $managerModel = new Manage(); | ||
| 214 | + $info = $managerModel->read(['mobile'=>$mobile]); | ||
| 215 | + if($info === false){ | ||
| 216 | + $this->fail('当前号码已存在'); | ||
| 217 | + } | ||
| 218 | + $data = [ | ||
| 219 | + 'name'=>$name, | ||
| 220 | + 'mobile'=>$mobile, | ||
| 221 | + 'password'=>Hash::make('globalsov6'), | ||
| 222 | + 'gid'=>4, | ||
| 223 | + ]; | ||
| 224 | + return $managerModel->addReturnId($data); | ||
| 225 | + } | ||
| 183 | } | 226 | } |
| @@ -23,6 +23,13 @@ class ManageLogic extends BaseLogic | @@ -23,6 +23,13 @@ class ManageLogic extends BaseLogic | ||
| 23 | $this->model = new Manage(); | 23 | $this->model = new Manage(); |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | + /** | ||
| 27 | + * @remark :保存管理员 | ||
| 28 | + * @name :managerSave | ||
| 29 | + * @author :lyh | ||
| 30 | + * @method :post | ||
| 31 | + * @time :2023/9/11 9:34 | ||
| 32 | + */ | ||
| 26 | public function managerSave(){ | 33 | public function managerSave(){ |
| 27 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 34 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 28 | if(isset($this->param['password']) && !empty($this->param['password'])){ | 35 | if(isset($this->param['password']) && !empty($this->param['password'])){ |
| @@ -68,7 +75,8 @@ class ManageLogic extends BaseLogic | @@ -68,7 +75,8 @@ 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']]); | 78 | + $info = $this->model->read(['id'=>$this->param['id']], |
| 79 | + ['id','name','email','mobile','status','gid','sort','dept_id','is_dept_manager','created_at','role','updated_at']); | ||
| 72 | if($info === false){ | 80 | if($info === false){ |
| 73 | $this->fail('error'); | 81 | $this->fail('error'); |
| 74 | } | 82 | } |
| @@ -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(){ |
| 78 | + if(isset($this->param['user_list']) && !empty($this->param['user_list'])){ | ||
| 90 | $this->param['user_list'] = ','.trim($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 | +} |
| @@ -2,6 +2,9 @@ | @@ -2,6 +2,9 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Http\Logic\Aside\Project; | 3 | namespace App\Http\Logic\Aside\Project; |
| 4 | 4 | ||
| 5 | +use App\Models\Devops\ServerConfig; | ||
| 6 | +use App\Models\User\ProjectMenu; | ||
| 7 | +use App\Models\User\ProjectRole; | ||
| 5 | use Illuminate\Support\Arr as SupArr; | 8 | use Illuminate\Support\Arr as SupArr; |
| 6 | use App\Helper\Arr; | 9 | use App\Helper\Arr; |
| 7 | use App\Helper\Common; | 10 | use App\Helper\Common; |
| @@ -47,14 +50,11 @@ class ProjectLogic extends BaseLogic | @@ -47,14 +50,11 @@ class ProjectLogic extends BaseLogic | ||
| 47 | * @time :2023/7/28 17:11 | 50 | * @time :2023/7/28 17:11 |
| 48 | */ | 51 | */ |
| 49 | public function getProjectInfo($id){ | 52 | public function getProjectInfo($id){ |
| 50 | -// $info = Common::get_user_cache($this->model->getTable(),$id); | ||
| 51 | -// if(empty($info)){ | ||
| 52 | $info = $this->model->with('payment')->with('deploy_build')->with('deploy_optimize')->with('online_check') | 53 | $info = $this->model->with('payment')->with('deploy_build')->with('deploy_optimize')->with('online_check') |
| 53 | ->with('project_after')->where(['id'=>$id])->first()->toArray(); | 54 | ->with('project_after')->where(['id'=>$id])->first()->toArray(); |
| 54 | if(!empty($info['online_check']['created_manage_id'])){ | 55 | if(!empty($info['online_check']['created_manage_id'])){ |
| 55 | $info['online_check']['name'] = (new Manage())->read(['id'=>$info['online_check']['created_manage_id']])['name'] ?? ''; | 56 | $info['online_check']['name'] = (new Manage())->read(['id'=>$info['online_check']['created_manage_id']])['name'] ?? ''; |
| 56 | } | 57 | } |
| 57 | - | ||
| 58 | if(isset($info['deploy_optimize']['minor_keywords']) && !empty($info['deploy_optimize']['minor_keywords'])){ | 58 | if(isset($info['deploy_optimize']['minor_keywords']) && !empty($info['deploy_optimize']['minor_keywords'])){ |
| 59 | $info['deploy_optimize']['minor_keywords'] = json_decode($info['deploy_optimize']['minor_keywords']) ?? ''; | 59 | $info['deploy_optimize']['minor_keywords'] = json_decode($info['deploy_optimize']['minor_keywords']) ?? ''; |
| 60 | }else{ | 60 | }else{ |
| @@ -63,8 +63,6 @@ class ProjectLogic extends BaseLogic | @@ -63,8 +63,6 @@ class ProjectLogic extends BaseLogic | ||
| 63 | if($info['extend_type'] != 0){ | 63 | if($info['extend_type'] != 0){ |
| 64 | $info['type'] = $info['extend_type']; | 64 | $info['type'] = $info['extend_type']; |
| 65 | } | 65 | } |
| 66 | -// Common::set_user_cache($info,$this->model->getTable(),$id); | ||
| 67 | -// } | ||
| 68 | return $this->success($info); | 66 | return $this->success($info); |
| 69 | } | 67 | } |
| 70 | 68 | ||
| @@ -164,6 +162,9 @@ class ProjectLogic extends BaseLogic | @@ -164,6 +162,9 @@ class ProjectLogic extends BaseLogic | ||
| 164 | */ | 162 | */ |
| 165 | protected function saveProjectDeployBuild($deploy_build){ | 163 | protected function saveProjectDeployBuild($deploy_build){ |
| 166 | $deployBuildModel = new DeployBuild(); | 164 | $deployBuildModel = new DeployBuild(); |
| 165 | + if(isset($deploy_build['configuration']) && !empty($deploy_build['configuration'])){ | ||
| 166 | + $deploy_build['configuration'] = Arr::a2s($deploy_build['configuration']); | ||
| 167 | + } | ||
| 167 | $deployBuildModel->edit($deploy_build,['id'=>$deploy_build['id']]); | 168 | $deployBuildModel->edit($deploy_build,['id'=>$deploy_build['id']]); |
| 168 | return $this->success(); | 169 | return $this->success(); |
| 169 | } | 170 | } |
| @@ -178,8 +179,9 @@ class ProjectLogic extends BaseLogic | @@ -178,8 +179,9 @@ class ProjectLogic extends BaseLogic | ||
| 178 | protected function saveProjectDeployOptimize($deploy_optimize){ | 179 | protected function saveProjectDeployOptimize($deploy_optimize){ |
| 179 | $deployOptimizeModel = new DeployOptimize(); | 180 | $deployOptimizeModel = new DeployOptimize(); |
| 180 | if(isset($deploy_optimize['domain']) && !empty($deploy_optimize['domain'])){ | 181 | if(isset($deploy_optimize['domain']) && !empty($deploy_optimize['domain'])){ |
| 181 | - if (!preg_match('/http/', $deploy_optimize['domain'])) { | ||
| 182 | - $deploy_optimize['domain'] = 'https://'.trim($deploy_optimize['domain'],'/').'/'; | 182 | + //更改域名 |
| 183 | + if(isset($deploy_optimize['domain']) && !empty($deploy_optimize['domain'])){ | ||
| 184 | + $this->editDomainStatus($deploy_optimize['domain'],$deploy_optimize['project_id']); | ||
| 183 | } | 185 | } |
| 184 | } | 186 | } |
| 185 | if(isset($deploy_optimize['minor_languages']) && !empty($deploy_optimize['minor_languages'])){ | 187 | if(isset($deploy_optimize['minor_languages']) && !empty($deploy_optimize['minor_languages'])){ |
| @@ -214,12 +216,20 @@ class ProjectLogic extends BaseLogic | @@ -214,12 +216,20 @@ class ProjectLogic extends BaseLogic | ||
| 214 | * @time :2023/8/30 14:30 | 216 | * @time :2023/8/30 14:30 |
| 215 | */ | 217 | */ |
| 216 | public function createProjectData($param){ | 218 | public function createProjectData($param){ |
| 219 | + //查看当前项目状态是否为初始项目 | ||
| 220 | + $info = $this->model->read(['id'=>$param['id']]); | ||
| 221 | + //项目为初始项目时,只能选择建站中 | ||
| 222 | + if($info['type'] == Project::TYPE_ZERO){ | ||
| 223 | + $param['type'] = Project::TYPE_ONE; | ||
| 224 | + } | ||
| 217 | //创建默认数据库 | 225 | //创建默认数据库 |
| 218 | if($param['type'] == Project::TYPE_ONE){ | 226 | if($param['type'] == Project::TYPE_ONE){ |
| 219 | //初始化数据库 | 227 | //初始化数据库 |
| 220 | if(isset($param['mysql_id']) && !empty($param['mysql_id'])){ | 228 | if(isset($param['mysql_id']) && !empty($param['mysql_id'])){ |
| 221 | $this->initializationMysql($param['id']); | 229 | $this->initializationMysql($param['id']); |
| 222 | } | 230 | } |
| 231 | + //创建初始角色 | ||
| 232 | +// $this->createdRole($param['id']); | ||
| 223 | //初始账号 | 233 | //初始账号 |
| 224 | if(isset($param['mobile']) && !empty($param['mobile'])){ | 234 | if(isset($param['mobile']) && !empty($param['mobile'])){ |
| 225 | $this->createUser($param['mobile'],$param['id'],$param['lead_name']); | 235 | $this->createUser($param['mobile'],$param['id'],$param['lead_name']); |
| @@ -258,8 +268,8 @@ class ProjectLogic extends BaseLogic | @@ -258,8 +268,8 @@ class ProjectLogic extends BaseLogic | ||
| 258 | * @time :2023/8/28 10:50 | 268 | * @time :2023/8/28 10:50 |
| 259 | */ | 269 | */ |
| 260 | public function updateServe($serve_id){ | 270 | public function updateServe($serve_id){ |
| 261 | - $domainModel = new DomainInfo(); | ||
| 262 | - $domainModel->edit(['status'=>$domainModel::STATUS_ONE],['id'=>$serve_id]); | 271 | + $serverModel = new ServerConfig(); |
| 272 | + $serverModel->edit(['status'=>$serverModel::STATUS_ONE],['id'=>$serve_id]); | ||
| 263 | return $this->success(); | 273 | return $this->success(); |
| 264 | } | 274 | } |
| 265 | 275 | ||
| @@ -291,7 +301,32 @@ class ProjectLogic extends BaseLogic | @@ -291,7 +301,32 @@ class ProjectLogic extends BaseLogic | ||
| 291 | return $this->success(); | 301 | return $this->success(); |
| 292 | } | 302 | } |
| 293 | 303 | ||
| 294 | - | 304 | + /** |
| 305 | + * @remark :创建角色 | ||
| 306 | + * @name :createdRole | ||
| 307 | + * @author :lyh | ||
| 308 | + * @method :post | ||
| 309 | + * @time :2023/9/6 11:16 | ||
| 310 | + */ | ||
| 311 | + public function createdRole($project_id){ | ||
| 312 | + $roleModel = new ProjectRole(); | ||
| 313 | + //查看当前用户是否存在 | ||
| 314 | + $info = $roleModel->read(['project_id'=>$project_id]); | ||
| 315 | + if($info === false){ | ||
| 316 | + $menuModel = new ProjectMenu(); | ||
| 317 | + $ids = $menuModel->where(['status'=>0])->pluck('id')->toArray(); | ||
| 318 | + $data = [ | ||
| 319 | + 'name'=>'超级管理员', | ||
| 320 | + 'role_menu'=>implode(',',$ids), | ||
| 321 | + 'project_id'=>$project_id, | ||
| 322 | + 'type'=>1, | ||
| 323 | + 'operator_id'=>$this->manager['id'], | ||
| 324 | + 'create_id'=>$this->manager['id'], | ||
| 325 | + ]; | ||
| 326 | + $roleModel->add($data); | ||
| 327 | + } | ||
| 328 | + return $this->success(); | ||
| 329 | + } | ||
| 295 | 330 | ||
| 296 | public function clearCache($id) | 331 | public function clearCache($id) |
| 297 | { | 332 | { |
| @@ -355,8 +390,38 @@ class ProjectLogic extends BaseLogic | @@ -355,8 +390,38 @@ class ProjectLogic extends BaseLogic | ||
| 355 | } | 390 | } |
| 356 | 391 | ||
| 357 | 392 | ||
| 393 | + /** | ||
| 394 | + * @remark :修改域名时,同时更改其状态 | ||
| 395 | + * @name :domainStatus | ||
| 396 | + * @author :lyh | ||
| 397 | + * @method :post | ||
| 398 | + * @time :2023/9/4 14:29 | ||
| 399 | + */ | ||
| 400 | + public function editDomainStatus($domain,$project_id){ | ||
| 401 | + $domainModel = new DomainInfo(); | ||
| 402 | + //先清空上一次所绑定的域名 | ||
| 403 | + $info = $domainModel->read(['project_id'=>$project_id]); | ||
| 404 | + if($info !== false){ | ||
| 405 | + $domainModel->edit(['project_id'=>0,'status'=>DomainInfo::STATUS_ZERO],['id'=>$info['id']]); | ||
| 406 | + } | ||
| 407 | + //重新设置域名 | ||
| 408 | + $domainModel->edit(['status'=>DomainInfo::STATUS_ONE,'project_id'=>$project_id],['id'=>$domain]); | ||
| 409 | + return $this->success(); | ||
| 410 | + } | ||
| 358 | 411 | ||
| 359 | - | ||
| 360 | - | 412 | + /** |
| 413 | + * @remark : | ||
| 414 | + * @name :projectDel | ||
| 415 | + * @author :lyh | ||
| 416 | + * @method :post | ||
| 417 | + * @time :2023/9/8 15:23 | ||
| 418 | + */ | ||
| 419 | + public function projectDel(){ | ||
| 420 | + $rs = $this->edit(['delete_status'=>1],['id'=>$this->param['id']]); | ||
| 421 | + if($rs === false){ | ||
| 422 | + $this->fail('error'); | ||
| 423 | + } | ||
| 424 | + return $this->success(); | ||
| 425 | + } | ||
| 361 | 426 | ||
| 362 | } | 427 | } |
| @@ -25,7 +25,7 @@ class ATemplateLogic extends BaseLogic | @@ -25,7 +25,7 @@ class ATemplateLogic extends BaseLogic | ||
| 25 | * @method :post | 25 | * @method :post |
| 26 | * @time :2023/6/28 17:03 | 26 | * @time :2023/6/28 17:03 |
| 27 | */ | 27 | */ |
| 28 | - public function aTemplateList($map,$page,$row,$order = ['created_at'],$filed = ['id','name','url','status','deleted_status','sort','image']){ | 28 | + public function aTemplateList($map,$page,$row,$order = ['created_at'],$filed = ['*']){ |
| 29 | $map['deleted_status'] = 0; | 29 | $map['deleted_status'] = 0; |
| 30 | $map['status'] = 0; | 30 | $map['status'] = 0; |
| 31 | $lists = $this->model->lists($map,$page,$row,$order,$filed); | 31 | $lists = $this->model->lists($map,$page,$row,$order,$filed); |
| @@ -115,4 +115,19 @@ class ProjectMenuLogic extends BaseLogic | @@ -115,4 +115,19 @@ class ProjectMenuLogic extends BaseLogic | ||
| 115 | $list = $this->model->list(['pid'=>$this->param['id'], 'is_role'=>1]); | 115 | $list = $this->model->list(['pid'=>$this->param['id'], 'is_role'=>1]); |
| 116 | return $this->success($list); | 116 | return $this->success($list); |
| 117 | } | 117 | } |
| 118 | + | ||
| 119 | + /** | ||
| 120 | + * @remark :设置排序 | ||
| 121 | + * @name :setSort | ||
| 122 | + * @author :lyh | ||
| 123 | + * @method :post | ||
| 124 | + * @time :2023/8/10 16:42 | ||
| 125 | + */ | ||
| 126 | + public function setParamStatus(){ | ||
| 127 | + $rs = $this->model->edit(['sort'=>$this->param['sort']],['id'=>$this->param['id']]); | ||
| 128 | + if($rs === false){ | ||
| 129 | + $this->fail('修改失败'); | ||
| 130 | + } | ||
| 131 | + return $this->success(); | ||
| 132 | + } | ||
| 118 | } | 133 | } |
| @@ -159,4 +159,19 @@ class UserLogic extends BaseLogic | @@ -159,4 +159,19 @@ class UserLogic extends BaseLogic | ||
| 159 | Common::del_user_cache($this->model, $ids, 'A'); | 159 | Common::del_user_cache($this->model, $ids, 'A'); |
| 160 | return $this->success(); | 160 | return $this->success(); |
| 161 | } | 161 | } |
| 162 | + | ||
| 163 | + /** | ||
| 164 | + * @remark :设置排序 | ||
| 165 | + * @name :setSort | ||
| 166 | + * @author :lyh | ||
| 167 | + * @method :post | ||
| 168 | + * @time :2023/8/10 16:42 | ||
| 169 | + */ | ||
| 170 | + public function setParamStatus(){ | ||
| 171 | + $rs = $this->model->edit(['sort'=>$this->param['sort']],['id'=>$this->param['id']]); | ||
| 172 | + if($rs === false){ | ||
| 173 | + $this->fail('修改失败'); | ||
| 174 | + } | ||
| 175 | + return $this->success(); | ||
| 176 | + } | ||
| 162 | } | 177 | } |
| @@ -14,6 +14,7 @@ use App\Models\Template\BTemplate; | @@ -14,6 +14,7 @@ use App\Models\Template\BTemplate; | ||
| 14 | use App\Models\Template\BTemplateLog; | 14 | use App\Models\Template\BTemplateLog; |
| 15 | use App\Models\Template\Template; | 15 | use App\Models\Template\Template; |
| 16 | use Illuminate\Support\Facades\DB; | 16 | use Illuminate\Support\Facades\DB; |
| 17 | +use mysql_xdevapi\Exception; | ||
| 17 | 18 | ||
| 18 | /** | 19 | /** |
| 19 | * @remark :b端模块 | 20 | * @remark :b端模块 |
| @@ -316,6 +317,43 @@ class BTemplateLogic extends BaseLogic | @@ -316,6 +317,43 @@ class BTemplateLogic extends BaseLogic | ||
| 316 | return $info['values']; | 317 | return $info['values']; |
| 317 | } | 318 | } |
| 318 | 319 | ||
| 320 | + /** | ||
| 321 | + * @remark :设置主题公共head | ||
| 322 | + * @name :setHeadInfo | ||
| 323 | + * @author :lyh | ||
| 324 | + * @method :post | ||
| 325 | + * @time :2023/7/10 15:32 | ||
| 326 | + */ | ||
| 327 | + public function setHeadFooterSave(){ | ||
| 328 | + $serviceSettingModel = new ServiceSettingModel(); | ||
| 329 | + DB::beginTransaction(); | ||
| 330 | + try { | ||
| 331 | + $serviceSettingModel->del(['type'=>2]); | ||
| 332 | + $data = [ | ||
| 333 | + ['type'=>2,'key'=>'head','values'=>$this->param['head'],'created_at'=>date('Y-m-d H:i:s'),'updated_at'=>date('Y-m-d H:i:s')], | ||
| 334 | + ['type'=>2,'key'=>'footer','values'=>$this->param['footer'],'created_at'=>date('Y-m-d H:i:s'),'updated_at'=>date('Y-m-d H:i:s')] | ||
| 335 | + ]; | ||
| 336 | + $serviceSettingModel->insert($data); | ||
| 337 | + DB::commit(); | ||
| 338 | + }catch (Exception $e){ | ||
| 339 | + DB::rollBack(); | ||
| 340 | + $this->fail('error'); | ||
| 341 | + } | ||
| 342 | + } | ||
| 343 | + | ||
| 344 | + /** | ||
| 345 | + * @remark :获取主题公共head | ||
| 346 | + * @name :getHeadInfo | ||
| 347 | + * @author :lyh | ||
| 348 | + * @method :post | ||
| 349 | + * @time :2023/7/10 15:33 | ||
| 350 | + */ | ||
| 351 | + public function getHeadFooterList(){ | ||
| 352 | + $serviceSettingModel = new ServiceSettingModel(); | ||
| 353 | + $list = $serviceSettingModel->list(['type'=>2],'created_at'); | ||
| 354 | + return $this->success($list); | ||
| 355 | + } | ||
| 356 | + | ||
| 319 | 357 | ||
| 320 | /** | 358 | /** |
| 321 | * @remark :获取类型 | 359 | * @remark :获取类型 |
| @@ -77,12 +77,12 @@ class CustomTemplateLogic extends BaseLogic | @@ -77,12 +77,12 @@ class CustomTemplateLogic extends BaseLogic | ||
| 77 | } | 77 | } |
| 78 | //路由映射 | 78 | //路由映射 |
| 79 | if(isset($this->param['url']) && !empty($this->param['url'])){ | 79 | if(isset($this->param['url']) && !empty($this->param['url'])){ |
| 80 | - RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $id, $this->user['project_id']); | 80 | + $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $id, $this->user['project_id']); |
| 81 | //TODO::通知网站更新 | 81 | //TODO::通知网站更新 |
| 82 | $data = [ | 82 | $data = [ |
| 83 | 'project_id'=>$this->user['project_id'], | 83 | 'project_id'=>$this->user['project_id'], |
| 84 | 'type'=>RouteMap::SOURCE_PAGE, | 84 | 'type'=>RouteMap::SOURCE_PAGE, |
| 85 | - 'route'=>$this->param['url'], | 85 | + 'route'=>$route, |
| 86 | ]; | 86 | ]; |
| 87 | $this->updateNotify($data); | 87 | $this->updateNotify($data); |
| 88 | } | 88 | } |
| @@ -122,6 +122,8 @@ class CustomTemplateLogic extends BaseLogic | @@ -122,6 +122,8 @@ class CustomTemplateLogic extends BaseLogic | ||
| 122 | 'project_id'=>$this->user['project_id'], | 122 | 'project_id'=>$this->user['project_id'], |
| 123 | 'source'=>1//首页 | 123 | 'source'=>1//首页 |
| 124 | ]); | 124 | ]); |
| 125 | + $html = ''; | ||
| 126 | + if($TemplateInfo !== false){ | ||
| 125 | if(empty($preg_html)){ | 127 | if(empty($preg_html)){ |
| 126 | $preg_html = "<main></main>"; | 128 | $preg_html = "<main></main>"; |
| 127 | $html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', "<style id='globalsojs-styles'></style>", $TemplateInfo['html']); | 129 | $html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', "<style id='globalsojs-styles'></style>", $TemplateInfo['html']); |
| @@ -130,6 +132,7 @@ class CustomTemplateLogic extends BaseLogic | @@ -130,6 +132,7 @@ class CustomTemplateLogic extends BaseLogic | ||
| 130 | } | 132 | } |
| 131 | //内容 | 133 | //内容 |
| 132 | $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', $preg_html, $html); | 134 | $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', $preg_html, $html); |
| 135 | + } | ||
| 133 | return $html; | 136 | return $html; |
| 134 | } | 137 | } |
| 135 | 138 |
| @@ -8,6 +8,7 @@ use App\Exceptions\BsideGlobalException; | @@ -8,6 +8,7 @@ use App\Exceptions\BsideGlobalException; | ||
| 8 | use App\Http\Logic\Logic; | 8 | use App\Http\Logic\Logic; |
| 9 | use App\Models\Com\UpdateNotify; | 9 | use App\Models\Com\UpdateNotify; |
| 10 | use App\Models\Project\Project; | 10 | use App\Models\Project\Project; |
| 11 | +use App\Models\RouteMap\RouteDelete; | ||
| 11 | use Illuminate\Support\Facades\Cache; | 12 | use Illuminate\Support\Facades\Cache; |
| 12 | 13 | ||
| 13 | /** | 14 | /** |
| @@ -159,4 +160,23 @@ class BaseLogic extends Logic | @@ -159,4 +160,23 @@ class BaseLogic extends Logic | ||
| 159 | } | 160 | } |
| 160 | return $this->success(); | 161 | return $this->success(); |
| 161 | } | 162 | } |
| 163 | + | ||
| 164 | + /** | ||
| 165 | + * @remark :删除和编辑路由时生成一条记录 | ||
| 166 | + * @name :setRouteDeleteSave | ||
| 167 | + * @author :lyh | ||
| 168 | + * @method :post | ||
| 169 | + * @time :2023/9/7 9:38 | ||
| 170 | + */ | ||
| 171 | + public function setRouteDeleteSave($param){ | ||
| 172 | + $routeDeleteModel = new RouteDelete(); | ||
| 173 | + $data = [ | ||
| 174 | + 'project_id'=>$this->user['project_id'], | ||
| 175 | + 'source'=>$param['source'], | ||
| 176 | + 'created_at'=>date('Y-m-d H:i:s'), | ||
| 177 | + 'route'=>$param['route'], | ||
| 178 | + ]; | ||
| 179 | + $routeDeleteModel->insert($data); | ||
| 180 | + return $this->success(); | ||
| 181 | + } | ||
| 162 | } | 182 | } |
| @@ -35,23 +35,35 @@ class BlogCategoryLogic extends BaseLogic | @@ -35,23 +35,35 @@ class BlogCategoryLogic extends BaseLogic | ||
| 35 | $v['category_name'] = trim($str,','); | 35 | $v['category_name'] = trim($str,','); |
| 36 | return $this->success($v); | 36 | return $this->success($v); |
| 37 | } | 37 | } |
| 38 | + | ||
| 38 | /** | 39 | /** |
| 39 | - * @name :添加时验证上级分类是否有商品,有则替换带当前分类下 | ||
| 40 | - * @return void | ||
| 41 | - * @author :liyuhang | ||
| 42 | - * @method | 40 | + * @remark :保存数据 |
| 41 | + * @name :categorySave | ||
| 42 | + * @author :lyh | ||
| 43 | + * @method :post | ||
| 44 | + * @time :2023/9/7 13:42 | ||
| 43 | */ | 45 | */ |
| 44 | - public function add_blog_category(){ | 46 | + public function categorySave(){ |
| 45 | //验证名称是否存在 | 47 | //验证名称是否存在 |
| 46 | $this->verifyParamName($this->param['name']); | 48 | $this->verifyParamName($this->param['name']); |
| 47 | - //拼接参数 | ||
| 48 | - $this->param = $this->addParamProcessing($this->param); | ||
| 49 | DB::beginTransaction(); | 49 | DB::beginTransaction(); |
| 50 | try { | 50 | try { |
| 51 | - $cate_id = $this->model->insertGetId($this->param); | 51 | + if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 52 | + //验证参数是否可编辑 | ||
| 53 | + $this->verifyParamEdit($this->param['id'],$this->param['pid']); | ||
| 54 | + //查看路由是否更新 | ||
| 55 | + $id = $this->editCategoryRoute($this->param['id'],$this->param['alias']); | ||
| 56 | + $this->param['operator_id'] = $this->user['id']; | ||
| 57 | + $this->edit($this->param,['id'=>$this->param['id']]); | ||
| 58 | + }else{ | ||
| 59 | + //拼接参数 | ||
| 60 | + $this->param = $this->addParamProcessing($this->param); | ||
| 61 | + $id = $this->model->addReturnId($this->param); | ||
| 52 | //处理子集 | 62 | //处理子集 |
| 53 | - $this->addProcessingSon($cate_id); | ||
| 54 | - $route = RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_BLOG_CATE, $cate_id, $this->user['project_id']); | 63 | + $this->addProcessingSon($id); |
| 64 | + } | ||
| 65 | + $route = RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']); | ||
| 66 | + $this->edit(['alias'=>$route],['id'=>$id]); | ||
| 55 | DB::commit(); | 67 | DB::commit(); |
| 56 | }catch (\Exception $e){ | 68 | }catch (\Exception $e){ |
| 57 | DB::rollBack(); | 69 | DB::rollBack(); |
| @@ -63,24 +75,26 @@ class BlogCategoryLogic extends BaseLogic | @@ -63,24 +75,26 @@ class BlogCategoryLogic extends BaseLogic | ||
| 63 | } | 75 | } |
| 64 | 76 | ||
| 65 | /** | 77 | /** |
| 66 | - * @name :编辑分类 | ||
| 67 | - * @return void | ||
| 68 | - * @author :liyuhang | ||
| 69 | - * @method | 78 | + * @remark :编辑路由时生成路由记录 |
| 79 | + * @name :editCategoryRoute | ||
| 80 | + * @author :lyh | ||
| 81 | + * @method :post | ||
| 82 | + * @time :2023/9/7 10:51 | ||
| 70 | */ | 83 | */ |
| 71 | - public function edit_blog_category(){ | ||
| 72 | - //验证名称是否存在 | ||
| 73 | - $this->verifyParamName($this->param['name'],$this->param['id']); | ||
| 74 | - //验证参数是否可编辑 | ||
| 75 | - $this->verifyParamEdit($this->param['id'],$this->param['pid']); | ||
| 76 | - $this->param['operator_id'] = $this->user['id']; | ||
| 77 | - $this->edit($this->param,['id'=>$this->param['id']]); | ||
| 78 | - $route = RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_BLOG_CATE, $this->param['id'], $this->user['project_id']); | ||
| 79 | - //通知更新 | ||
| 80 | - $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_BLOG_CATE, 'route'=>$route]); | 84 | + public function editCategoryRoute($id,$route){ |
| 85 | + //生成一条删除路由记录 | ||
| 86 | + $info = $this->model->read(['id'=>$id],['id','alias']); | ||
| 87 | + if($info['alias'] != $route){ | ||
| 88 | + $data = [ | ||
| 89 | + 'source'=>RouteMap::SOURCE_NEWS_CATE, | ||
| 90 | + 'route'=>$info['alias'], | ||
| 91 | + ]; | ||
| 92 | + $this->setRouteDeleteSave($data); | ||
| 93 | + } | ||
| 81 | return $this->success(); | 94 | return $this->success(); |
| 82 | } | 95 | } |
| 83 | 96 | ||
| 97 | + | ||
| 84 | /** | 98 | /** |
| 85 | * @remark :查看参数是否可编辑 | 99 | * @remark :查看参数是否可编辑 |
| 86 | * @name :verifyParamEdit | 100 | * @name :verifyParamEdit |
| @@ -115,7 +129,7 @@ class BlogCategoryLogic extends BaseLogic | @@ -115,7 +129,7 @@ class BlogCategoryLogic extends BaseLogic | ||
| 115 | * @method | 129 | * @method |
| 116 | */ | 130 | */ |
| 117 | public function info_blog_category(){ | 131 | public function info_blog_category(){ |
| 118 | - $info = $this->info($this->param); | 132 | + $info = $this->model->read($this->param); |
| 119 | return $this->success($info); | 133 | return $this->success($info); |
| 120 | } | 134 | } |
| 121 | 135 | ||
| @@ -139,24 +153,35 @@ class BlogCategoryLogic extends BaseLogic | @@ -139,24 +153,35 @@ class BlogCategoryLogic extends BaseLogic | ||
| 139 | * @author :liyuhang | 153 | * @author :liyuhang |
| 140 | * @method | 154 | * @method |
| 141 | */ | 155 | */ |
| 142 | - public function del_blog_category(){ | ||
| 143 | - $ids = $this->param['id']; | ||
| 144 | - foreach ($ids as $v){ | 156 | + public function delBlogCategory(){ |
| 157 | + foreach ($this->param['id'] as $id){ | ||
| 158 | + $this->verifyIsDelete($id); | ||
| 159 | + //删除路由 | ||
| 160 | + $this->delRoute($id); | ||
| 161 | + $this->model->del(['id'=>$id]); | ||
| 162 | + } | ||
| 163 | + return $this->success(); | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + /** | ||
| 167 | + * @remark :验证是否可删除 | ||
| 168 | + * @name :VerifyIsDelete | ||
| 169 | + * @author :lyh | ||
| 170 | + * @method :post | ||
| 171 | + * @time :2023/9/7 14:40 | ||
| 172 | + */ | ||
| 173 | + public function verifyIsDelete($id){ | ||
| 145 | //查询是否有子分类 | 174 | //查询是否有子分类 |
| 146 | - $rs = $this->model->read(['pid'=>$v],['id']); | 175 | + $rs = $this->model->read(['pid'=>$id],['id']); |
| 147 | if($rs !== false){ | 176 | if($rs !== false){ |
| 148 | $this->response('当前分类拥有子分类不允许删除'); | 177 | $this->response('当前分类拥有子分类不允许删除'); |
| 149 | } | 178 | } |
| 150 | //查看当前分内下是否有博客 | 179 | //查看当前分内下是否有博客 |
| 151 | $blogModel = new BlogModel(); | 180 | $blogModel = new BlogModel(); |
| 152 | - $rs = $blogModel->read(['category_id'=>$v],['id']); | 181 | + $rs = $blogModel->read(['category_id'=>$id],['id']); |
| 153 | if($rs !== false){ | 182 | if($rs !== false){ |
| 154 | $this->response('当前分类拥有博客,不允许删除'); | 183 | $this->response('当前分类拥有博客,不允许删除'); |
| 155 | } | 184 | } |
| 156 | - RouteMap::delRoute(RouteMap::SOURCE_BLOG_CATE, $v, $this->user['project_id']); | ||
| 157 | - } | ||
| 158 | - $this->param['id'] = ['in',$this->param['id']]; | ||
| 159 | - $this->del($this->param,$ids); | ||
| 160 | return $this->success(); | 185 | return $this->success(); |
| 161 | } | 186 | } |
| 162 | 187 | ||
| @@ -186,8 +211,6 @@ class BlogCategoryLogic extends BaseLogic | @@ -186,8 +211,6 @@ class BlogCategoryLogic extends BaseLogic | ||
| 186 | $param['project_id'] = $this->user['project_id']; | 211 | $param['project_id'] = $this->user['project_id']; |
| 187 | $param['operator_id'] = $this->user['id']; | 212 | $param['operator_id'] = $this->user['id']; |
| 188 | $param['create_id'] = $this->user['id']; | 213 | $param['create_id'] = $this->user['id']; |
| 189 | - $param['created_at'] = date('Y-m-d H:i:s'); | ||
| 190 | - $param['updated_at'] = date('Y-m-d H:i:s'); | ||
| 191 | return $this->success($param); | 214 | return $this->success($param); |
| 192 | } | 215 | } |
| 193 | 216 | ||
| @@ -197,16 +220,14 @@ class BlogCategoryLogic extends BaseLogic | @@ -197,16 +220,14 @@ class BlogCategoryLogic extends BaseLogic | ||
| 197 | * @method :post | 220 | * @method :post |
| 198 | * @time :2023/6/13 11:41 | 221 | * @time :2023/6/13 11:41 |
| 199 | */ | 222 | */ |
| 200 | - public function verifyParamName($name,$id = ''){ | ||
| 201 | - if(isset($id) && !empty($id)){ | 223 | + public function verifyParamName($name){ |
| 224 | + if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 202 | $condition = [ | 225 | $condition = [ |
| 203 | - 'id'=>['!=',$id], | 226 | + 'id'=>['!=',$this->param['id']], |
| 204 | 'name'=>$name, | 227 | 'name'=>$name, |
| 205 | ]; | 228 | ]; |
| 206 | }else{ | 229 | }else{ |
| 207 | - $condition = [ | ||
| 208 | - 'name'=>$name | ||
| 209 | - ]; | 230 | + $condition = ['name'=>$name]; |
| 210 | } | 231 | } |
| 211 | $info = $this->model->read($condition); | 232 | $info = $this->model->read($condition); |
| 212 | if($info !== false){ | 233 | if($info !== false){ |
| @@ -246,4 +267,23 @@ class BlogCategoryLogic extends BaseLogic | @@ -246,4 +267,23 @@ class BlogCategoryLogic extends BaseLogic | ||
| 246 | return $this->success(); | 267 | return $this->success(); |
| 247 | } | 268 | } |
| 248 | 269 | ||
| 270 | + /** | ||
| 271 | + * @remark :删除路由 | ||
| 272 | + * @name :delRoute | ||
| 273 | + * @author :lyh | ||
| 274 | + * @method :post | ||
| 275 | + * @time :2023/9/7 10:50 | ||
| 276 | + */ | ||
| 277 | + public function delRoute($id){ | ||
| 278 | + //删除路由映射 | ||
| 279 | + RouteMap::delRoute(RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']); | ||
| 280 | + //生成一条删除路由记录 | ||
| 281 | + $info = $this->model->read(['id'=>$id],['id','alias']); | ||
| 282 | + $data = [ | ||
| 283 | + 'source'=>RouteMap::SOURCE_BLOG_CATE, | ||
| 284 | + 'route'=>$info['alias'], | ||
| 285 | + ]; | ||
| 286 | + $this->setRouteDeleteSave($data); | ||
| 287 | + return $this->success(); | ||
| 288 | + } | ||
| 249 | } | 289 | } |
| @@ -47,20 +47,28 @@ class BlogLogic extends BaseLogic | @@ -47,20 +47,28 @@ class BlogLogic extends BaseLogic | ||
| 47 | } | 47 | } |
| 48 | return $this->success($list); | 48 | return $this->success($list); |
| 49 | } | 49 | } |
| 50 | + | ||
| 50 | /** | 51 | /** |
| 51 | - * @name :添加博客 | ||
| 52 | - * @return void | ||
| 53 | - * @author :liyuhang | ||
| 54 | - * @method | 52 | + * @remark :保存数据 |
| 53 | + * @name :blogSave | ||
| 54 | + * @author :lyh | ||
| 55 | + * @method :post | ||
| 56 | + * @time :2023/9/7 11:49 | ||
| 55 | */ | 57 | */ |
| 56 | - public function blogAdd(){ | 58 | + public function blogSave(){ |
| 57 | //拼接参数 | 59 | //拼接参数 |
| 58 | DB::beginTransaction(); | 60 | DB::beginTransaction(); |
| 59 | try { | 61 | try { |
| 60 | $this->param = $this->paramProcessing($this->param); | 62 | $this->param = $this->paramProcessing($this->param); |
| 61 | - $rs = $this->model->insertGetId($this->param); | ||
| 62 | - $route = $this->param['url'] = RouteMap::setRoute($this->param['url'] ?: $this->param['name'], | ||
| 63 | - RouteMap::SOURCE_BLOG, $rs, $this->user['project_id']); | 63 | + if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 64 | + //是否更新路由 | ||
| 65 | + $id = $this->editNewsRoute($this->param['id'],$this->param['url']); | ||
| 66 | + $this->edit($this->param,['id'=>$this->param['id']]); | ||
| 67 | + }else{ | ||
| 68 | + $id = $this->model->addReturnId($this->param); | ||
| 69 | + } | ||
| 70 | + $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $id, $this->user['project_id']); | ||
| 71 | + $this->edit(['url'=>$route],['id'=>$id]); | ||
| 64 | DB::commit(); | 72 | DB::commit(); |
| 65 | }catch (\Exception $e){ | 73 | }catch (\Exception $e){ |
| 66 | DB::rollBack(); | 74 | DB::rollBack(); |
| @@ -72,28 +80,25 @@ class BlogLogic extends BaseLogic | @@ -72,28 +80,25 @@ class BlogLogic extends BaseLogic | ||
| 72 | } | 80 | } |
| 73 | 81 | ||
| 74 | /** | 82 | /** |
| 75 | - * @name : 编辑博客 | ||
| 76 | - * @return void | ||
| 77 | - * @author :liyuhang | ||
| 78 | - * @method | 83 | + * @remark :查看是否编辑路由 |
| 84 | + * @name :editCategoryRoute | ||
| 85 | + * @author :lyh | ||
| 86 | + * @method :post | ||
| 87 | + * @time :2023/9/7 11:05 | ||
| 79 | */ | 88 | */ |
| 80 | - public function blogEdit(){ | ||
| 81 | - //拼接参数 | ||
| 82 | - $this->param = $this->paramProcessing($this->param); | ||
| 83 | - DB::beginTransaction(); | ||
| 84 | - try { | ||
| 85 | - $route = RouteMap::setRoute($this->param['url'] ?: $this->param['name'], | ||
| 86 | - RouteMap::SOURCE_BLOG, $this->param['id'], $this->user['project_id']); | ||
| 87 | - $this->edit($this->param,['id'=>$this->param['id']]); | ||
| 88 | - DB::commit(); | ||
| 89 | - }catch (\Exception $e){ | ||
| 90 | - DB::rollBack(); | ||
| 91 | - $this->fail('error'); | 89 | + public function editNewsRoute($id,$route){ |
| 90 | + //生成一条删除路由记录 | ||
| 91 | + $info = $this->model->read(['id'=>$id],['id','url']); | ||
| 92 | + if($info['url'] != $route){ | ||
| 93 | + $data = [ | ||
| 94 | + 'source'=>RouteMap::SOURCE_BLOG, | ||
| 95 | + 'route'=>$info['url'], | ||
| 96 | + ]; | ||
| 97 | + $this->setRouteDeleteSave($data); | ||
| 92 | } | 98 | } |
| 93 | - //通知更新 | ||
| 94 | - $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_BLOG, 'route'=>$route]); | ||
| 95 | - return $this->success(); | 99 | + return $id; |
| 96 | } | 100 | } |
| 101 | + | ||
| 97 | /** | 102 | /** |
| 98 | * @name :编辑seo | 103 | * @name :编辑seo |
| 99 | * @return void | 104 | * @return void |
| @@ -108,6 +113,8 @@ class BlogLogic extends BaseLogic | @@ -108,6 +113,8 @@ class BlogLogic extends BaseLogic | ||
| 108 | } | 113 | } |
| 109 | return $this->success(); | 114 | return $this->success(); |
| 110 | } | 115 | } |
| 116 | + | ||
| 117 | + | ||
| 111 | /** | 118 | /** |
| 112 | * @name :获取数据详情 | 119 | * @name :获取数据详情 |
| 113 | * @return array | 120 | * @return array |
| @@ -128,8 +135,7 @@ class BlogLogic extends BaseLogic | @@ -128,8 +135,7 @@ class BlogLogic extends BaseLogic | ||
| 128 | //获取标签名称 | 135 | //获取标签名称 |
| 129 | $blogLabelLogic = new BlogLabelLogic(); | 136 | $blogLabelLogic = new BlogLabelLogic(); |
| 130 | $info = $blogLabelLogic->get_label_name($info); | 137 | $info = $blogLabelLogic->get_label_name($info); |
| 131 | - $info['route'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG, $info['id'], $this->user['project_id']); | ||
| 132 | - $info['url'] = $this->user['domain'] . $info['route']; | 138 | + $info['url'] = $this->user['domain'] . $info['url']; |
| 133 | $info['image_link'] = getImageUrl($info['image']); | 139 | $info['image_link'] = getImageUrl($info['image']); |
| 134 | //写入缓存 | 140 | //写入缓存 |
| 135 | Common::set_user_cache($info,$this->model->getTable(),$this->param['id']); | 141 | Common::set_user_cache($info,$this->model->getTable(),$this->param['id']); |
| @@ -144,7 +150,7 @@ class BlogLogic extends BaseLogic | @@ -144,7 +150,7 @@ class BlogLogic extends BaseLogic | ||
| 144 | * @author :liyuhang | 150 | * @author :liyuhang |
| 145 | * @method | 151 | * @method |
| 146 | */ | 152 | */ |
| 147 | - public function blog_status(){ | 153 | + public function blogStatus(){ |
| 148 | $this->param['operator_id'] = $this->user['id']; | 154 | $this->param['operator_id'] = $this->user['id']; |
| 149 | $rs = $this->model->edit($this->param,['id'=>['in',$this->param['id']]]); | 155 | $rs = $this->model->edit($this->param,['id'=>['in',$this->param['id']]]); |
| 150 | if($rs === false){ | 156 | if($rs === false){ |
| @@ -159,14 +165,12 @@ class BlogLogic extends BaseLogic | @@ -159,14 +165,12 @@ class BlogLogic extends BaseLogic | ||
| 159 | * @author :liyuhang | 165 | * @author :liyuhang |
| 160 | * @method | 166 | * @method |
| 161 | */ | 167 | */ |
| 162 | - public function blog_del(){ | ||
| 163 | - $ids = $this->param['id']; | 168 | + public function blogDel(){ |
| 164 | DB::beginTransaction(); | 169 | DB::beginTransaction(); |
| 165 | try { | 170 | try { |
| 166 | - $this->param['id'] = ['in',$this->param['id']]; | ||
| 167 | - $this->del($this->param,$ids); | ||
| 168 | - foreach ($ids as $id){ | ||
| 169 | - RouteMap::delRoute(RouteMap::SOURCE_BLOG, $id, $this->user['project_id']); | 171 | + foreach ($this->param['id'] as $id){ |
| 172 | + $this->delRoute($id); | ||
| 173 | + $this->model->del(['id'=>$id]); | ||
| 170 | } | 174 | } |
| 171 | DB::commit(); | 175 | DB::commit(); |
| 172 | }catch (Exception $e){ | 176 | }catch (Exception $e){ |
| @@ -176,6 +180,25 @@ class BlogLogic extends BaseLogic | @@ -176,6 +180,25 @@ class BlogLogic extends BaseLogic | ||
| 176 | return $this->success(); | 180 | return $this->success(); |
| 177 | } | 181 | } |
| 178 | 182 | ||
| 183 | + /** | ||
| 184 | + * @remark :删除路由 | ||
| 185 | + * @name :delRoute | ||
| 186 | + * @author :lyh | ||
| 187 | + * @method :post | ||
| 188 | + * @time :2023/9/7 10:50 | ||
| 189 | + */ | ||
| 190 | + public function delRoute($id){ | ||
| 191 | + //删除路由映射 | ||
| 192 | + RouteMap::delRoute(RouteMap::SOURCE_BLOG, $id, $this->user['project_id']); | ||
| 193 | + //生成一条删除路由记录 | ||
| 194 | + $info = $this->model->read(['id'=>$id],['id','url']); | ||
| 195 | + $data = [ | ||
| 196 | + 'source'=>RouteMap::SOURCE_BLOG, | ||
| 197 | + 'route'=>$info['url'], | ||
| 198 | + ]; | ||
| 199 | + $this->setRouteDeleteSave($data); | ||
| 200 | + return $this->success(); | ||
| 201 | + } | ||
| 179 | 202 | ||
| 180 | /** | 203 | /** |
| 181 | * @name :(参数处理)paramProcessing | 204 | * @name :(参数处理)paramProcessing |
| @@ -191,8 +214,6 @@ class BlogLogic extends BaseLogic | @@ -191,8 +214,6 @@ class BlogLogic extends BaseLogic | ||
| 191 | $param['create_id'] = $this->user['id']; | 214 | $param['create_id'] = $this->user['id']; |
| 192 | $param['operator_id'] = $this->user['id']; | 215 | $param['operator_id'] = $this->user['id']; |
| 193 | $param['project_id'] = $this->user['project_id']; | 216 | $param['project_id'] = $this->user['project_id']; |
| 194 | - $param['created_at'] = date('Y-m-d H:i:s',time()); | ||
| 195 | - $param['updated_at'] = date('Y-m-d H:i:s',time()); | ||
| 196 | $param['category_id'] = ','.$param['category_id'].','; | 217 | $param['category_id'] = ','.$param['category_id'].','; |
| 197 | } | 218 | } |
| 198 | return $this->success($param); | 219 | return $this->success($param); |
| @@ -22,7 +22,7 @@ class MailLogic extends BaseLogic | @@ -22,7 +22,7 @@ class MailLogic extends BaseLogic | ||
| 22 | * @author :liyuhang | 22 | * @author :liyuhang |
| 23 | */ | 23 | */ |
| 24 | public function mail_info(){ | 24 | public function mail_info(){ |
| 25 | - $info = $this->info($this->param); | 25 | + $info = $this->model->read($this->param); |
| 26 | //生成一条阅读记录 | 26 | //生成一条阅读记录 |
| 27 | $mailUserModel = new MailUserModel(); | 27 | $mailUserModel = new MailUserModel(); |
| 28 | $data = [ | 28 | $data = [ |
| @@ -5,6 +5,8 @@ namespace App\Http\Logic\Bside\Nav; | @@ -5,6 +5,8 @@ namespace App\Http\Logic\Bside\Nav; | ||
| 5 | 5 | ||
| 6 | use App\Http\Logic\Bside\BaseLogic; | 6 | use App\Http\Logic\Bside\BaseLogic; |
| 7 | use App\Models\Nav\BNav; | 7 | use App\Models\Nav\BNav; |
| 8 | +use App\Models\RouteMap\RouteMap; | ||
| 9 | +use Illuminate\Support\Facades\DB; | ||
| 8 | 10 | ||
| 9 | 11 | ||
| 10 | /** | 12 | /** |
| @@ -32,7 +34,33 @@ class NavLogic extends BaseLogic | @@ -32,7 +34,33 @@ class NavLogic extends BaseLogic | ||
| 32 | */ | 34 | */ |
| 33 | public function navSave() | 35 | public function navSave() |
| 34 | { | 36 | { |
| 37 | + DB::beginTransaction(); | ||
| 38 | + try { | ||
| 35 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 39 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 40 | + $this->handleEditParam();//验证是否可编辑分类 | ||
| 41 | + $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 42 | + }else{ | ||
| 43 | + $this->param['project_id'] = $this->user['project_id']; | ||
| 44 | + $this->model->add($this->param); | ||
| 45 | + } | ||
| 46 | + DB::commit(); | ||
| 47 | + }catch (\Exception $e){ | ||
| 48 | + DB::rollBack(); | ||
| 49 | + $this->fail('error'); | ||
| 50 | + } | ||
| 51 | + //编辑菜单后,通知更新 | ||
| 52 | + $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NAV, 'route'=>'all']); | ||
| 53 | + return $this->success(); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * @remark :验证是否可编辑 | ||
| 58 | + * @name :handleEditParam | ||
| 59 | + * @author :lyh | ||
| 60 | + * @method :post | ||
| 61 | + * @time :2023/9/7 14:36 | ||
| 62 | + */ | ||
| 63 | + public function handleEditParam(){ | ||
| 36 | $info = $this->model->read(['id'=>$this->param['id']]); | 64 | $info = $this->model->read(['id'=>$this->param['id']]); |
| 37 | if($this->param['pid'] == $info['id']){ | 65 | if($this->param['pid'] == $info['id']){ |
| 38 | $this->fail('不允许成为自己的上级'); | 66 | $this->fail('不允许成为自己的上级'); |
| @@ -41,14 +69,6 @@ class NavLogic extends BaseLogic | @@ -41,14 +69,6 @@ class NavLogic extends BaseLogic | ||
| 41 | if(($pid_info !== false) && $this->param['pid'] != $info['pid']){ | 69 | if(($pid_info !== false) && $this->param['pid'] != $info['pid']){ |
| 42 | $this->fail('当前菜单拥有子集不允许修改上级'); | 70 | $this->fail('当前菜单拥有子集不允许修改上级'); |
| 43 | } | 71 | } |
| 44 | - $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 45 | - }else{ | ||
| 46 | - $this->param['project_id'] = $this->user['project_id']; | ||
| 47 | - $rs = $this->model->add($this->param); | ||
| 48 | - } | ||
| 49 | - if($rs === false){ | ||
| 50 | - $this->fail('error'); | ||
| 51 | - } | ||
| 52 | return $this->success(); | 72 | return $this->success(); |
| 53 | } | 73 | } |
| 54 | 74 | ||
| @@ -70,6 +90,8 @@ class NavLogic extends BaseLogic | @@ -70,6 +90,8 @@ class NavLogic extends BaseLogic | ||
| 70 | if($rs === false){ | 90 | if($rs === false){ |
| 71 | $this->fail('error'); | 91 | $this->fail('error'); |
| 72 | } | 92 | } |
| 93 | + //编辑菜单后,通知更新 | ||
| 94 | + $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NAV, 'route'=>'all']); | ||
| 73 | return $this->success(); | 95 | return $this->success(); |
| 74 | } | 96 | } |
| 75 | 97 |
| @@ -44,57 +44,65 @@ class NewsCategoryLogic extends BaseLogic | @@ -44,57 +44,65 @@ class NewsCategoryLogic extends BaseLogic | ||
| 44 | * @method | 44 | * @method |
| 45 | */ | 45 | */ |
| 46 | public function info_news_category(){ | 46 | public function info_news_category(){ |
| 47 | - $info = $this->info($this->param); | 47 | + $info = $this->model->read($this->param); |
| 48 | return $this->success($info); | 48 | return $this->success($info); |
| 49 | } | 49 | } |
| 50 | + | ||
| 50 | /** | 51 | /** |
| 51 | - * @name :添加时验证上级分类是否有商品,有则替换带当前分类下 | ||
| 52 | - * @return void | ||
| 53 | - * @author :liyuhang | ||
| 54 | - * @method | 52 | + * @remark :保存数据 |
| 53 | + * @name :newsCategorySave | ||
| 54 | + * @author :lyh | ||
| 55 | + * @method :post | ||
| 56 | + * @time :2023/9/7 14:53 | ||
| 55 | */ | 57 | */ |
| 56 | - public function add_news_category(){ | 58 | + public function newsCategorySave(){ |
| 57 | //验证名称是否存在 | 59 | //验证名称是否存在 |
| 58 | $this->verifyParamName($this->param['name']); | 60 | $this->verifyParamName($this->param['name']); |
| 59 | - //参数处理 | ||
| 60 | - $this->param = $this->addParamProcessing($this->param); | ||
| 61 | DB::beginTransaction(); | 61 | DB::beginTransaction(); |
| 62 | try { | 62 | try { |
| 63 | - $cate_id = $this->model->insertGetId($this->param); | ||
| 64 | - //当父级分类拥有产品时,处理产品 | ||
| 65 | - $this->addProcessingSon($cate_id); | ||
| 66 | - RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], | ||
| 67 | - RouteMap::SOURCE_NEWS_CATE, $cate_id, $this->user['project_id']); | 63 | + if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 64 | + //验证是否可编辑 | ||
| 65 | + $this->verifyEditParam($this->param['id'],$this->param['pid']); | ||
| 66 | + $this->param['operator_id'] = $this->user['id']; | ||
| 67 | + //查看路由是否更新 | ||
| 68 | + $id = $this->editCategoryRoute($this->param['id'],$this->param['alias']); | ||
| 69 | + $this->edit($this->param,['id'=>$this->param['id']]); | ||
| 70 | + }else{ | ||
| 71 | + $id = $this->model->addReturnId($this->param); | ||
| 72 | + //当父级分类拥有产品时,处理子集 | ||
| 73 | + $this->addProcessingSon($id); | ||
| 74 | + } | ||
| 75 | + $route = RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']); | ||
| 76 | + $this->model->edit(['alias'=>$route],['id'=>$id]); | ||
| 68 | DB::commit(); | 77 | DB::commit(); |
| 69 | }catch (\Exception $e){ | 78 | }catch (\Exception $e){ |
| 70 | DB::rollBack(); | 79 | DB::rollBack(); |
| 71 | $this->fail('error'); | 80 | $this->fail('error'); |
| 72 | } | 81 | } |
| 73 | - //通知更新 | ||
| 74 | - $this->updateNotify(['project_id'=>$this->user['project_id'], | ||
| 75 | - 'type'=>RouteMap::SOURCE_NEWS_CATE, 'route'=>$this->param['alias']]); | 82 | + //更新通知记录表 |
| 83 | + $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NEWS_CATE, 'route'=>$this->param['alias']]); | ||
| 76 | return $this->success(); | 84 | return $this->success(); |
| 77 | } | 85 | } |
| 78 | 86 | ||
| 87 | + | ||
| 79 | /** | 88 | /** |
| 80 | - * @name :编辑分类 | ||
| 81 | - * @return void | ||
| 82 | - * @author :liyuhang | ||
| 83 | - * @method | 89 | + * @remark :编辑路由时生成路由记录 |
| 90 | + * @name :editCategoryRoute | ||
| 91 | + * @author :lyh | ||
| 92 | + * @method :post | ||
| 93 | + * @time :2023/9/7 10:51 | ||
| 84 | */ | 94 | */ |
| 85 | - public function edit_news_category(){ | ||
| 86 | - //验证名称是否存在 | ||
| 87 | - $this->verifyParamName($this->param['name'],$this->param['id']); | ||
| 88 | - //验证是否可编辑 | ||
| 89 | - $this->verifyEditParam($this->param['id'],$this->param['pid']); | ||
| 90 | - $this->param['operator_id'] = $this->user['id']; | ||
| 91 | - $this->param['alias'] = RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], | ||
| 92 | - RouteMap::SOURCE_NEWS_CATE, $this->param['id'], $this->user['project_id']); | ||
| 93 | - $this->edit($this->param,['id'=>$this->param['id']]); | ||
| 94 | - //通知更新 | ||
| 95 | - $this->updateNotify(['project_id'=>$this->user['project_id'], | ||
| 96 | - 'type'=>RouteMap::SOURCE_NEWS_CATE, 'route'=>$this->param['alias']]); | ||
| 97 | - return $this->success(); | 95 | + public function editCategoryRoute($id,$route){ |
| 96 | + //生成一条删除路由记录 | ||
| 97 | + $info = $this->model->read(['id'=>$id],['id','alias']); | ||
| 98 | + if($info['alias'] != $route){ | ||
| 99 | + $data = [ | ||
| 100 | + 'source'=>RouteMap::SOURCE_NEWS_CATE, | ||
| 101 | + 'route'=>$info['alias'], | ||
| 102 | + ]; | ||
| 103 | + $this->setRouteDeleteSave($data); | ||
| 104 | + } | ||
| 105 | + return $id; | ||
| 98 | } | 106 | } |
| 99 | 107 | ||
| 100 | /** | 108 | /** |
| @@ -144,23 +152,21 @@ class NewsCategoryLogic extends BaseLogic | @@ -144,23 +152,21 @@ class NewsCategoryLogic extends BaseLogic | ||
| 144 | * @method | 152 | * @method |
| 145 | */ | 153 | */ |
| 146 | public function del_news_category(){ | 154 | public function del_news_category(){ |
| 147 | - $ids = $this->param['id']; | ||
| 148 | - foreach ($this->param['id'] as $v){ | 155 | + foreach ($this->param['id'] as $id){ |
| 149 | //查询是否有子分类 | 156 | //查询是否有子分类 |
| 150 | - $rs = $this->model->read(['pid'=>$v],['id']); | 157 | + $rs = $this->model->read(['pid'=>$id],['id']); |
| 151 | if($rs !== false){ | 158 | if($rs !== false){ |
| 152 | $this->fail('当前分类拥有子分类不允许删除'); | 159 | $this->fail('当前分类拥有子分类不允许删除'); |
| 153 | } | 160 | } |
| 154 | //查看当前分内下是否有商品 | 161 | //查看当前分内下是否有商品 |
| 155 | $newsModel = new NewsModel(); | 162 | $newsModel = new NewsModel(); |
| 156 | - $rs = $newsModel->read(['category_id'=>$v],['id']); | 163 | + $rs = $newsModel->read(['category_id'=>$id],['id']); |
| 157 | if($rs !== false){ | 164 | if($rs !== false){ |
| 158 | $this->fail('当前分类拥有商品'); | 165 | $this->fail('当前分类拥有商品'); |
| 159 | } | 166 | } |
| 160 | - RouteMap::delRoute(RouteMap::SOURCE_NEWS_CATE, $v, $this->user['project_id']); | 167 | + $this->delRoute($id); |
| 168 | + $this->model->del(['id'=>$id]); | ||
| 161 | } | 169 | } |
| 162 | - $this->param['id'] = ['in',$this->param['id']]; | ||
| 163 | - $this->del($this->param,$ids); | ||
| 164 | return $this->success(); | 170 | return $this->success(); |
| 165 | } | 171 | } |
| 166 | 172 | ||
| @@ -186,16 +192,11 @@ class NewsCategoryLogic extends BaseLogic | @@ -186,16 +192,11 @@ class NewsCategoryLogic extends BaseLogic | ||
| 186 | * @method :post | 192 | * @method :post |
| 187 | * @time :2023/6/13 11:41 | 193 | * @time :2023/6/13 11:41 |
| 188 | */ | 194 | */ |
| 189 | - public function verifyParamName($name,$id = ''){ | ||
| 190 | - if(isset($id) && !empty($id)){ | ||
| 191 | - $condition = [ | ||
| 192 | - 'id'=>['!=',$id], | ||
| 193 | - 'name'=>$name, | ||
| 194 | - ]; | 195 | + public function verifyParamName($name){ |
| 196 | + if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 197 | + $condition = ['id'=>['!=',$this->param['id']], 'name'=>$name]; | ||
| 195 | }else{ | 198 | }else{ |
| 196 | - $condition = [ | ||
| 197 | - 'name'=>$name | ||
| 198 | - ]; | 199 | + $condition = ['name'=>$name]; |
| 199 | } | 200 | } |
| 200 | $info = $this->model->read($condition); | 201 | $info = $this->model->read($condition); |
| 201 | if($info !== false){ | 202 | if($info !== false){ |
| @@ -214,8 +215,6 @@ class NewsCategoryLogic extends BaseLogic | @@ -214,8 +215,6 @@ class NewsCategoryLogic extends BaseLogic | ||
| 214 | $param['project_id'] = $this->user['project_id']; | 215 | $param['project_id'] = $this->user['project_id']; |
| 215 | $param['operator_id'] = $this->user['id']; | 216 | $param['operator_id'] = $this->user['id']; |
| 216 | $param['create_id'] = $this->user['id']; | 217 | $param['create_id'] = $this->user['id']; |
| 217 | - $param['created_at'] = date('Y-m-d H:i:s'); | ||
| 218 | - $param['updated_at'] = date('Y-m-d H:i:s'); | ||
| 219 | return $this->success($param); | 218 | return $this->success($param); |
| 220 | } | 219 | } |
| 221 | 220 | ||
| @@ -248,4 +247,24 @@ class NewsCategoryLogic extends BaseLogic | @@ -248,4 +247,24 @@ class NewsCategoryLogic extends BaseLogic | ||
| 248 | } | 247 | } |
| 249 | return $this->success(); | 248 | return $this->success(); |
| 250 | } | 249 | } |
| 250 | + | ||
| 251 | + /** | ||
| 252 | + * @remark :删除路由 | ||
| 253 | + * @name :delRoute | ||
| 254 | + * @author :lyh | ||
| 255 | + * @method :post | ||
| 256 | + * @time :2023/9/7 10:50 | ||
| 257 | + */ | ||
| 258 | + public function delRoute($id){ | ||
| 259 | + //删除路由映射 | ||
| 260 | + RouteMap::delRoute(RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']); | ||
| 261 | + //生成一条删除路由记录 | ||
| 262 | + $info = $this->model->read(['id'=>$id],['id','alias']); | ||
| 263 | + $data = [ | ||
| 264 | + 'source'=>RouteMap::SOURCE_NEWS_CATE, | ||
| 265 | + 'route'=>$info['alias'], | ||
| 266 | + ]; | ||
| 267 | + $this->setRouteDeleteSave($data); | ||
| 268 | + return $this->success(); | ||
| 269 | + } | ||
| 251 | } | 270 | } |
| @@ -48,18 +48,27 @@ class NewsLogic extends BaseLogic | @@ -48,18 +48,27 @@ class NewsLogic extends BaseLogic | ||
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | /** | 50 | /** |
| 51 | - * @name :添加博客 | ||
| 52 | - * @return void | ||
| 53 | - * @author :liyuhang | ||
| 54 | - * @method | 51 | + * @remark :保存数据 |
| 52 | + * @name :newsSave | ||
| 53 | + * @author :lyh | ||
| 54 | + * @method :post | ||
| 55 | + * @time :2023/9/7 11:02 | ||
| 55 | */ | 56 | */ |
| 56 | - public function news_add(){ | 57 | + public function newsSave(){ |
| 57 | //拼接参数 | 58 | //拼接参数 |
| 58 | DB::beginTransaction(); | 59 | DB::beginTransaction(); |
| 59 | try { | 60 | try { |
| 60 | $this->param = $this->paramProcessing($this->param); | 61 | $this->param = $this->paramProcessing($this->param); |
| 61 | - $rs = $this->model->insertGetId($this->param); | ||
| 62 | - $route = RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']); | 62 | + if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 63 | + //是否更新路由 | ||
| 64 | + $id = $this->editNewsRoute($this->param['id'],$this->param['url']); | ||
| 65 | + $this->edit($this->param,['id'=>$this->param['id']]); | ||
| 66 | + }else{ | ||
| 67 | + $id = $this->model->addReturnId($this->param); | ||
| 68 | + } | ||
| 69 | + //更新路由 | ||
| 70 | + $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $id, $this->user['project_id']); | ||
| 71 | + $this->edit(['url'=>$route],['id'=>$id]); | ||
| 63 | DB::commit(); | 72 | DB::commit(); |
| 64 | }catch (\Exception $e){ | 73 | }catch (\Exception $e){ |
| 65 | DB::rollBack(); | 74 | DB::rollBack(); |
| @@ -71,29 +80,26 @@ class NewsLogic extends BaseLogic | @@ -71,29 +80,26 @@ class NewsLogic extends BaseLogic | ||
| 71 | } | 80 | } |
| 72 | 81 | ||
| 73 | /** | 82 | /** |
| 74 | - * @name :编辑 | ||
| 75 | - * @return void | ||
| 76 | - * @author :liyuhang | ||
| 77 | - * @method | 83 | + * @remark :查看是否编辑路由 |
| 84 | + * @name :editCategoryRoute | ||
| 85 | + * @author :lyh | ||
| 86 | + * @method :post | ||
| 87 | + * @time :2023/9/7 11:05 | ||
| 78 | */ | 88 | */ |
| 79 | - public function news_edit(){ | ||
| 80 | - //拼接参数 | ||
| 81 | - $this->param = $this->paramProcessing($this->param); | ||
| 82 | - DB::beginTransaction(); | ||
| 83 | - try { | ||
| 84 | - //设置路由 | ||
| 85 | - $route = RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_NEWS, $this->param['id'], $this->user['project_id']); | ||
| 86 | - $this->edit($this->param,['id'=>$this->param['id']]); | ||
| 87 | - DB::commit(); | ||
| 88 | - }catch (\exception $e){ | ||
| 89 | - DB::rollBack(); | ||
| 90 | - $this->fail('参数错误或其他服务器原因,编辑失败'); | ||
| 91 | - } | ||
| 92 | - //通知更新 | ||
| 93 | - $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NEWS, 'route'=>$route]); | ||
| 94 | - return $this->success(); | 89 | + public function editNewsRoute($id,$route){ |
| 90 | + //生成一条删除路由记录 | ||
| 91 | + $info = $this->model->read(['id'=>$id],['id','url']); | ||
| 92 | + if($info['url'] != $route){ | ||
| 93 | + $data = [ | ||
| 94 | + 'source'=>RouteMap::SOURCE_NEWS, | ||
| 95 | + 'route'=>$info['url'], | ||
| 96 | + ]; | ||
| 97 | + $this->setRouteDeleteSave($data); | ||
| 98 | + } | ||
| 99 | + return $id; | ||
| 95 | } | 100 | } |
| 96 | 101 | ||
| 102 | + | ||
| 97 | /** | 103 | /** |
| 98 | * @name :编辑seo | 104 | * @name :编辑seo |
| 99 | * @return void | 105 | * @return void |
| @@ -132,16 +138,10 @@ class NewsLogic extends BaseLogic | @@ -132,16 +138,10 @@ class NewsLogic extends BaseLogic | ||
| 132 | * @author :liyuhang | 138 | * @author :liyuhang |
| 133 | * @method | 139 | * @method |
| 134 | */ | 140 | */ |
| 135 | - public function news_info(){ | ||
| 136 | - //读取缓存 | ||
| 137 | - $info = Common::get_user_cache($this->model->getTable(),$this->param['id']); | ||
| 138 | - if(empty($info)){ | 141 | + public function newsInfo(){ |
| 139 | $info = $this->model->read($this->param); | 142 | $info = $this->model->read($this->param); |
| 140 | $newsCategoryLogic = new NewsCategoryLogic(); | 143 | $newsCategoryLogic = new NewsCategoryLogic(); |
| 141 | $info = $newsCategoryLogic->get_category_name($info); | 144 | $info = $newsCategoryLogic->get_category_name($info); |
| 142 | - //写入缓存 | ||
| 143 | - Common::set_user_cache($info,$this->model->getTable(),$this->param['id']); | ||
| 144 | - } | ||
| 145 | return $this->success($info); | 145 | return $this->success($info); |
| 146 | } | 146 | } |
| 147 | 147 | ||
| @@ -151,19 +151,17 @@ class NewsLogic extends BaseLogic | @@ -151,19 +151,17 @@ class NewsLogic extends BaseLogic | ||
| 151 | * @author :liyuhang | 151 | * @author :liyuhang |
| 152 | * @method | 152 | * @method |
| 153 | */ | 153 | */ |
| 154 | - public function news_del(){ | ||
| 155 | - $ids = $this->param['id']; | 154 | + public function newsDel(){ |
| 156 | DB::beginTransaction(); | 155 | DB::beginTransaction(); |
| 157 | try { | 156 | try { |
| 158 | - $this->param['id'] = ['in',$this->param['id']]; | ||
| 159 | - $this->del($this->param,$ids); | ||
| 160 | - foreach ($ids as $id){ | ||
| 161 | - RouteMap::delRoute(RouteMap::SOURCE_NEWS, $id, $this->user['project_id']); | 157 | + foreach ($this->param['id'] as $id){ |
| 158 | + $this->delRoute($id); | ||
| 159 | + $this->model->del(['id'=>$id]); | ||
| 162 | } | 160 | } |
| 163 | DB::commit(); | 161 | DB::commit(); |
| 164 | }catch (Exception $e){ | 162 | }catch (Exception $e){ |
| 165 | DB::rollBack(); | 163 | DB::rollBack(); |
| 166 | - $this->fail('当前数据不存在'); | 164 | + $this->fail('error'); |
| 167 | } | 165 | } |
| 168 | return $this->success(); | 166 | return $this->success(); |
| 169 | } | 167 | } |
| @@ -182,8 +180,6 @@ class NewsLogic extends BaseLogic | @@ -182,8 +180,6 @@ class NewsLogic extends BaseLogic | ||
| 182 | $param['create_id'] = $this->user['id']; | 180 | $param['create_id'] = $this->user['id']; |
| 183 | $param['operator_id'] = $this->user['id']; | 181 | $param['operator_id'] = $this->user['id']; |
| 184 | $param['project_id'] = $this->user['project_id']; | 182 | $param['project_id'] = $this->user['project_id']; |
| 185 | - $param['created_at'] = date('Y-m-d H:i:s',time()); | ||
| 186 | - $param['updated_at'] = date('Y-m-d H:i:s',time()); | ||
| 187 | $param['category_id'] = ','.$param['category_id'].','; | 183 | $param['category_id'] = ','.$param['category_id'].','; |
| 188 | } | 184 | } |
| 189 | return $this->success($param); | 185 | return $this->success($param); |
| @@ -223,4 +219,24 @@ class NewsLogic extends BaseLogic | @@ -223,4 +219,24 @@ class NewsLogic extends BaseLogic | ||
| 223 | } | 219 | } |
| 224 | return $this->success(); | 220 | return $this->success(); |
| 225 | } | 221 | } |
| 222 | + | ||
| 223 | + /** | ||
| 224 | + * @remark :删除路由 | ||
| 225 | + * @name :delRoute | ||
| 226 | + * @author :lyh | ||
| 227 | + * @method :post | ||
| 228 | + * @time :2023/9/7 10:50 | ||
| 229 | + */ | ||
| 230 | + public function delRoute($id){ | ||
| 231 | + //删除路由映射 | ||
| 232 | + RouteMap::delRoute(RouteMap::SOURCE_NEWS, $id, $this->user['project_id']); | ||
| 233 | + //生成一条删除路由记录 | ||
| 234 | + $info = $this->model->read(['id'=>$id],['id','url']); | ||
| 235 | + $data = [ | ||
| 236 | + 'source'=>RouteMap::SOURCE_NEWS, | ||
| 237 | + 'route'=>$info['url'], | ||
| 238 | + ]; | ||
| 239 | + $this->setRouteDeleteSave($data); | ||
| 240 | + return $this->success(); | ||
| 241 | + } | ||
| 226 | } | 242 | } |
| @@ -2,11 +2,9 @@ | @@ -2,11 +2,9 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Http\Logic\Bside\Product; | 3 | namespace App\Http\Logic\Bside\Product; |
| 4 | 4 | ||
| 5 | -use App\Exceptions\BsideGlobalException; | ||
| 6 | use App\Helper\Arr; | 5 | use App\Helper\Arr; |
| 7 | use App\Http\Logic\Bside\BaseLogic; | 6 | use App\Http\Logic\Bside\BaseLogic; |
| 8 | use App\Models\Product\Category; | 7 | use App\Models\Product\Category; |
| 9 | -use App\Models\Product\CategoryRelated; | ||
| 10 | use App\Models\Product\Product; | 8 | use App\Models\Product\Product; |
| 11 | use App\Models\RouteMap\RouteMap; | 9 | use App\Models\RouteMap\RouteMap; |
| 12 | use Illuminate\Support\Facades\DB; | 10 | use Illuminate\Support\Facades\DB; |
| @@ -69,7 +67,8 @@ class CategoryLogic extends BaseLogic | @@ -69,7 +67,8 @@ class CategoryLogic extends BaseLogic | ||
| 69 | try { | 67 | try { |
| 70 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 68 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 71 | $this->handleEditParam($this->param); | 69 | $this->handleEditParam($this->param); |
| 72 | - $id = $this->param['id']; | 70 | + //是否编辑路由 |
| 71 | + $id = $this->editCategoryRoute($this->param['id'],$this->param['route']); | ||
| 73 | $this->model->edit($this->param,['id'=>$this->param['id']]); | 72 | $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 74 | }else{ | 73 | }else{ |
| 75 | $this->param['project_id'] = $this->user['project_id']; | 74 | $this->param['project_id'] = $this->user['project_id']; |
| @@ -77,17 +76,43 @@ class CategoryLogic extends BaseLogic | @@ -77,17 +76,43 @@ class CategoryLogic extends BaseLogic | ||
| 77 | } | 76 | } |
| 78 | //路由映射 | 77 | //路由映射 |
| 79 | $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']); | 78 | $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']); |
| 79 | + $this->edit(['route'=>$route],['id'=>$id]); | ||
| 80 | DB::commit(); | 80 | DB::commit(); |
| 81 | } catch (\Exception $e){ | 81 | } catch (\Exception $e){ |
| 82 | DB::rollBack(); | 82 | DB::rollBack(); |
| 83 | $this->fail('保存失败'); | 83 | $this->fail('保存失败'); |
| 84 | } | 84 | } |
| 85 | //通知更新 | 85 | //通知更新 |
| 86 | - $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT_CATE, 'route'=>$route]); | 86 | + $notifyData = [ |
| 87 | + 'project_id'=>$this->user['project_id'], | ||
| 88 | + 'type'=>RouteMap::SOURCE_PRODUCT_CATE, | ||
| 89 | + 'route'=>$route | ||
| 90 | + ]; | ||
| 91 | + $this->updateNotify($notifyData); | ||
| 87 | return $this->success(); | 92 | return $this->success(); |
| 88 | } | 93 | } |
| 89 | 94 | ||
| 90 | /** | 95 | /** |
| 96 | + * @remark :编辑路由时生成路由记录 | ||
| 97 | + * @name :editCategoryRoute | ||
| 98 | + * @author :lyh | ||
| 99 | + * @method :post | ||
| 100 | + * @time :2023/9/7 10:51 | ||
| 101 | + */ | ||
| 102 | + public function editCategoryRoute($id,$route){ | ||
| 103 | + //生成一条删除路由记录 | ||
| 104 | + $info = $this->model->read(['id'=>$id],['id','route']); | ||
| 105 | + if($info['route'] != $route){ | ||
| 106 | + $data = [ | ||
| 107 | + 'source'=>RouteMap::SOURCE_PRODUCT_CATE, | ||
| 108 | + 'route'=>$info['route'], | ||
| 109 | + ]; | ||
| 110 | + $this->setRouteDeleteSave($data); | ||
| 111 | + } | ||
| 112 | + return $id; | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + /** | ||
| 91 | * @remark :验证编辑时是否可修改pid | 116 | * @remark :验证编辑时是否可修改pid |
| 92 | * @name :handleEditParam | 117 | * @name :handleEditParam |
| 93 | * @author :lyh | 118 | * @author :lyh |
| @@ -108,7 +133,7 @@ class CategoryLogic extends BaseLogic | @@ -108,7 +133,7 @@ class CategoryLogic extends BaseLogic | ||
| 108 | if(($product_info !== false) && ($info['pid'] != $param['pid'])){ | 133 | if(($product_info !== false) && ($info['pid'] != $param['pid'])){ |
| 109 | $this->fail('当前产品分类拥有产品不允许编辑上级分类'); | 134 | $this->fail('当前产品分类拥有产品不允许编辑上级分类'); |
| 110 | } | 135 | } |
| 111 | - return true; | 136 | + return $this->success(); |
| 112 | } | 137 | } |
| 113 | 138 | ||
| 114 | 139 | ||
| @@ -129,10 +154,10 @@ class CategoryLogic extends BaseLogic | @@ -129,10 +154,10 @@ class CategoryLogic extends BaseLogic | ||
| 129 | if($product_info !== false){ | 154 | if($product_info !== false){ |
| 130 | $this->fail('当前分类拥有产品不允许删除'); | 155 | $this->fail('当前分类拥有产品不允许删除'); |
| 131 | } | 156 | } |
| 132 | - //删除路由映射 | ||
| 133 | - RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']); | 157 | + //删除路由 |
| 158 | + $this->delRoute($id); | ||
| 159 | + $this->model->del(['id'=>$id]); | ||
| 134 | } | 160 | } |
| 135 | - $this->model->del(['id'=>['in',$ids]]); | ||
| 136 | DB::commit(); | 161 | DB::commit(); |
| 137 | }catch (\Exception $e){ | 162 | }catch (\Exception $e){ |
| 138 | DB::rollBack(); | 163 | DB::rollBack(); |
| @@ -141,4 +166,23 @@ class CategoryLogic extends BaseLogic | @@ -141,4 +166,23 @@ class CategoryLogic extends BaseLogic | ||
| 141 | return $this->success(); | 166 | return $this->success(); |
| 142 | } | 167 | } |
| 143 | 168 | ||
| 169 | + /** | ||
| 170 | + * @remark :删除路由 | ||
| 171 | + * @name :delRoute | ||
| 172 | + * @author :lyh | ||
| 173 | + * @method :post | ||
| 174 | + * @time :2023/9/7 10:50 | ||
| 175 | + */ | ||
| 176 | + public function delRoute($id){ | ||
| 177 | + //删除路由映射 | ||
| 178 | + RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']); | ||
| 179 | + //生成一条删除路由记录 | ||
| 180 | + $info = $this->model->read(['id'=>$id],['id','route']); | ||
| 181 | + $data = [ | ||
| 182 | + 'source'=>RouteMap::SOURCE_PRODUCT_CATE, | ||
| 183 | + 'route'=>$info['route'], | ||
| 184 | + ]; | ||
| 185 | + $this->setRouteDeleteSave($data); | ||
| 186 | + return $this->success(); | ||
| 187 | + } | ||
| 144 | } | 188 | } |
| @@ -51,16 +51,18 @@ class KeywordLogic extends BaseLogic | @@ -51,16 +51,18 @@ class KeywordLogic extends BaseLogic | ||
| 51 | DB::beginTransaction(); | 51 | DB::beginTransaction(); |
| 52 | try { | 52 | try { |
| 53 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 53 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 54 | - $id = $this->param['id']; | 54 | + $route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $this->param['id'], $this->user['project_id']); |
| 55 | + $id = $this->editCategoryRoute($this->param['id'],$route); | ||
| 55 | $this->model->edit($this->param,['id'=>$this->param['id']]); | 56 | $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 56 | }else{ | 57 | }else{ |
| 57 | $this->param['project_id'] = $this->user['project_id']; | 58 | $this->param['project_id'] = $this->user['project_id']; |
| 58 | $this->param['created_at'] = date('Y-m-d H:i:s'); | 59 | $this->param['created_at'] = date('Y-m-d H:i:s'); |
| 59 | $this->param['updated_at'] = $this->param['created_at']; | 60 | $this->param['updated_at'] = $this->param['created_at']; |
| 60 | $id = $this->model->insertGetId($this->param); | 61 | $id = $this->model->insertGetId($this->param); |
| 61 | - } | ||
| 62 | //路由映射 | 62 | //路由映射 |
| 63 | $route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); | 63 | $route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); |
| 64 | + } | ||
| 65 | + $this->model->edit(['route'=>$route],['id'=>$id]); | ||
| 64 | DB::commit(); | 66 | DB::commit(); |
| 65 | }catch (\Exception $e){ | 67 | }catch (\Exception $e){ |
| 66 | DB::rollBack(); | 68 | DB::rollBack(); |
| @@ -72,6 +74,26 @@ class KeywordLogic extends BaseLogic | @@ -72,6 +74,26 @@ class KeywordLogic extends BaseLogic | ||
| 72 | } | 74 | } |
| 73 | 75 | ||
| 74 | /** | 76 | /** |
| 77 | + * @remark :编辑路由时生成路由记录 | ||
| 78 | + * @name :editCategoryRoute | ||
| 79 | + * @author :lyh | ||
| 80 | + * @method :post | ||
| 81 | + * @time :2023/9/7 10:51 | ||
| 82 | + */ | ||
| 83 | + public function editCategoryRoute($id,$route){ | ||
| 84 | + //生成一条删除路由记录 | ||
| 85 | + $info = $this->model->read(['id'=>$id],['id','route']); | ||
| 86 | + if($info['route'] != $route){ | ||
| 87 | + $data = [ | ||
| 88 | + 'source'=>RouteMap::SOURCE_PRODUCT_KEYWORD, | ||
| 89 | + 'route'=>$info['route'], | ||
| 90 | + ]; | ||
| 91 | + $this->setRouteDeleteSave($data); | ||
| 92 | + } | ||
| 93 | + return $id; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + /** | ||
| 75 | * @remark :批量添加数据 | 97 | * @remark :批量添加数据 |
| 76 | * @name :batchAdd | 98 | * @name :batchAdd |
| 77 | * @author :lyh | 99 | * @author :lyh |
| @@ -107,10 +129,29 @@ class KeywordLogic extends BaseLogic | @@ -107,10 +129,29 @@ class KeywordLogic extends BaseLogic | ||
| 107 | if($product_info !== false){ | 129 | if($product_info !== false){ |
| 108 | $this->fail('当前关键词拥有产品不允许删除'); | 130 | $this->fail('当前关键词拥有产品不允许删除'); |
| 109 | } | 131 | } |
| 110 | - RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); | 132 | + $this->delRoute($id); |
| 133 | + $this->model->del(['id'=>$id]); | ||
| 111 | } | 134 | } |
| 112 | - $this->model->del(['id'=>['in',$ids]]); | ||
| 113 | return $this->success(); | 135 | return $this->success(); |
| 114 | } | 136 | } |
| 115 | 137 | ||
| 138 | + /** | ||
| 139 | + * @remark :删除路由 | ||
| 140 | + * @name :delRoute | ||
| 141 | + * @author :lyh | ||
| 142 | + * @method :post | ||
| 143 | + * @time :2023/9/7 10:50 | ||
| 144 | + */ | ||
| 145 | + public function delRoute($id){ | ||
| 146 | + //删除路由映射 | ||
| 147 | + RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); | ||
| 148 | + //生成一条删除路由记录 | ||
| 149 | + $info = $this->model->read(['id'=>$id],['id','route']); | ||
| 150 | + $data = [ | ||
| 151 | + 'source'=>RouteMap::SOURCE_PRODUCT_KEYWORD, | ||
| 152 | + 'route'=>$info['route'], | ||
| 153 | + ]; | ||
| 154 | + $this->setRouteDeleteSave($data); | ||
| 155 | + return $this->success(); | ||
| 156 | + } | ||
| 116 | } | 157 | } |
| @@ -33,20 +33,24 @@ class ProductLogic extends BaseLogic | @@ -33,20 +33,24 @@ class ProductLogic extends BaseLogic | ||
| 33 | * @time :2023/8/21 18:35 | 33 | * @time :2023/8/21 18:35 |
| 34 | */ | 34 | */ |
| 35 | public function productSave(){ | 35 | public function productSave(){ |
| 36 | + //参数处理 | ||
| 36 | $this->param = $this->handleSaveParam($this->param); | 37 | $this->param = $this->handleSaveParam($this->param); |
| 37 | DB::beginTransaction(); | 38 | DB::beginTransaction(); |
| 38 | try { | 39 | try { |
| 39 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 40 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 40 | - $id = $this->param['id']; | 41 | + //查看路由是否更新 |
| 42 | + $id = $this->editProductRoute($this->param['id'],$this->param['route']); | ||
| 41 | $this->model->edit($this->param,['id'=>$this->param['id']]); | 43 | $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 42 | }else{ | 44 | }else{ |
| 43 | $this->param['project_id'] = $this->user['project_id']; | 45 | $this->param['project_id'] = $this->user['project_id']; |
| 44 | $this->param['created_at'] = date('Y-m-d H:i:s'); | 46 | $this->param['created_at'] = date('Y-m-d H:i:s'); |
| 45 | $this->param['updated_at'] = $this->param['created_at']; | 47 | $this->param['updated_at'] = $this->param['created_at']; |
| 46 | - $id = $this->model->insertGetId($this->param); | 48 | + $id = $this->model->addReturnId($this->param); |
| 47 | } | 49 | } |
| 48 | //路由映射 | 50 | //路由映射 |
| 49 | $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']); | 51 | $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']); |
| 52 | + //更新路由 | ||
| 53 | + $this->model->edit(['route'=>$route],['id'=>$id]); | ||
| 50 | DB::commit(); | 54 | DB::commit(); |
| 51 | }catch (\Exception $e){ | 55 | }catch (\Exception $e){ |
| 52 | DB::rollBack(); | 56 | DB::rollBack(); |
| @@ -58,6 +62,26 @@ class ProductLogic extends BaseLogic | @@ -58,6 +62,26 @@ class ProductLogic extends BaseLogic | ||
| 58 | } | 62 | } |
| 59 | 63 | ||
| 60 | /** | 64 | /** |
| 65 | + * @remark :编辑产品 | ||
| 66 | + * @name :editProduct | ||
| 67 | + * @author :lyh | ||
| 68 | + * @method :post | ||
| 69 | + * @time :2023/9/7 10:02 | ||
| 70 | + */ | ||
| 71 | + public function editProductRoute($id,$route){ | ||
| 72 | + $info = $this->model->read(['id'=>$this->param['id']]); | ||
| 73 | + if($info['route'] != $route){ | ||
| 74 | + //生成一条删除路由记录 | ||
| 75 | + $data = [ | ||
| 76 | + 'source'=>RouteMap::SOURCE_PRODUCT, | ||
| 77 | + 'route'=>$route, | ||
| 78 | + ]; | ||
| 79 | + $this->setRouteDeleteSave($data); | ||
| 80 | + } | ||
| 81 | + return $id; | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + /** | ||
| 61 | * @remark :不使用save处理参数 | 85 | * @remark :不使用save处理参数 |
| 62 | * @name :handleSaveParam | 86 | * @name :handleSaveParam |
| 63 | * @author :lyh | 87 | * @author :lyh |
| @@ -91,6 +115,7 @@ class ProductLogic extends BaseLogic | @@ -91,6 +115,7 @@ class ProductLogic extends BaseLogic | ||
| 91 | return $param; | 115 | return $param; |
| 92 | } | 116 | } |
| 93 | 117 | ||
| 118 | + | ||
| 94 | /** | 119 | /** |
| 95 | * @remark :删除数据 | 120 | * @remark :删除数据 |
| 96 | * @name :delete | 121 | * @name :delete |
| @@ -104,8 +129,7 @@ class ProductLogic extends BaseLogic | @@ -104,8 +129,7 @@ class ProductLogic extends BaseLogic | ||
| 104 | foreach ($this->param['ids'] as $k => $id) { | 129 | foreach ($this->param['ids'] as $k => $id) { |
| 105 | $info = $this->model->read(['id'=>$id]); | 130 | $info = $this->model->read(['id'=>$id]); |
| 106 | if($info['status'] == Product::STATUS_RECYCLE){ | 131 | if($info['status'] == Product::STATUS_RECYCLE){ |
| 107 | - //删除路由映射 | ||
| 108 | - RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']); | 132 | + $this->delRoute($id); |
| 109 | //删除当前产品模版 | 133 | //删除当前产品模版 |
| 110 | $this->delProductModule($id); | 134 | $this->delProductModule($id); |
| 111 | $this->model->del(['id'=>$id]); | 135 | $this->model->del(['id'=>$id]); |
| @@ -119,7 +143,26 @@ class ProductLogic extends BaseLogic | @@ -119,7 +143,26 @@ class ProductLogic extends BaseLogic | ||
| 119 | DB::rollBack(); | 143 | DB::rollBack(); |
| 120 | $this->fail('删除失败'); | 144 | $this->fail('删除失败'); |
| 121 | } | 145 | } |
| 146 | + return $this->success(); | ||
| 147 | + } | ||
| 122 | 148 | ||
| 149 | + /** | ||
| 150 | + * @remark :删除路由 | ||
| 151 | + * @name :delRoute | ||
| 152 | + * @author :lyh | ||
| 153 | + * @method :post | ||
| 154 | + * @time :2023/9/7 10:50 | ||
| 155 | + */ | ||
| 156 | + public function delRoute($id){ | ||
| 157 | + //删除路由映射 | ||
| 158 | + RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']); | ||
| 159 | + //生成一条删除路由记录 | ||
| 160 | + $info = $this->model->read(['id'=>$id],['id','route']); | ||
| 161 | + $data = [ | ||
| 162 | + 'source'=>RouteMap::SOURCE_PRODUCT, | ||
| 163 | + 'route'=>$info['route'], | ||
| 164 | + ]; | ||
| 165 | + $this->setRouteDeleteSave($data); | ||
| 123 | return $this->success(); | 166 | return $this->success(); |
| 124 | } | 167 | } |
| 125 | 168 |
| @@ -5,6 +5,8 @@ namespace App\Http\Logic\Bside\Setting; | @@ -5,6 +5,8 @@ namespace App\Http\Logic\Bside\Setting; | ||
| 5 | use App\Helper\Common as CommonHelper; | 5 | use App\Helper\Common as CommonHelper; |
| 6 | use App\Http\Logic\Bside\BaseLogic; | 6 | use App\Http\Logic\Bside\BaseLogic; |
| 7 | use App\Models\Com\UpdateNotify; | 7 | use App\Models\Com\UpdateNotify; |
| 8 | +use App\Models\Com\UpdateProgress; | ||
| 9 | +use App\Models\RouteMap\RouteMap; | ||
| 8 | use App\Models\WebSetting\WebSetting; | 10 | use App\Models\WebSetting\WebSetting; |
| 9 | 11 | ||
| 10 | class WebSettingLogic extends BaseLogic | 12 | class WebSettingLogic extends BaseLogic |
| @@ -57,29 +59,7 @@ class WebSettingLogic extends BaseLogic | @@ -57,29 +59,7 @@ class WebSettingLogic extends BaseLogic | ||
| 57 | return $this->success(); | 59 | return $this->success(); |
| 58 | } | 60 | } |
| 59 | 61 | ||
| 60 | - /** | ||
| 61 | - * 通知c端 | ||
| 62 | - * @param string $type | ||
| 63 | - * @return array | ||
| 64 | - */ | ||
| 65 | - public function sendNotifyMessage($type = ''){ | ||
| 66 | - //获取当前项目所有未处理的更新并更换为1:处理中 2:处理完成 | ||
| 67 | - $updateNotifyModel = new UpdateNotify(); | ||
| 68 | -// $list = $updateNotifyModel->list(['project_id'=>$this->user['project_id'],'status'=>1]); | ||
| 69 | -// if(!empty($list)){ | ||
| 70 | -// return $this->success($list); | ||
| 71 | -// } | ||
| 72 | - $field = $type == UpdateNotify::TYPE_MINOR ? 'minor_languages_status' : 'status'; | ||
| 73 | - $updateNotifyModel->edit([$field => 1], ['project_id' => $this->user['project_id'], $field => 0]); | ||
| 74 | - $param = [ | ||
| 75 | - 'project_id' => $this->user['project_id'], | ||
| 76 | - 'type' => $type, | ||
| 77 | - 'route' => 'all' | ||
| 78 | - ]; | ||
| 79 | - $string = http_build_query($param); | ||
| 80 | - $urlStr = $this->user['domain'].'api/updateHtmlNotify/?' . $string; | ||
| 81 | - http_get($urlStr,["charset = UTF-8"]); | ||
| 82 | - return $this->success(); | ||
| 83 | - } | 62 | + |
| 63 | + | ||
| 84 | 64 | ||
| 85 | } | 65 | } |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :WebSettingSeoLogic.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2023/9/11 16:32 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Logic\Bside\Setting; | ||
| 11 | + | ||
| 12 | +use App\Http\Logic\Bside\BaseLogic; | ||
| 13 | +use App\Models\WebSetting\WebSettingSeo; | ||
| 14 | + | ||
| 15 | +class WebSettingSeoLogic extends BaseLogic | ||
| 16 | +{ | ||
| 17 | + public function __construct() | ||
| 18 | + { | ||
| 19 | + parent::__construct(); | ||
| 20 | + $this->model = new WebSettingSeo(); | ||
| 21 | + $this->param = $this->requestAll; | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * @remark :获取详情 | ||
| 26 | + * @name :seoInfo | ||
| 27 | + * @author :lyh | ||
| 28 | + * @method :post | ||
| 29 | + * @time :2023/9/11 16:33 | ||
| 30 | + */ | ||
| 31 | + public function seoInfo(){ | ||
| 32 | + $info = $this->model->read(['project_id'=>$this->user['project_id']]); | ||
| 33 | + if($info === false){ | ||
| 34 | + return $this->success(); | ||
| 35 | + } | ||
| 36 | + return $this->success($info); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * @remark :保存数据 | ||
| 41 | + * @name :save | ||
| 42 | + * @author :lyh | ||
| 43 | + * @method :post | ||
| 44 | + * @time :2023/9/11 16:34 | ||
| 45 | + */ | ||
| 46 | + public function seoSave(){ | ||
| 47 | +// try { | ||
| 48 | + $info = $this->model->read(['project_id'=>$this->user['project_id']]); | ||
| 49 | + if($info === false){ | ||
| 50 | + $this->param['project_id'] = $this->user['project_id']; | ||
| 51 | + $this->model->add($this->param); | ||
| 52 | + }else{ | ||
| 53 | + $this->model->edit($this->param,['project_id'=>$this->user['project_id']]); | ||
| 54 | + } | ||
| 55 | +// }catch (\Exception $e){ | ||
| 56 | +// $this->fail('error'); | ||
| 57 | +// } | ||
| 58 | + return $this->success(); | ||
| 59 | + } | ||
| 60 | +} |
| @@ -47,7 +47,7 @@ class RoleLogic extends BaseLogic | @@ -47,7 +47,7 @@ class RoleLogic extends BaseLogic | ||
| 47 | * @time :2023/6/17 16:39 | 47 | * @time :2023/6/17 16:39 |
| 48 | */ | 48 | */ |
| 49 | public function role_info(){ | 49 | public function role_info(){ |
| 50 | - $info = $this->info($this->param); | 50 | + $info = $this->model->read($this->param); |
| 51 | return $this->success($info); | 51 | return $this->success($info); |
| 52 | } | 52 | } |
| 53 | 53 |
-
请 注册 或 登录 后发表评论