作者 zhl

Merge branch 'develop' of 47.244.231.31:zhl/globalso-v6 into develop

  1 +<?php
  2 +
  3 +namespace App\Console\Commands\Import;
  4 +
  5 +use App\Http\Logic\Bside\News\NewsLogic;
  6 +use App\Models\Import\ImportTask;
  7 +use App\Services\ProjectServer;
  8 +use Illuminate\Console\Command;
  9 +use Illuminate\Support\Facades\DB;
  10 +
  11 +/**
  12 + * Class GoogleRank
  13 + * @package App\Console\Commands
  14 + * @author Akun
  15 + * @date 2023/9/20 15:18
  16 + */
  17 +class ProjectImport extends Command
  18 +{
  19 + /**
  20 + * The name and signature of the console command.
  21 + *
  22 + * @var string
  23 + */
  24 + protected $signature = 'project_import';
  25 +
  26 + /**
  27 + * The console command description.
  28 + *
  29 + * @var string
  30 + */
  31 + protected $description = '执行项目导入任务';
  32 +
  33 +
  34 + public function handle()
  35 + {
  36 + while (true) {
  37 + $this->start_import();
  38 + }
  39 + }
  40 +
  41 + protected function start_import()
  42 + {
  43 + $task = ImportTask::where('status', ImportTask::STATUS_UN)->first();
  44 + if (!$task) {
  45 + sleep(2);
  46 + return true;
  47 + }
  48 +
  49 + echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', import start' . PHP_EOL;
  50 +
  51 + //读取csv文件
  52 + $line_of_text = [];
  53 + try {
  54 + $file_handle = fopen($task->file_url, 'r');
  55 + while (!feof($file_handle)) {
  56 + $line_of_text[] = fgetcsv($file_handle, 0, ',');
  57 + }
  58 + fclose($file_handle);
  59 + } catch (\Exception $e) {
  60 + echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', import fail, error: ' . $e->getMessage() . PHP_EOL;
  61 + $task->status = ImportTask::STATUS_COM;//导入完成
  62 + $task->save();
  63 + return true;
  64 + }
  65 +
  66 + $success_count = 0; //成功导入条数
  67 + $count_line = count($line_of_text); //总条数
  68 + if ($count_line > 1) {
  69 + $task->status = ImportTask::STATUS_ING;//导入中
  70 + $task->total_count = $count_line - 1;
  71 + $task->save();
  72 +
  73 + //设置数据库
  74 + $project = ProjectServer::useProject($task->project_id);
  75 + if ($project) {
  76 + foreach ($line_of_text as $k => $v) {
  77 + if ($k > 0) {
  78 + if ($task->type == ImportTask::TYPE_NEWS) {
  79 + if ((new NewsLogic())->importNews($task->project_id, $task->user_id, $v)) {
  80 + $success_count += 1;
  81 + }
  82 + }
  83 + }
  84 + }
  85 + }
  86 + //关闭数据库
  87 + DB::disconnect('custom_mysql');
  88 + }
  89 +
  90 + $task->status = ImportTask::STATUS_COM;//导入完成
  91 + $task->success_count = $success_count;
  92 + $task->save();
  93 +
  94 + echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', import end, total count: ' . ($count_line - 1) . ', success count: ' . $success_count . PHP_EOL;
  95 +
  96 + sleep(2);
  97 + }
  98 +}
@@ -9,6 +9,7 @@ use App\Helper\QuanqiusouApi; @@ -9,6 +9,7 @@ use App\Helper\QuanqiusouApi;
9 use App\Http\Controllers\Bside\BaseController; 9 use App\Http\Controllers\Bside\BaseController;
10 use App\Http\Logic\Aside\Project\ProjectLogic; 10 use App\Http\Logic\Aside\Project\ProjectLogic;
11 use App\Http\Logic\Bside\RankData\RankDataLogic; 11 use App\Http\Logic\Bside\RankData\RankDataLogic;
  12 +use App\Models\Domain\DomainInfo;
12 use App\Models\RankData\RankData; 13 use App\Models\RankData\RankData;
13 use App\Models\RankData\Speed as GoogleSpeedModel; 14 use App\Models\RankData\Speed as GoogleSpeedModel;
14 use App\Services\BatchExportService; 15 use App\Services\BatchExportService;
@@ -58,7 +59,7 @@ class RankDataController extends BaseController @@ -58,7 +59,7 @@ class RankDataController extends BaseController
58 public function speed(ProjectLogic $projectLogic, GoogleSpeedApi $googleSpeedApi){ 59 public function speed(ProjectLogic $projectLogic, GoogleSpeedApi $googleSpeedApi){
59 $project_id = $this->user['project_id']; 60 $project_id = $this->user['project_id'];
60 $project = $projectLogic->getProjectInfo($project_id); 61 $project = $projectLogic->getProjectInfo($project_id);
61 - $domain = $project['deploy_optimize']['domain'] ?? ''; 62 + $domain = (!empty($project['deploy_optimize']['domain']) ? ((new DomainInfo())->getDomain($project['deploy_optimize']['domain'])) : '');
62 $data = $googleSpeedApi->run($domain); 63 $data = $googleSpeedApi->run($domain);
63 if($data){ 64 if($data){
64 $model = GoogleSpeedModel::where('project_id', $project_id)->first(); 65 $model = GoogleSpeedModel::where('project_id', $project_id)->first();
@@ -19,7 +19,7 @@ class DomainInfoLogic extends BaseLogic @@ -19,7 +19,7 @@ class DomainInfoLogic extends BaseLogic
19 public function getDomainInfo($project_id) 19 public function getDomainInfo($project_id)
20 { 20 {
21 $project = app(ProjectLogic::class)->getInfo($project_id); 21 $project = app(ProjectLogic::class)->getInfo($project_id);
22 - $domain = $project['deploy_optimize']['domain'] ?? ''; 22 + $domain = (!empty($project['deploy_optimize']['domain']) ? ((new \App\Models\Domain\DomainInfo())->getDomain($project['deploy_optimize']['domain'])) : '');
23 $info = $this->model->where('project_id', $project_id)->first(); 23 $info = $this->model->where('project_id', $project_id)->first();
24 //不存在或时间过期了 重新获取信息 24 //不存在或时间过期了 重新获取信息
25 $expiration_date = $info['domain_info']['expiration_date'] ?? ''; 25 $expiration_date = $info['domain_info']['expiration_date'] ?? '';
@@ -4,6 +4,7 @@ namespace App\Http\Logic\Aside\Project; @@ -4,6 +4,7 @@ namespace App\Http\Logic\Aside\Project;
4 4
5 5
6 use App\Http\Logic\Aside\BaseLogic; 6 use App\Http\Logic\Aside\BaseLogic;
  7 +use App\Models\Domain\DomainInfo;
7 use App\Models\Project\ProcessRecords; 8 use App\Models\Project\ProcessRecords;
8 use App\Models\Project\Project; 9 use App\Models\Project\Project;
9 10
@@ -30,7 +31,7 @@ class ProcessRecordsLogic extends BaseLogic @@ -30,7 +31,7 @@ class ProcessRecordsLogic extends BaseLogic
30 $data['project_company'] = $project['company'] ?? ''; 31 $data['project_company'] = $project['company'] ?? '';
31 $data['project_plan'] = Project::planMap()[$project['deploy_build']['plan']]; 32 $data['project_plan'] = Project::planMap()[$project['deploy_build']['plan']];
32 $data['project_service_duration'] = $project['deploy_build']['service_duration'] ?? ''; 33 $data['project_service_duration'] = $project['deploy_build']['service_duration'] ?? '';
33 - $data['domain'] = $project['deploy_optimize']['domain'] ?? ''; 34 + $data['domain'] = (!empty($project['deploy_optimize']['domain']) ? ((new DomainInfo())->getDomain($project['deploy_optimize']['domain'])) : '');;
34 $data['test_domain'] = $project['deploy_build']['test_domain'] ?? ''; 35 $data['test_domain'] = $project['deploy_build']['test_domain'] ?? '';
35 $data['login_mobile'] = $project['deploy_build']['login_mobile'] ?? ''; 36 $data['login_mobile'] = $project['deploy_build']['login_mobile'] ?? '';
36 $data['data_source'] = [ 37 $data['data_source'] = [
@@ -408,7 +408,7 @@ class ProjectLogic extends BaseLogic @@ -408,7 +408,7 @@ class ProjectLogic extends BaseLogic
408 { 408 {
409 $project = $this->getCacheInfo($param['project_id']); 409 $project = $this->getCacheInfo($param['project_id']);
410 //同步到接口 410 //同步到接口
411 - $domain = parse_url($project['deploy_optimize']['domain'])['host']; 411 + $domain = parse_url((!empty($project['deploy_optimize']['domain']) ? ((new DomainInfo())->getDomain($project['deploy_optimize']['domain'])) : ''))['host'];
412 $emails = Arr::arrToSet($param['emails']??'', 'trim'); 412 $emails = Arr::arrToSet($param['emails']??'', 'trim');
413 $phones = Arr::arrToSet($param['phones']??'', 'trim'); 413 $phones = Arr::arrToSet($param['phones']??'', 'trim');
414 $form_global_api = new FormGlobalsoApi(); 414 $form_global_api = new FormGlobalsoApi();
@@ -46,8 +46,8 @@ class BlogCategoryLogic extends BaseLogic @@ -46,8 +46,8 @@ class BlogCategoryLogic extends BaseLogic
46 public function categorySave(){ 46 public function categorySave(){
47 //验证名称是否存在 47 //验证名称是否存在
48 $this->verifyParamName($this->param['name']); 48 $this->verifyParamName($this->param['name']);
49 - DB::beginTransaction();  
50 - try { 49 +// DB::beginTransaction();
  50 +// try {
51 if(isset($this->param['id']) && !empty($this->param['id'])){ 51 if(isset($this->param['id']) && !empty($this->param['id'])){
52 //验证参数是否可编辑 52 //验证参数是否可编辑
53 $this->verifyParamEdit($this->param['id'],$this->param['pid']); 53 $this->verifyParamEdit($this->param['id'],$this->param['pid']);
@@ -65,11 +65,11 @@ class BlogCategoryLogic extends BaseLogic @@ -65,11 +65,11 @@ class BlogCategoryLogic extends BaseLogic
65 $route = RouteMap::setRoute(isset($this->param['alias']) ? $this->param['alias'] : $this->param['name'], 65 $route = RouteMap::setRoute(isset($this->param['alias']) ? $this->param['alias'] : $this->param['name'],
66 RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']); 66 RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']);
67 $this->edit(['alias'=>$route],['id'=>$id]); 67 $this->edit(['alias'=>$route],['id'=>$id]);
68 - DB::commit();  
69 - }catch (\Exception $e){  
70 - DB::rollBack();  
71 - $this->fail('error');  
72 - } 68 +// DB::commit();
  69 +// }catch (\Exception $e){
  70 +// DB::rollBack();
  71 +// $this->fail('error');
  72 +// }
73 //通知更新 73 //通知更新
74 $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_BLOG_CATE, 'route'=>$route]); 74 $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_BLOG_CATE, 'route'=>$route]);
75 return $this->success(); 75 return $this->success();
@@ -7,6 +7,7 @@ use App\Helper\FormGlobalsoApi; @@ -7,6 +7,7 @@ use App\Helper\FormGlobalsoApi;
7 use App\Helper\Translate; 7 use App\Helper\Translate;
8 use App\Http\Logic\Aside\Project\ProjectLogic; 8 use App\Http\Logic\Aside\Project\ProjectLogic;
9 use App\Http\Logic\Bside\BaseLogic; 9 use App\Http\Logic\Bside\BaseLogic;
  10 +use App\Models\Domain\DomainInfo;
10 11
11 /** 12 /**
12 * Class InquiryLogic 13 * Class InquiryLogic
@@ -31,7 +32,8 @@ class InquiryLogic extends BaseLogic @@ -31,7 +32,8 @@ class InquiryLogic extends BaseLogic
31 $search = $this->request['search'] ?: ''; 32 $search = $this->request['search'] ?: '';
32 $page = $this->request['page'] ?: 1; 33 $page = $this->request['page'] ?: 1;
33 $project = (new ProjectLogic())->getProjectInfo($this->user['project_id']); 34 $project = (new ProjectLogic())->getProjectInfo($this->user['project_id']);
34 - $domain = $project['deploy_optimize']['domain'] ?? ''; 35 + $domain = (!empty(
  36 + $project['deploy_optimize']['domain']) ? ((new DomainInfo())->getDomain($project['deploy_optimize']['domain'])) : '');
35 $list = $this->form_globalso_api->getInquiryList($domain, $search, $page, $page_size); 37 $list = $this->form_globalso_api->getInquiryList($domain, $search, $page, $page_size);
36 //处理格式 免得前端又改 38 //处理格式 免得前端又改
37 $data = [ 39 $data = [
@@ -54,7 +56,7 @@ class InquiryLogic extends BaseLogic @@ -54,7 +56,7 @@ class InquiryLogic extends BaseLogic
54 public function getInfo($id) 56 public function getInfo($id)
55 { 57 {
56 $project = (new ProjectLogic())->getProjectInfo($this->user['project_id']); 58 $project = (new ProjectLogic())->getProjectInfo($this->user['project_id']);
57 - $domain = $project['deploy_optimize']['domain'] ?: ''; 59 + $domain = (!empty($project['deploy_optimize']['domain']) ? ((new DomainInfo())->getDomain($project['deploy_optimize']['domain'])) : '');
58 //修改状态为已读 60 //修改状态为已读
59 if($this->request['read_status']){ 61 if($this->request['read_status']){
60 $this->form_globalso_api->saveInquiryRead($domain, $id); 62 $this->form_globalso_api->saveInquiryRead($domain, $id);
@@ -70,7 +72,7 @@ class InquiryLogic extends BaseLogic @@ -70,7 +72,7 @@ class InquiryLogic extends BaseLogic
70 public function delete($ids, $map = []) 72 public function delete($ids, $map = [])
71 { 73 {
72 $project = (new ProjectLogic())->getProjectInfo($this->user['project_id']); 74 $project = (new ProjectLogic())->getProjectInfo($this->user['project_id']);
73 - $domain = $project['deploy_optimize']['domain'] ?: ''; 75 + $domain = (!empty($project['deploy_optimize']['domain']) ? ((new DomainInfo())->getDomain($project['deploy_optimize']['domain'])) : '');
74 $ids = array_filter(Arr::splitFilterToArray($ids), 'intval'); 76 $ids = array_filter(Arr::splitFilterToArray($ids), 'intval');
75 if(!$ids){ 77 if(!$ids){
76 $this->fail('ID不能为空'); 78 $this->fail('ID不能为空');
@@ -59,9 +59,9 @@ class NewsCategoryLogic extends BaseLogic @@ -59,9 +59,9 @@ class NewsCategoryLogic extends BaseLogic
59 */ 59 */
60 public function newsCategorySave(){ 60 public function newsCategorySave(){
61 //验证名称是否存在 61 //验证名称是否存在
62 - $this->verifyParamName($this->param['name']);  
63 - DB::beginTransaction();  
64 - try { 62 +// $this->verifyParamName($this->param['name']);
  63 +// DB::beginTransaction();
  64 +// try {
65 if(isset($this->param['id']) && !empty($this->param['id'])){ 65 if(isset($this->param['id']) && !empty($this->param['id'])){
66 //验证是否可编辑 66 //验证是否可编辑
67 $this->verifyEditParam($this->param['id'],$this->param['pid']); 67 $this->verifyEditParam($this->param['id'],$this->param['pid']);
@@ -77,11 +77,11 @@ class NewsCategoryLogic extends BaseLogic @@ -77,11 +77,11 @@ class NewsCategoryLogic extends BaseLogic
77 } 77 }
78 $route = RouteMap::setRoute(isset($this->param['alias']) ? $this->param['alias'] : $this->param['name'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']); 78 $route = RouteMap::setRoute(isset($this->param['alias']) ? $this->param['alias'] : $this->param['name'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
79 $this->model->edit(['alias'=>$route],['id'=>$id]); 79 $this->model->edit(['alias'=>$route],['id'=>$id]);
80 - DB::commit();  
81 - }catch (\Exception $e){  
82 - DB::rollBack();  
83 - $this->fail('error');  
84 - } 80 +// DB::commit();
  81 +// }catch (\Exception $e){
  82 +// DB::rollBack();
  83 +// $this->fail('error');
  84 +// }
85 //更新通知记录表 85 //更新通知记录表
86 $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NEWS_CATE, 'route'=>$route]); 86 $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NEWS_CATE, 'route'=>$route]);
87 return $this->success(); 87 return $this->success();
@@ -270,4 +270,38 @@ class NewsCategoryLogic extends BaseLogic @@ -270,4 +270,38 @@ class NewsCategoryLogic extends BaseLogic
270 $this->setRouteDeleteSave($data); 270 $this->setRouteDeleteSave($data);
271 return $this->success(); 271 return $this->success();
272 } 272 }
  273 +
  274 + public function importNewsCategory($project_id,$user_id,$category){
  275 + $return = [];
  276 +
  277 + $cate_arr = explode('/',$category);
  278 + $p_cate = $cate_arr[0];
  279 + $c_cate = $cate_arr[1];
  280 +
  281 + $p_category = $this->model->read(['name'=>$p_cate,'pid'=>0]);
  282 + if(!$p_category){
  283 + $p_id = $this->model->addReturnId(['name'=>$p_cate,'project_id'=>$project_id,'operator_id'=>$user_id,'create_id'=>$user_id]);
  284 +
  285 + $route = RouteMap::setRoute($p_cate, RouteMap::SOURCE_NEWS_CATE, $p_id, $project_id);
  286 + $this->model->edit(['alias'=>$route],['id'=>$p_id]);
  287 + }else{
  288 + $p_id = $p_category['id'];
  289 + }
  290 + $return[] = $p_id;
  291 +
  292 + if($c_cate){
  293 + $c_category = $this->model->read(['name'=>$c_cate,'pid'=>$p_id]);
  294 + if(!$c_category){
  295 + $c_id = $this->model->addReturnId(['name'=>$c_cate,'pid'=>$p_id,'project_id'=>$project_id,'operator_id'=>$user_id,'create_id'=>$user_id]);
  296 +
  297 + $route = RouteMap::setRoute($c_cate, RouteMap::SOURCE_NEWS_CATE, $c_id, $project_id);
  298 + $this->model->edit(['alias'=>$route],['id'=>$c_id]);
  299 + }else{
  300 + $c_id = $c_category['id'];
  301 + }
  302 + $return[] = $c_id;
  303 + }
  304 +
  305 + return ','.implode(',',$return).',';
  306 + }
273 } 307 }
@@ -28,20 +28,21 @@ class NewsLogic extends BaseLogic @@ -28,20 +28,21 @@ class NewsLogic extends BaseLogic
28 * @author :liyuhang 28 * @author :liyuhang
29 * @method 29 * @method
30 */ 30 */
31 - public function news_get_category_list(){ 31 + public function news_get_category_list()
  32 + {
32 $this->map['status'] = 0; 33 $this->map['status'] = 0;
33 $this->map['project_id'] = $this->user['project_id']; 34 $this->map['project_id'] = $this->user['project_id'];
34 $newsCategoryModel = new NewsCategoryModel(); 35 $newsCategoryModel = new NewsCategoryModel();
35 - $cate_list = $newsCategoryModel->list($this->map,'sort');  
36 - if($cate_list === false){  
37 - $this->fail('error',Code::USER_ERROR); 36 + $cate_list = $newsCategoryModel->list($this->map, 'sort');
  37 + if ($cate_list === false) {
  38 + $this->fail('error', Code::USER_ERROR);
38 } 39 }
39 $list = []; 40 $list = [];
40 - foreach ($cate_list as $v){ 41 + foreach ($cate_list as $v) {
41 $v = (array)$v; 42 $v = (array)$v;
42 if ($v['pid'] == 0) { 43 if ($v['pid'] == 0) {
43 $v['sub'] = _get_child($v['id'], $cate_list); 44 $v['sub'] = _get_child($v['id'], $cate_list);
44 - $list[] = $v; 45 + $list[] = $v;
45 } 46 }
46 } 47 }
47 return $this->success($list); 48 return $this->success($list);
@@ -54,28 +55,29 @@ class NewsLogic extends BaseLogic @@ -54,28 +55,29 @@ class NewsLogic extends BaseLogic
54 * @method :post 55 * @method :post
55 * @time :2023/9/7 11:02 56 * @time :2023/9/7 11:02
56 */ 57 */
57 - public function newsSave(){ 58 + public function newsSave()
  59 + {
58 //拼接参数 60 //拼接参数
59 DB::beginTransaction(); 61 DB::beginTransaction();
60 try { 62 try {
61 $this->param = $this->paramProcessing($this->param); 63 $this->param = $this->paramProcessing($this->param);
62 - if(isset($this->param['id']) && !empty($this->param['id'])){ 64 + if (isset($this->param['id']) && !empty($this->param['id'])) {
63 //是否更新路由 65 //是否更新路由
64 - $id = $this->editNewsRoute($this->param['id'],$this->param['url']);  
65 - $this->edit($this->param,['id'=>$this->param['id']]);  
66 - }else{ 66 + $id = $this->editNewsRoute($this->param['id'], $this->param['url']);
  67 + $this->edit($this->param, ['id' => $this->param['id']]);
  68 + } else {
67 $id = $this->model->addReturnId($this->param); 69 $id = $this->model->addReturnId($this->param);
68 } 70 }
69 //更新路由 71 //更新路由
70 $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $id, $this->user['project_id']); 72 $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
71 - $this->edit(['url'=>$route],['id'=>$id]); 73 + $this->edit(['url' => $route], ['id' => $id]);
72 DB::commit(); 74 DB::commit();
73 - }catch (\Exception $e){ 75 + } catch (\Exception $e) {
74 DB::rollBack(); 76 DB::rollBack();
75 $this->fail('添加失败'); 77 $this->fail('添加失败');
76 } 78 }
77 //通知更新 79 //通知更新
78 - $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NEWS, 'route'=>$route]); 80 + $this->updateNotify(['project_id' => $this->user['project_id'], 'type' => RouteMap::SOURCE_NEWS, 'route' => $route]);
79 return $this->success(); 81 return $this->success();
80 } 82 }
81 83
@@ -86,13 +88,14 @@ class NewsLogic extends BaseLogic @@ -86,13 +88,14 @@ class NewsLogic extends BaseLogic
86 * @method :post 88 * @method :post
87 * @time :2023/9/7 11:05 89 * @time :2023/9/7 11:05
88 */ 90 */
89 - public function editNewsRoute($id,$route){ 91 + public function editNewsRoute($id, $route)
  92 + {
90 //生成一条删除路由记录 93 //生成一条删除路由记录
91 - $info = $this->model->read(['id'=>$id],['id','url']);  
92 - if($info['url'] != $route){ 94 + $info = $this->model->read(['id' => $id], ['id', 'url']);
  95 + if ($info['url'] != $route) {
93 $data = [ 96 $data = [
94 - 'source'=>RouteMap::SOURCE_NEWS,  
95 - 'route'=>$info['url'], 97 + 'source' => RouteMap::SOURCE_NEWS,
  98 + 'route' => $info['url'],
96 ]; 99 ];
97 $this->setRouteDeleteSave($data); 100 $this->setRouteDeleteSave($data);
98 } 101 }
@@ -106,10 +109,11 @@ class NewsLogic extends BaseLogic @@ -106,10 +109,11 @@ class NewsLogic extends BaseLogic
106 * @author :liyuhang 109 * @author :liyuhang
107 * @method 110 * @method
108 */ 111 */
109 - public function edit_seo(){ 112 + public function edit_seo()
  113 + {
110 $this->param['operator_id'] = $this->user['id']; 114 $this->param['operator_id'] = $this->user['id'];
111 - $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);  
112 - if($rs === false){ 115 + $rs = $this->model->edit($this->param, ['id' => $this->param['id']]);
  116 + if ($rs === false) {
113 $this->fail('error'); 117 $this->fail('error');
114 } 118 }
115 return $this->success(); 119 return $this->success();
@@ -122,10 +126,11 @@ class NewsLogic extends BaseLogic @@ -122,10 +126,11 @@ class NewsLogic extends BaseLogic
122 * @author :liyuhang 126 * @author :liyuhang
123 * @method 127 * @method
124 */ 128 */
125 - public function news_status(){ 129 + public function news_status()
  130 + {
126 $this->param['operator_id'] = $this->user['id']; 131 $this->param['operator_id'] = $this->user['id'];
127 - $rs = $this->model->edit($this->param,['id'=>['in',$this->param['id']]]);  
128 - if($rs === false){ 132 + $rs = $this->model->edit($this->param, ['id' => ['in', $this->param['id']]]);
  133 + if ($rs === false) {
129 $this->fail('error'); 134 $this->fail('error');
130 } 135 }
131 return $this->success(); 136 return $this->success();
@@ -138,7 +143,8 @@ class NewsLogic extends BaseLogic @@ -138,7 +143,8 @@ class NewsLogic extends BaseLogic
138 * @author :liyuhang 143 * @author :liyuhang
139 * @method 144 * @method
140 */ 145 */
141 - public function newsInfo(){ 146 + public function newsInfo()
  147 + {
142 $info = $this->model->read($this->param); 148 $info = $this->model->read($this->param);
143 $info['image_link'] = getImageUrl($info['image']); 149 $info['image_link'] = getImageUrl($info['image']);
144 $newsCategoryLogic = new NewsCategoryLogic(); 150 $newsCategoryLogic = new NewsCategoryLogic();
@@ -152,15 +158,16 @@ class NewsLogic extends BaseLogic @@ -152,15 +158,16 @@ class NewsLogic extends BaseLogic
152 * @author :liyuhang 158 * @author :liyuhang
153 * @method 159 * @method
154 */ 160 */
155 - public function newsDel(){ 161 + public function newsDel()
  162 + {
156 DB::beginTransaction(); 163 DB::beginTransaction();
157 try { 164 try {
158 - foreach ($this->param['id'] as $id){ 165 + foreach ($this->param['id'] as $id) {
159 $this->delRoute($id); 166 $this->delRoute($id);
160 - $this->model->del(['id'=>$id]); 167 + $this->model->del(['id' => $id]);
161 } 168 }
162 DB::commit(); 169 DB::commit();
163 - }catch (Exception $e){ 170 + } catch (Exception $e) {
164 DB::rollBack(); 171 DB::rollBack();
165 $this->fail('error'); 172 $this->fail('error');
166 } 173 }
@@ -173,18 +180,19 @@ class NewsLogic extends BaseLogic @@ -173,18 +180,19 @@ class NewsLogic extends BaseLogic
173 * @method :post 180 * @method :post
174 * @time :2023/6/13 11:30 181 * @time :2023/6/13 11:30
175 */ 182 */
176 - public function paramProcessing($param){  
177 - if(isset($this->param['id'])){ 183 + public function paramProcessing($param)
  184 + {
  185 + if (isset($this->param['id'])) {
178 $param['operator_id'] = $this->user['id']; 186 $param['operator_id'] = $this->user['id'];
179 - if(isset($param['category_id']) && !empty($param['category_id'])){  
180 - $param['category_id'] = ','.trim($param['category_id'],',').','; 187 + if (isset($param['category_id']) && !empty($param['category_id'])) {
  188 + $param['category_id'] = ',' . trim($param['category_id'], ',') . ',';
181 } 189 }
182 - }else{ 190 + } else {
183 $param['create_id'] = $this->user['id']; 191 $param['create_id'] = $this->user['id'];
184 $param['operator_id'] = $this->user['id']; 192 $param['operator_id'] = $this->user['id'];
185 $param['project_id'] = $this->user['project_id']; 193 $param['project_id'] = $this->user['project_id'];
186 - if(isset($param['category_id']) && !empty($param['category_id'])){  
187 - $param['category_id'] = ','.$param['category_id'].','; 194 + if (isset($param['category_id']) && !empty($param['category_id'])) {
  195 + $param['category_id'] = ',' . $param['category_id'] . ',';
188 } 196 }
189 } 197 }
190 return $this->success($param); 198 return $this->success($param);
@@ -197,14 +205,15 @@ class NewsLogic extends BaseLogic @@ -197,14 +205,15 @@ class NewsLogic extends BaseLogic
197 * @method :post 205 * @method :post
198 * @time :2023/6/19 9:42 206 * @time :2023/6/19 9:42
199 */ 207 */
200 - public function getStatusNumber(){ 208 + public function getStatusNumber()
  209 + {
201 //三种状态 0:草稿 1:发布 2:回收站 210 //三种状态 0:草稿 1:发布 2:回收站
202 - $data = ['dra'=>0,'pub'=>1,'del'=>2,'tal'=>3];  
203 - foreach ($data as $k => $v){  
204 - if($v == 3){  
205 - $data[$k] = $this->model->where(['project_id'=>$this->user['project_id']])->count();  
206 - }else{  
207 - $data[$k] = $this->model->where(['status'=>$v,'project_id'=>$this->user['project_id']])->count(); 211 + $data = ['dra' => 0, 'pub' => 1, 'del' => 2, 'tal' => 3];
  212 + foreach ($data as $k => $v) {
  213 + if ($v == 3) {
  214 + $data[$k] = $this->model->where(['project_id' => $this->user['project_id']])->count();
  215 + } else {
  216 + $data[$k] = $this->model->where(['status' => $v, 'project_id' => $this->user['project_id']])->count();
208 } 217 }
209 } 218 }
210 return $this->success($data); 219 return $this->success($data);
@@ -217,9 +226,10 @@ class NewsLogic extends BaseLogic @@ -217,9 +226,10 @@ class NewsLogic extends BaseLogic
217 * @method :post 226 * @method :post
218 * @time :2023/8/19 11:16 227 * @time :2023/8/19 11:16
219 */ 228 */
220 - public function setSort(){  
221 - $rs = $this->model->edit(['sort'=>$this->param['sort']],['id'=>$this->param['id']]);  
222 - if($rs === false){ 229 + public function setSort()
  230 + {
  231 + $rs = $this->model->edit(['sort' => $this->param['sort']], ['id' => $this->param['id']]);
  232 + if ($rs === false) {
223 $this->fail('error'); 233 $this->fail('error');
224 } 234 }
225 return $this->success(); 235 return $this->success();
@@ -232,16 +242,28 @@ class NewsLogic extends BaseLogic @@ -232,16 +242,28 @@ class NewsLogic extends BaseLogic
232 * @method :post 242 * @method :post
233 * @time :2023/9/7 10:50 243 * @time :2023/9/7 10:50
234 */ 244 */
235 - public function delRoute($id){ 245 + public function delRoute($id)
  246 + {
236 //删除路由映射 247 //删除路由映射
237 RouteMap::delRoute(RouteMap::SOURCE_NEWS, $id, $this->user['project_id']); 248 RouteMap::delRoute(RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
238 //生成一条删除路由记录 249 //生成一条删除路由记录
239 - $info = $this->model->read(['id'=>$id],['id','url']); 250 + $info = $this->model->read(['id' => $id], ['id', 'url']);
240 $data = [ 251 $data = [
241 - 'source'=>RouteMap::SOURCE_NEWS,  
242 - 'route'=>$info['url'], 252 + 'source' => RouteMap::SOURCE_NEWS,
  253 + 'route' => $info['url'],
243 ]; 254 ];
244 $this->setRouteDeleteSave($data); 255 $this->setRouteDeleteSave($data);
245 return $this->success(); 256 return $this->success();
246 } 257 }
  258 +
  259 + public function importNews($project_id, $user_id, $data)
  260 + {
  261 + $category_id = '';
  262 + if (!empty($data[2])) {
  263 + //处理分类
  264 + $newsCategoryLogic = new NewsCategoryLogic();
  265 + $category_id = $newsCategoryLogic->importNewsCategory($project_id, $user_id, $data[2]);
  266 + }
  267 + dd($category_id);
  268 + }
247 } 269 }
@@ -9,6 +9,7 @@ use App\Helper\Translate; @@ -9,6 +9,7 @@ use App\Helper\Translate;
9 use App\Http\Logic\Aside\Project\DomainInfoLogic; 9 use App\Http\Logic\Aside\Project\DomainInfoLogic;
10 use App\Http\Logic\Aside\Project\ProjectLogic; 10 use App\Http\Logic\Aside\Project\ProjectLogic;
11 use App\Http\Logic\Bside\BaseLogic; 11 use App\Http\Logic\Bside\BaseLogic;
  12 +use App\Models\Domain\DomainInfo;
12 use App\Models\Project\DeployBuild; 13 use App\Models\Project\DeployBuild;
13 use App\Models\Project\DeployOptimize; 14 use App\Models\Project\DeployOptimize;
14 use App\Models\Project\Project; 15 use App\Models\Project\Project;
@@ -59,7 +60,7 @@ class RankDataLogic extends BaseLogic @@ -59,7 +60,7 @@ class RankDataLogic extends BaseLogic
59 //项目信息 60 //项目信息
60 $data['project'] = [ 61 $data['project'] = [
61 'company' => $project['company'], 62 'company' => $project['company'],
62 - 'domain' => $project['deploy_optimize']['domain'] ?? '', 63 + 'domain' => (!empty($project['deploy_optimize']['domain']) ? ((new DomainInfo())->getDomain($project['deploy_optimize']['domain'])) : ''),
63 'domain_info' => ($domain_info['domain_info']['creation_date'] ?? '') . ' - ' . ($domain_info['domain_info']['expiration_date'] ?? ''), 64 'domain_info' => ($domain_info['domain_info']['creation_date'] ?? '') . ' - ' . ($domain_info['domain_info']['expiration_date'] ?? ''),
64 'cert_info' => ($domain_info['ssl']['start_time'] ?? '') . ' - ' . ($domain_info['ssl']['end_time'] ?? ''), 65 'cert_info' => ($domain_info['ssl']['start_time'] ?? '') . ' - ' . ($domain_info['ssl']['end_time'] ?? ''),
65 'plan' => Project::planMap()[$project['deploy_build']['plan']], 66 'plan' => Project::planMap()[$project['deploy_build']['plan']],
@@ -144,7 +145,7 @@ class RankDataLogic extends BaseLogic @@ -144,7 +145,7 @@ class RankDataLogic extends BaseLogic
144 $project_id = $this->user['project_id']; 145 $project_id = $this->user['project_id'];
145 $project = app(ProjectLogic::class)->getInfo($project_id); 146 $project = app(ProjectLogic::class)->getInfo($project_id);
146 $api_no = $project['deploy_optimize']['api_no'] ?? ''; 147 $api_no = $project['deploy_optimize']['api_no'] ?? '';
147 - $domain = $project['deploy_optimize']['domain'] ?? ''; 148 + $domain = (!empty($project['deploy_optimize']['domain']) ? ((new DomainInfo())->getDomain($project['deploy_optimize']['domain'])) : '');
148 $domain_arr = parse_url($domain); 149 $domain_arr = parse_url($domain);
149 $domain = $domain_arr['host'] ?? $domain_arr['path']; 150 $domain = $domain_arr['host'] ?? $domain_arr['path'];
150 //复制站点域名 151 //复制站点域名
@@ -164,8 +164,7 @@ class UserLoginLogic @@ -164,8 +164,7 @@ class UserLoginLogic
164 $info['aicc'] = $project['aicc'] ?? ''; 164 $info['aicc'] = $project['aicc'] ?? '';
165 $info['hagro'] = $project['hagro'] ?? ''; 165 $info['hagro'] = $project['hagro'] ?? '';
166 $info['plan'] = Project::planMap()[$project['deploy_build']['plan']]; 166 $info['plan'] = Project::planMap()[$project['deploy_build']['plan']];
167 - $info['domain'] = (!empty($project['deploy_optimize']['domain']) ?  
168 - ((new DomainInfo())->getDomain($project['deploy_optimize']['domain'])) : ($project['deploy_build']['test_domain'] ?? '')); 167 + $info['domain'] = (!empty($project['deploy_optimize']['domain']) ? ((new DomainInfo())->getDomain($project['deploy_optimize']['domain'])) : ($project['deploy_build']['test_domain'] ?? ''));
169 //保存项目缓存 168 //保存项目缓存
170 Cache::put('user-'.$info['project_id'],$project,$minutes = null); 169 Cache::put('user-'.$info['project_id'],$project,$minutes = null);
171 return $this->success($info); 170 return $this->success($info);
@@ -188,8 +187,7 @@ class UserLoginLogic @@ -188,8 +187,7 @@ class UserLoginLogic
188 $info['aicc'] = $project['aicc'] ?? ''; 187 $info['aicc'] = $project['aicc'] ?? '';
189 $info['hagro'] = $project['hagro'] ?? ''; 188 $info['hagro'] = $project['hagro'] ?? '';
190 $info['plan'] = Project::planMap()[$project['deploy_build']['plan']]; 189 $info['plan'] = Project::planMap()[$project['deploy_build']['plan']];
191 - $info['domain'] = (!empty($project['deploy_optimize']['domain']) ?  
192 - ((new DomainInfo())->getDomain($project['deploy_optimize']['domain'])) : ($project['deploy_build']['test_domain'] ?? '')); 190 + $info['domain'] = (!empty($project['deploy_optimize']['domain']) ? ((new DomainInfo())->getDomain($project['deploy_optimize']['domain'])) : ($project['deploy_build']['test_domain'] ?? ''));
193 //保存项目缓存 191 //保存项目缓存
194 Cache::put('user-'.$info['project_id'],$project,$minutes = null); 192 Cache::put('user-'.$info['project_id'],$project,$minutes = null);
195 return $this->success($info); 193 return $this->success($info);