作者 刘锟

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

<?php
/**
* @remark :
* @name :AiDomainTask.php
* @author :lyh
* @method :post
* @time :2025/6/19 10:53
*/
namespace App\Console\Commands\Ai;
use App\Models\Domain\DomainInfo;
use Illuminate\Console\Command;
/**
* @remark :拉取项目Ai域名
* @name :AiDomainTask
* @author :lyh
* @method :post
* @time :2025/6/19 10:54
*/
class AiDomainTask extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'ai_domain';
/**
* The console command description.
*
* @var string
*/
protected $description = '获取对应域名的ai复制站域名';
public $url = 'https://www.cmer.site/api/globalso_site';
/**
* @remark :执行方法
* @name :handle
* @author :lyh
* @method :post
* @time :2025/6/19 11:32
*/
public function handle(){
$pageSize = 300;
$page = 1;
$res = http_get($this->url.'?pagesize='.$pageSize.'&page='.$page);
if($res['status'] != 200){
echo date('Y-m-d H:i:s').'请求失败,状态码错误'.PHP_EOL;
return false;
}
if(empty($res['data']['data'])){
echo date('Y-m-d H:i:s').'请求失败,未拉取到数据'.PHP_EOL;
return false;
}
$data = $res['data']['data'];
while($page <= $res['data']['last_page']){
$res = http_get($this->url.'?pagesize='.$pageSize.'&page='.$page);
if($res['status'] != 200){
echo date('Y-m-d H:i:s').'第'.$page.'请求失败,未拉取到数据'.PHP_EOL;
return false;
}
$data = array_values(array_merge($data,$res['data']['data']));
$page++;
}
//处理数据
$this->handleData($data);
echo 'end'.PHP_EOL;
return true;
}
/**
* @remark :处理数据
* @name :handleData
* @author :lyh
* @method :post
* @time :2025/6/19 11:21
*/
public function handleData($data){
$domainInfoModel = new DomainInfo();
foreach ($data as $item){
$info = $domainInfoModel->read(['domain'=>$item['domain']],'id');
if($info === false){
$info = $domainInfoModel->read(['domain'=>$item['globalso_domain']],'id');
if($info !== false){
$domainInfoModel->edit(['ai_domain'=>$item['domain']],['id'=>$info['id']]);
}
}else{
$domainInfoModel->edit(['ai_domain'=>$item['globalso_domain']],['id'=>$info['id']]);
}
}
return true;
}
}
... ...
... ... @@ -736,7 +736,12 @@ class RelayInquiry extends Command
// 所有可用url
$urls = $inquiry_urls = [];
//入口url 首页30%,单页10%,聚合页60%
$type = getRandByRatio([40,20,40]);
if ($re_website == 'https://www.hikelok.com/') {
$type = getRandByRatio([50,49,1]);
} else {
$type = getRandByRatio([40,20,40]);
}
$inlet = $re_website;
$type == 1 && $inlet = $page_url ? Arr::random($page_url) : $re_website;
$type == 2 && $inlet = $keywords_url ? Arr::random($keywords_url) : $re_website;
... ...
... ... @@ -52,9 +52,9 @@ class LyhImportTest extends Command
* @time :2023/11/20 15:13
*/
public function handle(){
ProjectServer::useProject(3951);
ProjectServer::useProject(3654);
echo date('Y-m-d H:i:s') . 'start' . PHP_EOL;
$this->import2140CustomModule('https://ecdn6.globalso.com/upload/p/2140/file/2025-05/daoru.csv',3951);
$this->importProductCategory('https://ecdn6-nc.globalso.com/upload/p/3654/file/2025-06/products-1.csv',3654);
DB::disconnect('custom_mysql');
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
... ... @@ -129,23 +129,43 @@ class LyhImportTest extends Command
if($k < 1){
continue;
}
if(empty($val[1])){
echo '跳过的名称:'.$val[1];
if(empty($val[0])){
echo '跳过的名称:'.$val[0];
continue;
}
try {
$categoryModel->edit(['sort'=>$val[1]],['title'=>$val[0]]);
// $id = $categoryModel->addReturnId(['project_id'=>$project_id,'title'=>$val[1],'seo_title'=>$val[0],'seo_des'=>$val[2]]);
// $pid = 0;
// if($val[2] != 0){
// //查询上级id
// $pidCate = $categoryModel->read(['seo_title'=>$val[2]]);
// if($pidCate !== false){
// $pid = $pidCate['id'];
// }
// }
// $route = RouteMap::setRoute($val[1],RouteMap::SOURCE_PRODUCT_CATE,$id,$project_id);
// $categoryModel->edit(['route'=>$route,'pid'=>$pid],['id'=>$id]);
$cateArr = explode('/',$val[0]);
$pid = 0;
$two_pid = 0;
foreach ($cateArr as $key => $item){
if($key == 0){
//查看一级分类是否存在
$info = $categoryModel->read(['title'=>$item,'pid'=>0],['id']);
if($info === false){
$pid = $categoryModel->addReturnId(['project_id'=>$project_id,'title'=>$item]);
//设置路由
$route = RouteMap::setRoute($item,RouteMap::SOURCE_PRODUCT_CATE,$pid,$project_id);
$categoryModel->edit(['route'=>$route],['id'=>$pid]);
}else{
$pid = $info['id'];
}
}elseif ($key == 1){
//查看当前下面的子级别是否存在
$two_info = $categoryModel->read(['title'=>$item,'pid'=>$pid],['id']);
if($two_info === false){
$two_pid = $categoryModel->addReturnId(['project_id'=>$project_id,'title'=>$item,'pid'=>$pid]);
//设置路由
$route = RouteMap::setRoute($item,RouteMap::SOURCE_PRODUCT_CATE,$two_pid,$project_id);
$categoryModel->edit(['route'=>$route],['id'=>$two_pid]);
}else{
$two_pid = $two_info['id'];
}
}else{
$id = $categoryModel->addReturnId(['project_id'=>$project_id,'title'=>$item,'pid'=>$two_pid]);
$route = RouteMap::setRoute($item,RouteMap::SOURCE_PRODUCT_CATE,$id,$project_id);
$categoryModel->edit(['route'=>$route],['id'=>$id]);
}
}
echo date('Y-m-d H:i:s') . '产品分类id:'.PHP_EOL;
}catch (\Exception $e){
echo date('Y-m-d H:i:s') . '跳过的名称:'. $val[1];
... ...
... ... @@ -58,28 +58,7 @@ class lyhDemo extends Command
protected $description = '更新路由';
public function handle(){
$projectModel = new Project();
$buildModel = new DeployBuild();
$lists = $projectModel->list(['delete_status' => 0,'project_type'=>0,'is_upgrade'=>0,'id'=>['<',1659],'extend_type'=>0,'type'=>['in',[1,2,3,4,6]]], 'id', ['id','notice_order_id']);
foreach ($lists as $item){
echo date('Y-m-d H:i:s') . '开始--项目的id:'. $item['id'] . PHP_EOL;
try {
if(!empty($item['notice_order_id'])){
$api = new OaGlobalsoApi();
$data = $api->order_info($item['notice_order_id']);
if(!empty($data)){
if(isset($data['data']['ads_price'])){
echo '奖励金额:'.$data['data']['ads_price'].PHP_EOL;
$buildModel->edit(['ads_price'=>$data['data']['ads_price'] ?? 0],['project_id'=>$item['id']]);
}
}
}
}catch (\Exception $e){
continue;
}
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . '结束。。。' . PHP_EOL;
}
public function _actionTemplateMain(){
... ...
... ... @@ -183,6 +183,7 @@ class CountAllProject extends Command
}
}
$channel = Channel::getChannelText($v['channel']['user_id'] ?? 0);
$plan = Project::planMap();
$data[] = [
'project_id'=>$v['id'],
'version'=>1,//代表6.0
... ... @@ -196,7 +197,7 @@ class CountAllProject extends Command
'keywords_num'=>$v['key'],
'service_num'=>$v['day'],
'production_num'=>intval(abs((empty($v['uptime']) ? time() : strtotime($v['uptime'])) - strtotime($v['created_at'])) / 86400),
'plan'=>Project::planMap()[$v['plan']],
'plan'=>$plan[$v['plan']] ?? '无版本信息',
'status'=>$type,
'category'=>$category,
'is_admin5' => 6,
... ...
... ... @@ -51,11 +51,12 @@ class GeneratePage extends Command
{
$noticeModel = new NoticeLog();
while (true){
$noticeInfo = $noticeModel->read(['status'=>0,'type'=>$noticeModel::GENERATE_PAGE,'start_at'=>['<=',date('Y-m-d H:i:s')]]);
$task_id = $this->getTaskId();
if (empty($noticeInfo)) {
sleep(10);
continue;
}
$noticeInfo = $noticeModel->read(['id'=>$task_id]);
try {
$this->output(' taskID: ' . $noticeInfo['id'] . ' start');
$notice_data = json_decode($noticeInfo['data'],true);
... ... @@ -80,6 +81,28 @@ class GeneratePage extends Command
return true;
}
/**
* @remark :获取任务id
* @name :getTaskId
* @author :lyh
* @method :post
* @time :2025/6/19 10:02
*/
public function getTaskId()
{
$task_id = Redis::rpop('generate_page_id');
if (empty($task_id)) {
$noticeModel = new NoticeLog();
$ids = $noticeModel->selectField(['status'=>0],'id');
if(!empty($ids)){
foreach ($ids as $id) {
Redis::lpush('generate_page_id', $id);
}
}
$task_id = Redis::rpop('generate_page_id');
}
return $task_id;
}
/**
* 输出message
... ...
... ... @@ -61,7 +61,7 @@ if (!function_exists('http_post')) {
* @param type $url
* @param type $post_data
*/
function http_post($url, $post_data, $header = [],$is_json = true)
function http_post($url, $post_data, $header = [],$is_json = true,$timeout = 60)
{
if (empty($header)) {
$header = array(
... ... @@ -73,6 +73,7 @@ if (!function_exists('http_post')) {
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
... ... @@ -1189,7 +1190,7 @@ function getDeployOptimize($project_id){
$info = Cache::get($cache_key);
if(!$info){
$projectOptimizeModel = new DeployOptimize();
$info = $projectOptimizeModel->read(['project_id' => $project_id], ['id', 'company_en_name', 'company_en_description', 'keyword_prefix', 'keyword_suffix']);
$info = $projectOptimizeModel->read(['project_id' => $project_id], ['id', 'company_en_name', 'company_en_description', 'keyword_prefix', 'keyword_suffix', 'special']);
$projectKeywordModel = new ProjectKeyword();
$keywordInfo = $projectKeywordModel->read(['project_id'=>$project_id]);
$info['main_keyword'] = '';
... ...
... ... @@ -142,7 +142,7 @@ class IndexController extends BaseController
Cache::add($token,$info,12 * 3600);
$languageModel = new WebLanguage();
$languageInfo = $languageModel->read(['id'=>$info['main_lang_id']],['short','english','chinese']);
$data = ['token'=>$token,'main_lang_id'=>$info['main_lang_id'],'language_info'=>$languageInfo];
$data = ['token'=>$token,'main_lang_id'=>$info['main_lang_id'],'language_info'=>$languageInfo,'project_seo_type'=>$info['project_seo_type']];
$this->response('success',Code::SUCCESS,$data);
}
... ...
... ... @@ -51,10 +51,10 @@ class UpdateController extends BaseController
if (empty($info['company_en_description'])) {
$this->fail('公司英文描述未设置');
}
if (empty($info['keyword_prefix'])) {
if (empty($info['keyword_prefix']) && !in_array(8, explode(',', $info['special']))) {
$this->fail('前缀关键词未设置');
}
if (empty($info['keyword_suffix'])) {
if (empty($info['keyword_suffix']) && !in_array(8, explode(',', $info['special']))) {
$this->fail('后缀关键词未设置');
}
try {
... ...
... ... @@ -234,6 +234,7 @@ class OptimizeController extends BaseController
'gl_project_deploy_optimize.first_compliance_time AS first_compliance_time',
'gl_domain_info.amp_status AS amp_status',
'gl_domain_info.domain AS domain',
'gl_domain_info.ai_domain AS ai_domain',
];
return $select;
}
... ... @@ -262,6 +263,9 @@ class OptimizeController extends BaseController
if(isset($this->map['ai_video']) && !empty($this->map['ai_video'])){
$query = $query->where('gl_project_deploy_optimize.ai_video',$this->map['ai_video']);
}
if(isset($this->map['ai_domain']) && !empty($this->map['ai_domain'])){
$query = $query->whereNotNull('gl_domain_info.ai_domain');
}
if(isset($this->map['amp_status'])){
$query = $query->where('gl_domain_info.amp_status',$this->map['amp_status']);
}
... ...
... ... @@ -61,6 +61,7 @@ class ProjectController extends BaseController
->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
->leftJoin('gl_project_online_check', 'gl_project.id', '=', 'gl_project_online_check.project_id')
->leftJoin('gl_web_setting_template', 'gl_project.id', '=', 'gl_web_setting_template.project_id')
->leftJoin('gl_project_association', 'gl_project.id', '=', 'gl_project_association.project_id')
->where('gl_project.delete_status',Project::TYPE_ZERO);
$query = $this->searchParam($query);
$query = $this->orderByList($query);
... ... @@ -122,6 +123,7 @@ class ProjectController extends BaseController
'gl_project_deploy_optimize.design_mid AS design_mid',
'gl_project_deploy_optimize.api_no AS api_no',
'gl_web_setting_template.template_id AS template_id',
'gl_project_association.friend_id as friend_id',
];
return $select;
}
... ... @@ -172,7 +174,7 @@ class ProjectController extends BaseController
*/
public function searchType(&$query){
if(isset($this->map['type'])){
$query->where('gl_project.extend_type', '!=' ,5);
$query->where('gl_project.extend_type', '!=' ,5)->where('gl_project.extend_type', '!=' ,8);
if (in_array($this->map['type'], [Project::TYPE_ZERO, Project::TYPE_ONE, Project::TYPE_TWO, Project::TYPE_THREE])){
$query->where('gl_project.type', $this->map['type']);
} elseif ($this->map['type'] == 8){
... ... @@ -295,6 +297,16 @@ class ProjectController extends BaseController
if(isset($this->map['plan'])){
$query = $query->where('gl_project_deploy_build.plan',$this->map['plan']);
}
if(isset($this->map['friend_id'])){
if($this->map['friend_id'] == 1){
$query = $query->where('gl_project_association.friend_id', '!=', 0);
}else{
$query = $query->where(function ($subQuery) {
$subQuery->where('gl_project_association.friend_id', 0)
->orWhereNull('gl_project_association.friend_id');
});
}
}
if(isset($this->map['seo_plan'])){
$query = $query->where('gl_project_deploy_build.seo_plan',$this->map['seo_plan']);
}
... ...
... ... @@ -210,7 +210,7 @@ class CNoticeController extends BaseController
* 更新通知C端
* @param Request $request
* @return \Illuminate\Http\JsonResponse
* @param : type : 1->主站更新 4->聚合页更新
* @param : type : 1->主站更新 4->聚合页更新 7->ai博客
*/
public function sendNotify(Request $request)
{
... ... @@ -301,8 +301,11 @@ class CNoticeController extends BaseController
'language'=> $language,
'is_sitemap' => $is_sitemap
];
// http_post($c_url, json_encode($c_param));
NoticeLog::createLog(NoticeLog::GENERATE_PAGE, json_encode(['c_url'=>$c_url,'c_params'=>$c_param]));
try {
http_post($c_url, json_encode($c_param));
}catch (\Exception $e){
NoticeLog::createLog(NoticeLog::GENERATE_PAGE, json_encode(['c_url'=>$c_url,'c_params'=>$c_param]));
}
}
$this->response('更新中请稍后, 更新完成将会发送站内信通知更新结果!');
}
... ...
... ... @@ -93,7 +93,7 @@ class OperationHeartbeatController extends BaseController
if($info === false){
$info = [];
}else{
$date_time = strtotime($info['updated_at']) + 120;
$date_time = strtotime($info['updated_at']) + 60;
if($date_time < time()){
$operationHeartbeatModel->edit(['status'=>0,'ip'=>'127.0.0.1'],$condition);
$info['status'] = 0;
... ...
... ... @@ -359,7 +359,7 @@ class ProductController extends BaseController
}
if (!empty($new_content)){
$detailModel = new Detail();
$detailInfo = $detailModel->read(['column_id'=>1]);
$detailInfo = $detailModel->read(['column_id'=>1,'product_id'=>$this->param['product_id']]);
if($detailInfo !== false && !empty($detailInfo['content'])){
$productInfo['content'] = $new_content . $detailInfo['content']['content'];
}
... ...
... ... @@ -70,7 +70,7 @@ class LoginLogic extends BaseLogic
// Cache::pull(Common::MANAGE_TOKEN . $manage['token']);
// }
//生成新token
$token = md5(uniqid().$manage['id']);
$token = $manage['id'].'_a'.md5(uniqid().$manage['id']);
unset($manage['password']);
//更新用户信息
$manage->token = $token;
... ...
... ... @@ -90,7 +90,7 @@ class UserLoginLogic
Cache::pull($info['token']);
}
//生成新token
$token = md5(uniqid().$info['id']);
$token = $info['id'].'_b'.md5(uniqid().$info['id']);
//存储缓存
$info['token'] = $token;
Cache::add($token,$info,3600 * 12);
... ...