作者 赵彬吉
... ... @@ -61,7 +61,7 @@ class AiBlogTask extends Command
//保存当前项目ai_blog数据
ProjectServer::useProject($info['project_id']);
$aiBlogModel = new AiBlog();
$aiBlogModel->edit(['new_title'=>$result['data']['title'] ?? '','text'=>$result['data']['text'] ?? '','status'=>2],['task_id'=>$info['task_id']]);
$aiBlogModel->edit(['new_title'=>$result['data']['title'],'image'=>$result['data']['thumb'],'text'=>$result['data']['section'],'status'=>2],['task_id'=>$info['task_id']]);
DB::disconnect('custom_mysql');
echo '结束->任务id:' . $info['task_id'] . PHP_EOL . date('Y-m-d H:i:s');
}
... ...
<?php
/**
* @remark :
* @name :ForwardInquiryCount.php
* @author :lyh
* @method :post
* @time :2023/8/18 9:41
*/
namespace App\Console\Commands\MonthlyCount;
use App\Models\Inquiry\ForwardCount;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
/**
* @remark :转发询盘人员统计
* @name :ForwardInquiryCount
* @author :lyh
* @method :post
* @time :2023/8/18 9:42
*/
class ForwardInquiryCount extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'forward_count';
/**
* The console command description.
*
* @var string
*/
protected $description = '月转发报告统计';
/**
* @remark :统计报告
* @name :handle
* @author :lyh
* @method :post
* @time :2023/8/18 9:52
*/
public function handle(){
// 获取上个月的开始时间
$startTime = Carbon::now()->subMonth()->startOfMonth()->toDateString();
// 获取上个月的结束时间
$endTime = Carbon::now()->subMonth()->endOfMonth()->toDateString();
$list = DB::table('gl_inquiry_info')->groupBy('user_name')
->select("user_name",DB::raw('COUNT(*) as count'))
->where('send_time','>=',$startTime.' 00:00:00')
->where('send_time','<=',$endTime.' 23:59:59')
->get();
if(!empty($list)){
$list = $list->toArray();
$forwardModel = new ForwardCount();
foreach ($list as $v){
$data = [
'date'=>Carbon::now()->subMonth()->format('Y-m'),
'name'=>$v['user_name'],
'count'=>$v['count']
];
$forwardModel->add($data);
}
}
return 1;
}
}
... ... @@ -26,7 +26,6 @@ class Kernel extends ConsoleKernel
// $schedule->command('web_traffic_special')->everyMinute()->withoutOverlapping(1); // 特殊引流
// $schedule->command('web_traffic_russia_special')->everyMinute()->withoutOverlapping(1); // 特殊引流
$schedule->command('sync_channel')->dailyAt('06:00')->withoutOverlapping(1); // 渠道信息,每天执行一次
$schedule->command('forward_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计转发询盘记录
// $schedule->command('inquiry_delay')->everyMinute()->withoutOverlapping(1);//TODO::上线放开,转发询盘,每分钟执行一次
$schedule->command('inquiry_count')->dailyAt('01:00')->withoutOverlapping(1); // 询盘统计数据,每天凌晨执行一次
// $schedule->command('domain_info')->dailyAt('01:20')->withoutOverlapping(1);// 更新域名|证书结束时间,每天凌晨1点执行一次
... ...
... ... @@ -2,11 +2,13 @@
namespace App\Http\Logic\Bside\Ai;
use App\Helper\Translate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Ai\AiBlog;
use App\Models\Project\AiBlogTask;
use App\Models\Project\Project;
use App\Models\Project\ProjectAiSetting;
use App\Models\RouteMap\RouteMap;
use App\Services\AiBlogService;
class AiBlogLogic extends BaseLogic
... ... @@ -50,6 +52,9 @@ class AiBlogLogic extends BaseLogic
$aiBlogService = new AiBlogService();
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
$aiBlogService->key = $aiSettingInfo['key'];
if(!empty($this->param['route'])){
$aiBlogService->route = generateRoute(Translate::tran($this->param['route'], 'en'));
}
$result = $aiBlogService->createTask($this->param['keyword'],$this->param['type']);
if($result['status'] == 200){
try {
... ...
... ... @@ -362,6 +362,7 @@ class KeywordLogic extends BaseLogic
$routeMapModel->del(['source'=>'product_keyword']);
$productModel = new Product();
$productModel->edit(['keyword_id'=>''],['id'=>['>',0]]);
$this->curlDelRoute(['old_route'=>'all_product_keyword']);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
... ...
... ... @@ -17,7 +17,7 @@ class AiBlogService
public $sign = '';//签名
public $key = 'b3e4c722b821';//默认key
public $webhook = 'https://develop.globalso.com/api/ai_webhook';//回调地址
public $route = '';//回调地址
public $task_id = '';//任务id
/**
... ... @@ -69,14 +69,14 @@ class AiBlogService
* @time :2025/2/13 14:39
* @param :type=(1作者2文章) keyword=关键词 subtype=blog url=回调url
*/
public function createTask($keyword,$type = 1,$subtype = 'Blog',$template_id = 1){
public function createTask($keyword,$type = 2,$subtype = 'Blog',$template_id = 1){
$request_url = $this->url.'api/task/create';
$param = [
'mch_id'=>$this->mch_id,
'keyword'=>$keyword,
'type'=>$type,
'subtype'=>$subtype,
'url'=>$this->webhook,
'url'=>$this->route,
'template_id'=>$template_id
];
$this->sign = $this->generateSign($param,$this->key);
... ...