作者 lyh

gx脚本

... ... @@ -9,9 +9,11 @@
namespace App\Console\Commands\ProjectWeeklyReport;
use App\Helper\FormGlobalsoApi;
use App\Models\Blog\Blog;
use App\Models\Com\Notify;
use App\Models\Com\V6WeeklyReport;
use App\Models\Domain\DomainInfo;
use App\Models\HomeCount\Count;
use App\Models\News\News;
use App\Models\Product\Product;
... ... @@ -53,8 +55,14 @@ class WeekProject extends Command
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['delete_status'=>0,'type'=>['in',[1,2,3,4,6]]],'id',['id','title']);
$domainModel = new DomainInfo();
foreach ($list as $k => $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
$domainInfo = $domainModel->read(['project_id'=>$v['id']]);
if($domainInfo === false){
continue;
}
$v['domain'] = $domainInfo['domain'];
ProjectServer::useProject($v['id']);
$this->weekData($v);
DB::disconnect('custom_mysql');
... ... @@ -84,10 +92,11 @@ class WeekProject extends Command
$data['end_date'] = $endOfLastWeekFormatted = date('Y-m-d', $endOfLastWeek);
$countModel = new Count();
$startOfThisWeek = date('Y-m-d', strtotime("monday this week"));
$startOfLastWeekFormattedInfo = $countModel->read(['date'=>$startOfLastWeekFormatted,'project_id'=>$value['id']],['inquiry_num','country']);
$endOfLastWeekFormattedInfo = $countModel->read(['date'=>$startOfThisWeek,'project_id'=>$value['id']],['inquiry_num','country']);
$data['inquiry_total'] = $endOfLastWeekFormattedInfo['inquiry_num'] ?? 0;//询盘数量
$data['inquiry_country'] = $endOfLastWeekFormattedInfo['country'] ?? json_encode([]);
//获取上一周询盘数量
$result = (new FormGlobalsoApi())->getDateInquiry($value['domain'],$data['start_date'],$data['end_date']);
$data['week_inquiry_total'] = ($endOfLastWeekFormattedInfo['inquiry_num'] ?? 0) - ($startOfLastWeekFormattedInfo['inquiry_num'] ?? 0);
$rankDataModel = new RankData();
$rankInfo = $rankDataModel->read(['project_id'=>$value['id'],'lang'=>''],['first_num','first_page_num','first_three_pages_num','first_five_pages_num','first_ten_pages_num','indexed_pages_num']);
... ...
... ... @@ -212,4 +212,29 @@ class FormGlobalsoApi
echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL;
return $res;
}
/**
* @remark :按时间区间
* @name :getMonthInquiry
* @author :lyh
* @method :post
* @time :2025/3/1 9:49
* https://form.globalso.com/api/external-interface/date_count?sta_date=2025-02-26&end_date=2025-02-28&domain=www.ultrasounddawei.com
*/
public function getDateInquiry($url,$start,$end,$is_upgrade = 0){
$url = 'https://'.$url.'/';
$token = md5($url.date("Y-m-d"));
$data = [
'domain' => $url,
'token' => $token,
'source'=> $is_upgrade ? '1,2,3,4,5' : '1,3,5',
'end_date' => $end,
'sta_date'=>$start,
];
$queryString = http_build_query($data);
$url = 'https://www.globalso.site/api/external-interface/date_count?'.$queryString;
$res = http_get($url,['charset=utf-8']);
echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL;
return $res;
}
}
... ...
... ... @@ -10,6 +10,7 @@
namespace App\Http\Controllers\Bside;
use App\Enums\Common\Code;
use App\Helper\FormGlobalsoApi;
use App\Helper\PayStripeApi;
use App\Http\Logic\Bside\News\NewsLogic;
use App\Models\Ai\AiBlog;
... ... @@ -19,6 +20,7 @@ use App\Models\CustomModule\CustomModuleContent;
use App\Models\CustomModule\CustomModuleExtentContent;
use App\Models\Domain\DomainInfo;
use App\Models\ExtentModule\ExtensionModuleValue;
use App\Models\HomeCount\Count;
use App\Models\Manage\ManageHr;
use App\Models\Project\CountAllProject as AllProject;
use App\Models\Project\Project;
... ... @@ -38,22 +40,15 @@ class TestController extends BaseController
* @time :2025/2/13 16:34
*/
public function ceshi(){
$aiBlogService = new AiBlogService();
$aiBlogService->mch_id = '100008';
$aiBlogService->key = '8a9c925bdcca';
$result = $aiBlogService->createTask('apple');
if($result['status'] == 200){
$param = [
'keywords'=>'apple',
'status'=>$result['data']['status'],
'task_id'=>$result['data']['task_id'],
'project_id'=>1,
];
ProjectServer::useProject(1);
$aiBlogModel = new AiBlog();
$aiBlogModel->add($param);
DB::disconnect('custom_mysql');
}
$this->response('success',Code::SUCCESS,$param);
// 上一周的开始时间(周一 00:00:00)
$startOfLastWeek = strtotime("last week monday");
// 上一周的结束时间(周日 23:59:59)
$endOfLastWeek = strtotime("last week sunday 23:59:59");
// 格式化为日期时间字符串
$data['start_date'] = $startOfLastWeekFormatted = date('Y-m-d', $startOfLastWeek);
$data['end_date'] = $endOfLastWeekFormatted = date('Y-m-d', $endOfLastWeek);
//获取上一周询盘数量
$result = (new FormGlobalsoApi())->getDateInquiry('www.rzalubottle.com',$data['start_date'],$data['end_date']);
$this->response('success',Code::SUCCESS,$result);
}
}
... ...