作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

... ... @@ -9,7 +9,9 @@
namespace App\Console\Commands\LyhTest;
use App\Models\Com\NoticeLog;
use App\Models\Project\AiBlogTask;
use App\Models\Project\Project;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
... ... @@ -31,11 +33,9 @@ class lyhDemo extends Command
protected $description = '更新路由';
public function handle(){
$client = new \GuzzleHttp\Client();
$data = $client->request('GET', 'https://quanqiusou.cn/extend_api/v6/update.php?postid='.'13810', [
'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号
])->getBody()->getContents();
$data = json_decode($data, true);
dd($data);
$projectModel = new Project();
$noticeModel = new NoticeLog();
$lists = $projectModel->list(['from_order_id'=>null]);
return true;
}
}
... ...
... ... @@ -269,6 +269,16 @@ class SyncProject extends Command
}
/**
* @remark :生成唯一的13位数字
* @name :stringTo13DigitNumber
* @author :lyh
* @method :post
* @time :2025/3/27 15:09
*/
public function generateUniqueString($input) {
return substr(md5($input), 0, 13);
}
/**
* @remark :设置post_id
* @name :setPostId
* @author :lyh
... ... @@ -299,6 +309,9 @@ class SyncProject extends Command
$param['channel'] = Arr::a2s(["user_id"=>"", "zone_id"=>"", "channel_id"=>""]);
}
$projectModel = new Project();
if(empty($param['from_order_id'])){
$param['from_order_id'] = $this->generateUniqueString($param['notice_order_id']);
}
$info = $projectModel->read(['from_order_id'=>$param['from_order_id'],'delete_status'=>0]);
if($info !== false){
unset($param['type']); //更新的 不更新状态了
... ...
... ... @@ -67,7 +67,7 @@ class SyncSubmitTask extends Command
$task_info->remark = $e->getMessage();
$task_info->save();
$this->output('任务完成');
$this->output('任务完成' . $e->getMessage());
} catch (\Exception $e) {
$task_info->retry = $task_info->retry + 1;
... ...
... ... @@ -980,7 +980,7 @@ class Country
* @method :post
* @time :2025/3/27 10:38
*/
public function getCountryNameByAlpha3($alpha3) {
public static function getCountryNameByAlpha3($alpha3) {
// ISO 3166-1 alpha-3 国家码与国家名称的映射
$countries = [
'AFG' => 'Afghanistan',
... ...
... ... @@ -12,6 +12,7 @@ use App\Models\ASide\APublicModel;
use App\Models\Channel\Channel;
use App\Models\Com\KeywordVideoTask;
use App\Models\Domain\DomainInfo;
use App\Models\HomeCount\AfterCount;
use App\Models\Manage\ManageHr;
use App\Models\Product\Category;
use App\Models\Product\Keyword;
... ... @@ -570,4 +571,15 @@ class OptimizeController extends BaseController
$this->response('success',Code::SUCCESS,$list);
}
/**
* @remark :售后数据统计
* @name :getAfterCount
* @author :lyh
* @method :post
* @time :2025/3/27 17:21
*/
public function getAfterCount(AfterCount $afterCount){
$list = $afterCount->lists($this->map,$this->page,$this->row);
$this->response('success',Code::SUCCESS,$list);
}
}
... ...
<?php
/**
* @remark :
* @name :GoogleSearchController.php
* @author :lyh
* @method :post
* @time :2025/3/27 13:53
*/
namespace App\Http\Controllers\Bside\GoogleKeywordInsight;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Services\GoogleSearchService;
class GoogleSearchController extends BaseController
{
/**
* @remark :google搜索数据
* @name :searchList
* @author :lyh
* @method :post
* @time :2025/3/27 13:59
*/
public function getSearchList(){
$this->request->validate([
'search' => 'required'
],[
'search.required' => '搜索类型不能为空',
]);
//获取当前项目域名
$domain = parse_url($this->user['domain'], PHP_URL_HOST);
$googleService = new GoogleSearchService();
$data = $googleService->googleSearch($domain,$this->param['search']);
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -34,11 +34,13 @@ class BlogCategoryLogic extends BaseLogic
DB::beginTransaction();
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$info = $this->model->read(['id'=>$this->param['id']],['id','alias']);
$id = $this->param['id'];
$this->param['alias'] = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']);
$route = $this->param['alias'];
$this->param['operator_id'] = $this->user['id'];
$this->edit($this->param,['id'=>$id]);
$this->curlDelRoute(['new_route'=>$route ?? '','old_route'=>$info['alias'] ?? '']);
}else{
//路由拼接
if(!isset($this->param['alias']) || empty($this->param['alias'])){
... ... @@ -49,6 +51,7 @@ class BlogCategoryLogic extends BaseLogic
$id = $this->model->addReturnId($this->param);
$route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']);
$this->edit(['alias'=>$route],['id'=>$id]);
$this->curlDelRoute(['new_route'=>$route]);
}
DB::commit();
}catch (\Exception $e){
... ... @@ -56,7 +59,6 @@ class BlogCategoryLogic extends BaseLogic
$this->fail('系统错误,请联系管理');
}
$this->addUpdateNotify(RouteMap::SOURCE_BLOG_CATE,$route);
$this->curlDelRoute(['new_route'=>$route]);
return $this->success(['id'=>$id]);
}
... ...
... ... @@ -30,6 +30,7 @@ class BlogLogic extends BaseLogic
//拼接参数
$this->param = $this->paramProcessing($this->param);
if(isset($this->param['id']) && !empty($this->param['id'])){
$info = $this->model->read(['id'=>$this->param['id']],['id','url']);
$id = $this->param['id'];
$is_upgrade = $this->param['is_upgrade'] ?? 0;//1:5.0数据 0:6.0
$six_read = $this->param['six_read'] ?? 0;//是否按6.0显示
... ... @@ -38,14 +39,15 @@ class BlogLogic extends BaseLogic
}
$route = $this->param['url'];
$this->edit($this->param,['id'=>$id]);
$this->curlDelRoute(['new_route'=>$route ?? '','old_route'=>$info['url'] ?? '']);
}else{
$this->param['sort'] = $this->setNewsSort();
$id = $this->model->addReturnId($this->param);
$route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $id, $this->user['project_id']);
$this->edit(['url'=>$route],['id'=>$id]);
$this->curlDelRoute(['new_route'=>$route]);
}
$this->addUpdateNotify(RouteMap::SOURCE_BLOG,$route);
$this->curlDelRoute(['new_route'=>$route]);
return $this->success(['id'=>$id]);
}
... ...
... ... @@ -63,6 +63,7 @@ class NewsCategoryLogic extends BaseLogic
$this->verifyParamName($this->param['name']);
$this->param = $this->handleParam($this->param);
if(isset($this->param['id']) && !empty($this->param['id'])){
$info = $this->model->read(['id'=>$this->param['id']],['id','alias']);
$id = $this->param['id'];
$this->param['alias'] = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
$route = $this->param['alias'];
... ... @@ -71,6 +72,7 @@ class NewsCategoryLogic extends BaseLogic
}
$this->param['operator_id'] = $this->user['id'];
$this->edit($this->param,['id'=>$id]);
$this->curlDelRoute(['new_route'=>$route ?? '','old_route'=>$info['alias'] ?? '']);
}else{
if(!isset($this->param['alias']) || empty($this->param['alias'])){
$this->param['alias'] = Translate::tran($this->param['name'], 'en');
... ... @@ -82,9 +84,9 @@ class NewsCategoryLogic extends BaseLogic
$id = $this->model->addReturnId($this->param);
$route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
$this->model->edit(['alias'=>$route],['id'=>$id]);
$this->curlDelRoute(['new_route'=>$route]);
}
$this->addUpdateNotify(RouteMap::SOURCE_NEWS_CATE,$route);
$this->curlDelRoute(['new_route'=>$route]);
return $this->success(['id'=>$id]);
}
... ...
... ... @@ -61,6 +61,7 @@ class NewsLogic extends BaseLogic
{
$this->param = $this->paramProcessing($this->param);
if (isset($this->param['id']) && !empty($this->param['id'])) {
$info = $this->model->read(['id'=>$this->param['id']],['id','url']);
$id = $this->param['id'];
$is_upgrade = $this->param['is_upgrade'] ?? 0;//1:5.0数据 0:6.0
$six_read = $this->param['six_read'] ?? 0;//是否按6.0显示
... ... @@ -70,14 +71,15 @@ class NewsLogic extends BaseLogic
//是否更新路由
$route = $this->param['url'];
$this->edit($this->param, ['id' => $id]);
$this->curlDelRoute(['new_route'=>$route ?? '','old_route'=>$info['url'] ?? '']);
} else {
$this->param['sort'] = $this->setNewsSort();
$id = $this->model->addReturnId($this->param);
$route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
$this->edit(['url' => $route], ['id' => $id]);
$this->curlDelRoute(['new_route'=>$route]);
}
$this->addUpdateNotify(RouteMap::SOURCE_NEWS,$route);
$this->curlDelRoute(['new_route'=>$route]);
return $this->success(['id'=>$id]);
}
... ...
... ... @@ -115,20 +115,22 @@ class CategoryLogic extends BaseLogic
public function categorySave(){
$this->param = $this->saveHandleParam($this->param);
if(isset($this->param['id']) && !empty($this->param['id'])){
$info = $this->model->read(['id'=>$this->param['id']],['id','route']);
$id = $this->param['id'];
$this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']);
$route = $this->param['route'];
$this->model->edit($this->param,['id'=>$id]);
$this->curlDelRoute(['new_route'=>$route ?? '','old_route'=>$info['route'] ?? '']);
}else{
$this->param['project_id'] = $this->user['project_id'];
$id = $this->model->addReturnId($this->param);
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']);
$this->edit(['route'=>$route],['id'=>$id]);
$this->curlDelRoute(['new_route'=>$route]);
}
//清除缓存
Common::del_user_cache('product_category',$this->user['project_id']);
$this->addUpdateNotify(RouteMap::SOURCE_PRODUCT_CATE,$route);
$this->curlDelRoute(['new_route'=>$route]);
return $this->success(['id'=>$id]);
}
... ...
... ... @@ -51,7 +51,6 @@ class ProductLogic extends BaseLogic
$this->saveExtendInfo($data['id'],$this->param['extend'] ?? []);//扩展字段
$this->saveDetail($data['id'],$this->param['detail'] ?? []);
$this->addUpdateNotify(RouteMap::SOURCE_PRODUCT,$data['route'] ?? '');
$this->curlDelRoute(['new_route'=>$data['route'] ?? '']);
return $this->success(['id'=>$data['id']]);
}
... ... @@ -73,6 +72,7 @@ class ProductLogic extends BaseLogic
$id = $this->model->addReturnId($param);
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
$this->model->edit(['route'=>$route],['id'=>$id]);
$this->curlDelRoute(['new_route'=>$route ?? '']);
return $this->success(['id'=>$id,'route'=>$route]);
}
... ... @@ -84,6 +84,7 @@ class ProductLogic extends BaseLogic
* @time :2024/12/18 10:09
*/
public function editProduct(){
$info = $this->model->read(['id'=>$this->param['id']],['id','route']);
//处理字段
$param = $this->handleSaveParam($this->param);
$route = $param['route'];
... ... @@ -95,6 +96,7 @@ class ProductLogic extends BaseLogic
$param['route'] = RouteMap::setRoute($param['route'], RouteMap::SOURCE_PRODUCT, $this->param['id'], $this->user['project_id']);
}
$this->model->edit($param,['id'=>$this->param['id']]);
$this->curlDelRoute(['new_route'=>$route ?? '','old_route'=>$info['route'] ?? '']);
return $this->success(['id'=>$this->param['id'],'route'=>$route]);
}
... ...
... ... @@ -10,6 +10,7 @@
namespace App\Models\Com;
use App\Models\Base;
use Illuminate\Support\Facades\Cache;
/**
* @remark :国家信息
... ... @@ -21,4 +22,14 @@ use App\Models\Base;
class WordCountry extends Base
{
protected $table = 'gl_world_country_city';
public static function getCountryByIso2($iso2){
$key = 'getCountryByIso2_' . $iso2;
$info = Cache::get($key);
if (!$info) {
$info = self::where('pid', 0)->where('iso2', $iso2)->first();
Cache::put($key, $info, 24 * 3600);
}
return $info;
}
}
... ...
... ... @@ -100,4 +100,17 @@ class WebLanguage extends Base
return $this->hasOne(CountryCustom::class, 'language_id', 'id');
}
public static function getShorts(){
$key = 'language_shorts';
$list = Cache::get($key);
if (!$list) {
$list = self::pluck('short')->toArray();
if($list){
Cache::put($key, $list, 24 * 3600);
}
}
return $list;
}
}
... ...
... ... @@ -9,6 +9,8 @@
namespace App\Services;
use App\Helper\Country;
/**
* @remark :google关键字扩展
* @name :GoogleSearchService
... ... @@ -21,7 +23,7 @@ class GoogleSearchService
public $url = "";
/**
* @remark :请求数据
* @remark :扩展关键词请求数据
* @name :requestUrl
* @author :lyh
* @method :post
... ... @@ -30,6 +32,30 @@ class GoogleSearchService
public function requestUrl($keyword){
$this->url = 'https://google-keyword-insight1.p.rapidapi.com/globalkey';
$url = $this->url.'/?keyword='.$keyword.'&lang=en';
return $this->curlGoogleApi($url);
}
/**
* @remark :热门关键词拉取
* @name :requestKeywordUrl
* @author :lyh
* @method :post
* @time :2025/3/27 16:57
*/
public function requestKeywordUrl($keyword){
$this->url = 'https://google-keyword-insight1.p.rapidapi.com/topkeys';
$url = $this->url.'/?keyword='.$keyword.'&location=US&&lang=en';
return $this->curlGoogleApi($url);
}
/**
* @remark :请求
* @name :curlGoogleApi
* @author :lyh
* @method :post
* @time :2025/3/27 16:59
*/
public function curlGoogleApi($url){
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $url,
... ... @@ -48,7 +74,7 @@ class GoogleSearchService
$err = curl_error($curl);
curl_close($curl);
if ($err) {
errorLog("关键词扩展cURL Error #:", $url, $err);
errorLog("热门关键词cURL Error #:", $url, $err);
return false;
} else {
return json_decode($response,true);
... ... @@ -61,12 +87,27 @@ class GoogleSearchService
* @author :lyh
* @method :post
* @time :2025/3/27 11:18
* @param :date,query,page,device,country
* @param :date,query,page,device,country/时间、聚合、前页、设备、国家
*/
public function googleSearch($data){
$this->url = 'https://www.cmer.site/api/google/search?domain=www.suertetextile.com&q=';
$url = $this->url.$data;
return http_get($url);
public function googleSearch($domain,$search){
$data = [
1=>'date',
2=>'query',
3=>'page',
4=>'device',
5=>'country'
];
$this->url = 'https://www.cmer.site/api/google/search';
$url = $this->url.'?domain='.$domain.'&q='.$data[$search];
$data = http_get($url);
$data = $data['data'] ?? [];
if(!empty($data) && ($search == 5)){
foreach ($data as $key => $val){
$val['keys_country'] = Country::getCountryNameByAlpha3(strtoupper($val['keys'][0]));
$data[$key] = $val;
}
}
return $data;
}
}
... ...
... ... @@ -4,6 +4,7 @@
namespace App\Services;
use App\Exceptions\InquiryFilterException;
use App\Models\Com\WordCountry;
use App\Models\Domain\CountryCode;
use App\Models\Domain\DomainInfo;
use App\Models\Inquiry\InquiryForm;
... ... @@ -15,6 +16,7 @@ use App\Models\Project\Project;
use App\Models\Subscribe\Email;
use App\Models\SyncSubmitTask\SyncSubmitTask;
use App\Models\Visit\Visit;
use App\Models\WebSetting\WebLanguage;
use App\Models\Workchat\MessagePush;
use App\Utils\LogUtils;
use Illuminate\Support\Facades\Cache;
... ... @@ -74,7 +76,24 @@ class SyncSubmitTaskService
}
}
}
//$data['data']['referrer_url']为空 && 访问小语种 && 访问国家和IP所在国家不匹配 不记录数据
//$data['data']['referrer_url']为空 && 任何小语种 美国都不记
if (empty($data['data']['referrer_url']) && $task['type'] == 'visit') {
$tran_visit = '';
//是否是小语种 二级域名或二级目录
$langs = WebLanguage::getShorts();
foreach ($langs as $lang){
if(Str::contains($data['data']['url'], [$lang . '.' .$data['domain'], $data['domain'] . '/' . $lang. '/'])){
$tran_visit = $lang;
break;
}
}
//直接根据 语种缩写 去匹配 国家简码 不搞麻烦了,将就用
$tran_country = WordCountry::getCountryByIso2($tran_visit)['chinese_name'] ?? '';
if ($tran_visit && $tran_visit !='en' && ($checkIpCountry['country'] == '美国' || $tran_country != $checkIpCountry['country'])) {
throw new InquiryFilterException( '判定为蜘蛛爬取小语种');
}
}
//域名 过滤国家或ip
$domain_info = DomainInfo::getCacheInfoByProjectId($project['id']);
if(!empty($domain_info['not_allow_country'])){
... ...
... ... @@ -302,7 +302,7 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/saveMinorLanguages', [Aside\Optimize\OptimizeController::class, 'saveMinorLanguages'])->name('admin.optimize_saveMinorLanguages');//设置小语种监控开关
Route::any('/editTranslateStatus', [Aside\Optimize\OptimizeController::class, 'editTranslateStatus'])->name('admin.optimize_editTranslateStatus');//设置robots开关
Route::any('/getAnchorLink', [Aside\Optimize\OptimizeController::class, 'getAnchorLink'])->name('admin.optimize_getAnchorLink');//设置robots开关
Route::any('/getAfterCount', [Aside\Optimize\OptimizeController::class, 'getAfterCount'])->name('admin.optimize_getAfterCount');//设置robots开关
});
//生成关键字
Route::prefix('create_keyword')->group(function () {
... ...
... ... @@ -700,7 +700,10 @@ Route::middleware(['bloginauth'])->group(function () {
Route::prefix('google_keyword_insight')->group(function () {
Route::any('/getKeywordInsight', [\App\Http\Controllers\Bside\GoogleKeywordInsight\GoogleKeywordInsightController::class, 'getKeywordInsight'])->name('google_keyword_insight_getKeywordInsight');
});
//google搜索数据
Route::prefix('google_search')->group(function () {
Route::any('/getSearchList', [\App\Http\Controllers\Bside\GoogleKeywordInsight\GoogleSearchController::class, 'getSearchList'])->name('google_search_getSearchList');
});
//企业产品库
Route::prefix('enterprise_product')->group(function () {
Route::any('/getEnterProduct', [\App\Http\Controllers\Bside\SeoSetting\EnterpriseProductController::class, 'getEnterProduct'])->name('enterprise_product_getEnterProduct');
... ...