作者 lyh

Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6 into master-server

... ... @@ -135,7 +135,7 @@ class Count extends Command
* @time :2023/6/14 15:44
*/
public function inquiry($arr,$domain,$project_id){
$inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
if($inquiry_list == false){
return false;
}
... ... @@ -143,17 +143,9 @@ class Count extends Command
$arr['inquiry_num'] = 0;
$countryArr = [];
}else{
$arr['inquiry_num'] = $inquiry_list['data']['total'];
$arr['inquiry_num'] = $inquiry_list['data']['count'];
//询盘国家统计
$countryData = $inquiry_list['data']['data'];
$countryArr = [];
foreach ($countryData as $v1){
if(isset($countryArr[$v1['country']])){
$countryArr[$v1['country']]++;
}else{
$countryArr[$v1['country']] = 1;
}
}
$countryArr = $inquiry_list['data']['country'];
}
//加上其他询盘
ProjectServer::useProject($project_id);
... ...
... ... @@ -102,7 +102,7 @@ class CountAll extends Command
* @time :2023/6/14 15:44
*/
public function inquiry($arr,$domain,$project_id){
$inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
if($inquiry_list == false){
return false;
}
... ... @@ -110,17 +110,9 @@ class CountAll extends Command
$arr['inquiry_num'] = 0;
$countryArr = [];
}else{
$arr['inquiry_num'] = $inquiry_list['data']['total'];
$arr['inquiry_num'] = $inquiry_list['data']['count'];
//询盘国家统计
$countryData = $inquiry_list['data']['data'];
$countryArr = [];
foreach ($countryData as $v1){
if(isset($countryArr[$v1['country']])){
$countryArr[$v1['country']]++;
}else{
$countryArr[$v1['country']] = 1;
}
}
$countryArr = $inquiry_list['data']['country'];
}
//加上其他询盘
ProjectServer::useProject($project_id);
... ...
... ... @@ -145,25 +145,18 @@ class CountProject extends Command
* @time :2023/6/14 15:44
*/
public function inquiry($arr,$domain,$project_id){
$inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
if($inquiry_list == false){
return false;
}
echo date('Y-m-d H:i:s') . '拉取询盘状态:' .json_encode($inquiry_list) . PHP_EOL;
if($inquiry_list['status'] == self::STATUS_ERROR){
$arr['inquiry_num'] = 0;
$countryArr = [];
}else{
$arr['inquiry_num'] = $inquiry_list['data']['total'];
$arr['inquiry_num'] = $inquiry_list['data']['count'];
//询盘国家统计
$countryData = $inquiry_list['data']['data'];
$countryArr = [];
foreach ($countryData as $v1){
if(isset($countryArr[$v1['country']])){
$countryArr[$v1['country']]++;
}else{
$countryArr[$v1['country']] = 1;
}
}
$countryArr = $inquiry_list['data']['country'];
}
//加上其他询盘
ProjectServer::useProject($project_id);
... ...
... ... @@ -85,25 +85,23 @@ class MonthAllCount extends Command
// 获取当月结束时间
$end = date('Y-m-t', strtotime($v['month']));
$arr['project_id'] = $project_id;
$res = $this->inquiry($url,$v['month']);
$arr['total'] = $arr['month_total'] = 0;
$res = (new FormGlobalsoApi())->getInquiryAll($url,$v['month']);
$arr['total'] = $arr['month_total'] = 0;
if(isset($res['data']['count'])){
echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL;
$arr['month_total'] = $res['data']['count'];
//获取上一个的count
$previousMonth = date('Y-m', strtotime($v['month'] . ' -1 month'));
$previousInfo = $monthCountModel->read(['month'=>$previousMonth,'project_id'=>$project_id]);
if($previousInfo === false){
$arr['total'] = $arr['month_total'];
}else{
$arr['total'] = $res['data']['count'] + ($previousInfo['total'] ?? 0);
}
$arr['month_total'] = $res['data']['count'] + InquiryFormData::getCount([$start.' 00:00:00',$end.' 00:00:00']);
}
//获取上一个的count
$previousMonth = date('Y-m', strtotime($v['month'] . ' -1 month'));
$previousInfo = $monthCountModel->read(['month'=>$previousMonth,'project_id'=>$project_id]);
if($previousInfo === false){
$arr['total'] = $arr['month_total'];
}else{
$arr['total'] = $arr['month_total'] + ($previousInfo['total'] ?? 0);
}
//获取当月的其他询盘
$arr['total'] += InquiryFormData::getCount([$start.' 00:00:00',$end.' 00:00:00']);
$country = [];
if(isset($res['data']['data'])){
$country = $res['data']['data'];
if(isset($res['data']['country'])){
$country = $res['data']['country'];
}
$countryData = InquiryFormData::getCountryCount([$start.' 00:00:00',$end.' 00:00:00']);
foreach ($countryData as $v1){
... ... @@ -193,13 +191,4 @@ class MonthAllCount extends Command
return $arr;
}
public function inquiry($url,$month){
$url = 'https://'.$url.'/';
$token = md5($url.date("Y-m-d"));
$url = 'https://form.globalso.com/api/external-interface/country_con/15243d63ed5a5738?domain='.$url.'&token='.$token.'&source=1,2,3,4&model=month&sta_date='.$month;
$res = http_get($url,['charset=utf-8']);
echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL;
return $res;
}
}
... ...
... ... @@ -9,6 +9,7 @@
namespace App\Console\Commands\MonthlyCount;
use App\Helper\FormGlobalsoApi;
use App\Models\Com\UpdateOldInfo;
use App\Models\Domain\DomainInfo;
use App\Models\Inquiry\InquiryFormData;
... ... @@ -108,25 +109,23 @@ class MonthCount extends Command
// 获取当月结束时间
$end = date('Y-m-t', strtotime($v['month']));
$arr['project_id'] = $project_id;
$res = $this->inquiry($url,$v['month']);
$res = (new FormGlobalsoApi())->getInquiryAll($url,$v['month']);
$arr['total'] = $arr['month_total'] = 0;
if(isset($res['data']['count'])){
echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL;
$arr['month_total'] = $res['data']['count'];
//获取上一个的count
$previousMonth = date('Y-m', strtotime($v['month'] . ' -1 month'));
$previousInfo = $monthCountModel->read(['month'=>$previousMonth,'project_id'=>$project_id]);
if($previousInfo === false){
$arr['total'] = $arr['month_total'];
}else{
$arr['total'] = $res['data']['count'] + ($previousInfo['total'] ?? 0);
}
$arr['month_total'] = $res['data']['count'] + InquiryFormData::getCount([$start.' 00:00:00',$end.' 00:00:00']);
}
//获取上一个的count
$previousMonth = date('Y-m', strtotime($v['month'] . ' -1 month'));
$previousInfo = $monthCountModel->read(['month'=>$previousMonth,'project_id'=>$project_id]);
if($previousInfo === false){
$arr['total'] = $arr['month_total'];
}else{
$arr['total'] = $arr['month_total'] + ($previousInfo['total'] ?? 0);
}
//获取当月的其他询盘
$arr['total'] += InquiryFormData::getCount([$start.' 00:00:00',$end.' 00:00:00']);
$country = [];
if(isset($res['data']['data'])){
$country = $res['data']['data'];
if(isset($res['data']['country'])){
$country = $res['data']['country'];
}
$countryData = InquiryFormData::getCountryCount([$start.' 00:00:00',$end.' 00:00:00']);
foreach ($countryData as $v1){
... ... @@ -145,7 +144,6 @@ class MonthCount extends Command
$firstDayOfNextMonth = date('Y-m-01 01:00:00', strtotime("$selectedDate +1 month"));
$arr['created_at'] = $firstDayOfNextMonth;
$arr['updated_at'] = $firstDayOfNextMonth;
// echo date('Y-m-d H:i:s') . '数据:'.json_encode($arr) . PHP_EOL;
$monthCountModel->insert($arr);
}else{
$monthCountModel->edit($arr,['id'=>$info['id']]);
... ... @@ -215,13 +213,4 @@ class MonthCount extends Command
return $arr;
}
public function inquiry($url,$month){
$url = 'https://'.$url.'/';
$token = md5($url.date("Y-m-d"));
$url = 'https://form.globalso.com/api/external-interface/country_con/15243d63ed5a5738?domain='.$url.'&token='.$token.'&source=1,2,3,4&model=month&sta_date='.$month;
$res = http_get($url,['charset=utf-8']);
echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL;
return $res;
}
}
... ...
... ... @@ -18,6 +18,7 @@ use App\Models\Project\Project;
use App\Models\Visit\Visit;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use App\Models\HomeCount\Count;
... ... @@ -61,38 +62,43 @@ class MonthProjectCount extends Command
* @time :2024/1/8 9:05
*/
public function count($project_id,$url){
$data = [];
$list = DB::connection('custom_mysql')->table('gl_customer_visit')
->select(DB::raw('DATE_FORMAT(updated_date, "%Y-%m") as month'))
->orderBy('month', 'asc')
->groupBy('month')->get()->toArray();
foreach ($list as $k=>$v){
foreach ($list as $v){
$data[] = $v->month;
}
$list = $this->fillMissingMonths($data);
foreach ($list as $v){
$arr = [];
$v = (array)$v;
$monthCountModel = new MonthCount();
$info = $monthCountModel->read(['month'=>$v['month'],'project_id'=>$project_id]);
$info = $monthCountModel->read(['month'=>$v,'project_id'=>$project_id]);
// 获取当月开始时间
$start = date('Y-m-01', strtotime($v['month']));
$start = date('Y-m-01', strtotime($v));
// 获取当月结束时间
$end = date('Y-m-t', strtotime($v['month']));
$end = date('Y-m-t', strtotime($v));
$arr['project_id'] = $project_id;
$res = $this->inquiry($url,$v['month']);
$res = (new FormGlobalsoApi())->getInquiryAll($url,$v);
echo date('Y-m-d H:i:s') . '月份:'.$v. PHP_EOL;
$arr['total'] = $arr['month_total'] = 0;
if(isset($res['data']['count'])){
echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL;
$arr['month_total'] = $res['data']['count'];
//获取上一个的count
$previousMonth = date('Y-m', strtotime($v['month'] . ' -1 month'));
$previousInfo = $monthCountModel->read(['month'=>$previousMonth,'project_id'=>$project_id]);
if($previousInfo === false){
$arr['total'] = $arr['month_total'];
}else{
$arr['total'] = $res['data']['count'] + ($previousInfo['total'] ?? 0);
}
$arr['month_total'] = $res['data']['count'] + InquiryFormData::getCount([$start.' 00:00:00',$end.' 00:00:00']);
}
//获取当月的其他询盘
$arr['total'] += InquiryFormData::getCount([$start.' 00:00:00',$end.' 00:00:00']);
//获取上一个的count
$previousMonth = date('Y-m', strtotime($v . ' -1 month'));
$previousInfo = $monthCountModel->read(['month'=>$previousMonth,'project_id'=>$project_id]);
if($previousInfo === false){
$arr['total'] = $arr['month_total'];
}else{
$arr['total'] = $arr['month_total'] + ($previousInfo['total'] ?? 0);
}
echo date('Y-m-d H:i:s') . '加上其他询盘:'.$arr['total'] . PHP_EOL;
$country = [];
if(isset($res['data']['data'])){
$country = $res['data']['data'];
if(isset($res['data']['country'])){
$country = $res['data']['country'];
}
$countryData = InquiryFormData::getCountryCount([$start.' 00:00:00',$end.' 00:00:00']);
foreach ($countryData as $v1){
... ... @@ -103,7 +109,7 @@ class MonthProjectCount extends Command
}
}
$arr['country'] = json_encode($country);
$arr['month'] = $v['month'];
$arr['month'] = $v;
$arr = $this->pv_ip($arr,$start,$end,$project_id);
$arr = $this->sourceCount($arr,$start,$end);
if($info === false){
... ... @@ -182,13 +188,37 @@ class MonthProjectCount extends Command
return $arr;
}
public function inquiry($url,$month){
$url = 'https://'.$url.'/';
$token = md5($url.date("Y-m-d"));
$url = 'https://form.globalso.com/api/external-interface/country_con/15243d63ed5a5738?domain='.$url.'&token='.$token.'&source=1,2,3,4&model=month&sta_date='.$month;
$res = http_get($url,['charset=utf-8']);
echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL;
return $res;
/**
* @remark :补齐月份
* @name :fillMissingMonths
* @author :lyh
* @method :post
* @time :2024/8/14 11:11
*/
public function fillMissingMonths($dates) {
// 将字符串日期转换为 Carbon 对象
$carbonDates = array_map(function($date) {
return Carbon::createFromFormat('Y-m', $date);
}, $dates);
// 排序日期,确保列表按时间顺序排列
usort($carbonDates, function($a, $b) {
return $a->gt($b);
});
// 用于存储完整日期的数组
$completeDates = [];
// 遍历日期列表,补齐中间缺失的月份
for ($i = 0; $i < count($carbonDates) - 1; $i++) {
$current = $carbonDates[$i];
$next = $carbonDates[$i + 1];
// 将当前月份加入完整日期数组
array_push($completeDates, $current->format('Y-m'));
// 循环补齐中间缺失的月份
while ($current->addMonth()->lt($next)) {
array_push($completeDates, $current->format('Y-m'));
}
}
// 加入最后一个月份
array_push($completeDates, $carbonDates[count($carbonDates) - 1]->format('Y-m'));
return $completeDates;
}
}
... ...
... ... @@ -22,6 +22,8 @@ use App\Models\File\File;
use App\Models\File\File as FileModel;
use App\Models\File\Image;
use App\Models\File\Image as ImageModel;
use App\Models\News\News;
use App\Models\News\NewsCategory;
use App\Models\Product\Keyword;
use App\Models\Product\Product;
use App\Models\Project\DeployOptimize;
... ... @@ -33,6 +35,7 @@ use App\Models\Template\BTemplateCom;
use App\Services\AmazonS3Service;
use App\Services\ProjectServer;
use App\Utils\EncryptUtils;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
... ... @@ -55,37 +58,73 @@ class Demo extends Command
protected $description = 'demo';
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>1462]);
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
$blogModel = new Blog();
$blogList = $blogModel->list(['status'=>0],'id',['*'],'asc');
foreach ($blogList as $blogV){
$customContentModel = new CustomModuleContent();
$id = $customContentModel->addReturnId([
'name'=>$blogV['name'],
'status'=>0,
'sort'=>$blogV['sort'],
'remark'=>$blogV['remark'],
'route'=>$blogV['url'],
'image'=>$blogV['image'],
'seo_title'=>$blogV['seo_title'],
'seo_keywords'=>$blogV['seo_keywords'],
'seo_description'=>$blogV['seo_description'],
'project_id'=>$blogV['project_id'],
'created_at'=>$blogV['created_at'],
'updated_at'=>$blogV['updated_at'],
'module_id'=>8,
'video'=>null,
'release_at'=>$blogV['release_at'],
'operator_id'=>$blogV['operator_id']
]);
RouteMap::setRoute($blogV['url'],RouteMap::SOURCE_MODULE,$id,1462);
}
DB::disconnect('custom_mysql');
$domain = "https://www.xawellauto.com/";
$token = md5($domain.date("Y-m-d"));
$url = "https://form.globalso.com/api/external-interface/domain_con/15243d63ed5a5738?domain=$domain&token=$token&source=1,2,3,4&num=15";
$url = $url."&sta_date=2024-07";
try {
$res = http_get($url,['charset=utf-8']);
} catch (\Exception | GuzzleException $e) {
errorLog('提交询盘信息失败', $domain, $e);
return false;
}
echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL;
return $res;
}
// public function handle(){
// $projectModel = new Project();
// $list = $projectModel->list(['id'=>503]);
// foreach ($list as $v){
// echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
// ProjectServer::useProject($v['id']);
// $newsModel = new News();
// $blogList = $newsModel->list(['status'=>1],'id',['*'],'asc');
// foreach ($blogList as $blogV){
// $customContentModel = new CustomModuleContent();
// $id = $customContentModel->addReturnId([
// 'name'=>$blogV['name'],
// 'status'=>0,
// 'sort'=>$blogV['sort'],
// 'remark'=>$blogV['remark'],
// 'route'=>$blogV['url'],
// 'image'=>$blogV['image'],
// 'seo_title'=>$blogV['seo_title'],
// 'seo_keywords'=>$blogV['seo_keywords'],
// 'seo_description'=>$blogV['seo_description'],
// 'project_id'=>$blogV['project_id'],
// 'created_at'=>$blogV['created_at'],
// 'updated_at'=>$blogV['updated_at'],
// 'module_id'=>10,
// 'video'=>null,
// 'release_at'=>$blogV['release_at'],
// 'operator_id'=>$blogV['operator_id']
// ]);
// RouteMap::setRoute($blogV['url'],RouteMap::SOURCE_MODULE,$id,503);
// }
// DB::disconnect('custom_mysql');
// }
// }
// public function handle(){
// ProjectServer::useProject(503);
// $newsCate = new NewsCategory();
// $newsList = $newsCate->list();
// foreach ($newsList as $v){
// $data = [
// 'name'=>$v['name'],
// 'status'=>0,
// 'sort'=>$v['sort'],
// 'pid'=>$v['pid'],
// 'route'=>$v['alias'],
// 'project_id'=>503,
// 'operator_id'=>$v['operator_id'],
// 'create_id'=>1101,
// 'module_id'=>10,
// ];
// $moduleCateModel = new CustomModuleCategory();
// $id = $moduleCateModel->addReturnId($data);
// RouteMap::setRoute($v['alias'],RouteMap::SOURCE_MODULE_CATE,$id,503);
// }
// DB::disconnect('custom_mysql');
// }
}
... ...
<?php
/**
* @remark :
* @name :SyncTimeFiles.php
* @author :lyh
* @method :post
* @time :2024/8/14 14:23
*/
namespace App\Console\Commands\Test;
use App\Models\File\ErrorFile;
use App\Models\File\File;
use Illuminate\Console\Command;
class SyncTimeFiles extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sync_videos';
/**
* The console command description.
*
* @var string
*/
protected $description = '按时间同步图片与文件';
public function handle()
{
$fileModel = new File();
$start = '2024-08-10 00:00:00';
$end = date('Y-m-d H:i:s');
$lists = $fileModel->list(['created_at'=>['between',[$start,$end]]]);
foreach ($lists as $v){
$path = $v['path'];
$this->param['name'] = basename($path);
$this->param['path'] = str_replace('/'.$this->param['name'],'',$path);
$file_path = $this->getUrl($this->param['path'].'/'.$this->param['name'], 0,0);
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->param['path'].'" https://v6-file.globalso.com/upload.php';
echo date('Y-m-d H:i:s') . ' | ' . $cmd . PHP_EOL;
$code = shell_exec($cmd);
if(200 != (int)$code){
echo date('Y-m-d H:i:s') . ' | 错误状态:' . $code . PHP_EOL;
// $errorFileModel = new ErrorFile();
// $errorFileModel->add(['path'=>$this->param['path'].'/'.$this->param['name']]);
}
echo date('Y-m-d H:i:s') . ' | ok:' . $code . PHP_EOL;
}
return true;
}
/**
* @remark :获取图片文件链接
* @name :getUrl
* @author :lyh
* @method :post
* @time :2024/5/22 11:53
*/
public function getUrl($path,$storage_type,$location){
if(is_array($path)){
$url =[];
foreach ($path as $v){
$url[] = $this->getUrl($v,$storage_type,$location);
}
}else{
if(empty($path)){
return '';
}
if((strpos($path,'https://')!== false) || (strpos($path,'http://') !== false)){
return $path;
}
if(substr($path,0,2) == '//'){
return 'https:'.$path;
}
if($location == 0){
$cos = config('filesystems.disks.cos');
$cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
$url = $cosCdn.$path;
}else{
$s3 = config('filesystems.disks.s3');
$cdn = $s3['cdn'];
$url = $cdn.$path;
}
}
return $url;
}
}
... ...
<?php
/**
* @remark :
* @name :SyncVideo.php
* @author :lyh
* @method :post
* @time :2024/8/14 13:50
*/
namespace App\Console\Commands\Test;
use App\Models\File\ErrorFile;
use Illuminate\Console\Command;
class SyncVideo extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sync_video {path}';
/**
* The console command description.
*
* @var string
*/
protected $description = '同步图片与文件';
public function handle()
{
$path = $this->argument('path');
$this->param['name'] = basename($path);
$this->param['path'] = str_replace('/'.$this->param['name'],'',$path);
$file_path = $this->getUrl($this->param['path'].'/'.$this->param['name'], 0,0);
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->param['path'].'" https://v6-file.globalso.com/upload.php';
echo date('Y-m-d H:i:s') . ' | ' . $cmd . PHP_EOL;
$code = shell_exec($cmd);
if(200 != (int)$code){
$errorFileModel = new ErrorFile();
$errorFileModel->add(['path'=>$this->param['path'].'/'.$this->param['name']]);
}
return true;
}
/**
* @remark :获取图片文件链接
* @name :getUrl
* @author :lyh
* @method :post
* @time :2024/5/22 11:53
*/
public function getUrl($path,$storage_type,$location){
if(is_array($path)){
$url =[];
foreach ($path as $v){
$url[] = $this->getUrl($v,$storage_type,$location);
}
}else{
if(empty($path)){
return '';
}
if((strpos($path,'https://')!== false) || (strpos($path,'http://') !== false)){
return $path;
}
if(substr($path,0,2) == '//'){
return 'https:'.$path;
}
if($location == 0){
$cos = config('filesystems.disks.cos');
$cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
$url = $cosCdn.$path;
}else{
$s3 = config('filesystems.disks.s3');
$cdn = $s3['cdn'];
$url = $cdn.$path;
}
}
return $url;
}
}
... ...
... ... @@ -150,24 +150,15 @@ class Test extends Command
}
public function inquiry($arr,$domain,$project_id){
$inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
if($inquiry_list['status'] == 400){
$arr['inquiry_num'] = 0;
$countryArr = [];
}else{
$arr['inquiry_num'] = $inquiry_list['data']['total'];
$arr['inquiry_num'] = $inquiry_list['data']['count'];
//询盘国家统计
$countryData = $inquiry_list['data']['data'];
$countryArr = [];
foreach ($countryData as $v1){
if(isset($countryArr[$v1['country']])){
$countryArr[$v1['country']]++;
}else{
$countryArr[$v1['country']] = 1;
}
}
$countryArr = $inquiry_list['data']['country'];
}
//加上其他询盘
$arr['inquiry_num'] += InquiryFormData::getCount();
$countryData = InquiryFormData::getCountryCount();
... ...
... ... @@ -597,6 +597,7 @@ class ProjectUpdate extends Command
$url = $api_url . '?' . http_build_query(['w' => $api_type, 'page' => 1, 'pagesize' => 0]);
$data = curl_c($url);
if (isset($data['code']) && $data['code'] == 200) {
$category = $data['data']['category'];
//判断分类里面是否存在自定义模块路由
$is_exist = 0;
if ($data['data']['category'] ?? []) {
... ... @@ -607,21 +608,15 @@ class ProjectUpdate extends Command
}
}
}
if ($is_exist) {
//存在,无需添加自定义模块路由为分类路由
$category = $data['data']['category'];
} else {
//不存在,需要添加自定义模块路由为分类路由
$category = [
[
'id' => 0,
'name' => $custom_info['route'],
'url' => '/' . $custom_info['route'],
'parent' => $data['data']['category'] ?? []
]
];
if (!$is_exist) {
array_push($category, [
'id' => 0,
'name' => $custom_info['route'],
'url' => '/' . $custom_info['route'],
'parent' => 0
]);
}
$this->category_custom_insert($project_id, $custom_info['id'], $category, 0);
$this->category_custom_insert($project_id, $custom_info['id'], $category);
$count = $data['data']['count'] ?? 0;
... ... @@ -914,35 +909,28 @@ class ProjectUpdate extends Command
}
//扩展模块多级分类入库
protected function category_custom_insert($project_id, $module_id, $items, $pid = 0)
protected function category_custom_insert($project_id, $module_id, $items)
{
$model = new CustomModuleCategory();
foreach ($items as $item) {
$route = $this->get_url_route($item['url'] ?? '');
if ($route) {
$parent = $model->read(['pid' => $pid, 'route' => $route], 'id');
if (!$parent) {
$cate = $model->read(['route' => $route], 'id');
if (!$cate) {
try {
$item['name'] = $this->special2str($item['name'] ?? '');
$parent_id = $model->addReturnId([
$cate_id = $model->addReturnId([
'project_id' => $project_id,
'module_id' => $module_id,
'name' => $item['name'],
'pid' => $pid,
'original_id' => $item['id'],
'route' => $route
]);
$this->set_map($route, RouteMap::SOURCE_MODULE_CATE, $parent_id, $project_id);
$this->set_map($route, RouteMap::SOURCE_MODULE_CATE, $cate_id, $project_id);
} catch (\Exception $e) {
echo 'date:' . date('Y-m-d H:i:s') . ', category_custom_insert error: ' . $e->getMessage() . PHP_EOL;
continue;
}
} else {
$parent_id = $parent['id'];
}
if (!empty($item['children'] ?? [])) {
$this->category_custom_insert($project_id, $module_id, $item['children'], $parent_id);
}
}
}
... ...
... ... @@ -15,6 +15,7 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('sync_file')->everyThirtyMinutes()->withoutOverlapping(1);//每半小时执行同步
// 每日更新最新模块
$schedule->command('template_label')->dailyAt('01:00')->withoutOverlapping(1);//最新模块
$schedule->command('popular_template_label')->dailyAt('01:30')->withoutOverlapping(1);//热门模块
... ...
... ... @@ -32,8 +32,22 @@ class LogFormatterFactory
$path = date('Y-m', $time) . '/' . date('d', $time) . '_' . $suffix . '.log';
$path = 'logs/' . $config['prefix'] . '/' . $path;
$path = storage_path($path);
try {
if (!file_exists($path)) {
$directory = pathinfo($path, PATHINFO_DIRNAME);
if(!file_exists($directory)){
mkdir($directory, 0644, true);
chown($directory, 'www');
}
touch($path);
chown($path, 'www');
}
}catch (\Throwable $exception){}
$handler = new StreamHandler($path, $level, false);
$handler->setFormatter(new LineFormatter(null, 'Y-m-d H:i:s', false, true));
return $handler;
}
... ...
... ... @@ -70,7 +70,7 @@ class FormGlobalsoApi
$res = HttpUtils::get($api_url, $params);
$res = Arr::s2a($res);
} catch (\Exception | GuzzleException $e) {
errorLog('询盘列表', $params, $e);
errorLog('询盘列表'.$api_url, $params, $e);
return false;
}
return $res;
... ... @@ -155,5 +155,28 @@ class FormGlobalsoApi
return $res;
}
/**
* @remark :获取当前项目所有询盘及询盘国家
* @name :getInquiryAll
* @author :lyh
* @method :post
* @time :2024/8/15 14:16
*/
public function getInquiryAll($domain,$start_month = ''){
if (!(strpos($domain, 'https://') === 0)) {
$domain = 'https://'.$domain.'/';
}
$token = md5($domain.date("Y-m-d"));
$url = "https://form.globalso.com/api/external-interface/domain_con/15243d63ed5a5738?domain=$domain&token=$token&source=1,2,3,4&num=15";
if(!empty($start_month)){
$url = $url."&sta_date=$start_month";
}
try {
$res = http_get($url,['charset=utf-8']);
} catch (\Exception | GuzzleException $e) {
errorLog('提交询盘信息失败', $domain, $e);
return false;
}
return $res;
}
}
... ...
... ... @@ -927,3 +927,5 @@ function base62_encode($num) {
}
... ...
... ... @@ -14,6 +14,7 @@ use App\Helper\Arr;
use App\Helper\FormGlobalsoApi;
use App\Models\Domain\DomainInfo;
use App\Models\HomeCount\Count;
use App\Models\HomeCount\MonthCount;
use App\Models\Inquiry\InquiryFormData;
use App\Models\Project\Project;
use App\Models\RankData\ExternalLinks;
... ... @@ -115,7 +116,7 @@ class OptimizationReportController extends BaseController
// 获取当前月的结束时间
$endTime = date('Y-m-t', strtotime($this->param['date']));
$arr = [];
$arr = $this->inquiryCount($arr,$startTime,$endTime,$domain);
$arr = $this->inquiryCount($arr,$startTime,$endTime,$domain,$project_id);
$arr = $this->flowCount($arr,$startTime,$endTime,$project_id);
$arr = $this->sourceCount($arr,$startTime,$endTime,$domain);
$arr['month'] = date('Y-m',time());
... ... @@ -131,42 +132,15 @@ class OptimizationReportController extends BaseController
* @method :post
* @time :2023/6/30 14:29
*/
public function inquiryCount(&$arr,&$startTime,&$endTime,$domain){
$inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
if(!empty($inquiry_list)){
//总数
$arr['total'] = $inquiry_list['data']['total'] ?? 0;
//数据详情
$data = $inquiry_list['data']['data'] ?? '';
$arr['month_total'] = 0;
$countryArr = [];
if(isset($data) && !empty($data)){
foreach ($data as $v){
if(($startTime.' 00:00:00' <= $v['submit_time']) && $v['submit_time'] <= $endTime.' 23:59:59'){
$arr['month_total']++;
if(isset($countryArr[$v['country']])){
$countryArr[$v['country']]++;
}else{
$countryArr[$v['country']] = 1;
}
}
}
}
}
//加上其他询盘
$arr['total'] += InquiryFormData::getCount();
$arr['month_total'] += InquiryFormData::getCount([$startTime, $endTime]);
$countryData = InquiryFormData::getCountryCount([$startTime, $endTime]);
foreach ($countryData as $v1){
if(isset($countryArr[$v1['country']])){
$countryArr[$v1['country']] += $v1['count'];
}else{
$countryArr[$v1['country']] = $v1['count'];
}
public function inquiryCount(&$arr, &$startTime, $project_id){
$month = date('Y-m',strtotime($startTime));
$monthCountModel = new MonthCount();
$info = $monthCountModel->read(['project_id'=>$project_id,'month'=>$month]);
if($info !== false){
$arr['country'] = $info['country'];
$arr['total'] = $info['total'];
$arr['month_total'] = $info['month_total'];
}
arsort($countryArr);
$top20 = array_slice($countryArr, 0, 15, true);
$arr['country'] = $top20;
return $arr;
}
... ... @@ -350,9 +324,9 @@ class OptimizationReportController extends BaseController
public function pv_ip($domain){
$pv = (new VisitItem())->count();
$ip = (new Visit())->count();
$inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
if(!empty($inquiry_list)){
$total = $inquiry_list['data']['total'] ?? 0;
$total = $inquiry_list['data']['count'] ?? 0;
}
return [
'total_pv'=>$pv,
... ...
... ... @@ -177,4 +177,21 @@ class KeywordVideoController extends BaseController
$data['end_total'] = $keywordModel->formatQuery(['status'=>1])->count();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :当月视频总数量
* @name :getVideoCount
* @author :lyh
* @method :post
* @time :2024/8/14 9:58
*/
public function getVideoCount(){
// 当月的开始时间
$start_of_month = date("Y-m-01 00:00:00");
// 当月的结束时间:使用 strtotime() 计算最后一天
$end_of_month = date("Y-m-d 23:59:59", strtotime("last day of this month"));
$taskLogModel = new KeywordVideoTaskLog();
$count = $taskLogModel->formatQuery(['created_at'=>['between',[$start_of_month,$end_of_month]]])->count();
$this->response('success',Code::SUCCESS,['count'=>$count]);
}
}
... ...
... ... @@ -16,6 +16,7 @@ use App\Models\Com\UpdateOldInfo;
use App\Models\Domain\DomainInfo;
use App\Models\News\NewsCategory;
use App\Models\Product\Category;
use App\Models\Product\Product;
use App\Models\Project\ProjectUpdateTdk;
use App\Models\Template\BTemplate;
use App\Models\Template\Setting;
... ... @@ -121,6 +122,17 @@ class UpdateController extends BaseController
}
}
//如果自己创建了6.0产品关联了分类,也不能再重采分类
$product_v6_list = Product::where('project_id', $this->param['project_id'])->where('is_upgrade', 0)->get();
if ($product_v6_list->count() > 0) {
foreach ($product_v6_list as $product_v6) {
if ($product_v6->category_id) {
$product_cate_type = 0;
break;
}
}
}
//新闻分类重采之前,判断新闻分类是否开启了可视化
$category_news_list = NewsCategory::where('project_id', $this->param['project_id'])->get();
if ($category_news_list->count() > 0) {
... ...
... ... @@ -88,9 +88,7 @@ class AyrReleaseController extends BaseController
}
//发送请求发布社交文章
$res = $ayrShare->post_send_msg($param,$share_info['profile_key']);
if($res){
$ayrReleaseLogic->release_add($res);
}
$res = $ayrReleaseLogic->release_add($res);
//保存返回的内容
$this->response('success',Code::SUCCESS,json_decode($res));
}
... ...
... ... @@ -65,6 +65,7 @@ class CNoticeController extends BaseController
if($domain_info){
//判断是否已有更新进行中
$notify_model = new Notify();
$type = $is_sitemap == 1 ? Notify::TYPE_ALL_SITEMAP : $type;
$data = [
'project_id' => $project_id,
'type' => $type,
... ... @@ -90,6 +91,7 @@ class CNoticeController extends BaseController
$data['data'] = Arr::a2s(['domain'=>$domain,'url'=>$url,'language'=>$language]);
$data['status'] = $is_sitemap == 1 ? Notify::STATUS_FINISH_PAGE : Notify::STATUS_INIT;
$data['is_pull_html_zip'] = $is_sitemap == 1 ? Notify::IS_PULL_HTML_ZIP_TRUE : Notify::IS_PULL_HTML_ZIP_FALSE;
$notify_model->add($data);
}
}
... ...
... ... @@ -64,10 +64,13 @@ class MonthReportController extends BaseController
if(!empty($info['country'])){
$info['country'] = json_decode($info['country']);
}
// 获取上个月的开始时间
$startTime = Carbon::now()->subMonth()->startOfMonth()->toDateString();
// 获取上个月的结束时间
$endTime = Carbon::now()->subMonth()->endOfMonth()->toDateString();
// 创建指定年月的 DateTime 对象
$date = $this->map['month'];
$start = new \DateTime("$date-01 00:00:00");
// 克隆 $start 对象并设置到下个月的第一天,减去1秒得到该月的最后一秒
$end = (clone $start)->modify('last day of this month')->setTime(23, 59, 59);
$startTime = $start->format('Y-m-d H:i:s');
$endTime = $end->format('Y-m-d H:i:s');
$param = [
'date' => ['between',[$startTime,$endTime]],
'project_id' => $this->user['project_id']
... ...
... ... @@ -254,6 +254,7 @@ class LoginController extends BaseController
}
//没有from_order_id的项目 进入演示版 运营中心
$arr['from_order_id'] = $arr['from_order_id'] ?? 0;
$arr['phone'] = $arr['phone'] ?? '';
if(!$arr['from_order_id']){
//有账号就直接登录, 没有账号创建账号登录
$user = (new User())->where('project_id', Project::DEMO_PROJECT_ID)->where('mobile', $arr['phone'])->first();
... ... @@ -277,16 +278,25 @@ class LoginController extends BaseController
'manager_id'=>0,
];
}else{
//有from_order_id, 找到对应的项目并登录账号
//有from_order_id, 找到对应的项目并登录对应账号
$project = (new Project())->read(['from_order_id'=>$arr['from_order_id'], 'delete_status' => Project::IS_DEL_FALSE]);
if(!$project){
$this->response('项目不存在,请联系管理员',Code::USER_ERROR);
}
$data = [
'project_id'=>$project['id'],
'manager_id'=>0,
];
$user = (new User())->where('project_id', $project['id'])->where('mobile', $arr['phone'])->first();
if(!$user){
$data = [
'project_id'=>$project['id'],
'manager_id'=>0,
];
}else{
$data = [
'user_id'=>$user['id'],
'manager_id'=>0,
];
}
}
$info = $logic->autologin($data);
$this->response('success',Code::SUCCESS,['info'=>$info]);
}
... ...
... ... @@ -346,23 +346,43 @@ class ProductController extends BaseController
return [];
}
$extendInfoModel = new ExtendInfo();
$infoList = $extendInfoModel->list(['product_id'=>$product_id],'created_at');
foreach ($list as $k=>$v){
$info = $extendInfoModel->read(['key'=>$v['key'],'product_id'=>$product_id]);
if($info == false){
if($v['type'] == 3 || $v['type'] == 4){
$v['values'] = [];
}else{
$v['values'] = '';
foreach ($infoList as $values){
if($v['key'] == $values['key']){
$v = $this->setTypValues($v,$values);
break;
}
}else{
$v = $this->setTypValues($v,$info);
}
$list[$k] = $v;
}
$list = $this->handleExtentList($list);
return $list;
}
/**
* @remark :处理详情数据(初始化)
* @name :handleList
* @author :lyh
* @method :post
* @time :2024/8/14 18:26
*/
public function handleExtentList($list){
foreach ($list as $k => $v){
if($v['type'] == 3 || $v['type'] == 4){
if(!isset($v['values'])){
$v['values'] = [];
}
}else{
if(!isset($v['values'])){
$v['values'] = '';
}
}
$list[$k] = $v;
}
return $this->success($list);
}
/**
* @remark :扩展字段根据type返回类型
* @name :setTypValues
* @author :lyh
... ...
... ... @@ -50,11 +50,12 @@ class AyrReleaseLogic extends BaseLogic
$this->model->add($this->param);
}else{
$result_data = json_decode($this->param['result_data']);
if(isset($result_data['status']) && $result_data['status'] == 'success'){
if(isset($result_data->status) && $result_data->status == 'success'){
$this->model->edit($this->param,['id'=>$info['id']]);
return $this->param['result_data'];
}
}
return $this->success();
return $this->param['result_data'];
}
/**
* @name :(上传第三方图片参数处理)get_param
... ...
... ... @@ -261,6 +261,8 @@ class TranslateLogic extends BaseLogic
foreach ($this->param['data'] as $k => $v){
if(!empty($v) && is_array($v)){
foreach ($v as $text => $translate){
$text = str_replace(['%22', '%', '+'], ['"', '%', '+'], $text);
$translate = str_replace(['%22', '%', '+'], ['"', '%', '+'], $translate);
$data[$text] = $translate;
}
}
... ... @@ -312,7 +314,8 @@ class TranslateLogic extends BaseLogic
* @time :2024/5/17 15:11
*/
public function getRouteSource($route){
$data = ['source'=>0,'source_id'=>0,'is_list'=>0,'is_custom'=>0];
$routes = $route;
$data = ['source'=>0,'source_id'=>0,'is_list'=>0,'is_custom'=>0,'page'=>0];
if(strtolower($route) == 'all'){
return $this->success($data);
}
... ... @@ -321,12 +324,20 @@ class TranslateLogic extends BaseLogic
return $this->success($data);
}
$route = basename($route);
$page = 0;
if (is_numeric($route)) {
$arr = explode('/',$routes);
$page = $arr[1];
$route = $arr[0];
}
$routeModel = new RouteMap();
$routeInfo = $routeModel->read(['route'=>$route]);
if($routeInfo === false){
return $data;
}
return $this->resultData($routeInfo,$data);
$data = $this->resultData($routeInfo,$data);
$data['page'] = $page;
return $data;
}
/**
... ...
... ... @@ -18,11 +18,12 @@ class Notify extends Base
const STATUS_ERROR = 9;
/**
* 类型 1:主站, 2:小语种, 3:amp
* 类型 1:主站, 2:小语种, 3:amp,4:sitemap
*/
const TYPE_MASTER = 1;
const TYPE_MINOR = 2;
const TYPE_AMP = 3;
const TYPE_ALL_SITEMAP = 4;
/**
* 路由
... ... @@ -41,6 +42,14 @@ class Notify extends Base
const ROUTE_PRODUCT_VIDEO_KEYWORD = 6;
/**
* 是否拉取HTML压缩包
* 0:默认不拉取
* 1:拉取
*/
const IS_PULL_HTML_ZIP_FALSE = 0;
const IS_PULL_HTML_ZIP_TRUE = 1;
/**
* 类型
* @return array
*/
... ...
... ... @@ -351,6 +351,7 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/edit', [Aside\Com\KeywordVideoController::class, 'edit'])->name('keyword_video_edit');
Route::any('/getVideoTaskLog', [Aside\Com\KeywordVideoController::class, 'getVideoTaskLog'])->name('keyword_video_getVideoTaskLog');
Route::any('/taskNum', [Aside\Com\KeywordVideoController::class, 'taskNum'])->name('keyword_video_taskNum');
Route::any('/getVideoCount', [Aside\Com\KeywordVideoController::class, 'getVideoCount'])->name('keyword_video_getVideoCount');
});
// 公共主题模版
... ...