Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6
正在显示
17 个修改的文件
包含
408 行增加
和
439 行删除
| @@ -17,7 +17,6 @@ yarn-error.log | @@ -17,7 +17,6 @@ yarn-error.log | ||
| 17 | /.idea | 17 | /.idea |
| 18 | /.vscode | 18 | /.vscode |
| 19 | composer.lock | 19 | composer.lock |
| 20 | -app/Console/Commands/Test/Demo.php | ||
| 21 | app/Console/Commands/Test/DataRecovery.php | 20 | app/Console/Commands/Test/DataRecovery.php |
| 22 | /public/upload | 21 | /public/upload |
| 23 | /public/runtime | 22 | /public/runtime |
| @@ -39,7 +39,7 @@ class AiBlogTask extends Command | @@ -39,7 +39,7 @@ class AiBlogTask extends Command | ||
| 39 | $aiBlogTaskModel = new AiBlogTaskModel(); | 39 | $aiBlogTaskModel = new AiBlogTaskModel(); |
| 40 | while (true){ | 40 | while (true){ |
| 41 | $info = $aiBlogTaskModel->where('status',1)->orderBy('id','asc')->first(); | 41 | $info = $aiBlogTaskModel->where('status',1)->orderBy('id','asc')->first(); |
| 42 | - if($info === false){ | 42 | + if(empty($info)){ |
| 43 | sleep(30); | 43 | sleep(30); |
| 44 | continue; | 44 | continue; |
| 45 | } | 45 | } |
| @@ -52,6 +52,11 @@ class AiBlogTask extends Command | @@ -52,6 +52,11 @@ class AiBlogTask extends Command | ||
| 52 | $aiBlogService->key = $aiSettingInfo['key']; | 52 | $aiBlogService->key = $aiSettingInfo['key']; |
| 53 | $aiBlogService->task_id = $info['task_id']; | 53 | $aiBlogService->task_id = $info['task_id']; |
| 54 | $result = $aiBlogService->getDetail(); | 54 | $result = $aiBlogService->getDetail(); |
| 55 | + if(!isset($result['status'])){ | ||
| 56 | + //修改任务状态 | ||
| 57 | + $aiBlogTaskModel->edit(['status'=>3],['id'=>$info['id']]); | ||
| 58 | + continue; | ||
| 59 | + } | ||
| 55 | if($result['status'] != 200){ | 60 | if($result['status'] != 200){ |
| 56 | sleep(10); | 61 | sleep(10); |
| 57 | continue; | 62 | continue; |
| @@ -19,6 +19,7 @@ use App\Services\ProjectServer; | @@ -19,6 +19,7 @@ use App\Services\ProjectServer; | ||
| 19 | use Illuminate\Console\Command; | 19 | use Illuminate\Console\Command; |
| 20 | use Illuminate\Support\Facades\DB; | 20 | use Illuminate\Support\Facades\DB; |
| 21 | use Illuminate\Support\Facades\Log; | 21 | use Illuminate\Support\Facades\Log; |
| 22 | +use Illuminate\Support\Facades\Redis; | ||
| 22 | 23 | ||
| 23 | /** | 24 | /** |
| 24 | * Class SyncInquiryProject | 25 | * Class SyncInquiryProject |
| @@ -38,7 +39,7 @@ class SyncInquiryProject extends Command | @@ -38,7 +39,7 @@ class SyncInquiryProject extends Command | ||
| 38 | * | 39 | * |
| 39 | * @var string | 40 | * @var string |
| 40 | */ | 41 | */ |
| 41 | - protected $description = '同步询盘信息:项目以及对应路由,'; | 42 | + protected $description = '同步询盘信息:项目'; |
| 42 | 43 | ||
| 43 | /** | 44 | /** |
| 44 | * Create a new command instance. | 45 | * Create a new command instance. |
| @@ -61,8 +62,6 @@ class SyncInquiryProject extends Command | @@ -61,8 +62,6 @@ class SyncInquiryProject extends Command | ||
| 61 | $this->syncGloV5(); | 62 | $this->syncGloV5(); |
| 62 | echo '开始同步v6' . PHP_EOL; | 63 | echo '开始同步v6' . PHP_EOL; |
| 63 | $this->syncGloV6(); | 64 | $this->syncGloV6(); |
| 64 | - echo '删除过期数据' . PHP_EOL; | ||
| 65 | - $this->deleteExpire(); | ||
| 66 | return true; | 65 | return true; |
| 67 | } | 66 | } |
| 68 | 67 | ||
| @@ -72,73 +71,50 @@ class SyncInquiryProject extends Command | @@ -72,73 +71,50 @@ class SyncInquiryProject extends Command | ||
| 72 | */ | 71 | */ |
| 73 | public function syncGloV5() | 72 | public function syncGloV5() |
| 74 | { | 73 | { |
| 74 | + $date = intval(date('Ymd')); | ||
| 75 | $result = http_get('https://www.quanqiusou.cn/extend_api/webs/globalso_v5_tg.php'); | 75 | $result = http_get('https://www.quanqiusou.cn/extend_api/webs/globalso_v5_tg.php'); |
| 76 | $channel = Channel::pluck('contact_mobile', 'id')->toArray(); | 76 | $channel = Channel::pluck('contact_mobile', 'id')->toArray(); |
| 77 | foreach ($result as $key=>$val) | 77 | foreach ($result as $key=>$val) |
| 78 | { | 78 | { |
| 79 | echo '同步项目:' . $val['postid'] . ' - ' . $val['company'] . PHP_EOL; | 79 | echo '同步项目:' . $val['postid'] . ' - ' . $val['company'] . PHP_EOL; |
| 80 | // 记录渠道商, 如果渠道有问题, 记录日志, 跳过当前项目, 处理数据后, 第二天再重新同步 | 80 | // 记录渠道商, 如果渠道有问题, 记录日志, 跳过当前项目, 处理数据后, 第二天再重新同步 |
| 81 | - $channel_flag = false; | ||
| 82 | $channel_tmp = []; | 81 | $channel_tmp = []; |
| 83 | foreach ($val['agent'] as $v) { | 82 | foreach ($val['agent'] as $v) { |
| 84 | $channel_id = array_search($v, $channel); | 83 | $channel_id = array_search($v, $channel); |
| 84 | + // 代理信息 只要找到一个, 就需要继续记录 | ||
| 85 | if (empty($channel_id)) { | 85 | if (empty($channel_id)) { |
| 86 | $this->log('ERROR 代理商找不到不记录当前项目, 代理商手机号码:' . $v); | 86 | $this->log('ERROR 代理商找不到不记录当前项目, 代理商手机号码:' . $v); |
| 87 | - $channel_flag = true; | ||
| 88 | - break; | 87 | + continue; |
| 89 | } | 88 | } |
| 90 | array_push($channel_tmp, $channel_id); | 89 | array_push($channel_tmp, $channel_id); |
| 91 | } | 90 | } |
| 92 | 91 | ||
| 93 | - if ($channel_flag || empty($channel_tmp)) { | 92 | + if (empty($channel_tmp)) { |
| 94 | $this->log('ERROR 代理商找不到不记录当前项目, 项目ID:' . $val['postid']); | 93 | $this->log('ERROR 代理商找不到不记录当前项目, 项目ID:' . $val['postid']); |
| 95 | continue; | 94 | continue; |
| 96 | } | 95 | } |
| 97 | 96 | ||
| 98 | - // 保存项目 以及路由 | ||
| 99 | - $project = InquiryProject::saveProject($val['v'], $val['postid'], $val['company'], implode(',', $channel_tmp), $val['main_url'], $val['is_split'], $val['test_url']); | 97 | + // 保存项目 以及 获取路由信息 |
| 98 | + $project = InquiryProject::saveProject($date, $val['v'], $val['postid'], $val['company'], implode(',', $channel_tmp), $val['main_url'], $val['is_split'], $val['test_url']); | ||
| 100 | $route_domain = $val['is_split'] && $val['test_url'] ? $val['test_url'] : $val['main_url']; | 99 | $route_domain = $val['is_split'] && $val['test_url'] ? $val['test_url'] : $val['main_url']; |
| 101 | - $this->syncGloV5Route($project->id, $route_domain); | ||
| 102 | - } | ||
| 103 | - return true; | ||
| 104 | - } | ||
| 105 | - | ||
| 106 | - /** | ||
| 107 | - * 同步v4 v5项目路由 | ||
| 108 | - * @param $project_id | ||
| 109 | - * @param $route_domain | ||
| 110 | - * @return bool | ||
| 111 | - */ | ||
| 112 | - public function syncGloV5Route($project_id, $route_domain) | ||
| 113 | - { | ||
| 114 | - try{ | ||
| 115 | - $result = http_get($route_domain . 'k_u_api.php'); | ||
| 116 | - if (empty($result)) { | ||
| 117 | - $this->log('syncGloV5Route 未获取到路由信息:' . $project_id . ', 路由获取地址:' . $route_domain . 'k_u_api.php'); | ||
| 118 | - return false; | ||
| 119 | - } | ||
| 120 | - } catch (\Exception $e) { | ||
| 121 | - $this->log('syncGloV5Route 未获取到路由信息:' . $project_id . ', 路由获取地址:' . $route_domain . 'k_u_api.php' . ', 错误信息:' . $e->getMessage()); | ||
| 122 | - echo 'syncGloV5Route 未获取到路由信息:' . $project_id . ', 路由获取地址:' . $route_domain . 'k_u_api.php' . ', 错误信息:' . $e->getMessage() . PHP_EOL; | ||
| 123 | - return false; | ||
| 124 | - } | ||
| 125 | - | ||
| 126 | - foreach ($result as $key=>$val) { | ||
| 127 | - try { | ||
| 128 | - $tmp = explode('|', $val); | ||
| 129 | - $url_tmp = parse_url($tmp[0]); | ||
| 130 | - $route = trim($url_tmp['path'], '/'); | ||
| 131 | - $title = str_replace('+', ' ', $tmp[1]); | ||
| 132 | - if (strlen($title) > 200 || strlen($route) > 200) { | ||
| 133 | - $this->log('syncGloV5Route 路由或标题过长,无效记录'); | 100 | + try{ |
| 101 | + $result = http_get($route_domain . 'k_u_api.php'); | ||
| 102 | + if (empty($result)) { | ||
| 103 | + $this->log('syncGloV5Route 未获取到路由信息:' . $project->id . ', 路由获取地址:' . $route_domain . 'k_u_api.php'); | ||
| 134 | continue; | 104 | continue; |
| 135 | } | 105 | } |
| 136 | - InquiryProjectRoute::saveProjectRoute($project_id, $title, $route); | 106 | + file_put_contents(storage_path('logs/sync_inquiry_project_route/' . $project->id . '.json'), json_encode($result)); |
| 107 | + $this->pushTask($project->id); | ||
| 137 | } catch (\Exception $e) { | 108 | } catch (\Exception $e) { |
| 138 | - $this->log('syncGloV5Route 解析路径:' . $val . ', 错误信息:' . $e->getMessage()); | ||
| 139 | - echo 'syncGloV5Route 解析路径:' . $val . ', 错误信息:' . $e->getMessage() . PHP_EOL; | 109 | + $this->log('syncGloV5Route 未获取到路由信息:' . $project->id . ', 路由获取地址:' . $route_domain . 'k_u_api.php' . ', 错误信息:' . $e->getMessage()); |
| 110 | + echo 'syncGloV5Route 未获取到路由信息:' . $project->id . ', 路由获取地址:' . $route_domain . 'k_u_api.php' . ', 错误信息:' . $e->getMessage() . PHP_EOL; | ||
| 111 | + continue; | ||
| 140 | } | 112 | } |
| 141 | } | 113 | } |
| 114 | + | ||
| 115 | + $ids = InquiryProject::where('date', '<', $date)->where('version', '<', InquiryProject::VERSION_SIX)->pluck('id')->toArray(); | ||
| 116 | + $this->deleteExpire($ids); | ||
| 117 | + | ||
| 142 | return true; | 118 | return true; |
| 143 | } | 119 | } |
| 144 | 120 | ||
| @@ -148,6 +124,7 @@ class SyncInquiryProject extends Command | @@ -148,6 +124,7 @@ class SyncInquiryProject extends Command | ||
| 148 | */ | 124 | */ |
| 149 | public function syncGloV6() | 125 | public function syncGloV6() |
| 150 | { | 126 | { |
| 127 | + $date = intval(date('Ymd')); | ||
| 151 | // 获取优化中台项目 | 128 | // 获取优化中台项目 |
| 152 | $project = Project::leftJoin('gl_project_online_check', 'gl_project.id', '=', 'gl_project_online_check.project_id') | 129 | $project = Project::leftJoin('gl_project_online_check', 'gl_project.id', '=', 'gl_project_online_check.project_id') |
| 153 | ->where('gl_project.type', Project::TYPE_TWO) | 130 | ->where('gl_project.type', Project::TYPE_TWO) |
| @@ -165,55 +142,40 @@ class SyncInquiryProject extends Command | @@ -165,55 +142,40 @@ class SyncInquiryProject extends Command | ||
| 165 | // 过滤暂停优化项目, 映射类型2, model没有定义常量 | 142 | // 过滤暂停优化项目, 映射类型2, model没有定义常量 |
| 166 | if (in_array(2, $val->level)) | 143 | if (in_array(2, $val->level)) |
| 167 | continue; | 144 | continue; |
| 168 | - $project = InquiryProject::saveProject(InquiryProject::VERSION_SIX, $val->id, $val->title, $val->channel['channel_id'], $domains[$val->id]); | ||
| 169 | - $this->syncGloV6Route($project->id, $val->id); | 145 | + $project = InquiryProject::saveProject($date,InquiryProject::VERSION_SIX, $val->id, $val->title, $val->channel['channel_id'], $domains[$val->id]); |
| 146 | + $this->pushTask($project->id); | ||
| 170 | } | 147 | } |
| 148 | + | ||
| 149 | + $ids = InquiryProject::where('date', '<', $date)->where('version', '=', InquiryProject::VERSION_SIX)->pluck('id')->toArray(); | ||
| 150 | + $this->deleteExpire($ids); | ||
| 151 | + | ||
| 171 | return true; | 152 | return true; |
| 172 | } | 153 | } |
| 173 | 154 | ||
| 155 | + | ||
| 174 | /** | 156 | /** |
| 175 | - * 同步v6项目路由 | ||
| 176 | - * @param $project_id | ||
| 177 | - * @param $origin_project_id | 157 | + * 删除过期数据, 非当日更新数据, 都删除, 误删第二天再重新同步更新 |
| 158 | + * @param $ids | ||
| 178 | * @return bool | 159 | * @return bool |
| 179 | */ | 160 | */ |
| 180 | - public function syncGloV6Route($project_id, $origin_project_id) | 161 | + public function deleteExpire($ids) |
| 181 | { | 162 | { |
| 182 | - ProjectServer::useProject($origin_project_id); | ||
| 183 | - // TODO 产品分类标题、路由, 产品标题、路由, 同步到路由表 | ||
| 184 | - $category = Category::where('status', Category::STATUS_ACTIVE)->get(['title', 'route']); | ||
| 185 | - foreach ($category as $key=>$val) { | ||
| 186 | - InquiryProjectRoute::saveProjectRoute($project_id, $val->title, $val->route); | ||
| 187 | - } | ||
| 188 | - | ||
| 189 | - // 产品数量会比较多, 所以使用分页 同步数据 | ||
| 190 | - $id = 0; | ||
| 191 | - while (true) { | ||
| 192 | - echo '同步项目路由:' . $id . PHP_EOL; | ||
| 193 | - $product = Product::where('status', Product::STATUS_ON)->where('id', '>', $id)->orderBy('id', 'asc')->limit(1000)->get(['id', 'title', 'route']); | ||
| 194 | - if ($product->isEmpty()) | ||
| 195 | - break; | ||
| 196 | - | ||
| 197 | - foreach ($product as $key=>$val) { | ||
| 198 | - $id = $val->id; | ||
| 199 | - InquiryProjectRoute::saveProjectRoute($project_id, $val->title, $val->route); | ||
| 200 | - } | ||
| 201 | - } | ||
| 202 | - | ||
| 203 | - DB::disconnect('custom_mysql'); | 163 | + if (empty($ids)) |
| 164 | + return true; | ||
| 165 | + $project_num = InquiryProject::whereIn('id', $ids)->delete(); | ||
| 166 | + $project_route_num = InquiryProjectRoute::whereIn('project_id', $ids)->delete(); | ||
| 167 | + $this->log('删除过期项目数量:' . $project_num . ', 删除过期项目路由数量:' . $project_route_num); | ||
| 204 | return true; | 168 | return true; |
| 205 | } | 169 | } |
| 206 | 170 | ||
| 207 | /** | 171 | /** |
| 208 | - * 删除过期数据, 非当日更新数据, 都删除, 误删第二天再重新同步更新 | 172 | + * 往任务队列中生产数据 |
| 173 | + * @param $id | ||
| 209 | * @return bool | 174 | * @return bool |
| 210 | */ | 175 | */ |
| 211 | - public function deleteExpire() | 176 | + public function pushTask($id) |
| 212 | { | 177 | { |
| 213 | - $date = intval(date('Ymd')); | ||
| 214 | - $project_num = InquiryProject::where('date', '<', $date)->delete(); | ||
| 215 | - $project_route_num = InquiryProjectRoute::where('date', '<', $date)->delete(); | ||
| 216 | - $this->log('删除过期项目数量:' . $project_num . ', 删除过期路由数量:' . $project_route_num); | 178 | + Redis::lPush('sync_inquiry_project_route_task', $id); |
| 217 | return true; | 179 | return true; |
| 218 | } | 180 | } |
| 219 | 181 |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * Created by PhpStorm. | ||
| 4 | + * User: zhl | ||
| 5 | + * Date: 2025/2/18 | ||
| 6 | + * Time: 17:10 | ||
| 7 | + */ | ||
| 8 | +namespace App\Console\Commands\Inquiry; | ||
| 9 | + | ||
| 10 | +use App\Models\Channel\Channel; | ||
| 11 | +use App\Models\Domain\DomainInfo; | ||
| 12 | +use App\Models\Inquiry\InquiryProject; | ||
| 13 | +use App\Models\Inquiry\InquiryProjectRoute; | ||
| 14 | +use App\Models\Product\Category; | ||
| 15 | +use App\Models\Product\Product; | ||
| 16 | +use App\Models\Project\OnlineCheck; | ||
| 17 | +use App\Models\Project\Project; | ||
| 18 | +use App\Services\ProjectServer; | ||
| 19 | +use Illuminate\Console\Command; | ||
| 20 | +use Illuminate\Support\Facades\DB; | ||
| 21 | +use Illuminate\Support\Facades\Log; | ||
| 22 | +use Illuminate\Support\Facades\Redis; | ||
| 23 | + | ||
| 24 | +/** | ||
| 25 | + * Class SyncInquiryProjectRoute | ||
| 26 | + * @package App\Console\Commands\Inquiry | ||
| 27 | + */ | ||
| 28 | +class SyncInquiryProjectRoute extends Command | ||
| 29 | +{ | ||
| 30 | + /** | ||
| 31 | + * The name and signature of the console command. | ||
| 32 | + * | ||
| 33 | + * @var string | ||
| 34 | + */ | ||
| 35 | + protected $signature = 'sync_inquiry_project_route'; | ||
| 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 | + * 同步优化项目及路由 | ||
| 56 | + * TODO 同步v4 v5 v6项目以及路由, 删除过期项目及路由 | ||
| 57 | + * @return bool | ||
| 58 | + */ | ||
| 59 | + public function handle() | ||
| 60 | + { | ||
| 61 | + while (true) { | ||
| 62 | + $sync_id = Redis::rpop('sync_inquiry_project_route_task'); | ||
| 63 | + if (empty($sync_id)) { | ||
| 64 | + sleep(60); | ||
| 65 | + continue; | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + $task = InquiryProject::where(['id' => $sync_id])->first(); | ||
| 69 | + if (empty($task)) | ||
| 70 | + continue; | ||
| 71 | + | ||
| 72 | + // 同步对应项目路由, 以及删除过期路由 | ||
| 73 | + if ($task->version == InquiryProject::VERSION_SIX){ | ||
| 74 | + $this->syncGloV6Route($task); | ||
| 75 | + } else { | ||
| 76 | + $this->syncGloV5Route($task); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + } | ||
| 80 | + return true; | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + /** | ||
| 84 | + * 同步v4 v5项目路由 | ||
| 85 | + * @param $task | ||
| 86 | + * @return bool | ||
| 87 | + */ | ||
| 88 | + public function syncGloV5Route($task) | ||
| 89 | + { | ||
| 90 | + $date = intval(date('Ymd')); | ||
| 91 | + | ||
| 92 | + $result = file_get_contents(storage_path('logs/sync_inquiry_project_route/' . $task->id . '.json')); | ||
| 93 | + $result = json_decode($result, true); | ||
| 94 | + if (empty($result)) { | ||
| 95 | + // 未获取到数据 删除当前项目过期路由 | ||
| 96 | + $this->deleteExpire($task->id, $date); | ||
| 97 | + $this->log('syncGloV5Route 未获取到路由信息:' . $task->id . ', 路由获取地址:' . ($task->is_split && $task->test_url ? $task->test_url : $task->main_url) . 'k_u_api.php'); | ||
| 98 | + return false; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + foreach ($result as $key=>$val) { | ||
| 102 | + try { | ||
| 103 | + $tmp = explode('|', $val); | ||
| 104 | + $url_tmp = parse_url($tmp[0]); | ||
| 105 | + $route = trim($url_tmp['path'], '/'); | ||
| 106 | + $title = str_replace('+', ' ', $tmp[1]); | ||
| 107 | + if (strlen($title) > 200 || strlen($route) > 200) { | ||
| 108 | + $this->log('syncGloV5Route 路由或标题过长,无效记录'); | ||
| 109 | + continue; | ||
| 110 | + } | ||
| 111 | + InquiryProjectRoute::saveProjectRoute($task->id, $title, $route, $date); | ||
| 112 | + } catch (\Exception $e) { | ||
| 113 | + $this->log('syncGloV5Route 解析路径:' . $val . ', 错误信息:' . $e->getMessage()); | ||
| 114 | + echo 'syncGloV5Route 解析路径:' . $val . ', 错误信息:' . $e->getMessage() . PHP_EOL; | ||
| 115 | + } | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + // 删除当前项目过期路由 | ||
| 119 | + $this->deleteExpire($task->id, $date); | ||
| 120 | + return true; | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + /** | ||
| 124 | + * 同步v6项目路由 | ||
| 125 | + * @param $task | ||
| 126 | + * @return bool | ||
| 127 | + */ | ||
| 128 | + public function syncGloV6Route($task) | ||
| 129 | + { | ||
| 130 | + echo '同步项目ID:' . $task->id . PHP_EOL; | ||
| 131 | + $date = intval(date('Ymd')); | ||
| 132 | + ProjectServer::useProject($task->primary_id); | ||
| 133 | + // TODO 产品分类标题、路由, 产品标题、路由, 同步到路由表 | ||
| 134 | + $category = Category::where('status', Category::STATUS_ACTIVE)->get(['title', 'route']); | ||
| 135 | + foreach ($category as $key=>$val) { | ||
| 136 | + InquiryProjectRoute::saveProjectRoute($task->id, $val->title, $val->route, $date); | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + // 产品数量会比较多, 所以使用分页 同步数据 | ||
| 140 | + $id = 0; | ||
| 141 | + while (true) { | ||
| 142 | + $product = Product::where('status', Product::STATUS_ON)->where('id', '>', $id)->orderBy('id', 'asc')->limit(1000)->get(['id', 'title', 'route']); | ||
| 143 | + if ($product->isEmpty()) | ||
| 144 | + break; | ||
| 145 | + | ||
| 146 | + foreach ($product as $key=>$val) { | ||
| 147 | + $id = $val->id; | ||
| 148 | + InquiryProjectRoute::saveProjectRoute($task->id, $val->title, $val->route, $date); | ||
| 149 | + } | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + DB::disconnect('custom_mysql'); | ||
| 153 | + | ||
| 154 | + // 删除当前项目过期路由 | ||
| 155 | + $this->deleteExpire($task->id, $date); | ||
| 156 | + | ||
| 157 | + return true; | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + /** | ||
| 161 | + * 删除过期数据, 非当前更新数据, 都删除, 误删第二天再重新同步更新 | ||
| 162 | + * @param $project_id | ||
| 163 | + * @param $date | ||
| 164 | + * @return bool | ||
| 165 | + */ | ||
| 166 | + public function deleteExpire($project_id, $date) | ||
| 167 | + { | ||
| 168 | + $project_route_num = InquiryProjectRoute::where(['project_id' => $project_id])->where('date', '<', $date)->delete(); | ||
| 169 | + $this->log('项目ID:' . $project_id . ', 删除过期路由数量:' . $project_route_num); | ||
| 170 | + return true; | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + /** | ||
| 174 | + * 输出日志到特定的文件内, 这个文件需要定时排除内容 | ||
| 175 | + * @param $message | ||
| 176 | + * @return bool | ||
| 177 | + */ | ||
| 178 | + public function log($message) | ||
| 179 | + { | ||
| 180 | + $message = date('Y-m-d H:i:s') . ' ' . $message . PHP_EOL; | ||
| 181 | + file_put_contents(storage_path('logs/zhl/output') . date('Y-m-d') . '.log', $message, FILE_APPEND); | ||
| 182 | + return true; | ||
| 183 | + } | ||
| 184 | +} |
| @@ -9,9 +9,13 @@ | @@ -9,9 +9,13 @@ | ||
| 9 | 9 | ||
| 10 | namespace App\Console\Commands\Project; | 10 | namespace App\Console\Commands\Project; |
| 11 | 11 | ||
| 12 | +use App\Helper\Common; | ||
| 12 | use App\Models\Domain\DomainInfo; | 13 | use App\Models\Domain\DomainInfo; |
| 13 | -use App\Models\Project\Project; | ||
| 14 | -use App\Models\WebSetting\WebSettingSeo; | 14 | +use App\Models\Product\Category; |
| 15 | +use App\Models\Product\CategoryRelated; | ||
| 16 | +use App\Models\Product\Detail; | ||
| 17 | +use App\Models\Product\Product; | ||
| 18 | +use App\Models\RouteMap\RouteMap; | ||
| 15 | use App\Services\ProjectServer; | 19 | use App\Services\ProjectServer; |
| 16 | use Illuminate\Console\Command; | 20 | use Illuminate\Console\Command; |
| 17 | use Illuminate\Support\Facades\DB; | 21 | use Illuminate\Support\Facades\DB; |
| @@ -25,7 +29,7 @@ class DownloadProject extends Command | @@ -25,7 +29,7 @@ class DownloadProject extends Command | ||
| 25 | * | 29 | * |
| 26 | * @var string | 30 | * @var string |
| 27 | */ | 31 | */ |
| 28 | - protected $signature = 'downloads_project'; | 32 | + protected $signature = 'downloads_products'; |
| 29 | 33 | ||
| 30 | /** | 34 | /** |
| 31 | * The console command description. | 35 | * The console command description. |
| @@ -34,65 +38,95 @@ class DownloadProject extends Command | @@ -34,65 +38,95 @@ class DownloadProject extends Command | ||
| 34 | */ | 38 | */ |
| 35 | protected $description = '导出项目数据'; | 39 | protected $description = '导出项目数据'; |
| 36 | 40 | ||
| 37 | -// public function handle(){ | ||
| 38 | -// $projectModel = new Project(); | ||
| 39 | -// $data = $projectModel->formatQuery(['channel'=>['like','%"channel_id": "57"%'],'delete_status'=>0])->with(['deploy_optimize'])->get()->toArray(); | ||
| 40 | -// if(!empty($data)){ | ||
| 41 | -// $result = $this->exportData($data); | ||
| 42 | -// } | ||
| 43 | -// echo date('Y-m-d H:i:s') . ' ' . json_encode($result) . PHP_EOL; | ||
| 44 | -// return $result; | ||
| 45 | -// | ||
| 46 | -// } | ||
| 47 | - | ||
| 48 | public function handle(){ | 41 | public function handle(){ |
| 49 | - $data = []; | ||
| 50 | - $projectModel = new Project(); | ||
| 51 | - $projectList = $projectModel->formatQuery(['delete_status'=>0,'type'=>['in',[2,3]]])->with(['deploy_optimize'])->select(['id','status','type','title','remain_day'])->get()->toArray();; | ||
| 52 | - foreach ($projectList as $v){ | ||
| 53 | - ProjectServer::useProject($v['id']); | ||
| 54 | - $seoModel = new WebSettingSeo(); | ||
| 55 | - $seoInfo = $seoModel->read(['project_id'=>$v['id']]); | ||
| 56 | - if($seoInfo === false){ | ||
| 57 | - $data[] = $v; | ||
| 58 | - }else{ | ||
| 59 | - if(empty($seoInfo['single_page_suffix'])){ | ||
| 60 | - $data[] = $v; | 42 | + ProjectServer::useProject(1225); |
| 43 | + $data = $this->downloadProduct(); | ||
| 44 | + DB::disconnect('custom_mysql'); | ||
| 45 | + echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; | ||
| 46 | + return $this->exportData($data); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + public function downloadProduct() | ||
| 50 | + { | ||
| 51 | + $product = new Product(); | ||
| 52 | + $filed = ['id', 'project_id', 'title' ,'thumb' , 'route' ,'intro','content', | ||
| 53 | + 'category_id', 'status']; | ||
| 54 | + $this->order = 'sort'; | ||
| 55 | + $lists = $product->list(['status'=>1],'id',$filed); | ||
| 56 | + if(!empty($lists)){ | ||
| 57 | + $cate_data = $this->getCategoryList();//分类 | ||
| 58 | + foreach ($lists as $k => $v){ | ||
| 59 | + $v['url'] = 'https://www.autsikinta.com/' . getRouteMap(RouteMap::SOURCE_PRODUCT,$v['id']); | ||
| 60 | + $v['category_id_text'] = $this->categoryName($v['id'],$cate_data); | ||
| 61 | + //ToDo::处理图片及文件 | ||
| 62 | + if(!empty($v['thumb']) && !empty($v['thumb']['url'])){ | ||
| 63 | + $v['images'] = getImageUrl($v['thumb']['url']); | ||
| 64 | + }else{ | ||
| 65 | + $v['images'] = ''; | ||
| 61 | } | 66 | } |
| 67 | + $lists[$k] = $v; | ||
| 62 | } | 68 | } |
| 63 | - DB::disconnect('custom_mysql'); | ||
| 64 | } | 69 | } |
| 65 | - return $this->exportData($data); | 70 | + echo date('Y-m-d H:i:s') . '数据详情$v:'. json_encode($lists) . PHP_EOL; |
| 71 | + return $lists; | ||
| 72 | + } | ||
| 73 | + public function categoryName($product_id,$data){ | ||
| 74 | + $cateRelatedModel = new CategoryRelated(); | ||
| 75 | + $category_id = $cateRelatedModel->where('product_id',$product_id)->pluck('cate_id')->toArray(); | ||
| 76 | + $category_name = ''; | ||
| 77 | + if(!empty($category_id) && !empty($data)){ | ||
| 78 | + foreach ($category_id as $v){ | ||
| 79 | + if(isset($data[$v])){ | ||
| 80 | + $category_name .= $data[$v].','; | ||
| 81 | + } | ||
| 82 | + } | ||
| 83 | + $category_name = trim($category_name,','); | ||
| 84 | + } | ||
| 85 | + return $category_name; | ||
| 86 | + } | ||
| 87 | + /** | ||
| 88 | + * @remark :获取所有分类 | ||
| 89 | + * @name :getCategoryList | ||
| 90 | + * @author :lyh | ||
| 91 | + * @method :post | ||
| 92 | + * @time :2023/9/14 13:56 | ||
| 93 | + */ | ||
| 94 | + public function getCategoryList(){ | ||
| 95 | + $data = Common::get_user_cache('product_category',1225); | ||
| 96 | + if(empty($data)){ | ||
| 97 | + $categoryModel = new Category(); | ||
| 98 | + $data = []; | ||
| 99 | + $cateList = $categoryModel->list(['project_id'=>1225],['id','title']); | ||
| 100 | + if(!empty($cateList)){ | ||
| 101 | + foreach ($cateList as $value){ | ||
| 102 | + $data[$value['id']] = $value['title']; | ||
| 103 | + } | ||
| 104 | + } | ||
| 105 | + Common::set_user_cache($data,'product_category',1225); | ||
| 106 | + } | ||
| 107 | + return $data; | ||
| 66 | } | 108 | } |
| 67 | - | ||
| 68 | public function exportData($data){ | 109 | public function exportData($data){ |
| 69 | // 创建一个新的 Excel 电子表格实例 | 110 | // 创建一个新的 Excel 电子表格实例 |
| 70 | $spreadsheet = new Spreadsheet(); | 111 | $spreadsheet = new Spreadsheet(); |
| 71 | $sheet = $spreadsheet->getActiveSheet(); | 112 | $sheet = $spreadsheet->getActiveSheet(); |
| 72 | // 添加表头 | 113 | // 添加表头 |
| 73 | - $sheet->setCellValue('A1', '项目ID'); | ||
| 74 | - $sheet->setCellValue('B1', '项目名称'); | ||
| 75 | - $sheet->setCellValue('C1', '域名'); | ||
| 76 | - $sheet->setCellValue('D1', '状态'); | ||
| 77 | - $sheet->setCellValue('E1', '剩余服务时间'); | 114 | + $sheet->setCellValue('A1', '产品名称'); |
| 115 | + $sheet->setCellValue('B1', '产品短描述'); | ||
| 116 | + $sheet->setCellValue('C1', '产品内容'); | ||
| 117 | + $sheet->setCellValue('D1', '产品路由'); | ||
| 118 | + $sheet->setCellValue('E1', '产品分类'); | ||
| 119 | + $sheet->setCellValue('F1', '产品状态'); | ||
| 120 | + $sheet->setCellValue('G1', '产品主图'); | ||
| 78 | $rowCount = 2; | 121 | $rowCount = 2; |
| 79 | -// $allData = $this->countAll(); | ||
| 80 | foreach ($data as $v) { | 122 | foreach ($data as $v) { |
| 81 | - $domain = (new DomainInfo())->getDomain($v['deploy_optimize']['domain'] ?? 0); | ||
| 82 | - if($v['type'] == 1){ | ||
| 83 | - $status = '建站中'; | ||
| 84 | - }elseif ($v['type'] == 2){ | ||
| 85 | - $status = '优化中'; | ||
| 86 | - }elseif ($v['type'] == 3){ | ||
| 87 | - $status = '建站后'; | ||
| 88 | - }else{ | ||
| 89 | - $status = ''; | ||
| 90 | - } | ||
| 91 | - $sheet->setCellValue('A' . $rowCount, $v['id']); | ||
| 92 | - $sheet->setCellValue('B' . $rowCount, $v['title']); | ||
| 93 | - $sheet->setCellValue('C' . $rowCount, $domain); | ||
| 94 | - $sheet->setCellValue('D' . $rowCount, $status); | ||
| 95 | - $sheet->setCellValue('E' . $rowCount, $v['remain_day']); | 123 | + $sheet->setCellValue('A' . $rowCount, $v['title']); |
| 124 | + $sheet->setCellValue('B' . $rowCount, $v['intro']); | ||
| 125 | + $sheet->setCellValue('C' . $rowCount, $v['content']); | ||
| 126 | + $sheet->setCellValue('D' . $rowCount, $v['url']); | ||
| 127 | + $sheet->setCellValue('E' . $rowCount, $v['category_id_text']); | ||
| 128 | + $sheet->setCellValue('F' . $rowCount, '发布中'); | ||
| 129 | + $sheet->setCellValue('G' . $rowCount, $v['images']); | ||
| 96 | $rowCount++; | 130 | $rowCount++; |
| 97 | } | 131 | } |
| 98 | // 创建一个新的 Excel Writer 对象 | 132 | // 创建一个新的 Excel Writer 对象 |
app/Console/Commands/Test/Demo.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | -/** | ||
| 3 | - * Created by PhpStorm. | ||
| 4 | - * User: zhl | ||
| 5 | - * Date: 2023/2/7 | ||
| 6 | - * Time: 17:58 | ||
| 7 | - */ | ||
| 8 | -namespace App\Console\Commands\Test; | ||
| 9 | - | ||
| 10 | - | ||
| 11 | -use App\Helper\Arr; | ||
| 12 | -use App\Helper\Translate; | ||
| 13 | -use App\Mail\TextMail; | ||
| 14 | -use App\Models\Blog\Blog; | ||
| 15 | -use App\Models\Blog\BlogCategory; | ||
| 16 | -use App\Models\Com\KeywordVideoTask; | ||
| 17 | -use App\Models\Com\KeywordVideoTaskLog; | ||
| 18 | -use App\Models\CustomModule\CustomModuleCategory; | ||
| 19 | -use App\Models\CustomModule\CustomModuleContent; | ||
| 20 | -use App\Models\CustomModule\CustomModuleExtentContent; | ||
| 21 | -use App\Models\Devops\ServerConfig; | ||
| 22 | -use App\Models\Devops\Servers; | ||
| 23 | -use App\Models\Devops\ServersIp; | ||
| 24 | -use App\Models\ExtentModule\ExtensionModuleValue; | ||
| 25 | -use App\Models\File\File; | ||
| 26 | -use App\Models\File\File as FileModel; | ||
| 27 | -use App\Models\File\Image; | ||
| 28 | -use App\Models\File\Image as ImageModel; | ||
| 29 | -use App\Models\News\News; | ||
| 30 | -use App\Models\News\NewsCategory; | ||
| 31 | -use App\Models\Product\Keyword; | ||
| 32 | -use App\Models\Product\KeywordRelated; | ||
| 33 | -use App\Models\Product\Product; | ||
| 34 | -use App\Models\Project\AutoEmailLog; | ||
| 35 | -use App\Models\Project\DeployOptimize; | ||
| 36 | -use App\Models\Project\MinorLanguages; | ||
| 37 | -use App\Models\Project\Project; | ||
| 38 | -use App\Models\Purchaser\Purchaser; | ||
| 39 | -use App\Models\Purchaser\PurchaserInfo; | ||
| 40 | -use App\Models\RouteMap\RouteMap; | ||
| 41 | -use App\Models\Template\BCustomTemplate; | ||
| 42 | -use App\Models\Template\BTemplateCom; | ||
| 43 | -use App\Models\Template\Setting; | ||
| 44 | -use App\Models\Template\Template; | ||
| 45 | -use Hashids\Hashids; | ||
| 46 | -use Illuminate\Console\Command; | ||
| 47 | -use Illuminate\Support\Facades\Config; | ||
| 48 | -use Illuminate\Support\Facades\DB; | ||
| 49 | -use Illuminate\Support\Facades\Mail; | ||
| 50 | -use Illuminate\Support\Facades\Schema; | ||
| 51 | - | ||
| 52 | - | ||
| 53 | -class Demo extends Command | ||
| 54 | -{ | ||
| 55 | - /** | ||
| 56 | - * The name and signature of the console command. | ||
| 57 | - * | ||
| 58 | - * @var string | ||
| 59 | - */ | ||
| 60 | - protected $signature = 'demo'; | ||
| 61 | - | ||
| 62 | - /** | ||
| 63 | - * The console command description. | ||
| 64 | - * | ||
| 65 | - * @var string | ||
| 66 | - */ | ||
| 67 | - protected $description = 'demo'; | ||
| 68 | - | ||
| 69 | - public function handle(){ | ||
| 70 | - $this->copyMysql($old_project_id,$project_id); | ||
| 71 | - } | ||
| 72 | - public function copyProject($old_project_id){ | ||
| 73 | - $projectModel = new Project(); | ||
| 74 | - $data = $projectModel::where('id', $old_project_id)->first(); | ||
| 75 | - $data = $data->getAttributes(); | ||
| 76 | - $type = $data['type']; | ||
| 77 | - $data['type'] = 0; | ||
| 78 | - $data['status'] = 0; | ||
| 79 | - $data['finish_remain_day'] = 0; | ||
| 80 | - $data['title'] = $data['title'].'-copy'; | ||
| 81 | - $data['delete_status'] = 1; | ||
| 82 | - unset($data['id'],$data['robots'],$data['is_translate_tag'],$data['is_translate'],$data['is_minor_languages'],$data['uptime']); | ||
| 83 | - $project_id = $projectModel->insertGetId($data); | ||
| 84 | - $hashids = new Hashids($data['from_order_id'], 13, 'abcdefghjkmnpqrstuvwxyz1234567890'); | ||
| 85 | - $projectModel->edit(['from_order_id'=>$hashids->encode($project_id)],['id'=>$project_id]); | ||
| 86 | - //复制设置的模版 | ||
| 87 | - $settingTemplateModel = new Setting(); | ||
| 88 | - $settingData = $settingTemplateModel::where('project_id', $old_project_id)->first(); | ||
| 89 | - if(!empty($settingData)){ | ||
| 90 | - $data = [ | ||
| 91 | - 'template_id' =>$settingData['template_id'], | ||
| 92 | - 'project_id' => $project_id | ||
| 93 | - ]; | ||
| 94 | - $settingTemplateModel->add($data); | ||
| 95 | - } | ||
| 96 | - return ['project_id'=>$project_id,'type'=>$type]; | ||
| 97 | - } | ||
| 98 | - | ||
| 99 | - public function toQueue(){ | ||
| 100 | - $info = [ | ||
| 101 | - 'email' => '1123736022@qq.com', // 收件人邮箱 | ||
| 102 | - 'title' => '测试邮件', // 邮件标题 | ||
| 103 | - 'content' => '这是来自163邮箱的测试邮件', // 邮件内容 | ||
| 104 | - ]; | ||
| 105 | - Config::set('mail.mailers.smtp.host', 'smtp.163.com'); | ||
| 106 | - Config::set('mail.mailers.smtp.username', 'lyh103433@163.com'); | ||
| 107 | - Config::set('mail.mailers.smtp.password', 'BMf8B327Nhncunnb'); | ||
| 108 | - Config::set('mail.from.address', 'lyh103433@163.com'); | ||
| 109 | - Config::set('mail.from.name', 'lyh'); | ||
| 110 | - try { | ||
| 111 | - $status = AutoEmailLog::STATUS_SUCCESS; | ||
| 112 | - Mail::to([$info['email']])->send(new TextMail(['subject' => $info['title'], 'text' => $info['content']])); | ||
| 113 | - } catch (\Exception $e) { | ||
| 114 | - $status = AutoEmailLog::STATUS_ERROR; | ||
| 115 | - $this->output('任务:' . $info['id'] . ' 邮箱' . $info['email'] . '发送失败,' . $e->getMessage()); | ||
| 116 | - } | ||
| 117 | - return $status; | ||
| 118 | - } | ||
| 119 | - public function projectList(){ | ||
| 120 | - $data = '深圳澄通睿视科技有限公司, 日照源洋包装材料有限公司, 河北途铂机电设备有限责任公司, 宁波市海曙玖鼎纸制品有限公司, 青岛众瑞智能仪器有限公司, 河北新秋国际贸易有限公司, 江西乔森电气有限公司, 沧州艾斯克粉业制造有限公司, 上海希然化工科技有限公司, 石家庄中创进出口有限公司, 东光县恒创利纸箱机械有限公司2021, 天津正能管业有限公司, 河北帷幄纺织有限公司, 广东顺德宝绅源环保科技有限公司, 石家庄艾文尔生物科技有限公司, 浙江福俄电气有限公司, 深圳市嘉盛数据科技有限公司, 江西米德实业有限公司, 苏州稼瑞机械有限公司, 青岛卓亚塑料机械有限公司, 宁波中力螺栓制造有限公司, 中山市万格电器有限公司, 廊坊禹神节水灌溉技术有限公司, 山东索玛特制帽有限公司, 蓝启生物技术(深圳)有限公司, 南宁奥展五金紧固件有限公司, 河北茉悠科技有限公司, 莱科阀门(天津)有限公司, 四川零点自动化系统有限公司, 厦门市戴尔乐新能源汽车有限公司, 宁波爱克利浦电器有限公司, 扬州天定成玩具礼品有限公司, 宁波市金典照明电器有限公司, 杭州法埃姆斯钢构有限公司, 北京迪文科技有限公司, 无锡动为储能科技有限公司, 河北唐蕴生物科技有限公司, 绍兴苏尔黛纺织品有限公司, 河北祈强金属制品有限公司, 上池诊断科技(深圳)有限公司, 泉州市三颖超硬工具有限公司, 宁波杰广电子有限公司, 石家庄德烨管业有限公司, 山东凯特钻具有限公司, 北京思普瑞特科技发展有限公司, 广州市印科标识科技有限公司, 优之科技(深圳)有限公司, 南通赫美特国际贸易有限公司, 天津誉瑞特品科技有限公司, 河北坤焰建材科技有限公司, 绍兴睿博机械有限公司, 西安法斯拓进出口有限公司, 深圳市德诺威电子有限公司, 百润(中国)有限公司, 达时科科技有限责任公司, 陈海英, 四川蓉腾自动化设备有限公司, 石家庄晋吉建材科技有限公司, 石家庄安瑞科气体机械有限公司, 深圳市扬帆纸制品有限公司, 舟山威尔曼机械科技有限公司, 佰纳通科技(北京)有限公司, 宁波嘉佑行科技有限公司, 东莞市凯信脚轮有限公司, 宝鸡轩泰颜料科技有限公司, 东莞市华腾五金制品有限公司, 深圳市思锐宇光电有限公司, 东莞市奥彩数码科技有限公司, 上海垂普国际贸易有限公司, 扬州爱拓户外用品有限公司, 余姚市立鑫电子有限公司, 晋州市金昌盛化工有限公司, 广东阿酷达箱包科技有限公司, 泉州市杰斯特仪器设备有限公司, 三和长兴科技有限公司, 佛山市精一家具有限公司谷腾分公司, 天津市洁雅妇女卫生保健制品有限公司, 江西海瑞天然植物有限公司, 九江贝海玻纤有限公司(客户做新站), 瑞安市齐笙科技有限公司, 石家庄华圣方洲国际贸易有限公司, 深圳市方成教学设备有限公司, 连云港索娜斯贸易有限公司, 睿華電子有限公司, 扬州市极盛照明有限公司, 天津市实丰国际贸易有限责任公司, 厦门亚迅工贸有限公司, 威海旺展旅游用品有限公司, 宁波首安纸业有限公司, 浙江乐马电气有限公司, 广东金莱特智能科技有限公司, 河北科星药业有限公司, 宁波迈可森汽配有限公司, 邯郸市常岚紧固件制造有限公司, 宁波市晶艳贸易有限公司, 苏州荃华生物材料有限公司, 青岛洛城通信息科技有限公司, 合肥领派克机械设备有限公司, 广西绿城工贸有限公司, 一元电气科技有限公司【主站】, 立圣丰(厦门)纺织科技有限公司, 深圳市汉瑞通科技有限公司, 扬州市润芳塑胶包装材料有限公司, 扬州浩邦新能源科技有限公司项目2, 深圳市锦昊安科技有限公司, 四川途乐乐科技有限公司, 天津广大纸业股份有限公司, 西安禾为生物科技有限公司, 西安奥谷生物科技有限公司, 佛山市三水歌谷电器有限公司, 西安麦克斯农用化学有限公司, 瑞安市富锐思进出口有限公司(黑格客户), 北京新科以仁科技发展有限公司, 镇江市惠灵顿膜业有限公司'; | ||
| 121 | - $arr = explode(',',$data); | ||
| 122 | - $projectModel = new Project(); | ||
| 123 | - $opModel = new DeployOptimize(); | ||
| 124 | - foreach ($arr as $k => $v){ | ||
| 125 | - $v = trim($v); | ||
| 126 | - $info = $projectModel->read(['title'=>['like','%'.$v.'%']],['id']); | ||
| 127 | - if($info === false){ | ||
| 128 | - echo date('Y-m-d H:i:s') . '未查询到的项目--'.$v . PHP_EOL; | ||
| 129 | - }else{ | ||
| 130 | - $opInfo = $opModel->read(['project_id'=>$info['id']]); | ||
| 131 | - if (strpos($opInfo['special'], '15') !== false) { | ||
| 132 | - echo date('Y-m-d H:i:s') . '已包含' . PHP_EOL; | ||
| 133 | - } else { | ||
| 134 | - if(!empty($opInfo['special'])){ | ||
| 135 | - $special = ','.trim($opInfo['special'],',').',15,'; | ||
| 136 | - }else{ | ||
| 137 | - $special = ',15,'; | ||
| 138 | - } | ||
| 139 | - $opModel->edit(['special'=>$special],['id'=>$opInfo['id']]); | ||
| 140 | - echo date('Y-m-d H:i:s') . '未包含AI案例的project_id:'.$opInfo['project_id'] . PHP_EOL; | ||
| 141 | - } | ||
| 142 | - } | ||
| 143 | - } | ||
| 144 | - echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; | ||
| 145 | - return true; | ||
| 146 | - } | ||
| 147 | - | ||
| 148 | - /** | ||
| 149 | - * @remark :删除product | ||
| 150 | - * @name :delProduct | ||
| 151 | - * @author :lyh | ||
| 152 | - * @method :post | ||
| 153 | - * @time :2025/1/10 9:35 | ||
| 154 | - */ | ||
| 155 | - public function delProduct(){ | ||
| 156 | - $productModel = new Product(); | ||
| 157 | - $list = $productModel->list(['status'=>2]); | ||
| 158 | - foreach ($list as $k => $v){ | ||
| 159 | - $routeModel = new RouteMap(); | ||
| 160 | - $routeModel->del(['source'=>'product','source_id'=>$v['id']]); | ||
| 161 | - } | ||
| 162 | - $productModel->del(['status'=>2]); | ||
| 163 | - return true; | ||
| 164 | - } | ||
| 165 | - | ||
| 166 | - /** | ||
| 167 | - * @remark :统计当前模版使用情况 | ||
| 168 | - * @name :countTemplate | ||
| 169 | - * @author :lyh | ||
| 170 | - * @method :post | ||
| 171 | - * @time :2025/1/9 10:59 | ||
| 172 | - */ | ||
| 173 | - public function countTemplate(){ | ||
| 174 | - $bSettingModel = new Setting(); | ||
| 175 | - $lists = $bSettingModel->list(); | ||
| 176 | - $templateModel = new Template(); | ||
| 177 | - foreach ($lists as $v){ | ||
| 178 | - echo date('Y-m-d H:i:s') . '执行的模版id:' .$v['template_id'] . PHP_EOL; | ||
| 179 | - $templateModel->where(['id'=>$v['template_id']])->increment('number',1); | ||
| 180 | - } | ||
| 181 | - return true; | ||
| 182 | - } | ||
| 183 | - | ||
| 184 | - /** | ||
| 185 | - * @remark :更新产品 | ||
| 186 | - * @name :getProduct | ||
| 187 | - * @author :lyh | ||
| 188 | - * @method :post | ||
| 189 | - * @time :2024/11/27 15:40 | ||
| 190 | - */ | ||
| 191 | - public function getProduct(){ | ||
| 192 | - $productModel = new Product(); | ||
| 193 | - $lists = $productModel->list(['status'=>['!=',3]]); | ||
| 194 | - if(!empty($lists)){ | ||
| 195 | - foreach ($lists as $v){ | ||
| 196 | - if(!empty($v['keyword_video_id'])){ | ||
| 197 | - foreach ($v['keyword_video_id'] as $val){ | ||
| 198 | - $keywordRelaModel = new KeywordRelated(); | ||
| 199 | - echo date('Y-m-d H:i:s') . 'keyword_id :'.$val . 'product_id :'.$v['id'] . PHP_EOL; | ||
| 200 | - $keywordRelaModel->edit(['type'=>2],['keyword_id'=>$val,'product_id'=>$v['id']]); | ||
| 201 | - } | ||
| 202 | - } | ||
| 203 | - } | ||
| 204 | - } | ||
| 205 | - } | ||
| 206 | - | ||
| 207 | - /** | ||
| 208 | - * @remark :复制表及结构 | ||
| 209 | - * @name :copyProduct | ||
| 210 | - * @author :lyh | ||
| 211 | - * @method :post | ||
| 212 | - * @time :2024/11/27 16:09 | ||
| 213 | - */ | ||
| 214 | - public function copyProduct(){ | ||
| 215 | - $tableName = 'gl_product'; | ||
| 216 | - $copyTableName = 'gl_product_c'; | ||
| 217 | - if (Schema::connection('custom_mysql')->hasTable($copyTableName)) { | ||
| 218 | - DB::connection('custom_mysql')->statement("DROP TABLE {$copyTableName}"); | ||
| 219 | - } | ||
| 220 | - // 创建新表并复制数据 | ||
| 221 | - DB::connection('custom_mysql')->statement("CREATE TABLE {$copyTableName} LIKE {$tableName}"); | ||
| 222 | - DB::connection('custom_mysql')->statement("INSERT INTO {$copyTableName} SELECT * FROM {$tableName}"); | ||
| 223 | - } | ||
| 224 | - | ||
| 225 | - /** | ||
| 226 | - * @remark :保存供应商详情 | ||
| 227 | - * @name :savePurchaserInfo | ||
| 228 | - * @author :lyh | ||
| 229 | - * @method :post | ||
| 230 | - * @time :2024/5/29 16:38 | ||
| 231 | - */ | ||
| 232 | - public function savePurchaserInfo(){ | ||
| 233 | - $purchaserModel = new Purchaser(); | ||
| 234 | - $list = $purchaserModel->list(); | ||
| 235 | - foreach ($list as $val){ | ||
| 236 | - $project_id = $val['project_id']; | ||
| 237 | - $keyword = $val['keyword']; | ||
| 238 | - $data = json_decode($val['data'],JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); | ||
| 239 | - $purchaserInfoModel = new PurchaserInfo(); | ||
| 240 | - if(!empty($data)){ | ||
| 241 | - foreach ($data as $k =>$v){ | ||
| 242 | - $v['project_id'] = $project_id; | ||
| 243 | - $v['keyword'] = $keyword; | ||
| 244 | - $v['email'] = json_encode($v['email'] ?? [],JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); | ||
| 245 | - $v['mobile'] = json_encode($v['mobile'] ?? [],JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); | ||
| 246 | - $v['social_media'] = json_encode($v['social_media'] ?? [],JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); | ||
| 247 | - $v['image'] = str_replace('admin.hagro.cn','fob.ai.cc',$v['image'] ?? ''); | ||
| 248 | - $param = $v; | ||
| 249 | - $info = $purchaserInfoModel->read(['keyword'=>$keyword,'buyer_id'=>$v['buyer_id'] ?? '','project_id'=>$project_id],['id']); | ||
| 250 | - | ||
| 251 | - if($info === false){ | ||
| 252 | - echo date('Y-m-d H:i:s') . '执行新增 :' . PHP_EOL; | ||
| 253 | - $purchaserInfoModel->add($param); | ||
| 254 | - }else{ | ||
| 255 | - echo date('Y-m-d H:i:s') . '数据已存在 :'.$info['id'] . PHP_EOL; | ||
| 256 | - } | ||
| 257 | - } | ||
| 258 | - } | ||
| 259 | - } | ||
| 260 | - return true; | ||
| 261 | - } | ||
| 262 | -} |
| @@ -23,7 +23,10 @@ use App\Models\RouteMap\RouteMap; | @@ -23,7 +23,10 @@ use App\Models\RouteMap\RouteMap; | ||
| 23 | use App\Models\Template\BTemplate; | 23 | use App\Models\Template\BTemplate; |
| 24 | use App\Models\Template\Setting; | 24 | use App\Models\Template\Setting; |
| 25 | use App\Services\ProjectServer; | 25 | use App\Services\ProjectServer; |
| 26 | +use App\Utils\HttpUtils; | ||
| 27 | +use GuzzleHttp\Exception\GuzzleException; | ||
| 26 | use Illuminate\Console\Command; | 28 | use Illuminate\Console\Command; |
| 29 | +use Illuminate\Support\Facades\Cache; | ||
| 27 | use Illuminate\Support\Facades\DB; | 30 | use Illuminate\Support\Facades\DB; |
| 28 | use Illuminate\Support\Facades\Schema; | 31 | use Illuminate\Support\Facades\Schema; |
| 29 | 32 | ||
| @@ -58,26 +61,36 @@ class UpdateRoute extends Command | @@ -58,26 +61,36 @@ class UpdateRoute extends Command | ||
| 58 | * @time :2023/11/20 15:13 | 61 | * @time :2023/11/20 15:13 |
| 59 | */ | 62 | */ |
| 60 | public function handle(){ | 63 | public function handle(){ |
| 61 | - $projectModel = new Project(); | ||
| 62 | - $list = $projectModel->list(['delete_status'=>['=',0],'id'=>2902]); | ||
| 63 | - foreach ($list as $v){ | ||
| 64 | - echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; | ||
| 65 | - ProjectServer::useProject($v['id']); | ||
| 66 | - $this->getProduct(); | ||
| 67 | - DB::disconnect('custom_mysql'); | ||
| 68 | - } | ||
| 69 | - echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; | 64 | + |
| 65 | + $data = $this->ceshi(); | ||
| 66 | + | ||
| 67 | + echo date('Y-m-d H:i:s') . 'end'.json_encode($data) . PHP_EOL; | ||
| 70 | } | 68 | } |
| 71 | 69 | ||
| 72 | - public function ceshi($project_id){ | ||
| 73 | - $templateModel = new BTemplate(); | ||
| 74 | - $info = $templateModel->orderBy('id','desc')->first(); | ||
| 75 | - if(!empty($info)){ | ||
| 76 | - $webSettingModel = new Setting(); | ||
| 77 | - $webSettingModel->add(['template_id'=>$info->template_id,'project_id'=>$project_id]); | 70 | + |
| 71 | + public function ceshi($api_no = null) | ||
| 72 | + { | ||
| 73 | + $key = 'extend_projects_list'; | ||
| 74 | + $data = Cache::get($key); | ||
| 75 | + if (!$data) { | ||
| 76 | + $api_url = 'http://api.quanqiusou.cn/google-rank/api/extend_projects.php'; | ||
| 77 | + try { | ||
| 78 | + $data = HttpUtils::get($api_url, []); | ||
| 79 | + if ($data) { | ||
| 80 | + $data = Arr::s2a($data); | ||
| 81 | + Cache::put($key, $data, 4 * 3600); | ||
| 82 | + } | ||
| 83 | + } catch (\Exception | GuzzleException $e) { | ||
| 84 | + errorLog('复制站点项目获取失败', [], $e); | ||
| 85 | + return false; | ||
| 86 | + } | ||
| 87 | + } | ||
| 88 | + if ($api_no !== null) { | ||
| 89 | + $data = collect($data)->where('apino', $api_no)->first(); | ||
| 90 | + return $data ?: []; | ||
| 78 | } | 91 | } |
| 92 | + return $data; | ||
| 79 | } | 93 | } |
| 80 | - | ||
| 81 | /** | 94 | /** |
| 82 | * @remark :更新产品 | 95 | * @remark :更新产品 |
| 83 | * @name :updateProduct | 96 | * @name :updateProduct |
| @@ -111,11 +124,11 @@ class UpdateRoute extends Command | @@ -111,11 +124,11 @@ class UpdateRoute extends Command | ||
| 111 | */ | 124 | */ |
| 112 | public function custom_to_blogs(){ | 125 | public function custom_to_blogs(){ |
| 113 | $customContentModel = new CustomModuleContent(); | 126 | $customContentModel = new CustomModuleContent(); |
| 114 | - $lists = $customContentModel->list(['module_id'=>9]); | 127 | + $lists = $customContentModel->list(['module_id'=>8]); |
| 115 | foreach ($lists as $k => $v){ | 128 | foreach ($lists as $k => $v){ |
| 116 | $data = [ | 129 | $data = [ |
| 117 | 'name'=>$v['name'], | 130 | 'name'=>$v['name'], |
| 118 | - 'category_id'=>',1,', | 131 | + 'category_id'=>',1,2,', |
| 119 | 'remark'=>$v['remark'], | 132 | 'remark'=>$v['remark'], |
| 120 | 'text'=>$v['content'], | 133 | 'text'=>$v['content'], |
| 121 | 'url'=>$v['route'], | 134 | 'url'=>$v['route'], |
| @@ -123,7 +136,7 @@ class UpdateRoute extends Command | @@ -123,7 +136,7 @@ class UpdateRoute extends Command | ||
| 123 | 'seo_title'=>$v['seo_title'], | 136 | 'seo_title'=>$v['seo_title'], |
| 124 | 'seo_description'=>$v['seo_description'], | 137 | 'seo_description'=>$v['seo_description'], |
| 125 | 'seo_keywords'=>$v['seo_keywords'], | 138 | 'seo_keywords'=>$v['seo_keywords'], |
| 126 | - 'project_id'=>1750, | 139 | + 'project_id'=>1462, |
| 127 | 'operator_id'=>$v['operator_id'], | 140 | 'operator_id'=>$v['operator_id'], |
| 128 | 'create_id'=>$v['operator_id'], | 141 | 'create_id'=>$v['operator_id'], |
| 129 | 'created_at'=>$v['created_at'], | 142 | 'created_at'=>$v['created_at'], |
| @@ -132,8 +145,8 @@ class UpdateRoute extends Command | @@ -132,8 +145,8 @@ class UpdateRoute extends Command | ||
| 132 | ]; | 145 | ]; |
| 133 | $blogModel = new Blog(); | 146 | $blogModel = new Blog(); |
| 134 | $id = $blogModel->insertGetId($data); | 147 | $id = $blogModel->insertGetId($data); |
| 135 | - RouteMap::setRoute($v['route'], RouteMap::SOURCE_BLOG, $id, 1750); | ||
| 136 | } | 148 | } |
| 149 | + return true; | ||
| 137 | } | 150 | } |
| 138 | 151 | ||
| 139 | public function editProductAlt(){ | 152 | public function editProductAlt(){ |
| @@ -14,6 +14,8 @@ use App\Http\Controllers\Aside\BaseController; | @@ -14,6 +14,8 @@ use App\Http\Controllers\Aside\BaseController; | ||
| 14 | use App\Http\Logic\Aside\Devops\ServersLogic; | 14 | use App\Http\Logic\Aside\Devops\ServersLogic; |
| 15 | use App\Models\Devops\Servers as ServersModel; | 15 | use App\Models\Devops\Servers as ServersModel; |
| 16 | use App\Models\Devops\ServersIp; | 16 | use App\Models\Devops\ServersIp; |
| 17 | +use App\Models\Domain\DomainInfo; | ||
| 18 | +use App\Models\Project\DeployOptimize; | ||
| 17 | use App\Models\Project\Project; | 19 | use App\Models\Project\Project; |
| 18 | 20 | ||
| 19 | class ServersController extends BaseController | 21 | class ServersController extends BaseController |
| @@ -59,6 +61,22 @@ class ServersController extends BaseController | @@ -59,6 +61,22 @@ class ServersController extends BaseController | ||
| 59 | } | 61 | } |
| 60 | unset($this->map['project_name']); | 62 | unset($this->map['project_name']); |
| 61 | } | 63 | } |
| 64 | + if(isset($this->map['domain']) && !empty($this->map['domain'])){ | ||
| 65 | + $domainModel = new DomainInfo(); | ||
| 66 | + $domainInfo = $domainModel->read(['domain'=>['like','%'.$this->map['domain'].'%']],['id','project_id']); | ||
| 67 | + if($domainInfo !== false && !empty($domainInfo['project_id'])){ | ||
| 68 | + $projectModel = new Project(); | ||
| 69 | + $projectInfo = $projectModel->read(['id'=>$domainInfo['project_id']],['serve_id']); | ||
| 70 | + if($projectInfo !== false){ | ||
| 71 | + $serversIpModel = new ServersIp(); | ||
| 72 | + $ipInfo = $serversIpModel->read(['id'=>$projectInfo['serve_id']],['servers_id']); | ||
| 73 | + if($ipInfo !== false){ | ||
| 74 | + $this->map['id'] = $ipInfo['servers_id']; | ||
| 75 | + } | ||
| 76 | + } | ||
| 77 | + } | ||
| 78 | + unset($this->map['domain']); | ||
| 79 | + } | ||
| 62 | $serversModel = new ServersModel(); | 80 | $serversModel = new ServersModel(); |
| 63 | $data = $serversModel->lists($this->map,$this->page,$this->row,$this->order); | 81 | $data = $serversModel->lists($this->map,$this->page,$this->row,$this->order); |
| 64 | $this->response('success',Code::SUCCESS,$data); | 82 | $this->response('success',Code::SUCCESS,$data); |
| @@ -34,10 +34,10 @@ class AiBlogController extends BaseController | @@ -34,10 +34,10 @@ class AiBlogController extends BaseController | ||
| 34 | * @time :2025/2/14 13:59 | 34 | * @time :2025/2/14 13:59 |
| 35 | */ | 35 | */ |
| 36 | public function getAiBlog(AiBlog $aiBlog){ | 36 | public function getAiBlog(AiBlog $aiBlog){ |
| 37 | - $lists = $aiBlog->lists($this->map,$this->page,$this->row,'id',['id','new_title','task_id','status','created_at','updated_at']); | 37 | + $lists = $aiBlog->lists($this->map,$this->page,$this->row,'id',['id','new_title','image','task_id','status','created_at','updated_at']); |
| 38 | if(!empty($lists) && !empty($lists['list'])){ | 38 | if(!empty($lists) && !empty($lists['list'])){ |
| 39 | foreach ($lists['list'] as $k => $v){ | 39 | foreach ($lists['list'] as $k => $v){ |
| 40 | - $v['image'] = getImageUrl($v['url'],$this->user['storage_type'],$this->user['project_location']); | 40 | + $v['image'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']); |
| 41 | $lists['list'][$k] = $v; | 41 | $lists['list'][$k] = $v; |
| 42 | } | 42 | } |
| 43 | } | 43 | } |
| @@ -54,10 +54,12 @@ class AiBlogController extends BaseController | @@ -54,10 +54,12 @@ class AiBlogController extends BaseController | ||
| 54 | public function sendTask(AiBlogLogic $aiBlogLogic){ | 54 | public function sendTask(AiBlogLogic $aiBlogLogic){ |
| 55 | $this->request->validate([ | 55 | $this->request->validate([ |
| 56 | 'keyword'=>['required'], | 56 | 'keyword'=>['required'], |
| 57 | - 'type'=>['required'] | 57 | + 'type'=>['required'], |
| 58 | + 'route'=>['required'] | ||
| 58 | ],[ | 59 | ],[ |
| 59 | 'keyword.required' => '关键字不能为空', | 60 | 'keyword.required' => '关键字不能为空', |
| 60 | 'type.required' => '场景不能为空', | 61 | 'type.required' => '场景不能为空', |
| 62 | + 'route.required' => '路由不能为空', | ||
| 61 | ]); | 63 | ]); |
| 62 | //获取当前项目的ai_blog设置 | 64 | //获取当前项目的ai_blog设置 |
| 63 | $result = $aiBlogLogic->sendTask(); | 65 | $result = $aiBlogLogic->sendTask(); |
| @@ -77,6 +77,9 @@ class SuppliersController extends BaseController | @@ -77,6 +77,9 @@ class SuppliersController extends BaseController | ||
| 77 | if(isset($res['status_code']) && $res['status_code'] != 200){ | 77 | if(isset($res['status_code']) && $res['status_code'] != 200){ |
| 78 | $this->response($res['message'],Code::SYSTEM_ERROR); | 78 | $this->response($res['message'],Code::SYSTEM_ERROR); |
| 79 | } | 79 | } |
| 80 | + if(isset($res['data']['image']) && !empty($res['data']['image'])){ | ||
| 81 | + $res['data']['image'] = str_replace('admin.hagro.cn','fob.ai.cc',$res['data']['image']??''); | ||
| 82 | + } | ||
| 80 | return $this->success($res['data'] ?? []); | 83 | return $this->success($res['data'] ?? []); |
| 81 | } | 84 | } |
| 82 | /** | 85 | /** |
| @@ -134,8 +137,12 @@ class SuppliersController extends BaseController | @@ -134,8 +137,12 @@ class SuppliersController extends BaseController | ||
| 134 | if(isset($this->param['position'])){ | 137 | if(isset($this->param['position'])){ |
| 135 | $param['position'] = $this->param['position']; | 138 | $param['position'] = $this->param['position']; |
| 136 | } | 139 | } |
| 137 | - $res = $this->_action($api_url,$action_name,$param); | ||
| 138 | - $this->response('success',Code::SUCCESS,$res); | 140 | + try { |
| 141 | + $res = $this->_action($api_url,$action_name,$param); | ||
| 142 | + $this->response('success',Code::SUCCESS,$res); | ||
| 143 | + }catch (\Exception $e){ | ||
| 144 | + $this->fail('请求失败,请联系管理员'); | ||
| 145 | + } | ||
| 139 | } | 146 | } |
| 140 | 147 | ||
| 141 | /** | 148 | /** |
| @@ -253,4 +260,5 @@ class SuppliersController extends BaseController | @@ -253,4 +260,5 @@ class SuppliersController extends BaseController | ||
| 253 | $res = $this->_action($api_url,$action_name,$param); | 260 | $res = $this->_action($api_url,$action_name,$param); |
| 254 | $this->response('success',Code::SUCCESS,$res); | 261 | $this->response('success',Code::SUCCESS,$res); |
| 255 | } | 262 | } |
| 263 | + | ||
| 256 | } | 264 | } |
| @@ -161,10 +161,10 @@ class ProjectLogic extends BaseLogic | @@ -161,10 +161,10 @@ class ProjectLogic extends BaseLogic | ||
| 161 | $this->createProjectData($this->param); | 161 | $this->createProjectData($this->param); |
| 162 | //双向绑定服务器,需放到保存项目的上方 | 162 | //双向绑定服务器,需放到保存项目的上方 |
| 163 | $this->setServers($this->param['serve_id'],$this->param['id']); | 163 | $this->setServers($this->param['serve_id'],$this->param['id']); |
| 164 | - //保存项目信息 | ||
| 165 | - $this->saveProject($this->param); | ||
| 166 | //ai_blog | 164 | //ai_blog |
| 167 | $this->setAiBlog($this->param['id'],$this->param['main_lang_id'],$this->param['is_ai_blog'],$this->param['title']); | 165 | $this->setAiBlog($this->param['id'],$this->param['main_lang_id'],$this->param['is_ai_blog'],$this->param['title']); |
| 166 | + //保存项目信息 | ||
| 167 | + $this->saveProject($this->param); | ||
| 168 | //保存建站部署信息 | 168 | //保存建站部署信息 |
| 169 | $this->saveProjectDeployBuild($this->param['deploy_build']); | 169 | $this->saveProjectDeployBuild($this->param['deploy_build']); |
| 170 | //保存付费信息 | 170 | //保存付费信息 |
| @@ -202,7 +202,7 @@ class ProjectLogic extends BaseLogic | @@ -202,7 +202,7 @@ class ProjectLogic extends BaseLogic | ||
| 202 | return true; | 202 | return true; |
| 203 | } | 203 | } |
| 204 | $projectModel = new Project(); | 204 | $projectModel = new Project(); |
| 205 | - $projectInfo = $projectModel->read(['id'=>$project_id],['is_ai_blog','main_lang_id']); | 205 | + $projectInfo = $projectModel->read(['id'=>$project_id],['title','is_ai_blog','main_lang_id','company']); |
| 206 | //获取项目主语种 | 206 | //获取项目主语种 |
| 207 | $languageModel = new WebLanguage(); | 207 | $languageModel = new WebLanguage(); |
| 208 | $languageInfo = $languageModel->read(['id'=>$main_lang_id],['short']); | 208 | $languageInfo = $languageModel->read(['id'=>$main_lang_id],['short']); |
| @@ -770,7 +770,6 @@ class ProjectLogic extends BaseLogic | @@ -770,7 +770,6 @@ class ProjectLogic extends BaseLogic | ||
| 770 | * @time :2023/9/4 14:29 | 770 | * @time :2023/9/4 14:29 |
| 771 | */ | 771 | */ |
| 772 | public function editDomainStatus($domain,$project_id){ | 772 | public function editDomainStatus($domain,$project_id){ |
| 773 | - | ||
| 774 | $projectOptimize = new DeployOptimize(); | 773 | $projectOptimize = new DeployOptimize(); |
| 775 | $optimizeInfo = $projectOptimize->read(['project_id'=>$project_id],['domain']); | 774 | $optimizeInfo = $projectOptimize->read(['project_id'=>$project_id],['domain']); |
| 776 | if($optimizeInfo['domain'] == $domain){ | 775 | if($optimizeInfo['domain'] == $domain){ |
| @@ -977,9 +976,7 @@ class ProjectLogic extends BaseLogic | @@ -977,9 +976,7 @@ class ProjectLogic extends BaseLogic | ||
| 977 | public function saveWebTrafficConfig($config){ | 976 | public function saveWebTrafficConfig($config){ |
| 978 | $config['main_countries'] = textareaToArr($config['main_countries']); | 977 | $config['main_countries'] = textareaToArr($config['main_countries']); |
| 979 | $config['filter_countries'] = textareaToArr($config['filter_countries']); | 978 | $config['filter_countries'] = textareaToArr($config['filter_countries']); |
| 980 | - | ||
| 981 | $ip_area = InquiryIP::getIpAreas(); | 979 | $ip_area = InquiryIP::getIpAreas(); |
| 982 | - | ||
| 983 | foreach ($config['main_countries'] as $v) { | 980 | foreach ($config['main_countries'] as $v) { |
| 984 | if (!in_array($v, $ip_area)) { | 981 | if (!in_array($v, $ip_area)) { |
| 985 | throw new AsideGlobalException(Code::SYSTEM_ERROR, '[' . $v . ']不存在,请检查后再次提交'); | 982 | throw new AsideGlobalException(Code::SYSTEM_ERROR, '[' . $v . ']不存在,请检查后再次提交'); |
| @@ -990,11 +987,8 @@ class ProjectLogic extends BaseLogic | @@ -990,11 +987,8 @@ class ProjectLogic extends BaseLogic | ||
| 990 | throw new AsideGlobalException(Code::SYSTEM_ERROR, '[' . $v . ']不存在,请检查后再次提交'); | 987 | throw new AsideGlobalException(Code::SYSTEM_ERROR, '[' . $v . ']不存在,请检查后再次提交'); |
| 991 | } | 988 | } |
| 992 | } | 989 | } |
| 993 | - | ||
| 994 | - | ||
| 995 | $config['main_countries'] = json_encode($config['main_countries']); | 990 | $config['main_countries'] = json_encode($config['main_countries']); |
| 996 | $config['filter_countries'] = json_encode($config['filter_countries']); | 991 | $config['filter_countries'] = json_encode($config['filter_countries']); |
| 997 | - | ||
| 998 | $model = WebTrafficConfig::where('project_id', $config['project_id'])->first(); | 992 | $model = WebTrafficConfig::where('project_id', $config['project_id'])->first(); |
| 999 | if (!$model) { | 993 | if (!$model) { |
| 1000 | $model = new WebTrafficConfig(); | 994 | $model = new WebTrafficConfig(); |
| @@ -1002,9 +996,7 @@ class ProjectLogic extends BaseLogic | @@ -1002,9 +996,7 @@ class ProjectLogic extends BaseLogic | ||
| 1002 | } else { | 996 | } else { |
| 1003 | $model->edit($config, ['project_id' => $config['project_id']]); | 997 | $model->edit($config, ['project_id' => $config['project_id']]); |
| 1004 | } | 998 | } |
| 1005 | - | ||
| 1006 | Cache::forget(WebTrafficConfig::cacheKey($config['project_id'])); | 999 | Cache::forget(WebTrafficConfig::cacheKey($config['project_id'])); |
| 1007 | - | ||
| 1008 | return $this->success(); | 1000 | return $this->success(); |
| 1009 | } | 1001 | } |
| 1010 | 1002 | ||
| @@ -1086,6 +1078,4 @@ class ProjectLogic extends BaseLogic | @@ -1086,6 +1078,4 @@ class ProjectLogic extends BaseLogic | ||
| 1086 | } | 1078 | } |
| 1087 | return true; | 1079 | return true; |
| 1088 | } | 1080 | } |
| 1089 | - | ||
| 1090 | - | ||
| 1091 | } | 1081 | } |
| @@ -55,9 +55,7 @@ class AiBlogLogic extends BaseLogic | @@ -55,9 +55,7 @@ class AiBlogLogic extends BaseLogic | ||
| 55 | $aiBlogService = new AiBlogService(); | 55 | $aiBlogService = new AiBlogService(); |
| 56 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | 56 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; |
| 57 | $aiBlogService->key = $aiSettingInfo['key']; | 57 | $aiBlogService->key = $aiSettingInfo['key']; |
| 58 | - if(!empty($this->param['route'])){ | ||
| 59 | - $aiBlogService->route = generateRoute(Translate::tran($this->param['route'], 'en')); | ||
| 60 | - } | 58 | + $aiBlogService->route = generateRoute(Translate::tran($this->param['route'], 'en')); |
| 61 | $result = $aiBlogService->createTask($this->param['keyword'],$this->param['type']); | 59 | $result = $aiBlogService->createTask($this->param['keyword'],$this->param['type']); |
| 62 | if($result['status'] == 200){ | 60 | if($result['status'] == 200){ |
| 63 | $aiBlogTaskModel = new AiBlogTask(); | 61 | $aiBlogTaskModel = new AiBlogTask(); |
| @@ -149,6 +149,11 @@ class CategoryLogic extends BaseLogic | @@ -149,6 +149,11 @@ class CategoryLogic extends BaseLogic | ||
| 149 | }else{ | 149 | }else{ |
| 150 | $param['describe_image'] = json_encode([]); | 150 | $param['describe_image'] = json_encode([]); |
| 151 | } | 151 | } |
| 152 | + if(isset($param['cate_tak']) && !empty($param['cate_tak'])){ | ||
| 153 | + $param['cate_tak'] = json_encode($param['cate_tak']); | ||
| 154 | + }else{ | ||
| 155 | + $param['cate_tak'] = json_encode([]);; | ||
| 156 | + } | ||
| 152 | return $this->success($param); | 157 | return $this->success($param); |
| 153 | } | 158 | } |
| 154 | 159 |
| @@ -27,6 +27,7 @@ class InquiryProject extends Base | @@ -27,6 +27,7 @@ class InquiryProject extends Base | ||
| 27 | 27 | ||
| 28 | /** | 28 | /** |
| 29 | * 保存项目信息 | 29 | * 保存项目信息 |
| 30 | + * @param $date | ||
| 30 | * @param $version | 31 | * @param $version |
| 31 | * @param $primary_id | 32 | * @param $primary_id |
| 32 | * @param $project | 33 | * @param $project |
| @@ -36,9 +37,8 @@ class InquiryProject extends Base | @@ -36,9 +37,8 @@ class InquiryProject extends Base | ||
| 36 | * @param string $test_domain | 37 | * @param string $test_domain |
| 37 | * @return InquiryProject | 38 | * @return InquiryProject |
| 38 | */ | 39 | */ |
| 39 | - public static function saveProject($version, $primary_id, $project, $channel, $domain, $is_split = 0, $test_domain = '') | 40 | + public static function saveProject($date, $version, $primary_id, $project, $channel, $domain, $is_split = 0, $test_domain = '') |
| 40 | { | 41 | { |
| 41 | - $date = date('Ymd'); | ||
| 42 | $log = self::where(compact('version', 'primary_id'))->first(); | 42 | $log = self::where(compact('version', 'primary_id'))->first(); |
| 43 | if ($log) { | 43 | if ($log) { |
| 44 | $log->date = $date; | 44 | $log->date = $date; |
| @@ -25,11 +25,11 @@ class InquiryProjectRoute extends Base | @@ -25,11 +25,11 @@ class InquiryProjectRoute extends Base | ||
| 25 | * @param int $project_id gl_inquiry_project 表ID | 25 | * @param int $project_id gl_inquiry_project 表ID |
| 26 | * @param $title | 26 | * @param $title |
| 27 | * @param $route | 27 | * @param $route |
| 28 | + * @param $date | ||
| 28 | * @return InquiryProjectRoute | 29 | * @return InquiryProjectRoute |
| 29 | */ | 30 | */ |
| 30 | - public static function saveProjectRoute($project_id, $title, $route) | 31 | + public static function saveProjectRoute($project_id, $title, $route, $date) |
| 31 | { | 32 | { |
| 32 | - $date = date('Ymd'); | ||
| 33 | $log = self::where(compact('project_id', 'title'))->first(); | 33 | $log = self::where(compact('project_id', 'title'))->first(); |
| 34 | if ($log) { | 34 | if ($log) { |
| 35 | $log->date = $date; | 35 | $log->date = $date; |
| @@ -33,6 +33,19 @@ class Category extends Base | @@ -33,6 +33,19 @@ class Category extends Base | ||
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | /** | 35 | /** |
| 36 | + * @remark :获取tdk | ||
| 37 | + * @name :getCateTdkAttribute | ||
| 38 | + * @author :lyh | ||
| 39 | + * @method :post | ||
| 40 | + * @time :2025/2/19 11:03 | ||
| 41 | + */ | ||
| 42 | + public function getCateTdkAttribute($value){ | ||
| 43 | + if(!empty($value)){ | ||
| 44 | + $value = Arr::s2a($value); | ||
| 45 | + } | ||
| 46 | + return $value; | ||
| 47 | + } | ||
| 48 | + /** | ||
| 36 | * 根据产品分类获取分类列表和产品 | 49 | * 根据产品分类获取分类列表和产品 |
| 37 | */ | 50 | */ |
| 38 | public static function getCategoryBySelfCategory($projectId,$routerMap) | 51 | public static function getCategoryBySelfCategory($projectId,$routerMap) |
-
请 注册 或 登录 后发表评论