Merge remote-tracking branch 'origin/master' into akun
正在显示
14 个修改的文件
包含
46 行增加
和
42 行删除
| @@ -38,7 +38,7 @@ abstract class BaseCommands extends Command | @@ -38,7 +38,7 @@ abstract class BaseCommands extends Command | ||
| 38 | if($error){ | 38 | if($error){ |
| 39 | echo 'error'; | 39 | echo 'error'; |
| 40 | } | 40 | } |
| 41 | - $error && sleep(60); | 41 | + $error && sleep(10); |
| 42 | }while($error); | 42 | }while($error); |
| 43 | } | 43 | } |
| 44 | 44 |
| @@ -47,7 +47,7 @@ class ExternalLinks extends BaseCommands | @@ -47,7 +47,7 @@ class ExternalLinks extends BaseCommands | ||
| 47 | continue; | 47 | continue; |
| 48 | } | 48 | } |
| 49 | $model = ExternalLinksModel::where('project_id', $project_id)->first(); | 49 | $model = ExternalLinksModel::where('project_id', $project_id)->first(); |
| 50 | - if ($model && $model->updated_date == getThisWeekStarDate()) { | 50 | + if ($model && $model->updated_date >= getThisWeekStarDate()) { |
| 51 | continue; | 51 | continue; |
| 52 | } | 52 | } |
| 53 | if (!$model) { | 53 | if (!$model) { |
| @@ -42,7 +42,7 @@ class IndexedPages extends BaseCommands | @@ -42,7 +42,7 @@ class IndexedPages extends BaseCommands | ||
| 42 | LogUtils::info('start rank_data_indexed_pages:' . count($list)); | 42 | LogUtils::info('start rank_data_indexed_pages:' . count($list)); |
| 43 | foreach ($list as $project_id => $api_no) { | 43 | foreach ($list as $project_id => $api_no) { |
| 44 | $model = IndexedPagesModel::where('project_id', $project_id)->first(); | 44 | $model = IndexedPagesModel::where('project_id', $project_id)->first(); |
| 45 | - if($model && $model->updated_date == getThisWeekStarDate()){ | 45 | + if($model && $model->updated_date >= getThisWeekStarDate()){ |
| 46 | continue; | 46 | continue; |
| 47 | } | 47 | } |
| 48 | 48 |
| @@ -59,7 +59,7 @@ class RankDataTask extends Command | @@ -59,7 +59,7 @@ class RankDataTask extends Command | ||
| 59 | $api = new QuanqiusouApi(); | 59 | $api = new QuanqiusouApi(); |
| 60 | $site_res = $api->getSiteRes(); | 60 | $site_res = $api->getSiteRes(); |
| 61 | 61 | ||
| 62 | - (new RankDataLogic())->syncRankData($item['data']['api_no'], $site_res); | 62 | + (new RankDataLogic())->syncRankData($item['data']['api_no'], $site_res, true); |
| 63 | 63 | ||
| 64 | $item->status = NoticeLog::STATUS_SUCCESS; | 64 | $item->status = NoticeLog::STATUS_SUCCESS; |
| 65 | $item->save(); | 65 | $item->save(); |
| @@ -53,7 +53,7 @@ class RankWeek extends BaseCommands | @@ -53,7 +53,7 @@ class RankWeek extends BaseCommands | ||
| 53 | LogUtils::info('start rank_data_week:' . count($list)); | 53 | LogUtils::info('start rank_data_week:' . count($list)); |
| 54 | foreach ($list as $project_id => $api_no) { | 54 | foreach ($list as $project_id => $api_no) { |
| 55 | $rank_week = RankWeekModel::where('project_id', $project_id)->first(); | 55 | $rank_week = RankWeekModel::where('project_id', $project_id)->first(); |
| 56 | - if ($rank_week && $rank_week->updated_date == getThisWeekStarDate()) { | 56 | + if ($rank_week && $rank_week->updated_date >= getThisWeekStarDate()) { |
| 57 | //本周数据已更新 | 57 | //本周数据已更新 |
| 58 | continue; | 58 | continue; |
| 59 | } | 59 | } |
| @@ -46,7 +46,7 @@ class RecommDomain extends BaseCommands | @@ -46,7 +46,7 @@ class RecommDomain extends BaseCommands | ||
| 46 | continue; | 46 | continue; |
| 47 | } | 47 | } |
| 48 | $model = RecommDomainModel::where('project_id', $project_id)->first(); | 48 | $model = RecommDomainModel::where('project_id', $project_id)->first(); |
| 49 | - if ($model && $model->updated_date == getThisWeekStarDate()) { | 49 | + if ($model && $model->updated_date >= getThisWeekStarDate()) { |
| 50 | continue; | 50 | continue; |
| 51 | } | 51 | } |
| 52 | if (!$model) { | 52 | if (!$model) { |
| @@ -47,7 +47,7 @@ class Speed extends BaseCommands | @@ -47,7 +47,7 @@ class Speed extends BaseCommands | ||
| 47 | LogUtils::info('start rank_data_speed:' . count($list)); | 47 | LogUtils::info('start rank_data_speed:' . count($list)); |
| 48 | foreach ($list as $project_id => $domain) { | 48 | foreach ($list as $project_id => $domain) { |
| 49 | $model = GoogleSpeedModel::where('project_id', $project_id)->first(); | 49 | $model = GoogleSpeedModel::where('project_id', $project_id)->first(); |
| 50 | - if ($model && $model->updated_date == getThisWeekStarDate()) { | 50 | + if ($model && $model->updated_date >= getThisWeekStarDate()) { |
| 51 | //今周已更新 跳过 | 51 | //今周已更新 跳过 |
| 52 | continue; | 52 | continue; |
| 53 | } | 53 | } |
| @@ -19,11 +19,11 @@ class Kernel extends ConsoleKernel | @@ -19,11 +19,11 @@ class Kernel extends ConsoleKernel | ||
| 19 | $schedule->command('remain_day')->dailyAt('03:00')->withoutOverlapping(1); // 项目剩余服务时长 | 19 | $schedule->command('remain_day')->dailyAt('03:00')->withoutOverlapping(1); // 项目剩余服务时长 |
| 20 | $schedule->command('rank_data_task')->everyMinute()->withoutOverlapping(1); // 排名数据更新任务 | 20 | $schedule->command('rank_data_task')->everyMinute()->withoutOverlapping(1); // 排名数据更新任务 |
| 21 | $schedule->command('rank_data')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据,每天凌晨执行一次 | 21 | $schedule->command('rank_data')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据,每天凌晨执行一次 |
| 22 | - $schedule->command('rank_data_speed')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-测速数据,每周一凌晨执行一次 | ||
| 23 | - $schedule->command('rank_data_external_links')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-外链,每周一凌晨执行一次 | ||
| 24 | - $schedule->command('rank_data_indexed_pages')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-页面收录,每周一凌晨执行一次 | ||
| 25 | - $schedule->command('rank_data_recomm_domain')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-引荐域名,每周一凌晨执行一次 | ||
| 26 | - $schedule->command('rank_data_week')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次 | 22 | + $schedule->command('rank_data_speed')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据-测速数据,每周一凌晨执行一次 |
| 23 | + $schedule->command('rank_data_external_links')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据-外链,每周一凌晨执行一次 | ||
| 24 | + $schedule->command('rank_data_indexed_pages')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据-页面收录,每周一凌晨执行一次 | ||
| 25 | + $schedule->command('rank_data_recomm_domain')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据-引荐域名,每周一凌晨执行一次 | ||
| 26 | + $schedule->command('rank_data_week')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次 | ||
| 27 | // $schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次 | 27 | // $schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次 |
| 28 | $schedule->command('count')->dailyAt('01:00')->withoutOverlapping(1); //每天凌晨1点执行一次 | 28 | $schedule->command('count')->dailyAt('01:00')->withoutOverlapping(1); //每天凌晨1点执行一次 |
| 29 | $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次 | 29 | $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次 |
| @@ -34,7 +34,7 @@ class QuanqiusouApi | @@ -34,7 +34,7 @@ class QuanqiusouApi | ||
| 34 | $res = HttpUtils::get($api_url, []); | 34 | $res = HttpUtils::get($api_url, []); |
| 35 | if($res){ | 35 | if($res){ |
| 36 | $res = Arr::s2a($res); | 36 | $res = Arr::s2a($res); |
| 37 | - Cache::put($key, $res, 24 * 3600); | 37 | + Cache::put($key, $res, 2 * 3600); |
| 38 | } | 38 | } |
| 39 | } catch (\Exception | GuzzleException $e) { | 39 | } catch (\Exception | GuzzleException $e) { |
| 40 | errorLog('获取站点收录页面数', [], $e); | 40 | errorLog('获取站点收录页面数', [], $e); |
| @@ -60,7 +60,7 @@ class QuanqiusouApi | @@ -60,7 +60,7 @@ class QuanqiusouApi | ||
| 60 | $res = HttpUtils::get($api_url, ['apino' => $api_no]); | 60 | $res = HttpUtils::get($api_url, ['apino' => $api_no]); |
| 61 | if($res){ | 61 | if($res){ |
| 62 | $res = Arr::s2a($res); | 62 | $res = Arr::s2a($res); |
| 63 | - Cache::put($key, $res, 24 * 3600); | 63 | + Cache::put($key, $res, 2 * 3600); |
| 64 | } | 64 | } |
| 65 | } catch (\Exception | GuzzleException $e) { | 65 | } catch (\Exception | GuzzleException $e) { |
| 66 | errorLog('获取站点收录页面数', [], $e); | 66 | errorLog('获取站点收录页面数', [], $e); |
| @@ -80,11 +80,11 @@ class QuanqiusouApi | @@ -80,11 +80,11 @@ class QuanqiusouApi | ||
| 80 | * @author zbj | 80 | * @author zbj |
| 81 | * @date 2023/5/11 | 81 | * @date 2023/5/11 |
| 82 | */ | 82 | */ |
| 83 | - public function getGoogleRank($api_no, int $lang = 0, int $day = 7) | 83 | + public function getGoogleRank($api_no, int $lang = 0, int $day = 7, $force = true) |
| 84 | { | 84 | { |
| 85 | $key = "quanqiusou_api_rank_{$api_no}_{$lang}_{$day}_" . date('Y-m-d'); | 85 | $key = "quanqiusou_api_rank_{$api_no}_{$lang}_{$day}_" . date('Y-m-d'); |
| 86 | $res = Cache::get($key); | 86 | $res = Cache::get($key); |
| 87 | - if (!$res) { | 87 | + if (!$res || $force) { |
| 88 | $param = [ | 88 | $param = [ |
| 89 | 'key' => '289c1fc81c89d79c04ed4fd72822948e', | 89 | 'key' => '289c1fc81c89d79c04ed4fd72822948e', |
| 90 | 'w' => $api_no, | 90 | 'w' => $api_no, |
| @@ -100,7 +100,7 @@ class QuanqiusouApi | @@ -100,7 +100,7 @@ class QuanqiusouApi | ||
| 100 | $res = HttpUtils::get($api_url, $param); | 100 | $res = HttpUtils::get($api_url, $param); |
| 101 | if($res){ | 101 | if($res){ |
| 102 | $res = Arr::s2a($res); | 102 | $res = Arr::s2a($res); |
| 103 | - Cache::put($key, $res, 24 * 3600); | 103 | + Cache::put($key, $res, 2 * 3600); |
| 104 | } | 104 | } |
| 105 | } catch (\Exception | GuzzleException $e) { | 105 | } catch (\Exception | GuzzleException $e) { |
| 106 | errorLog('获取谷歌排名数据失败', $api_no, $e); | 106 | errorLog('获取谷歌排名数据失败', $api_no, $e); |
| @@ -127,7 +127,7 @@ class QuanqiusouApi | @@ -127,7 +127,7 @@ class QuanqiusouApi | ||
| 127 | $res = HttpUtils::get($api_url, []); | 127 | $res = HttpUtils::get($api_url, []); |
| 128 | if($res){ | 128 | if($res){ |
| 129 | $res = Arr::s2a($res); | 129 | $res = Arr::s2a($res); |
| 130 | - Cache::put($key, $res, 24 * 3600); | 130 | + Cache::put($key, $res, 2 * 3600); |
| 131 | } | 131 | } |
| 132 | } catch (\Exception | GuzzleException $e) { | 132 | } catch (\Exception | GuzzleException $e) { |
| 133 | errorLog('获取每周谷歌排名数据失败', [], $e); | 133 | errorLog('获取每周谷歌排名数据失败', [], $e); |
| @@ -162,7 +162,7 @@ class QuanqiusouApi | @@ -162,7 +162,7 @@ class QuanqiusouApi | ||
| 162 | $res = HttpUtils::get($api_url, $param); | 162 | $res = HttpUtils::get($api_url, $param); |
| 163 | if($res){ | 163 | if($res){ |
| 164 | $res = Arr::s2a($res); | 164 | $res = Arr::s2a($res); |
| 165 | - Cache::put($key, $res, 24 * 3600); | 165 | + Cache::put($key, $res, 2 * 3600); |
| 166 | } | 166 | } |
| 167 | } catch (\Exception | GuzzleException $e) { | 167 | } catch (\Exception | GuzzleException $e) { |
| 168 | errorLog('获取历史排名统计数据失败', [], $e); | 168 | errorLog('获取历史排名统计数据失败', [], $e); |
| @@ -221,7 +221,7 @@ class QuanqiusouApi | @@ -221,7 +221,7 @@ class QuanqiusouApi | ||
| 221 | $res = HttpUtils::get($api_url, $param); | 221 | $res = HttpUtils::get($api_url, $param); |
| 222 | if($res){ | 222 | if($res){ |
| 223 | $res = Arr::s2a($res); | 223 | $res = Arr::s2a($res); |
| 224 | - Cache::put($key, $res, 24 * 3600); | 224 | + Cache::put($key, $res, 2 * 3600); |
| 225 | } | 225 | } |
| 226 | } catch (\Exception | GuzzleException $e) { | 226 | } catch (\Exception | GuzzleException $e) { |
| 227 | errorLog('获取项目小语种数据失败', [], $e); | 227 | errorLog('获取项目小语种数据失败', [], $e); |
| @@ -249,7 +249,7 @@ class QuanqiusouApi | @@ -249,7 +249,7 @@ class QuanqiusouApi | ||
| 249 | $res = HttpUtils::get($api_url, $param); | 249 | $res = HttpUtils::get($api_url, $param); |
| 250 | if($res){ | 250 | if($res){ |
| 251 | $res = Arr::s2a($res); | 251 | $res = Arr::s2a($res); |
| 252 | - Cache::put($key, $res, 24 * 3600); | 252 | + Cache::put($key, $res, 2 * 3600); |
| 253 | } | 253 | } |
| 254 | } catch (\Exception | GuzzleException $e) { | 254 | } catch (\Exception | GuzzleException $e) { |
| 255 | errorLog('获取项目API_NO数据失败', [], $e); | 255 | errorLog('获取项目API_NO数据失败', [], $e); |
| @@ -35,9 +35,9 @@ class SemrushApi | @@ -35,9 +35,9 @@ class SemrushApi | ||
| 35 | ]; | 35 | ]; |
| 36 | try { | 36 | try { |
| 37 | $res = HttpUtils::get($url, $params); | 37 | $res = HttpUtils::get($url, $params); |
| 38 | - return $this->data($res)[0]; | 38 | + return $this->data($res)[0] ?? []; |
| 39 | }catch (\Exception|GuzzleException $e){ | 39 | }catch (\Exception|GuzzleException $e){ |
| 40 | - errorLog('获取站点外链数据', $params, $e); | 40 | + errorLog('获取站点外链数据失败', $params, $e); |
| 41 | return false; | 41 | return false; |
| 42 | } | 42 | } |
| 43 | } | 43 | } |
| @@ -63,7 +63,7 @@ class SemrushApi | @@ -63,7 +63,7 @@ class SemrushApi | ||
| 63 | $res = HttpUtils::get($url, $params); | 63 | $res = HttpUtils::get($url, $params); |
| 64 | return $this->data($res); | 64 | return $this->data($res); |
| 65 | }catch (\Exception|GuzzleException $e){ | 65 | }catch (\Exception|GuzzleException $e){ |
| 66 | - errorLog('获取站点外链数据', $params, $e); | 66 | + errorLog('获取站点外链数据失败', $params, $e); |
| 67 | return false; | 67 | return false; |
| 68 | } | 68 | } |
| 69 | } | 69 | } |
| @@ -81,8 +81,11 @@ class CreateKeywordLogic extends BaseLogic | @@ -81,8 +81,11 @@ class CreateKeywordLogic extends BaseLogic | ||
| 81 | $prefix_keyword_suffix = $this->prefixKeywordSuffix($this->param['prefix'] ?? [],$this->param['suffix'] ?? [],$this->param['keyword']); | 81 | $prefix_keyword_suffix = $this->prefixKeywordSuffix($this->param['prefix'] ?? [],$this->param['suffix'] ?? [],$this->param['keyword']); |
| 82 | $data = [ | 82 | $data = [ |
| 83 | 'prefix_keyword'=>$prefix_keyword, | 83 | 'prefix_keyword'=>$prefix_keyword, |
| 84 | + 'prefix_keyword_count'=>count($prefix_keyword), | ||
| 84 | 'keyword_suffix'=>$keyword_suffix, | 85 | 'keyword_suffix'=>$keyword_suffix, |
| 85 | - 'prefix_keyword_suffix'=>$prefix_keyword_suffix | 86 | + 'keyword_suffix_count'=>count($keyword_suffix), |
| 87 | + 'prefix_keyword_suffix'=>$prefix_keyword_suffix, | ||
| 88 | + 'prefix_keyword_suffix_count'=>count($prefix_keyword_suffix) | ||
| 86 | ]; | 89 | ]; |
| 87 | return $this->success($data); | 90 | return $this->success($data); |
| 88 | } | 91 | } |
| @@ -5,10 +5,8 @@ namespace App\Http\Logic\Aside\Project; | @@ -5,10 +5,8 @@ namespace App\Http\Logic\Aside\Project; | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | use App\Exceptions\AsideGlobalException; | 6 | use App\Exceptions\AsideGlobalException; |
| 7 | use App\Models\Com\NoticeLog; | 7 | use App\Models\Com\NoticeLog; |
| 8 | -use App\Models\Com\UpdateLog; | ||
| 9 | use App\Models\Devops\ServerConfig; | 8 | use App\Models\Devops\ServerConfig; |
| 10 | use App\Models\Project\ProjectRenew; | 9 | use App\Models\Project\ProjectRenew; |
| 11 | -use App\Models\Template\BSettingTemplate; | ||
| 12 | use App\Models\Template\Setting; | 10 | use App\Models\Template\Setting; |
| 13 | use App\Models\User\ProjectMenu; | 11 | use App\Models\User\ProjectMenu; |
| 14 | use App\Models\User\ProjectRole; | 12 | use App\Models\User\ProjectRole; |
| @@ -16,7 +14,6 @@ use App\Services\SyncService; | @@ -16,7 +14,6 @@ use App\Services\SyncService; | ||
| 16 | use App\Utils\HttpUtils; | 14 | use App\Utils\HttpUtils; |
| 17 | use App\Utils\LogUtils; | 15 | use App\Utils\LogUtils; |
| 18 | use GuzzleHttp\Exception\GuzzleException; | 16 | use GuzzleHttp\Exception\GuzzleException; |
| 19 | -use Illuminate\Support\Arr as SupArr; | ||
| 20 | use App\Helper\Arr; | 17 | use App\Helper\Arr; |
| 21 | use App\Helper\Common; | 18 | use App\Helper\Common; |
| 22 | use App\Helper\FormGlobalsoApi; | 19 | use App\Helper\FormGlobalsoApi; |
| @@ -38,9 +35,7 @@ use Hashids\Hashids; | @@ -38,9 +35,7 @@ use Hashids\Hashids; | ||
| 38 | use App\Models\User\User as UserModel; | 35 | use App\Models\User\User as UserModel; |
| 39 | use Illuminate\Support\Facades\DB; | 36 | use Illuminate\Support\Facades\DB; |
| 40 | use Illuminate\Support\Facades\Http; | 37 | use Illuminate\Support\Facades\Http; |
| 41 | -use Illuminate\Support\Facades\Log; | ||
| 42 | use Illuminate\Support\Facades\Schema; | 38 | use Illuminate\Support\Facades\Schema; |
| 43 | -use Illuminate\Support\Str; | ||
| 44 | use App\Http\Logic\Aside\Domain\DomainInfoLogic; | 39 | use App\Http\Logic\Aside\Domain\DomainInfoLogic; |
| 45 | 40 | ||
| 46 | /** | 41 | /** |
| @@ -39,6 +39,10 @@ class BTemplateLogLogic extends BaseLogic | @@ -39,6 +39,10 @@ class BTemplateLogLogic extends BaseLogic | ||
| 39 | $this->fail('error'); | 39 | $this->fail('error'); |
| 40 | } | 40 | } |
| 41 | $bTemplateModel = new BTemplate(); | 41 | $bTemplateModel = new BTemplate(); |
| 42 | + if($info['template_id'] == 0){//定制项目 | ||
| 43 | + $bTemplateModel->edit(['html'=>$info['text']],['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]); | ||
| 44 | + return $this->success(); | ||
| 45 | + } | ||
| 42 | //演示项目,不允许其他号码编辑 | 46 | //演示项目,不允许其他号码编辑 |
| 43 | if(($this->user['project_id'] == 1) && (!in_array($this->user['mobile'],$bTemplateModel->mobile)) && ($info['source'] == 1)){ | 47 | if(($this->user['project_id'] == 1) && (!in_array($this->user['mobile'],$bTemplateModel->mobile)) && ($info['source'] == 1)){ |
| 44 | $this->fail('演示项目仅支持演示功能,无法更改首页'); | 48 | $this->fail('演示项目仅支持演示功能,无法更改首页'); |
| @@ -357,19 +357,20 @@ class RankDataLogic extends BaseLogic | @@ -357,19 +357,20 @@ class RankDataLogic extends BaseLogic | ||
| 357 | * @author zbj | 357 | * @author zbj |
| 358 | * @date 2023/9/20 | 358 | * @date 2023/9/20 |
| 359 | */ | 359 | */ |
| 360 | - public function syncRankData($api_no, $site_res){ | ||
| 361 | - $project_id = DeployOptimize::where('api_no', $api_no)->value('project_id'); | 360 | + public function syncRankData($api_no, $site_res, $force=false){ |
| 361 | + $project_ids = DeployOptimize::where('api_no', $api_no)->pluck('project_id'); | ||
| 362 | + foreach ($project_ids as $project_id) { | ||
| 362 | $project = Project::find($project_id); | 363 | $project = Project::find($project_id); |
| 363 | - if(!$project){ | 364 | + if (!$project) { |
| 364 | throw new \Exception($api_no . '关联的项目不存在'); | 365 | throw new \Exception($api_no . '关联的项目不存在'); |
| 365 | } | 366 | } |
| 366 | 367 | ||
| 367 | $api = new QuanqiusouApi(); | 368 | $api = new QuanqiusouApi(); |
| 368 | 369 | ||
| 369 | $model = RankData::where('project_id', $project_id)->where('lang', '')->first(); | 370 | $model = RankData::where('project_id', $project_id)->where('lang', '')->first(); |
| 370 | - if (!$model || $model->updated_date != date('Y-m-d')) { | ||
| 371 | - $res = $api->getGoogleRank($api_no); | ||
| 372 | - if(!$res){ | 371 | + if (!$model || $model->updated_date != date('Y-m-d') || $force) { |
| 372 | + $res = $api->getGoogleRank($api_no, 0, 7, $force); | ||
| 373 | + if (!$res) { | ||
| 373 | throw new \Exception('接口数据获取失败'); | 374 | throw new \Exception('接口数据获取失败'); |
| 374 | } | 375 | } |
| 375 | //收录数 | 376 | //收录数 |
| @@ -378,24 +379,25 @@ class RankDataLogic extends BaseLogic | @@ -378,24 +379,25 @@ class RankDataLogic extends BaseLogic | ||
| 378 | } | 379 | } |
| 379 | //有小语种的 | 380 | //有小语种的 |
| 380 | $lang_list = $api->getLangList(); | 381 | $lang_list = $api->getLangList(); |
| 381 | - if(!empty($lang_list[$api_no])){ | 382 | + if (!empty($lang_list[$api_no])) { |
| 382 | $model = RankData::where('project_id', $project_id)->where('lang', '<>', '')->first(); | 383 | $model = RankData::where('project_id', $project_id)->where('lang', '<>', '')->first(); |
| 383 | - if (!$model || $model->updated_date != date('Y-m-d')) { | ||
| 384 | - $res = $api->getGoogleRank($api_no, 1); | ||
| 385 | - if(!$res){ | 384 | + if (!$model || $model->updated_date != date('Y-m-d') || $force) { |
| 385 | + $res = $api->getGoogleRank($api_no, 1, 7, $force); | ||
| 386 | + if (!$res) { | ||
| 386 | throw new \Exception('接口数据获取失败'); | 387 | throw new \Exception('接口数据获取失败'); |
| 387 | } | 388 | } |
| 388 | $data = []; | 389 | $data = []; |
| 389 | //不同的小语种取出来 | 390 | //不同的小语种取出来 |
| 390 | - foreach ($res as $keyword => $v){ | 391 | + foreach ($res as $keyword => $v) { |
| 391 | $data[Arr::last($v)['lang']][$keyword] = $v; | 392 | $data[Arr::last($v)['lang']][$keyword] = $v; |
| 392 | } | 393 | } |
| 393 | - foreach ($data as $lang => $rank){ | 394 | + foreach ($data as $lang => $rank) { |
| 394 | $this->save_rank($project_id, $rank, 0, $lang); | 395 | $this->save_rank($project_id, $rank, 0, $lang); |
| 395 | } | 396 | } |
| 396 | } | 397 | } |
| 397 | } | 398 | } |
| 398 | } | 399 | } |
| 400 | + } | ||
| 399 | 401 | ||
| 400 | /** | 402 | /** |
| 401 | * @param $project_id | 403 | * @param $project_id |
-
请 注册 或 登录 后发表评论