作者 赵彬吉
... ... @@ -82,7 +82,7 @@ class AiBlogAuthorTask extends Command
DB::disconnect('custom_mysql');
//修改任务状态
$aiBlogTaskModel->edit(['status'=>2],['id'=>$info['id']]);
echo '结束->任务id:' . $info['task_id'] . PHP_EOL . date('Y-m-d H:i:s');
echo '结束->任务id:' . $info['id'] . PHP_EOL . date('Y-m-d H:i:s');
}
return true;
}
... ... @@ -119,22 +119,33 @@ class AiBlogAuthorTask extends Command
}
$aiBlogAuthorModel = new AiBlogAuthor();
foreach ($data as $v){
//查询当前数据是否存在
$info = $aiBlogAuthorModel->read(['author_id'=>$v['id']]);
if($info === false){
$param = [
'author_id'=>$v['id'],
'title'=>$v['title'],
'image'=>str_replace_url($v['picture']),
'description'=>$v['description'],
];
//查询当前数据是否存在
$info = $aiBlogAuthorModel->read(['author_id'=>$v['id']]);
try {
if($info === false){
echo '执行新增'.PHP_EOL;
$id = $aiBlogAuthorModel->addReturnId($param);
$route = RouteMap::setRoute($v['route'] ?? $v['title'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $id, $project_id);
$aiBlogAuthorModel->edit(['route'=>$route],['id'=>$id]);
$param['route'] = RouteMap::setRoute($v['route'] ?? $v['title'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $id, $project_id);
$aiBlogAuthorModel->edit(['route'=>$param['route']],['id'=>$id]);
}else{
$param['route'] = RouteMap::setRoute($v['route'] ?? $v['title'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $info['id'], $project_id);
$aiBlogAuthorModel->edit($param,['id'=>$info['id']]);
echo '执行更新'.PHP_EOL;
}
$aiSettingInfo = $this->getSetting($project_id);
$aiBlogService = new AiBlogService();
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
$aiBlogService->key = $aiSettingInfo['key'];
$aiBlogService->updateAuthorInfo(['author_id'=>$param['author_id'],'route'=>$param['route'],'title'=>$param['title'],'picture'=>$param['image'],'description'=>$param['description']]);
}catch (\Exception $e){
echo 'error:'.$e->getMessage();
}
continue;
}
}
return true;
... ...
... ... @@ -9,10 +9,15 @@
namespace App\Console\Commands\Ai;
use App\Helper\Arr;
use App\Models\Ai\AiBlog;
use App\Models\Ai\AiBlogAuthor;
use App\Models\Ai\AiBlogList;
use App\Models\Com\Notify;
use App\Models\Devops\ServerConfig;
use App\Models\Devops\ServersIp;
use App\Models\Domain\DomainInfo;
use App\Models\Project\Project;
use App\Models\Project\ProjectAiSetting;
use App\Models\RouteMap\RouteMap;
use App\Services\AiBlogService;
... ... @@ -212,8 +217,41 @@ class AiBlogTask extends Command
//获取项目域名
$domain = $domainModel->getProjectIdDomain($project_id);
if(!empty($domain)){
//判断是否是自建站服务器,如果是,不请求C端接口,数据直接入库
$project_model = new Project();
$project_info = $project_model->read(['id'=>$project_id],['serve_id']);
if(!$project_info){
echo '项目不存在:' . $project_id . PHP_EOL . date('Y-m-d H:i:s');
return true;
}
$serve_ip_model = new ServersIp();
$serve_ip_info = $serve_ip_model->read(['id'=>$project_info['serve_id']],['servers_id']);
$servers_id = $serve_ip_info ? $serve_ip_info['servers_id'] : 0;
if($servers_id == ServerConfig::SELF_SITE_ID){
//判断是否已有更新进行中
$notify_model = new Notify();
$data = [
'project_id' => $project_id,
'type' => Notify::TYPE_MASTER,
'route' => Notify::ROUTE_AI_BLOG,
'server_id' => ServerConfig::SELF_SITE_ID,
'status' => ['!=',Notify::STATUS_FINISH_SITEMAP]
];
$notify = $notify_model->read($data,['id']);
if(!$notify){
$domain_array = parse_url($domain);
$data['data'] = Arr::a2s(['domain'=>$domain_array['host'],'url'=>[],'language'=>[]]);
$data['status'] = Notify::STATUS_INIT;
$data['sort'] = 2;
$notify_model->add($data);
}
echo '自建站项目:'.$project_id.'更新';
}else{
$url = $domain.'api/update_page/?project_id='.$project_id.'&route=7';
shell_exec('curl -k "'.$url.'"');
$res = http_get($url);
echo '返回数据:'.json_encode($res,true).PHP_EOL;
}
}else{
echo '域名不存在:' . $project_id . PHP_EOL . date('Y-m-d H:i:s');
}
... ...
... ... @@ -240,7 +240,7 @@ class PostInquiryForward extends Command
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36');
... ... @@ -280,7 +280,7 @@ class PostInquiryForward extends Command
$data['__amp_source_origin'] = trim($website, '/');
}
$url = $website . 'api/inquiryQd?source=5';
$res = Http::withoutVerifying()->timeout(30)->withHeaders(['User-Agent' => $detail['user_agent']])->post($url, $data)->json();
$res = Http::withoutVerifying()->timeout(60)->withHeaders(['User-Agent' => $detail['user_agent']])->post($url, $data)->json();
if (empty($res['code']) || $res['code'] != 200) {
$log->status = InquiryRelayDetailLog::STATUS_FAIL;
$log->remark = mb_substr($res['message'] ?? '', 0, 200);
... ... @@ -307,7 +307,7 @@ class PostInquiryForward extends Command
'submit_time' => date('Y-m-d H:i:s', time() + 60)
];
$url = 'https://' . $detail['website'] . '/wp-admin/admin-ajax.php?action=live_remort_receive';
$res = Http::withoutVerifying()->timeout(30)->withHeaders(['User-Agent' => $detail['user_agent']])->post($url, $data);
$res = Http::withoutVerifying()->timeout(60)->withHeaders(['User-Agent' => $detail['user_agent']])->post($url, $data);
$status = $res->status();
if ($status != 200) {
$log->status = InquiryRelayDetailLog::STATUS_FAIL;
... ... @@ -330,7 +330,7 @@ class PostInquiryForward extends Command
'source' => 5,
];
$url = 'https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f';
$res = Http::withoutVerifying()->timeout(30)->withHeaders(['User-Agent' => $detail['user_agent']])->post($url, $data)->json();
$res = Http::withoutVerifying()->timeout(60)->withHeaders(['User-Agent' => $detail['user_agent']])->post($url, $data)->json();
if (empty($res['status']) || $res['status'] != 200) {
$log->status = InquiryRelayDetailLog::STATUS_FAIL;
$log->remark = mb_substr($res['message'] ?? '', 0, 200);
... ...
... ... @@ -530,16 +530,18 @@ class UpdateRoute extends Command
$seoModel = new WebSettingSeo();
$seo_info = $seoModel->read(['project_id'=>$project_id]);
if($seo_info !== false){
$prefix = $seo_info['product_category_prefix'] ?? [];
$suffix = $seo_info['product_category_suffix'] ?? [];
$prefix = [];
$suffix = [];
if(!empty($seo_info['product_cate_prefix'])){
$prefix[] = ['name'=>$seo_info['product_cate_prefix']];
$prefix[] = ['val'=>[$seo_info['product_cate_prefix']],'level'=>1];
}
if(!empty($seo_info['product_cate_suffix'])){
$suffix[] = ['name'=>$seo_info['product_cate_suffix']];
$suffix[] = ['val'=>[$seo_info['product_cate_suffix']],'level'=>1];
}
if(!empty($prefix) && !empty($suffix)){
$seoModel->edit(['product_category_prefix'=>json_encode($prefix,true),'product_category_suffix'=>json_encode($suffix,true)],['project_id'=>$project_id]);
}
}
return true;
}
}
... ...
... ... @@ -314,17 +314,17 @@ class PrivateController extends BaseController
ProjectServer::useProject($project->id);
$result = [];
// 查询有效时间后 有效的产品、新闻、博客、聚合页 链接
$product = Product::where(['status' => Product::STATUS_ON])->where('created_at', '>=', $date)->pluck('route');
// $product = Product::where(['status' => Product::STATUS_ON])->where('created_at', '>=', $date)->pluck('route');
$news = News::where(['status' => News::STATUS_ONE])->where('release_at', '>', $date)->pluck('url');
$blog = Blog::where(['status' => Blog::STATUS_ONE])->where('release_at', '>', $date)->pluck('url');
// $keyword = Keyword::where('created_at', '>', $date)->pluck('route');
$ai_blog = AiBlog::where(['status' => AiBlog::STATUS_FINISH])->where('updated_at', '>=', $date)->pluck('route');
// 组装链接
foreach ($product as $item) {
$url = 'https://' . $domain . '/' . $item;
array_push($result, $url);
}
// foreach ($product as $item) {
// $url = 'https://' . $domain . '/' . $item;
// array_push($result, $url);
// }
// foreach ($keyword as $item) {
// $url = 'https://' . $domain . '/' . $item;
// array_push($result, $url);
... ...
... ... @@ -10,6 +10,7 @@ use App\Models\Project\AiBlogTask;
use App\Models\Project\ProjectAiSetting;
use App\Models\RouteMap\RouteMap;
use App\Services\AiBlogService;
use Illuminate\Support\Facades\Cache;
class AiBlogLogic extends BaseLogic
{
... ... @@ -28,11 +29,16 @@ class AiBlogLogic extends BaseLogic
* @time :2025/2/21 14:51
*/
public function getProjectAiSetting(){
$ai_cache = Cache::get('ai_blog_'.$this->user['project_id']);
if($ai_cache){
return $ai_cache;
}
$projectAiSettingModel = new ProjectAiSetting();
$aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$this->user['project_id']]);
if($aiSettingInfo === false){
$this->fail('请先联系管理员开启Ai博客');
}
Cache::put('ai_blog_'.$this->user['project_id'],$aiSettingInfo,3600);
return $aiSettingInfo;
}
... ... @@ -76,8 +82,11 @@ class AiBlogLogic extends BaseLogic
}
$this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $this->param['id'], $this->user['project_id']);
$aiAuthorModel->edit($this->param,['id'=>$this->param['id']]);
$aiSettingInfo = $this->getProjectAiSetting();
$aiBlogService = new AiBlogService();
$aiBlogService->updateAuthorInfo(['author_id'=>$this->param['author_id'],'title'=>$this->param['title'],'picture'=>$this->param['image'],'description'=>$this->param['description']]);
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
$aiBlogService->key = $aiSettingInfo['key'];
$aiBlogService->updateAuthorInfo(['author_id'=>$this->param['author_id'],'route'=>$this->param['route'],'title'=>$this->param['title'],'picture'=>$this->param['image'],'description'=>$this->param['description']]);
}catch (\Exception $e){
$this->fail('保存失败,请联系管理员');
}
... ...
... ... @@ -63,7 +63,10 @@ class UserLoginLogic
$projectArr[] = $v['project_id'];
}
$projectModel = new Project();
$project_list = $projectModel->list(['id'=>['in',$projectArr],'delete_status'=>0],'id',['id','title']);
$project_list = $projectModel->list(['id'=>['in',$projectArr],'type'=>['!=',8],'delete_status'=>0],'id',['id','title']);
if(empty($project_list)){
$this->fail('当前项目已关闭,请联系管理员');
}
foreach ($project_list as $k => $v){
$v['domain'] = (new DomainInfo())->getProjectIdDomain($v['id']);
$project_list[$k] = $v;
... ... @@ -181,12 +184,15 @@ class UserLoginLogic
* @time :2023/8/29 15:26
*/
public function assembleParam($mobile,$project_id){
$info = $this->model->read(['mobile'=>$mobile,'project_id'=>$project_id],['id','mobile','status','role_id','token','name','wechat','project_id']);
$info = $this->model->read(['mobile'=>$mobile,'project_id'=>$project_id],['id','mobile','status','type','role_id','token','name','wechat','project_id']);
//获取项目详情
$project = $this->getProjectInfo($project_id);
if($project['site_status'] != 0){//关闭站点
$this->fail('当前网站已过期,请联系管理员及时续费。');
}
if($project['type'] == 8){//关闭项目
$this->fail('当前网站已关闭,请联系管理员。');
}
$info = $this->handleInfo($info,$project);
$info['login_source'] = User::LOGIN_PASSWORD_SOURCE;//账号密码登录返回
//保存项目缓存
... ...
... ... @@ -91,7 +91,8 @@ class Project extends Base
4 => '推广续网站',
5 => '未续费项目',
6 => '特殊推广项目',
7 => '提单错误转续费'
7 => '提单错误转续费',
8 => '关闭项目',
];
}
... ...