作者 lyh

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6

正在显示 50 个修改的文件 包含 2580 行增加988 行删除

要显示太多修改。

为保证性能只显示 50 of 50+ 个文件。

/node_modules
/public/hot
/public/storage
/public/.user.ini
/storage
/vendor
/uploads
composer.json
composer.lock
.env
.env.backup
.phpunit.result.cache
... ... @@ -19,3 +20,6 @@ composer.lock
app/Console/Commands/Test/Demo.php
/public/upload
/public/runtime
public/nginx.htaccess
public/.htaccess
.gitignore
... ...
\ No newline at end of file
... ...
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
... ...
... ... @@ -66,7 +66,6 @@ class ShareUser extends Command
//删除用户第三方配置
if(!empty($v['profile_key'])){
$this->del_profiles($v);
continue;
}
//更新数据库
$this->save_ayr_share($ayr_share_model,$v);
... ...
<?php
namespace App\Console\Commands\Bside\Statistics;
use App\Models\Bside\Statistics\TrafficStatistics;
use App\Models\CustomerVisit\CustomerVisit;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Throwable;
class Logic
{
/**
* @param int $type 统计类型
* @return array
*/
public function getMonths(int $type = TrafficStatistics::TYPE_SOURCE)
{
$date = getPreviousMonthsDate();
$TrafficStatistics = new TrafficStatistics();
$lists = $TrafficStatistics->getMonthsLists($type, $date);
if (!empty($lists)) {
$dd = [];
$lists->map(function ($item) use (&$dd) {
$dd[] = $item->year . '-' . str_pad($item->month, 2, '0', STR_PAD_LEFT);
});
$date = array_diff($date, $dd);
}
return $date;
}
/**
* @param array $column 统计数据
* @param int $type 统计类型
* @param string|null $date 日期 格式:Y-m
* @param string $message
* @return array
* @throws Throwable
*/
public function save(array $column, int $type = TrafficStatistics::TYPE_SOURCE, string $date = null, $message = '统计当月访问来源数据')
{
DB::beginTransaction();
// 获取当天的IP|PV数量
$customerVisit = new CustomerVisit();
$ip_count = $customerVisit->getMonthIPCount($date);
$pv_count = $customerVisit->getMonthPVCount($date);
$column['pvnum'] = $pv_count;
$column['ipnum'] = $ip_count;
$date = $date ?? date('Y-m');
// 统计数据并插入到数据库
$dd = explode('-', $date);
$year = $dd[0];
$month = $dd[1];
$column['year'] = $year;
$column['month'] = $month;
$trafficStatistics = new TrafficStatistics();
$isRes = $trafficStatistics->getMonth($type, $year, $month);
if ($isRes) {
$trafficStatistics = $isRes;
}
foreach ($column as $key => $value) {
$trafficStatistics->$key = $value;
}
$res = $trafficStatistics->save();
if ($res) {
DB::commit();
$meg = "{$date} - {$message}成功!";
} else {
DB::rollBack();
$meg = "{$date} - {$message}失败!";
}
return ['status' => $res, 'msg' => $meg];
}
}
<?php
namespace App\Console\Commands\Bside\Statistics;
use App\Models\Bside\Statistics\TrafficTrends;
use App\Models\CustomerVisit\CustomerVisit;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Throwable;
class StatisticsDayTrend extends Command
{
public $error = 0;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'statistics_day_trend';
/**
* The console command description.
*
* @var string
*/
protected $description = '统计当天流量趋势数据';
/**
* @return void
* @throws GuzzleException
* @throws Throwable
*/
public function handle()
{
$date = getPreviousDaysDate();
$trafficTrends = new TrafficTrends();
$lists = $trafficTrends->getDaysLists($date);
if (!empty($lists)) {
$date = array_diff($date, $lists->pluck('day')->all());
}
if (!empty($date)) {
foreach ($date as $value) {
echo $this->statistics_day_trend($value);
}
}
echo $this->statistics_day_trend();
}
/**
* 统计当天流量趋势数据PV|IP数量
* @return int|mixed
* @throws GuzzleException|Throwable
*/
protected function statistics_day_trend($date = null)
{
DB::beginTransaction();
$date = $date ?? date('Y-m-d');
// 获取当天的IP|PV数量
$customerVisit = new CustomerVisit();
$ip_count = $customerVisit->getDayIPCount($date);
$pv_count = $customerVisit->getDayPVCount($date);
// 统计数据并插入到数据库
$trafficTrends = new TrafficTrends();
$isRes = $trafficTrends->getDay($date);
if ($isRes) {
$trafficTrends = $isRes;
}
$trafficTrends->day = $date;
$trafficTrends->pvnum = $pv_count;
$trafficTrends->ipnum = $ip_count;
$res = $trafficTrends->save();
if ($res) {
DB::commit();
$this->info($date . ' - 统计当天流量趋势数据PV|IP数量成功');
} else {
DB::rollBack();
$this->error++;
$this->info($date . ' - 统计当天流量趋势数据PV|IP数量失败');
}
return $this->error;
}
}
<?php
namespace App\Console\Commands\Bside\Statistics;
use App\Models\Bside\Statistics\TrafficStatistics;
use App\Models\CustomerVisit\CustomerVisit;
use Illuminate\Console\Command;
use Throwable;
class StatisticsDistribution extends Command
{
public $error = 0;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'statistics_distribution';
/**
* The console command description.
*
* @var string
*/
protected $description = '统计当月地域分布数据';
public $logic;
public function __construct()
{
parent::__construct();
$this->logic = new Logic();
}
/**
* 定时执行
* @return void
* @throws Throwable
*/
public function handle()
{
$date = $this->logic->getMonths(TrafficStatistics::TYPE_DISTRIBUTION);
if (!empty($date)) {
foreach ($date as $value) {
echo $this->statistics_distribution($value);
}
}
echo $this->statistics_distribution();
}
/**
* 统计当天流量趋势数据PV|IP数量
* @param string|null $date
* @return int|mixed
* @throws Throwable
*/
protected function statistics_distribution(string $date = null)
{
$customerVisit = new CustomerVisit();
$type = TrafficStatistics::TYPE_DISTRIBUTION;
$top = json_encode($customerVisit->getCountryCount($date) ?? []);
$res = $this->logic->save(compact('top', 'type'), $type, $date, '统计当月地域分布数据');
if (!$res['status']) {
$this->info($res['msg']);
$this->error++;
}
$this->info($res['msg']);
return $this->error;
}
}
<?php
namespace App\Console\Commands\Bside\Statistics;
use App\Models\Bside\Statistics\TrafficStatistics;
use App\Models\CustomerVisit\CustomerVisit;
use Illuminate\Console\Command;
use Throwable;
class StatisticsPage extends Command
{
public $error = 0;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'statistics_page';
/**
* The console command description.
*
* @var string
*/
protected $description = '统计当月受访页面数据';
public $logic;
public function __construct()
{
parent::__construct();
$this->logic = new Logic();
}
/**
* 定时执行
* @return void
*/
public function handle()
{
$date = $this->logic->getMonths(TrafficStatistics::TYPE_PAGE);
if (!empty($date)) {
foreach ($date as $value) {
echo $this->statistics_page($value);
}
}
echo $this->statistics_page();
}
/**
* 统计当月受访页面数据
* @param null $date
* @return int|mixed
* @throws Throwable
*/
protected function statistics_page($date = null)
{
$customerVisit = new CustomerVisit();
$top = json_encode($customerVisit->getPageCount($date) ?? []);
$type = TrafficStatistics::TYPE_PAGE;
$res = $this->logic->save(compact('top', 'type'), $type, $date, '统计当月受访页面数据');
if (!$res['status']) {
$this->info($res['msg']);
$this->error++;
}
$this->info($res['msg']);
return $this->error;
}
}
<?php
namespace App\Console\Commands\Bside\Statistics;
use App\Models\Bside\Statistics\TrafficStatistics;
use App\Models\CustomerVisit\CustomerVisit;
use Illuminate\Console\Command;
use Throwable;
class StatisticsSource extends Command
{
public $error = 0;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'statistics_source';
/**
* The console command description.
*
* @var string
*/
protected $description = '统计当月访问来源数据';
public $logic;
public function __construct()
{
parent::__construct();
$this->logic = new Logic();
}
/**
* @return void
* @throws Throwable
*/
public function handle()
{
$date = $this->logic->getMonths();
if (!empty($date)) {
foreach ($date as $value) {
echo $this->statistics_source($value);
}
}
echo $this->statistics_source();
}
/**
* 统计当天流量趋势数据
* @param string|null $date
* @return int|mixed
* @throws Throwable
*/
protected function statistics_source(string $date = null)
{
// 获取当天的IP|PV数量
$customerVisit = new CustomerVisit();
$top = json_encode($customerVisit->getUrlCount($date) ?? []);
$type = TrafficStatistics::TYPE_SOURCE;
$res = $this->logic->save(compact('top', 'type'), $type, $date);
if (!$res['status']) {
$this->info($res['msg']);
$this->error++;
}
$this->info($res['msg']);
return $this->error;
}
}
<?php
namespace App\Console\Commands\Bside\Statistics;
use App\Models\Bside\Statistics\TrafficStatistics;
use App\Models\CustomerVisit\CustomerVisit;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Console\Command;
use Throwable;
class StatisticsTerminal extends Command
{
public $error = 0;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'statistics_terminal';
/**
* The console command description.
*
* @var string
*/
protected $description = '统计当月访问终端数据';
public $logic;
public function __construct()
{
parent::__construct();
$this->logic = new Logic();
}
/**
* @return void
* @throws Throwable
*/
public function handle()
{
$date = $this->logic->getMonths(TrafficStatistics::TYPE_TERMINAL);
if (!empty($date)) {
foreach ($date as $value) {
echo $this->statistics_terminal($value);
}
}
echo $this->statistics_terminal();
}
/**
* 统计当月访问终端数据
* @param string|null $date
* @return int|mixed
* @throws Throwable
*/
protected function statistics_terminal(string $date = null)
{
$customerVisit = new CustomerVisit();
$pcnum = $customerVisit->getTerminalPcCount($date);
$mbnum = $customerVisit->getTerminalMobileCount($date);
$top = json_encode($customerVisit->getCountryCount($date) ?? []);
$type = TrafficStatistics::TYPE_TERMINAL;
$res = $this->logic->save(compact('top', 'type', 'pcnum', 'mbnum'), $type, $date, '统计当月访问终端数据');
if (!$res['status']) {
$this->info($res['msg']);
$this->error++;
}
$this->info($res['msg']);
return $this->error;
}
}
<?php
namespace App\Console\Commands\Bside\Statistics;
use App\Models\Bside\Statistics\TrafficStatistics;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Console\Command;
use Throwable;
class StatisticsTrend extends Command
{
public $error = 0;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'statistics_trend';
/**
* The console command description.
*
* @var string
*/
protected $description = '统计当月流量趋势数据';
public $logic;
public function __construct()
{
parent::__construct();
$this->logic = new Logic();
}
/**
* 定时执行
* @return void
* @throws GuzzleException|Throwable
*/
public function handle()
{
$date = $this->logic->getMonths(TrafficStatistics::TYPE_TREND);
if (!empty($date)) {
foreach ($date as $value) {
echo $this->statistics_trend($value);
}
}
echo $this->statistics_trend();
}
/**
* 统计当天流量趋势数据
* @param string|null $date
* @return int|mixed
* @throws GuzzleException|Throwable
*/
protected function statistics_trend(string $date = null)
{
$domain = request()->getHttpHost(); //'www.wowstainless.com';
$sta_date = !is_null($date) ? $date . "-01" : date('Y-m-01');
$inquiry = getInquiryInformation($domain, $sta_date);
$innum = $inquiry['count'] ?? 0;
$top = json_encode($inquiry['lists'] ?? []);
$type = TrafficStatistics::TYPE_TREND;
$res = $this->logic->save(compact('top', 'type', 'innum'), $type, $date, '统计当月流量趋势数据');
if (!$res['status']) {
$this->info($res['msg']);
$this->error++;
}
$this->info($res['msg']);
return $this->error;
}
}
<?php
namespace App\Console\Commands\YesterdayCount;
namespace App\Console\Commands\DayCount;
use App\Helper\Common;
use App\Helper\FormGlobalsoApi;
use App\Http\Logic\Aside\Project\ProjectLogic;
use App\Models\CustomerVisit\CustomerVisitItem;
use App\Models\Domain\DomainInfo;
use App\Models\Project\DeployBuild;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Project;
use App\Services\ProjectServer;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class Yesterday extends Command
class Count extends Command
{
const STATUS_ERROR = 400;
public $error = 0;
... ... @@ -20,7 +23,7 @@ class Yesterday extends Command
*
* @var string
*/
protected $signature = 'yesterday_count';
protected $signature = 'count';
/**
* The console command description.
... ... @@ -28,6 +31,7 @@ class Yesterday extends Command
* @var string
*/
protected $description = '统计昨日数据';
/**
* @name :(定时执行生成昨日数据统计)handle
* @author :lyh
... ... @@ -36,32 +40,54 @@ class Yesterday extends Command
*/
public function handle()
{
$deployModel = new DeployBuild();
$list = $deployModel->list();
$data = [];
$yesterday = Carbon::yesterday()->toDateString();
foreach ($list as $v){
$arr = [];
//统计时间
$arr['date'] = $yesterday;
//pv统计
$arr['pv_num'] = $this->pv_num($yesterday,$v['test_domain']);
//ip统计
$arr['ip_num'] = $this->ip_num($yesterday,$v['test_domain']);
//服务达标天数
$arr['compliance_day'] = $this->compliance_day($yesterday);
//剩余服务时常
$arr['service_day'] = $v['service_duration'] - Common::getDaysToTargetDate($v['created_at']);
//项目id
$arr['project_id'] = $v['project_id'];
$arr['created_at'] = date('Y-m-d H:i:s');
$arr['updated_at'] = date('Y-m-d H:i:s');
//询盘统计
$arr = $this->inquiry($arr,$v['test_domain']);
$data[] = $arr;
$list = DB::table('gl_project')->where('gl_project.extend_type','!=',5)
->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')
->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
->select($this->selectParam())->get();
try {
if(!empty($list)){
$list = $list->toArray();
$data = [];
$yesterday = Carbon::yesterday()->toDateString();
$domainInfo = new DomainInfo();
foreach ($list as $v){
$v = (array)$v;
if($v['type'] == Project::TYPE_ZERO){
continue;
}
if(!empty($v['domain'])){
$info = $domainInfo->read(['id'=>$v['domain']]);
if($info !== false){
$v['test_domain'] = $info['domain'];
}
}
$arr = [];
//统计时间
$arr['date'] = $yesterday;
ProjectServer::useProject($v['id']);
//pv统计
$arr['pv_num'] = $this->pv_num($yesterday,$v['test_domain']);
//ip统计
$arr['ip_num'] = $this->ip_num($yesterday,$v['test_domain']);
DB::disconnect('custom_mysql');
//服务达标天数
$arr['compliance_day'] = $this->compliance_day($v['id']);
//剩余服务时常
$arr['service_day'] = $v['remain_day'];
//项目id
$arr['project_id'] = $v['project_id'];
$arr['created_at'] = date('Y-m-d H:i:s');
$arr['updated_at'] = date('Y-m-d H:i:s');
//询盘统计
$arr = $this->inquiry($arr,$v['test_domain']);
$data[] = $arr;
}
//判断数据是否存在
DB::table('gl_count')->insert($data);
}
}catch (\Exception $e){
Log::error('同步数据执行失败');
}
//判断数据是否存在
DB::table('gl_count')->insert($data);
echo $this->error;
}
... ... @@ -72,18 +98,18 @@ class Yesterday extends Command
* @time :2023/6/14 15:40
*/
public function pv_num($yesterday,$domain){
$pv = DB::table('gl_customer_visit_item')->whereDate('updated_date', $yesterday)->where('domain',$domain)->count();
$pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $yesterday)->where('domain',$domain)->count();
return $pv;
}
/**
* @name :(统计pv)pv_num
* @name :(统计ip)ip_num
* @author :lyh
* @method :post
* @time :2023/6/14 15:40
*/
public function ip_num($yesterday,$domain){
$ip = DB::table('gl_customer_visit')->whereDate('updated_date', $yesterday)->where('domain',$domain)->count();
$ip = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $yesterday)->where('domain',$domain)->count();
return $ip;
}
... ... @@ -125,9 +151,9 @@ class Yesterday extends Command
* @method :post
* @time :2023/6/14 15:48
*/
public function compliance_day($yesterday){
public function compliance_day($project_id){
//服务达标天数
$rank_info = DB::table('gl_rank_data')->where(['updated_date'=>$yesterday,'lang'=>''])->select(['compliance_day'])->first();
$rank_info = DB::table('gl_rank_data')->where(['project_id'=>$project_id,'lang'=>''])->select(['compliance_day'])->first();
if(empty($rank_info)){
$compliance_day = 0;
}else{
... ... @@ -135,4 +161,25 @@ class Yesterday extends Command
}
return $compliance_day;
}
/**
* @name :(查询参数设置)selectParam
* @author :lyh
* @method :post
* @time :2023/6/14 15:00
*/
public function selectParam(){
$select = [
'gl_project.id AS id',
'gl_project.type AS type',
'gl_project.extend_type AS extend_type',
'gl_project.remain_day AS remain_day',
'gl_project_deploy_build.test_domain AS test_domain',
'gl_project_deploy_optimize.domain AS domain',
'gl_project_deploy_build.project_id AS project_id',
'gl_project.cooperate_date AS cooperate_date',
'gl_project_deploy_build.service_duration AS service_duration',
];
return $select;
}
}
... ...
<?php
namespace App\Console\Commands\DayCount;
use App\Models\Inquiry\InquiryCount as InquiryCountModel;
use App\Models\Inquiry\InquiryInfo;
use Carbon\Carbon;
use Illuminate\Console\Command;
/**
* @remark :
* @class :InquiryCount.php
* @author :lyh
* @time :2023/7/14 16:20
*/
class InquiryCount extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'inquiry_count';
/**
* The console command description.
*
* @var string
*/
protected $description = '每天统计询盘数量';
/**
* @var :根据状态统计
*/
public $status = [
1=>'站群询盘',
2=>'ai站群询盘',
3=>'amp自建平台',
4=>'fb询盘',
5=>'fb广告',
6=>'广告采集建站',
7=>'黄金平台询盘',
8=>'内部统计',
9=>'GlobalImporter',
10=>'whatsapp',
11=>'Skype',
12=>'建站客户',
13=>'ChinaCn',
14=>'EC21',
15=>'邮件群发'
];
/**
* @remark :统计
* @name :handle
* @author :lyh
* @method :post
* @time :2023/7/14 16:21
*/
public function handle(){
$data = [];
//获取昨天的时间
$yesterday = Carbon::yesterday()->toDateString();
$inquiryInfoModel = new InquiryInfo();
foreach ($this->status as $k=>$v){
$total = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']]])->count();
$untreated = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']],'status'=>1])->count();
$invalid = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']],'status'=>0])->count();
$data[] = [
'type'=>$k,
'day'=>$yesterday,
'total'=>$total ?? 0,
'untreated'=>$untreated ?? 0,
'invalid'=>$invalid ?? 0
];
}
$inquiryCount = new InquiryCountModel();
$inquiryCount->insert($data);
return true;
}
}
... ...
<?php
namespace App\Console\Commands\DayCount;
use App\Models\Inquiry\InquiryInfo;
use Illuminate\Console\Command;
/**
* @remark :
* @class :InquiryDelay.php
* @author :lyh
* @time :2023/7/14 10:16
*/
class InquiryDelay extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'inquiry_delay';
/**
* The console command description.
*
* @var string
*/
protected $description = '延时询盘转发';
/**
* @remark :延时询盘转发
* @name :handle
* @author :lyh
* @method :post
* @time :2023/7/14 10:17
*/
public function handle()
{
$inquiryInfoModel = new InquiryInfo();
$param = $inquiryInfoModel->formatQuery(['status'=>$inquiryInfoModel::STATUS_FOUR])->orderBy('send_time','asc')->first();
if(!empty($param)){
$time = date('Y-m-d H:i:s');
if($time >= $param['send_time']){
$data = [];
//TODO::处理转发的url
$arr_url = explode(',',$param['forward_url']);
foreach ($arr_url as $v){
$data['url'] = $v;
$this->inquiryForward($data);
}
$inquiryInfoModel->edit(['status'=>$inquiryInfoModel::STATUS_THREE],['id'=>$param['id']]);
}
}
return true;
}
/**
* @remark :询盘转发
* @name :inquiryForward
* @author :lyh
* @method :post
* @time :2023/7/13 14:39
*/
public function inquiryForward($post_data){
$url = 'https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f';
$post_data_new = [];
$post_data_new['refer'] = $post_data['url'];
$post_data_new['name'] = $post_data['name'];
$post_data_new['email'] = $post_data['email'];
$post_data_new['phone'] = $post_data['phone'];
$post_data_new['ip'] = $post_data['ip'];
$post_data_new['message'] = $post_data['message'];
$post_data_new['submit_time'] = date('Y-m-d H:i:s',time()+20);
$token = md5($post_data_new['refer'].$post_data_new['name'].$post_data_new['ip'].date("Y-m-d",time()));
$post_data_new['token'] = $token;
$header = array(
'CLIENT-IP: '.$post_data['ip'],
'X-FORWARDED-FOR: '.$post_data['ip']
);
return http_post($url,$post_data_new,$header);
}
}
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Console\Commands;
use App\Models\Devops\DevopsTaskLog;
use App\Models\Project\Project;
use App\Utils\EncryptUtils;
use Illuminate\Console\Command;
use App\Models\Devops\DevopsTask as DevopsTaskModel;
... ... @@ -45,16 +46,13 @@ class DevopsTask extends Command
*/
public function handle()
{
while (true){
$tasks = DevopsTaskModel::where('status', DevopsTaskModel::STATUS_PENDING)->get();
foreach ($tasks as $task){
echo "Start task " . $task->id . PHP_EOL;
if($task->type == DevopsTaskModel::TYPE_MYSQL){
$this->updateTable($task);
}
echo "End task " . $task->id . PHP_EOL;
$tasks = DevopsTaskModel::where('status', DevopsTaskModel::STATUS_PENDING)->get();
foreach ($tasks as $task){
echo "Start task " . $task->id;
if($task->type == DevopsTaskModel::TYPE_MYSQL){
$this->updateTable($task);
}
sleep(10);
echo "End task " . $task->id . PHP_EOL;
}
}
... ... @@ -64,6 +62,7 @@ class DevopsTask extends Command
echo "project " . $project->id;
$log = DevopsTaskLog::addLog($task->id, $project->id);
if($log->status == DevopsTaskModel::STATUS_ACTIVE){
echo 'continue' . PHP_EOL;
continue;
}
if(!$project->mysqlConfig){
... ... @@ -73,13 +72,21 @@ class DevopsTask extends Command
continue;
}
//DB类是单例模式,生命周期内修改配置不会生效
$conn = new \mysqli(
$project->mysqlConfig->host,
$project->mysqlConfig->user,
$project->mysqlConfig->password,
$project->databaseName(),
$project->mysqlConfig->port,
);
try {
$conn = new \mysqli(
$project->mysqlConfig->host,
$project->mysqlConfig->user,
$project->mysqlConfig->password,
$project->databaseName(),
$project->mysqlConfig->port,
);
}catch (\Exception $e){
$log->remark = mb_substr('数据库连接失败:' . $e->getMessage(), 0, 500);
$log->status = DevopsTaskLog::STATUS_ERROR;
$log->save();
echo '-->' . $log->remark . PHP_EOL;
continue;
}
$res = $conn->query($task->sql);
$log->status = $res ? DevopsTaskLog::STATUS_ACTIVE : DevopsTaskLog::STATUS_ERROR;
... ...
<?php
/**
* @remark :
* @name :DomainInfo.php
* @author :lyh
* @method :post
* @time :2023/9/11 14:37
*/
namespace App\Console\Commands\Domain;
use Illuminate\Console\Command;
use App\Models\Domain\DomainInfo as DomainInfoModel;
class DomainInfo extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'domain_info';
/**
* The console command description.
*
* @var string
*/
protected $description = '域名相关';
/**
* @remark :更新证书+证书有效时间
* @name :handle
* @author :lyh
* @method :post
* @time :2023/9/11 15:09
*/
public function handle(){
$domainModel = new DomainInfoModel();
$map = ['status'=>['!=',2]];
$list = $domainModel->list($map);
foreach ($list as $v){
$ssl = $this->updateDomainSsl($v['domain']);
$time = $this->updateDomain($v['domain']);
$data = [
'certificate_start_time'=>$ssl['from'],
'certificate_end_time'=>$ssl['to'],
'domain_start_time'=>$time['start'],
'domain_end_time'=>$time['end']
];
$domainModel->edit($data,['id'=>$v['id']]);
}
return 1;
}
/**
* @remark :更新域名证书
* @name :updateDomainSsl
* @author :lyh
* @method :post
* @time :2023/9/11 15:07
*/
public function updateDomainSsl($domain){
try {
$context = stream_context_create([
'ssl' => [
'capture_peer_cert' => true,
'capture_peer_cert_chain' => false,
],
]);
$stream = stream_socket_client('ssl://'.$domain.':443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);
if(!$stream) {
die("Failed to connect: $errno - $errstr");
}
$remote_cert = stream_context_get_params($stream)['options']['ssl']['peer_certificate'];
if(!$remote_cert) {
die("Failed to retrieve certificate");
}
$valid_from = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validFrom_time_t']);
$valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']);
fclose($stream);
}catch (\Exception $e){
$valid_from = date('Y-m-d H:i:s');
$valid_to = date('Y-m-d H:i:s');
}
return ['from'=>$valid_from,'to'=>$valid_to];
}
/**
* @remark :更新域名有限时间
* @name :updateDomain
* @author :lyh
* @method :post
* @time :2023/9/11 15:11
*/
public function updateDomain($domain){
$url = 'http://openai.waimaoq.com/v1/whois_api?domain='.$domain;
$response = http_get($url);
$start = '';
$end = '';
if($response['code'] == 200){
$start = $response['text']['creation_date'];
$end = $response['text']['expiration_date'];
}
return ['start'=>$start,'end'=>$end];
}
}
... ...
<?php
namespace App\Console\Commands\Domain;
use App\Exceptions\AsideGlobalException;
use App\Exceptions\BsideGlobalException;
use App\Http\Logic\Aside\Domain\DomainInfoLogic;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Console\Command;
class DomainTime extends Command
{
public $error = 0;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'domain_time';
/**
* The console command description.
*
* @var string
*/
protected $description = '域名定时任务 更新域名|证书到期时间';
/**
* @name :(定时执行)handle
* @author :lyh
* @method :post
* @time :2023/5/12 14:48
*/
public function handle()
{
echo $this->update_domain_time();
}
/**
* 更新域名|证书到期时间
* @return int|mixed|void
* @throws AsideGlobalException
* @throws BsideGlobalException|GuzzleException
*/
protected function update_domain_time()
{
$domainCon = new DomainInfoLogic();
$all = $domainCon->getAllDomain();
$all = $all->toArray();
if ( empty( $all ) ) {
$this->info( '未获取到数据' );
return;
}
foreach ( $all as $item ) {
$domain = $item['domain'];
// 域名到期时间
$domainT = $domainCon->getDomainTime( $domain );
if ( $domainT ) {
$domain_time = $item['domain_end_time'];
$domainValidFrom = $domainT['validFrom'];
$domainValidTo = $domainT['validTo'];
if ( strtotime( $domain_time ) < strtotime( $domainValidTo ) ) {
$this->info( $domain . '域名到期时间更新成功' );
$domainCon->updateDomain( $item['id'], [ 'domain_end_time' => $domainValidTo ] );
}
} else {
$this->error++;
$this->info( $domain . '域名到期时间获取失败' );
}
// 证书到期时间
$certificateT = $domainCon->getDomainCertificateTime( $domain );
if ( $certificateT ) {
$certificate_time = $item['certificate_end_time'];
$certificateValidFrom = $certificateT['validFrom'];
$certificateValidTo = $certificateT['validTo'];
if ( strtotime( $certificate_time ) < strtotime( $certificateValidTo ) ) {
$this->info( $domain . '证书到期时间更新成功' );
$domainCon->updateDomain( $item['id'], [ 'certificate_end_time' => $certificateValidTo ] );
}
} else {
$this->error++;
$this->info( $domain . '证书到期时间获取失败' );
}
}
return $this->error;
}
}
<?php
/**
* @remark :
* @name :ImportManager.php
* @author :lyh
* @method :post
* @time :2023/8/7 17:47
*/
namespace App\Console\Commands;
use App\Models\Manage\EntryPosition;
use App\Models\Manage\JobLevel;
use App\Models\Manage\ManageHr;
use App\Models\Service\Service;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class ImportManager extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'import_manager';
/**
* The console command description.
*
* @var string
*/
protected $description = '导入数据';
/**
* @remark :导入5.0管理员数据
* @name :handle
* @author :lyh
* @method :post
* @time :2023/8/7 17:49
*/
public function handle(){
$model = new Service();
$info = $model->read(['type'=>5]);
$values = json_decode($info['values']);
$values = array_reverse($values);
$hrModel = new ManageHr();
foreach ($values as $k => $v){
$v = (array)$v;
$info = $hrModel->read(['mobile'=>$v['mobile']]);
if($info !== false){
continue;
}
$data = [
'name'=>$v['name'],
'mobile'=>$v['mobile'],
'password'=>'$2y$10$ZNHxlIddWiQzQbIIzFgYJOsPlQ4n0cwWl8Sea53qvQvDXtu3WeYMC',
'created_at'=>date('Y-m-d H:i:s'),
'updated_at'=>date('Y-m-d H:i:s'),
];
$manager_id = DB::table('gl_manage')->insertGetId($data);
if($v['sex'] == '女'){
$v['sex'] = 2;
}else{
$v['sex'] = 1;
}
$education = [
'专科' => 1,
'大专' => 1,
'中专' => 0,
'本科' => 2,
'自考本科'=>0,
'全日制本科'=>2,
'本科在读'=>2,
'大学本科'=>2,
'硕士研究生' => 3,
'硕士'=>3,
'其他' => 0,
];
$belong_group = [
'-' => 0,
'KA组' => 1,
'A组' => 2,
'B组' => 3,
'C组'=>4,
'D组'=>5,
'E组'=>6,
'F组'=>7,
'G组' => 8,
'H组'=>9,
'GA组' => 10,
'GB组' => 11,
'GC组' => 12,
'前端组' => 13,
'后端组' => 14,
'黑格组' => 15,
'售后组' => 16,
'其他' => 0,
];
//获取入职岗位
$entryPositionModel = new EntryPosition();
$entry_position = $entryPositionModel->read(['name'=>$v['entry_position']]);
if($entry_position !== false){
$entry_position = $entry_position['id'];
}else{
$entry_position = 0;
}
//获取级别
$jobLevelModel = new JobLevel();
if(!empty($v['p_level'])){
$p_level = $jobLevelModel->read(['name'=>$v['p_level']]);
if($p_level !== false){
$p_level = $p_level['id'];
}else{
$p_level = 0;
}
}else{
$p_level = 0;
}
$manager_data = [
'manage_id'=>$manager_id,
'name'=>$v['name'],
'id_card'=>$v['id_card'],
'mobile'=>$v['mobile'],
'birthday'=>!empty($v['birthday']) ? $v['birthday'] : date('Y-m-d'),
'address'=>$v['address'],
'sex'=>$v['sex'],
'nationality'=>$v['nationality'],
'belong_group'=>$belong_group[$v['belong_group']],
'education'=>isset($education[$v['education']]) ? $education[$v['education']] : 0,
'major'=>$v['major'],
'graduate_school'=>$v['graduate_school'],
'english_level'=>$v['english_level'],
'entry_position'=>$entry_position ?? 0,
'p_level'=>$p_level,
'residential_address'=>$v['residential_address'],
'emergency_contact'=>$v['emergency_contact'],
'career_history'=>json_encode((array)$v['career_history']),
'learning_history'=>json_encode((array)$v['learning_history']),
'bank_card'=>$v['bank_card'],
'photo_gallery'=>json_encode((array)$v['photo_gallery']),
'id_card_gallery'=>json_encode((array)$v['id_card_gallery']),
'certificate_gallery'=>json_encode((array)$v['certificate_gallery']),
'dangyuan'=>$v['dangyuan'],
'dangzhibu'=>$v['dangzhibu'],
'dang_address'=>$v['dang_address'],
'join_date'=>!empty($v['join_date']) ? $v['join_date'] : date('Y-m-d'),
'status'=> 1,
'computer_account'=>$v['computer_account'],
'qq_account'=>$v['qq_account']
];
$hrModel->add($manager_data);
}
return 1;
}
}
... ...
<?php
namespace App\Console\Commands;
use App\Helper\Arr;
use App\Helper\FormGlobalsoApi;
use App\Http\Logic\Bside\InquiryLogic;
use App\Models\Product\Category;
use App\Models\Product\Product;
use App\Models\Project\OnlineCheck;
use App\Models\Project\Project;
use App\Models\RankData\RankData as GoogleRankModel;
use App\Models\RouteMap\RouteMap;
use GuzzleHttp\Client;
use GuzzleHttp\Promise\Utils;
use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
/**
* 最近一次询盘
* Class InquiryList
* @package App\Console\Commands
* @author zbj
* @date 2023/9/11
*/
class LastInquiry extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'last_inquiry';
/**
* The console command description.
*
* @var string
*/
protected $description = '询盘列表';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* @return bool
*/
public function handle()
{
$list = Project::with('deploy_optimize')->whereIn('type', [2,3,4])->get();
foreach ($list as $item){
if(empty($item['deploy_optimize']['domain'])){
continue;
}
$api = new FormGlobalsoApi();
$res = $api->getInquiryList($item['deploy_optimize']['domain']);
if($res && $res['status'] == 200){
if(empty($res['data']['data'][0])){
continue;
}
$item->last_inquiry_time = $res['data']['data'][0]['submit_time'];
$item->save();
}
}
}
}
... ...
<?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;
}
}
... ...
<?php
namespace App\Console\Commands\MonthlyCount;
use App\Helper\FormGlobalsoApi;
use App\Models\Domain\DomainInfo;
use App\Models\Project\Project;
use App\Services\ProjectServer;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class InquiryMonthlyCount extends Command
{
const STATUS_ERROR = 400;
public $error = 0;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'month_count';
/**
* The console command description.
*
* @var string
*/
protected $description = '询盘月报告统计';
/**
* @remark :询盘月报告
* @name :handle
* @author :lyh
* @method :post
* @time :2023/6/30 9:32
*/
public function handle(){
$list = DB::table('gl_project')->where('gl_project.extend_type','!=',5)
->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')
->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
->select($this->selectParam())->get()->toArray();
// 获取上个月的开始时间
$startTime = Carbon::now()->subMonth()->startOfMonth()->toDateString();
// 获取上个月的结束时间
$endTime = Carbon::now()->subMonth()->endOfMonth()->toDateString();
$domainInfo = new DomainInfo();
foreach ($list as $value){
$value = (array)$value;
if($value['type'] == Project::TYPE_ZERO){
continue;
}
if(!empty($value['domain'])){
$info = $domainInfo->read(['id'=>$value['domain']]);
if($info !== false){
$value['test_domain'] = $value['domain'];
}
}
$arr = [];
//按月统计询盘记录
$arr = $this->inquiryCount($arr,$startTime,$endTime,$value['test_domain']);
$arr = $this->flowCount($arr,$startTime,$endTime,$value['project_id']);
ProjectServer::useProject($value['project_id']);
$arr = $this->sourceCount($arr,$value['test_domain'],$startTime,$endTime);
DB::disconnect('custom_mysql');
$arr['created_at'] = date('Y-m-d H:i:s');
$arr['updated_at'] = date('Y-m-d H:i:s');
$arr['project_id'] = $value['project_id'];
// 获取当前日期时间
$arr['month'] = Carbon::now()->subMonth()->format('Y-m');
DB::table('gl_month_count')->insert($arr);
}
return true;
}
/**
* @param $domain
* @param $project_id
* @remark :询盘按月统计
* @name :inquiryCount
* @author :lyh
* @method :post
* @time :2023/6/30 14:29
*/
public function inquiryCount(&$arr,&$startTime,&$endTime,$domain){
$inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
//总数
$arr['total'] = $inquiry_list['data']['total'] ?? 0;
//数据详情
$data = $inquiry_list['data']['data'] ?? 0;
$arr['month_total'] = 0;
$countryArr = [];
$arr['country'] = "";
if(!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']] = 0;
}
}
arsort($countryArr);
$top20 = array_slice($countryArr, 0, 15, true);
$arr['country'] = json_encode($top20);
}
return $arr;
}
/**
* @remark :流量统计
* @name :flowCount
* @author :lyh
* @method :post
* @time :2023/6/30 14:31
*/
public function flowCount(&$arr,&$startTime,&$endTime,$project_id){
$pv_ip = DB::table('gl_count')
->where(['project_id'=>$project_id])
->where('date','>=',$startTime.' 00:00:00')
->where('date','<=',$endTime.' 23:59:59')
->select(DB::raw('SUM(pv_num) as pv_num'), DB::raw('SUM(ip_num) as ip_num'))
->first();
$arr['pv'] = $pv_ip->pv_num;
$arr['ip'] = $pv_ip->ip_num;
if($arr['ip'] != 0){
$arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 10,2);
}
return $arr;
}
/**
* @remark :来源访问前8
* @name :sourceCount
* @author :lyh
* @method :post
* @time :2023/6/30 16:14
*/
public function sourceCount(&$arr,$domain,$startTime,$endTime){
//访问来源前10
$source = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('referrer_url', DB::raw('COUNT(*) as count'))
->groupBy('referrer_url')->where(['domain'=>$domain])
->whereBetween('updated_date', [$startTime,$endTime])
->orderByDesc('count')->limit(10)->get()->toArray();
$arr['source'] = json_encode($source);
//访问国家前15
$source_country = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
->groupBy('country')->where(['domain'=>$domain])
->whereBetween('updated_date', [$startTime,$endTime])
->orderBy('ip','desc')->limit(15)->get()->toArray();
$arr['source_country'] = json_encode($source_country);
//受访界面前15
$referrer_url = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('url',DB::raw('COUNT(*) as num'))
->orderBy('num','desc')->where(['domain'=>$domain])
->whereBetween('updated_date', [$startTime,$endTime])
->groupBy('url')
->limit(15)->get()->toArray();
$arr['referrer_url'] = json_encode($referrer_url);
//访问端口
$referrer_port = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('device_port',DB::raw('COUNT(*) as num'))
->orderBy('num','desc')->where(['domain'=>$domain])
->whereBetween('updated_date', [$startTime,$endTime])
->groupBy('device_port')
->limit(15)->get()->toArray();
$arr['referrer_port'] = json_encode($referrer_port);
return $arr;
}
/**
* @name :(查询参数设置)selectParam
* @author :lyh
* @method :post
* @time :2023/6/14 15:00
*/
public function selectParam(){
$select = [
'gl_project.id AS id',
'gl_project.type AS type',
'gl_project.extend_type AS extend_type',
'gl_project_deploy_build.test_domain AS test_domain',
'gl_project_deploy_optimize.domain AS domain',
'gl_project_deploy_build.project_id AS project_id',
'gl_project.cooperate_date AS cooperate_date',
'gl_project_deploy_build.service_duration AS service_duration',
];
return $select;
}
}
... ...
... ... @@ -6,6 +6,7 @@ use App\Helper\Arr;
use App\Helper\SemrushApi;
use App\Models\RankData\ExternalLinks as ExternalLinksModel;
use App\Models\Project\DeployOptimize;
use App\Utils\LogUtils;
/**
* Class ExternalLinks
... ... @@ -39,7 +40,7 @@ class ExternalLinks extends BaseCommands
$semrushApi = new SemrushApi();
//有排名api编号的项目
$list = DeployOptimize::where('api_no', '>', 0)->pluck('domain', 'project_id')->toArray();
LogUtils::info('start rank_data_external_links:' . count($list));
foreach ($list as $project_id => $domain) {
if(!$domain){
continue;
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Console\Commands\RankData;
use App\Helper\QuanqiusouApi;
use App\Models\Project\DeployOptimize;
use App\Models\RankData\IndexedPages as IndexedPagesModel;
use App\Utils\LogUtils;
/**
* Class IndexedPages
... ... @@ -38,7 +39,7 @@ class IndexedPages extends BaseCommands
$api = new QuanqiusouApi();
//有排名api编号的项目
$list = DeployOptimize::where('api_no', '>', 0)->pluck('api_no', 'project_id')->toArray();
LogUtils::info('start rank_data_indexed_pages:' . count($list));
foreach ($list as $project_id => $api_no) {
$model = IndexedPagesModel::where('project_id', $project_id)->first();
if($model && $model->updated_date == getThisWeekStarDate()){
... ...
... ... @@ -6,7 +6,9 @@ use App\Helper\Arr;
use App\Helper\QuanqiusouApi;
use App\Models\Project\DeployBuild;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Project;
use App\Models\RankData\RankData as GoogleRankModel;
use App\Utils\LogUtils;
/**
* Class GoogleRank
... ... @@ -25,6 +27,7 @@ class RankData extends BaseCommands
/**
* The console command description.
* The console command description.
*
* @var string
*/
... ... @@ -40,6 +43,7 @@ class RankData extends BaseCommands
$api = new QuanqiusouApi();
//有排名api编号的项目
$list = DeployOptimize::where('api_no', '>' , 0)->select('api_no','minor_languages','project_id')->get();
LogUtils::info('start rank_data:' . count($list));
//当日所有站点谷歌收录数据
$site_res = $api->getSiteRes();
if(!$site_res){
... ... @@ -55,10 +59,8 @@ class RankData extends BaseCommands
}
//收录数
$indexed_pages_num = $site_res[$item['api_no']] ?? 0;
$this->save_rank($item['project_id'], $res, $indexed_pages_num);
}
//有小语种的
$lang_list = $api->getLangList();
if(!empty($lang_list[$item['api_no']])){
... ... @@ -142,11 +144,14 @@ class RankData extends BaseCommands
}
//关键词达标天数
$model->is_compliance = 0;
if($model->updated_date != date('Y-m-d')){
//保证关键词数
$keyword_num = DeployBuild::where('project_id', $project_id)->value('keyword_num');
if($first_page_num >= $keyword_num){
$type = Project::where('id', $project_id)->value('type');
if($keyword_num && $type == 2 && $first_page_num >= $keyword_num){
$model->compliance_day = $model->compliance_day + 1;
$model->is_compliance = 1;
}
}
... ... @@ -160,6 +165,7 @@ class RankData extends BaseCommands
$model->lang = $lang;
$model->data = $data;
$model->updated_date = date('Y-m-d');
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($model, true) . PHP_EOL, FILE_APPEND);
$model->save();
}
}
... ...
... ... @@ -7,6 +7,7 @@ use App\Helper\Arr;
use App\Helper\QuanqiusouApi;
use App\Models\Project\DeployOptimize;
use App\Models\RankData\RankWeek as RankWeekModel;
use App\Utils\LogUtils;
/**
* Class WeekRank
... ... @@ -49,7 +50,7 @@ class RankWeek extends BaseCommands
$res = Arr::s2a($res);
//有排名api编号的项目
$list = DeployOptimize::where('api_no', '>', 0)->pluck('api_no', 'project_id')->toArray();
LogUtils::info('start rank_data_week:' . count($list));
foreach ($list as $project_id => $api_no) {
$rank_week = RankWeekModel::where('project_id', $project_id)->first();
if ($rank_week && $rank_week->updated_date == getThisWeekStarDate()) {
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Console\Commands\RankData;
use App\Helper\SemrushApi;
use App\Models\RankData\RecommDomain as RecommDomainModel;
use App\Models\Project\DeployOptimize;
use App\Utils\LogUtils;
/**
* Class RecommDomain
... ... @@ -38,7 +39,7 @@ class RecommDomain extends BaseCommands
$semrushApi = new SemrushApi();
//有排名api编号的项目
$list = DeployOptimize::where('api_no', '>', 0)->pluck('domain', 'project_id')->toArray();
LogUtils::info('start rank_data_recomm_domain:' . count($list));
foreach ($list as $project_id => $domain) {
if(!$domain){
continue;
... ...
... ... @@ -6,6 +6,7 @@ use App\Helper\Arr;
use App\Helper\GoogleSpeedApi;
use App\Models\Project\DeployOptimize;
use App\Models\RankData\Speed as GoogleSpeedModel;
use App\Utils\LogUtils;
/**
* Class GoogleSpeed
... ... @@ -42,7 +43,7 @@ class Speed extends BaseCommands
//有排名api编号的项目
$list = DeployOptimize::where('api_no', '>', 0)->pluck('domain', 'project_id')->toArray();
LogUtils::info('start rank_data_speed:' . count($list));
foreach ($list as $project_id => $domain) {
$model = GoogleSpeedModel::where('project_id', $project_id)->first();
if ($model && $model->updated_date == getThisWeekStarDate()) {
... ... @@ -53,6 +54,7 @@ class Speed extends BaseCommands
$res = $googleSpeedApi->run($domain);
if (!$res) {
$error++;
continue;
}
if (!$model) {
$model = new GoogleSpeedModel;
... ...
<?php
namespace App\Console\Commands;
use App\Helper\Arr;
use App\Models\Product\Category;
use App\Models\Product\Product;
use App\Models\Project\OnlineCheck;
use App\Models\Project\Project;
use App\Models\RankData\RankData as GoogleRankModel;
use App\Models\RouteMap\RouteMap;
use GuzzleHttp\Client;
use GuzzleHttp\Promise\Utils;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
/**
* 剩余服务时长
* Class Traffic
* @package App\Console\Commands
* @author zbj
* @date 2023/5/18
*/
class RemainDay extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'remain_day';
/**
* The console command description.
*
* @var string
*/
protected $description = '网站服务剩余时长';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* @return bool
*/
public function handle()
{
$list = Project::whereIn('type', [2,3,4])->get();
foreach ($list as $item){
if($item['type'] == 3){
//排名达标天数
$compliance_day = GoogleRankModel::where(['project_id' => $item['id'], 'lang' => ''])->value('compliance_day') ?: 0;
$remain_day = $item['deploy_build']['service_duration'] - $compliance_day;
}else{
//审核上线后开始
$check_time = OnlineCheck::where('project_id', $item['id'])->where('status', 1)->value('created_at') ?: '';
if(!$check_time){
$remain_day = $item['deploy_build']['service_duration'];
}else{
$diff = time() - strtotime($check_time);
$remain_day = floor($diff / (60 * 60 * 24));
}
}
$item->remain_day = $remain_day > 0 ? $remain_day : 0;
$item->save();
}
}
}
... ...
<?php
namespace App\Console\Commands;
use App\Helper\OaGlobalsoApi;
use App\Models\Channel\Channel;
use App\Models\Channel\User;
use App\Models\Channel\Zone;
use Illuminate\Console\Command;
/**
* 渠道信息
* Class ChannelInfo
* @package App\Console\Commands
* @author zbj
* @date 2023/6/27
*/
class SyncChannel extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sync_channel';
/**
* The console command description.
*
* @var string
*/
protected $description = '更新渠道信息';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* @return bool
*/
public function handle()
{
$api = new OaGlobalsoApi();
$res = $api->agents_lists();
if($res && !empty($res['data'])){
foreach ($res['data'] as $item){
$zone = Zone::sync($item['belong']);
$channel = Channel::sync($item, $zone->id);
foreach ($item['users'] as $user){
User::sync($user, $channel->id);
}
}
}
return true;
}
}
... ...
<?php
namespace App\Console\Commands;
use App\Helper\Arr;
use App\Helper\Common;
use App\Helper\OaGlobalsoApi;
use App\Models\Channel\Channel;
use App\Models\Com\NoticeLog;
use App\Models\Project\After;
use App\Models\Project\DeployBuild;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Payment;
use App\Models\Project\Project;
use App\Models\Project\ProjectRenew;
use App\Utils\LogUtils;
use Hashids\Hashids;
use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
/**
* 同步项目信息
* Class ChannelInfo
* @package App\Console\Commands
* @author zbj
* @date 2023/6/27
*/
class SyncProject extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sync_project';
/**
* The console command description.
*
* @var string
*/
protected $description = '同步项目信息';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* @return bool
*/
public function handle()
{
while (true){
$list = NoticeLog::where('type', NoticeLog::TYPE_PROJECT)->where('status', NoticeLog::STATUS_PENDING)->get();
foreach ($list as $item){
try {
$api = new OaGlobalsoApi();
$data = $api->order_info($item['data']['order_id']);
if(!$data || empty($data['data'])){
LogUtils::error('OaGlobalsoApi order_info error', $data);
$this->retry($item);
}
if($data['data']['order_type'] == '首次'){
$this->sync($data['data']);
//同步aicc
if($data['data']['exclusive_aicc']){
$this->toAicc($data['data']);
}
//同步hagro
if($data['data']['exclusive_hagro']){
$this->toHagro($data['data']);
}
}
if($data['data']['order_type'] == '续费'){
$this->renewSync($data['data']);
}
$item->status = NoticeLog::STATUS_SUCCESS;
$item->save();
}catch (\Exception $e){
errorLog('项目同步失败', $item, $e);
$this->retry($item);
}
}
sleep(2);
}
}
/**
* @param NoticeLog $log
*/
public function retry($log){
if($log->retry >= 3){
$log->status = NoticeLog::STATUS_FAIL;
}else{
$log->retry = $log->retry + 1;
}
$log->save();
}
/**
* @remark :同步续费记录单
* @name :renewSync
* @author :lyh
* @method :post
* @time :2023/8/11 15:33
*/
public function renewSync($param){
$title = date('Ymd') . '-' . $param['company_name'];;
$data = [
'title' => '【续费单】'.$title,
'company' => $param['company_name'],
'lead_name' => $param['principal_name'],
'mobile' => $param['principal_mobile'],
'qq' => $param['customer_qq'],
'channel' => json_encode(Channel::getProjectChannel($param['company_id'], $param['username_sales'])),
'requirement' => $param['remark'],
'cooperate_date' => date('Y-m-d', $param['create_time']),
'service_duration' => $param['years'],
'plan' => $this->versionData($param['plan_marketing']),
// 'api_no' => $param['id'], //改手动填
'amount' => $param['plan_price'],
'contract' => json_encode($param['files']),
'bill' => json_encode($param['images']),
];
$renewModel = new ProjectRenew();
$rs = $renewModel->add($data);
if($rs === false){
errorLog('项目续费单同步失败');
}
return true;
}
/**
* @remark :获取版本
* @name :versionData
* @author :lyh
* @method :post
* @time :2023/8/9 14:46
*/
public function versionData($param){
$data = Project::planMap();
$data = array_flip($data);
if(isset($data[$param])){
return $data[$param];
}else{
return 1;
}
}
/**
* @remark :导入数据
* @name :sync
* @author :lyh
* @method :post
* @time :2023/8/9 15:04
*/
public function sync($param){
$title = date('Ymd') . '-' . $param['company_name'];
$data = [
'project'=>[
'title' => $title,
'company' => $param['company_name'],
'lead_name' => $param['principal_name'],
'mobile' => $param['principal_mobile'],
'mysql_id'=>Project::MYSQL_ID,
'qq' => $param['customer_qq'],
'channel' => Channel::getProjectChannel($param['company_id'], $param['username_sales']),
'requirement' => $param['remark'],
'cooperate_date' => date('Y-m-d', $param['create_time']),
'from_order_id' => $param['from_order_id'],
'aicc' => $param['exclusive_aicc'],
"exclusive_aicc_day" => $param['exclusive_aicc_day'],
'hagro' => $param['exclusive_hagro'],
"exclusive_hagro_day" => $param['exclusive_hagro_day'],
'notice_order_id' => $param['id'],
],
'deploy_build' => [
'service_duration' => $param['years'],
'plan' => $this->versionData($param['plan_marketing']),
'login_mobile'=>$param['principal_mobile']
],
'deploy_optimize' => [
'api_no' => $param['id']
],
'project_after' => [],
'payment' => [
'amount' => $param['plan_price'],
'contract'=>$param['files'],
'bill'=>$param['images']
],
];
DB::beginTransaction();
try {
$id = $this->saveProject($data['project']);
$this->setPostId($data['deploy_build']['plan'],$id);;
$this->savePayment($data['payment'],$id);
$this->saveDeployBuild($data['deploy_build'],$id);
$this->saveDeployOptimize($data['deploy_optimize'],$id);
$this->saveAfter($data['project_after'],$id);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
throw new \Exception($e->getMessage());
}
}
/**
* @remark :设置post_id
* @name :setPostId
* @author :lyh
* @method :post
* @time :2023/8/9 14:47
*/
public function setPostId($plan,$id){
$length = strlen((string)$id); // 获取变量的位数
$paddingLength = Project::TYPE_FIVE - $length; // 计算填充前面的 0 的位数
$zeros = str_repeat("0", $paddingLength);
$number = Project::TYPE_SIX.$plan.$zeros.$id;
$projectModel = new Project();
$projectModel->edit(['post_id'=>$number],['id'=>$id]);
return true;
}
/**
* @remark :保存项目
* @name :saveProject
* @author :lyh
* @method :post
* @time :2023/8/30 15:53
*/
public function saveProject($param){
if(isset($param['channel']) && !empty($param['channel'])){
$param['channel'] = Arr::a2s($param['channel']);
}
$projectModel = new Project();
$info = $projectModel->read(['from_order_id'=>$param['from_order_id'],'delete_status'=>0]);
if($info !== false){
$projectModel->edit($param, ['id' => $info['id']]);
return $info['id'];
}else{
return $projectModel->addReturnId($param);
}
}
/**
* 保存优化部署
* @author zbj
* @date 2023/4/26
*/
protected function saveAfter($param,$id){
$param['project_id'] = $id;
//查询数据是否存在
$afterModel = new After();
$info = $afterModel->read(['project_id'=>$id]);
if($info !== false){
$afterModel->edit($param,['id'=>$info['id']]);
}else{
$afterModel->add($param);
}
}
/**
* @remark :保存付款续费
* @name :savePayment
* @author :lyh
* @method :post
* @time :2023/8/29 16:19
*/
protected function savePayment($param,$id){
$param['project_id'] = $id;
$paymentModel= new Payment();
// if(isset($param['contract']) && !empty($param['contract'])){
$param['contract'] = Arr::a2s($param['contract']);
// }
// if(isset($param['bill']) && !empty($param['bill'])){
$param['bill'] = Arr::a2s($param['bill']);
// }
$info = $paymentModel->read(['project_id'=>$id]);
if($info !== false){
$paymentModel->edit($param,['id'=>$info['id']]);
}else{
$paymentModel->add($param);
}
}
/**
* @remark :保存建站部署
* @name :saveDeployBuild
* @author :lyh
* @method :post
* @time :2023/8/29 16:19
*/
protected function saveDeployBuild($param,$id){
$param['project_id'] = $id;
$hashids = new Hashids('test_domain', 5, 'abcdefghjkmnpqrstuvwxyz1234567890');
$code = $hashids->encode($id);
$param['test_domain'] = 'https://v6-' . $code . '.globalso.site/';
$deployBuildModel = new DeployBuild();
$info = $deployBuildModel->read(['project_id'=>$id]);
if($info !== false){
$deployBuildModel->edit($param,['id'=>$info['id']]);
}else{
$deployBuildModel->add($param);
}
}
/**
* @remark :保存优化信息
* @name :saveDeployOptimize
* @author :lyh
* @method :post
* @time :2023/8/30 16:11
*/
protected function saveDeployOptimize($param,$id){
$param['project_id'] = $id;
$deployOptimizeModel = new DeployOptimize();
$info = $deployOptimizeModel->read(['project_id'=>$id]);
if($info !== false){
$deployOptimizeModel->edit($param,['id'=>$info['id']]);
}else{
$deployOptimizeModel->add($param);
}
}
/**
* 同步到AICC
* @param $data
* @author zbj
* @date 2023/9/1
*/
protected function toAicc($data){
$url = 'https://biz.ai.cc/api/sync_company_for_order';
$param = [
'company_name' => $data['company_name'],
'company_address' => '',
'company_tel' => $data['principal_mobile'],
'company_email' => '',
'remark' => $data['remark'],
'level_id' => 6,
'level_day' => $data['exclusive_aicc_day'] ?: 1,
'from_order_id' => $data['from_order_id'],
];
//sign
ksort($param);
$tem = [];
foreach ($param as $key => $val) {
$tem[] = $key . '=' . urlencode($val);
}
$string = implode('&', $tem);
$key = md5('quanqiusou.com');
$param['sign'] = md5($string . $key);
$res = Http::withoutVerifying()->post($url, $param)->json();
if(empty($res['status']) || $res['status'] != 200){
LogUtils::error('ProjectToAicc error', $res);
}
}
/**
* 同步到Hagro
* @param $data
* @author zbj
* @date 2023/9/1
*/
protected function toHagro($data){
$url = 'https://admin.hagro.cn/globalso/create_project';
$param = [
'company' => $data['company_name'],
'phone' => $data['principal_mobile'],
'planday' => $data['exclusive_aicc_day'] ?: 1,
'from_order_id' => $data['from_order_id'],
];
$common = new Common();
$token = $common->encrypt($param);
$res = Http::withoutVerifying()->get($url, ['token' => $token])->json();
if(empty($res['code']) || $res['code'] != 200){
LogUtils::error('ProjectToHagro error', $res);
}
}
}
... ...
... ... @@ -7,11 +7,18 @@
*/
namespace App\Console\Commands\Test;
use App\Models\Blog\Blog;
use App\Models\Devops\ServerConfig;
use App\Models\File\Image;
use App\Models\Manage\BelongingGroup;
use App\Models\Manage\Dept;
use App\Models\Manage\EntryPosition;
use App\Models\Manage\ManageHr;
use App\Services\ProjectServer;
use GuzzleHttp\Client;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class Demo extends Command
{
... ... @@ -39,11 +46,194 @@ class Demo extends Command
parent::__construct();
}
public function curlRequest($url, $data, $method = 'POST', $header = [], $time_out = 60)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_TIMEOUT, $time_out);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
if ($data)
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array_merge([
'Expect:',
'Content-type: application/json',
'Accept: application/json',
], $header)
);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
$response = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return [$code, $response];
}
/**
* @return bool
*/
public function handle()
{
$data = [];
dd(isset($data['a']['b']));
$url = 'https://demo.globalso.site/';
$action = 'api/updateHtmlNotify/';
$data = [
'project_id' => 1,
'type' => 1,
'route' => 1
];;
$method = 'GET';
$result = $this->curlRequest($url . $action, $data, $method);
dd($result);
$context = stream_context_create([
'ssl' => [
'capture_peer_cert' => true,
'capture_peer_cert_chain' => false,
],
]);
$stream = stream_socket_client('ssl://oa.quanqiusou.cn:443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);
if(!$stream) {
die("Failed to connect: $errno - $errstr");
}
$remote_cert = stream_context_get_params($stream)['options']['ssl']['peer_certificate'];
if(!$remote_cert) {
die("Failed to retrieve certificate");
}
$valid_from = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validFrom_time_t']);
$valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']);
fclose($stream);
echo "Certificate Valid From: $valid_from<br>";
echo "Certificate Valid To: $valid_to<br>";
dd('end');
$dept_array = [
'品牌部',
'综合部',
'渠道部',
'广告推广部',
'AICC运营部',
'黑格运营部',
'直营运营部',
'直营销售部',
'深圳跨境部',
'外贸部',
'研发部',
'技术部',
'售后部',
];
foreach ($dept_array as $v) {
$dept = Dept::where(['title' => $v])->first();
if (FALSE == empty($dept))
continue;
$dept = new Dept();
$dept->title = $v;
$dept->save();
}
// dd('dept end');
$dept_map = Dept::pluck('title', 'id')->toArray();
$belonging_map = BelongingGroup::pluck('name', 'id')->toArray();
// dd($belonging_map);
$filename = storage_path('logs/oa_hr.txt');
$string = file_get_contents($filename);
$data = explode("\r\n", $string);
$data = array_filter($data);
$dept = '';
foreach ($data as $k=>$v) {
// var_dump($v) . PHP_EOL;
if ($k == 1)
continue;
$tmp = explode("\t", $v);
if (count($tmp) == 3) {
$dept = $tmp[0] ? : $dept;
$position = $tmp[1];
$name = $tmp[2];
} else if (count($tmp) == 2) {
$position = $tmp[0];
$name = $tmp[1];
} else {
Log::info($v . PHP_EOL);
continue;
}
// Log::info($dept . '---' . $position . '---' . $name . PHP_EOL);
// continue;
$dept_id = array_search($dept, $dept_map);
$belonging_id = 17;
if (FALSE !== strpos($dept,'技术部')) {
$belonging_string = str_replace('技术部', '', $dept);
if ($belonging_string) {
$belonging_string = $belonging_string . '组';
$belonging_id = array_search($belonging_string, $belonging_map);
}
$dept_tmp = '技术部';
$dept_id = array_search($dept_tmp, $dept_map);
}
if (FALSE !== strpos($dept,'售后')) {
$belonging_string = str_replace('售后', '', $dept);
if ($belonging_string)
$belonging_id = array_search($belonging_string, $belonging_map);
$dept_tmp = '售后部';
$dept_id = array_search($dept_tmp, $dept_map);
}
$position_log = EntryPosition::where(['name' => $position])->first();
if (empty($position_log)) {
$position_log = new EntryPosition();
$position_log->name = $position;
$position_log->save();
}
$position_id = $position_log->id;
$hr = ManageHr::where(['name' => $name])->first();
if (empty($hr)) {
Log::info($k . '-' . $name . '-' . $dept . '-' . $dept_id . '-' . $position . '-' . $position_id);
continue;
}
$hr->belong_group = $belonging_id;
$hr->dept_id = $dept_id;
$hr->entry_position = $position_id;
$hr->save();
echo $k . '-' . $name . '-' . $dept . '-' . $dept_id . '-' . $position . '-' . $position_id . '-' . '组' . '-' . $belonging_id . PHP_EOL;
}
dd('end');
exit;
if (($handle = fopen($filename, 'r')) !== false) {
while (($data = fgetcsv($handle, 1000, ',')) !== false) {
// 处理每行数据
Log::info(var_export($data, true));
}
fclose($handle);
}
exit;
$group = BelongingGroup::get();
dd($group->toArray());
$domain = parse_url('https//:dev.golbalso.site/');
dd($domain);
echo time() . PHP_EOL;
$blogModel = new Image();
$list = $blogModel->list();
echo time() . PHP_EOL;
dd(count($list));
return;
preg_match_all("/\@include\(\"([a-z0-9_]+)\"\)/i",'
@include("asdf")@include("")@include("asdtrw2erf")
',$include);
... ...
... ... @@ -5,7 +5,8 @@ namespace App\Console\Commands;
use App\Helper\Arr;
use App\Models\Product\Category;
use App\Models\Product\Product;
use App\Models\RouteMap;
use App\Models\RouteMap\RouteMap;
use App\Services\ProjectServer;
use GuzzleHttp\Client;
use GuzzleHttp\Promise\Utils;
use Illuminate\Console\Command;
... ... @@ -230,20 +231,26 @@ class WebTraffic extends Command
*/
protected function getProductUrls($project_id){
//产品分类页面
$product_cate_ids = Category::where('project_id', $project_id)->where('status', Category::STATUS_ACTIVE)->pluck('id')->toArray();
$data['urls_cats'] = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PRODUCT_CATE)->whereIn('source_id', $product_cate_ids)->get()->toArray();
ProjectServer::useProject($project_id);
$product_cate_ids = DB::connection('custom_mysql')->table('gl_product_category')
->where('project_id', $project_id)->where('status', 1)->pluck('id')->toArray();
$data['urls_cats'] = DB::connection('custom_mysql')->table('gl_route_map')
->where('project_id', $project_id)->where('source', 'product_category')->whereIn('source_id', $product_cate_ids)->get()->toArray();
//单页面
//todo 发布状态的单页面id
$data['urls_page'] = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PAGE)->get()->toArray();
$data['urls_page'] = DB::connection('custom_mysql')->table('gl_route_map')
->where('project_id', $project_id)->where('source', 'page')->get()->toArray();
//产品详情页
$product_ids = Product::where('project_id', $project_id)->where('status', Product::STATUS_ON)->pluck('id')->toArray();
$data['urls_details'] = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PRODUCT)->whereIn('source_id', $product_ids)->get()->toArray();
$product_ids = DB::connection('custom_mysql')->table('gl_product_category')
->where('project_id', $project_id)->where('status', 1)->pluck('id')->toArray();
$data['urls_details'] = DB::connection('custom_mysql')->table('gl_route_map')
->where('project_id', $project_id)->where('source', 'product')->whereIn('source_id', $product_ids)->get()->toArray();
$data['urls_cats'] = array_merge($data['urls_cats'], $data['urls_page']);
if(empty($data['urls_cats'])){
$data['urls_cats'] = $data['urls_details'];
}
DB::disconnect('custom_mysql');
return $data;
}
... ... @@ -312,10 +319,10 @@ class WebTraffic extends Command
$url = [];
if($res_sdzb == 0){//深度一页
$url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb])['route'] : '';
$url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb])->route : '';
}elseif($res_sdzb == 1){//深度两页
$url[] = $project_urls['home'];
$url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb])['route'] : '';
$url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb])->route : '';
}elseif($res_sdzb == 2){//深度3-6页
$yms = rand(2,5); //随机页面数
$url = Arr::pluck(Arr::random($all_url, $yms), 'route');
... ...
... ... @@ -16,6 +16,7 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
$schedule->command('remain_day')->dailyAt('03:00')->withoutOverlapping(1); // 项目剩余服务时长
$schedule->command('rank_data')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据,每天凌晨执行一次
$schedule->command('rank_data_speed')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-测速数据,每周一凌晨执行一次
$schedule->command('rank_data_external_links')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-外链,每周一凌晨执行一次
... ... @@ -23,27 +24,17 @@ class Kernel extends ConsoleKernel
$schedule->command('rank_data_recomm_domain')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-引荐域名,每周一凌晨执行一次
$schedule->command('rank_data_week')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次
$schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次
$schedule->command('yesterday_count')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次
$schedule->command('count')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次
$schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次
$schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次
$schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次
// // 更新域名|证书结束时间,每天凌晨1点执行一次
// $schedule->command('domain_time')->dailyAt('01:00')->withoutOverlapping(1);
// // B站 - 网站数据统计
// // 获取当前月份最后一天
// $lastDay = date('Y-m-t');
// // 统计当月访问来源数据,每月最后一天23:59点执行一次
// $schedule->command('statistics_source')->monthlyOn($lastDay, '23:59')->withoutOverlapping(1);
// // 统计当月地域分布数据,每月最后一天23:59点执行一次
// $schedule->command('statistics_distribution')->monthlyOn($lastDay, '23:59')->withoutOverlapping(1);
// // 统计当月受访页面数据,每月最后一天23:59点执行一次
// $schedule->command('statistics_page')->monthlyOn($lastDay, '23:59')->withoutOverlapping(1);
// // 统计当月访问终端数据,每月最后一天23:59点执行一次
// $schedule->command('statistics_terminal')->monthlyOn($lastDay, '23:59')->withoutOverlapping(1);
// // 统计当月流量趋势数据,每月最后一天23:59点执行一次
// $schedule->command('statistics_trend')->monthlyOn($lastDay, '23:59')->withoutOverlapping(1);
// // 统计当天流量趋势数据,每天23:59点执行一次
// $schedule->command('statistics_day_trend')->dailyAt('23:59')->withoutOverlapping(1);
$schedule->command('sync_channel')->dailyAt('06:00')->withoutOverlapping(1); // 渠道信息,每天执行一次
$schedule->command('month_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初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:00')->withoutOverlapping(1);// 更新域名|证书结束时间,每天凌晨1点执行一次
$schedule->command('last_inquiry')->dailyAt('04:00')->withoutOverlapping(1);// 最近一次询盘信息
}
/**
... ...
... ... @@ -18,4 +18,6 @@ final class Common extends Enum
//端
const A='a';
const B='b';
const MANAGE_TOKEN = 'manage_token:';
}
... ...
... ... @@ -21,4 +21,5 @@ class AsideGlobalException extends Exception
$this->message = Code::fromValue($code)->description;
}
}
}
... ...
... ... @@ -21,4 +21,5 @@ class BsideGlobalException extends Exception
$this->message = Code::fromValue($code)->description;
}
}
}
... ...
... ... @@ -261,9 +261,6 @@ class AliSms
'InvalidSendSms' => '1小时只能请求7次,谢谢',
'InvalidDayu.Malformed' => '变量不能是url,可以将变量固化在模板中',
);
if (isset($message[$status])) {
return $message[$status];
}
return $status;
}
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Helper;
use App\Models\Ai\AiCommand as AiCommandModel;
use App\Models\User\UserLog as UserLogModel;
use App\Models\User\UserLogin as UserLoginModel;
use Illuminate\Encryption\Encrypter;
use Illuminate\Support\Facades\Cache;
/**
... ... @@ -12,6 +13,8 @@ use Illuminate\Support\Facades\Cache;
*/
class Common
{
public $key = '66537a12d4fff992f6d8b67fdda6192f';
public $method = 'AES-256-CBC';
/**
* @name :生成用户操作日志
* @return void
... ... @@ -37,7 +40,9 @@ class Common
public static function set_user_login($param = []){
$data = [
'user_id'=>$param['user_id'],
'ip'=>$param['ip']
'ip'=>$param['ip'],
'project_id'=>$param['project_id'] ?: 0,
'remark'=>$param['remark'] ?? '',
];
$model = new UserLoginModel();
return $model->add($data);
... ... @@ -57,12 +62,27 @@ class Common
if($info === false){
response('指令不存在',400);
}
if (strpos($param['keywords'], '{') !== false && strpos($param['keywords'], '}') !== false) {
$pattern = '/\{([^}]+)\}/'; // 匹配大括号及其内容
if (preg_match($pattern, $param['keywords'], $matches)) {
$lang = $matches[1]; // 获取捕获的内容
}
} else {
//带原语种翻译
$result = Translate::translateSl($param['keywords'])->json();
if (isset($result['texts']['sl']) && isset(Translate::$tls_list[$result['texts']['sl']])) {
$lang = Translate::$tls_list[$result['texts']['sl']]['text'];
} else {
$lang = '中文';
}
}
$str = ',请使用'.$lang.'回答';
//替换关键字
$content = str_replace('$keyword$', $param['keywords'], $info['ai']);
$data = [
'messages'=>[
['role'=>'system','content'=>$info['scene']],
['role'=>'assistant','content'=>$content],
['role'=>'assistant','content'=>$content.$str],
]
];
return http_post($url,json_encode($data));
... ... @@ -148,4 +168,19 @@ class Common
$days = floor(($currentTimestamp - $targetTimestamp) / (60 * 60 * 24));
return (int)$days;
}
// 生成授授权码
public function encrypt($data)
{
$crypt = new Encrypter($this->key, $this->method);
return $crypt->encrypt($data);
}
// 解密授权码
public function decrypt($string)
{
$crypt = new Encrypter($this->key, $this->method);
return $crypt->decrypt($string);
}
}
... ...
... ... @@ -108,31 +108,30 @@ class GoogleSpeedApi
function run($url)
{
try {
$params = [
'url' => $url
];
$res = HttpUtils::get('http://45.136.131.72/api.php', $params);
if ($res) {
$res = Arr::s2a($res);
$area_data = Arr::s2a($res['area_data']);
if($url){
$params = [
'url' => $url
];
$res = HttpUtils::get('http://pagespeed.quanqiusou.cn/api.php', $params);
if ($res) {
$res = Arr::s2a($res);
$area_data = Arr::s2a($res['area_data']);
}
$numericValue = $area_data[0]['numericValue'] ?? rand(500, 1000);
foreach ($this->areas as &$area) {
$start = -$numericValue * 0.5;
$end = $numericValue * 0.5;
$numer = rand($start, $end);
$area["numericValue"] = ceil($numericValue - $numer);
}
}
$numericValue = $area_data[0]['numericValue'] ?? rand(500, 1000);
foreach ($this->areas as &$area) {
$start = -$numericValue * 0.5;
$end = $numericValue * 0.5;
$numer = rand($start, $end);
$area["numericValue"] = ceil($numericValue - $numer);
}
return [
"url" => $url,
"area_data" => $this->areas,
"created_at" => date("Y-m-d H:i:s")
];
} catch (\Exception | GuzzleException $e) {
errorLog('测速失败', $params, $e);
return false;
}
return [
"url" => $url,
"area_data" => $this->areas,
"created_at" => date("Y-m-d H:i:s")
];
}
}
... ...
<?php
namespace App\Helper;
use App\Utils\HttpUtils;
use GuzzleHttp\Exception\GuzzleException;
/**
* Class OaGlobalsoApi
* @package App\Helper
* @author zbj
* @date 2023/6/27
*/
class OaGlobalsoApi
{
//接口地址
protected $url = 'https://oa.cmer.com';
protected $token = '';
public function __construct()
{
$this->token = md5('oa' . date('Y-m-d'));
}
/**
* 项目信息
* @author zbj
* @date 2023/5/17
*/
public function order_info($order_id)
{
$api_url = $this->url . '/api/order_info?token='.$this->token.'&order_id='.$order_id;
$res = http_get($api_url,["charset" => "UTF-8"]);
return $res;
}
/**
* 渠道信息
* @author zbj
* @date 2023/5/17
*/
public function agents_lists()
{
$api_url = $this->url . '/api/agents_lists';
$params = [
'token' => $this->token,
];
try {
$res = HttpUtils::get($api_url, $params);
$res = Arr::s2a($res);
} catch (\Exception | GuzzleException $e) {
errorLog('渠道信息', $params, $e);
return false;
}
return $res;
}
}
... ...
<?php
/**
* @remark :
* @name :Socket.php
* @author :lyh
* @method :post
* @time :2023/8/24 10:43
*/
namespace App\Helper;
require __DIR__ . '/vendor/autoload.php';
use WebSocket\Client;
class Socket
{
private $client;
public $serverIp = '127.0.0.1';
public $serverPort = '9555';
public function __construct() {
$socketUrl = "ws://{$this->serverIp}:{$this->serverPort}";
$this->client = new Client($socketUrl);
}
/**
* @remark :发送消息
* @name :send
* @author :lyh
* @method :post
* @time :2023/8/31 10:18
*/
public function send($data) {
$this->client->send($data);
}
public function receive() {
return $this->client->receive();
}
/**
* @remark :关闭连接
* @name :close
* @author :lyh
* @method :post
* @time :2023/8/31 10:21
*/
public function close() {
$this->client->close();
}
}
... ...
... ... @@ -16,7 +16,8 @@ use Illuminate\Support\Facades\Http;
class Translate
{
//接口地址
public static $url = 'https://translate.hbb618.cn/translates';
// public static $url = 'https://translate.hbb618.cn/translates';
public static $url = 'https://translate.hbbapi.com/';
public static $tls_list = [
'en' => [
... ... @@ -24,659 +25,667 @@ class Translate
'lang_text' => 'English',
'con_flag' => 'con_flag/en.jfif',
'shop_lang' => 'en-gb',
'lang_en' => 'English'
],
'zh' => [
'text' => '中文',
'lang_text' => '简体中文',
'con_flag' => 'con_flag/zh.jfif',
'shop_lang' => 'zh-cn',
'lang_en' => 'Chinese'
],
'fr' => [
'text' => '法语',
'lang_text' => 'En français',
'con_flag' => '',
'lang_en' => 'French'
],
'de' => [
'text' => '德语',
'lang_text' => 'Das ist Deutsch.',
'con_flag' => '',
'lang_en' => 'German'
],
'ko' => [
'text' => '韩语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Korean'
],
'ja' => [
'text' => '日语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Japanese'
],
'es' => [
'text' => '西班牙语',
'lang_text' => 'Español.',
'con_flag' => '',
'lang_en' => 'Spanish'
],
'ar' => [
'text' => '阿拉伯语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Arabic'
],
'pt' => [
'text' => '葡萄牙语(葡萄牙、巴西)',
'lang_text' => 'Língua portuguesa',
'con_flag' => '',
'lang_en' => 'Portuguese'
],
'ru' => [
'text' => '俄语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Russian'
],
'af' => [
'text' => '南非荷兰语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Afrikaans'
],
'sq' => [
'text' => '阿尔巴尼亚语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'albanian'
],
'am' => [
'text' => '阿姆哈拉语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Amharic'
],
'hy' => [
'text' => '亚美尼亚语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Armenian'
],
'az' => [
'text' => '阿塞拜疆语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Azerbaijani'
],
'eu' => [
'text' => '巴斯克语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Basque'
],
'be' => [
'text' => '白俄罗斯语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'belarusian'
],
'bn' => [
'text' => '孟加拉语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Bengali'
],
'bs' => [
'text' => '波斯尼亚语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Bosnian'
],
'bg' => [
'text' => '保加利亚语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Bulgarian'
],
'ca' => [
'text' => '加泰罗尼亚语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Catalan'
],
'ceb' => [
'text' => '宿务语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Cebuano'
],
'zh-CN' => [
'text' => '中文(简体)',
'lang_text' => '简体中文',
'con_flag' => 'con_flag/zh.jfif',
'shop_lang' => 'zh-cn',
'lang_en' => 'Chinese'
],
'zh-TW' => [
'text' => '中文(繁体)',
'lang_text' => '繁体中文',
'con_flag' => 'con_flag/zh.jfif',
'lang_en' => 'Chinese'
],
'co' => [
'text' => '科西嘉语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'corsican'
],
'hr' => [
'text' => '克罗地亚语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Croatian'
],
'cs' => [
'text' => '捷克语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Czech'
],
'da' => [
'text' => '丹麦语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Danish'
],
'nl' => [
'text' => '荷兰语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Dutch'
],
'eo' => [
'text' => '世界语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Esperanto'
],
'et' => [
'text' => '爱沙尼亚语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Estonian'
],
'fi' => [
'text' => '芬兰语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Finnish'
],
'fy' => [
'text' => '弗里斯兰语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'frisian'
],
'gl' => [
'text' => '加利西亚语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'galician'
],
'ka' => [
'text' => '格鲁吉亚语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Georgian'
],
'el' => [
'text' => '希腊语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Greek'
],
'gu' => [
'text' => '古吉拉特语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Gujarati'
],
'ht' => [
'text' => '海地克里奥尔语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Haitian Creole'
],
'ha' => [
'text' => '豪萨语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'hausa'
],
'haw' => [
'text' => '夏威夷语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Hawaiian'
],
'iw' => [
'text' => '希伯来语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Hebrew'
],
'hi' => [
'text' => '印地语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Hindi'
],
'hmn' => [
'text' => '苗语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Miao language'
],
'hu' => [
'text' => '匈牙利语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Hungarian'
],
'is' => [
'text' => '冰岛语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Icelandic'
],
'ig' => [
'text' => '伊博语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'igbo'
],
'id' => [
'text' => '印度尼西亚语',
'lang_text' => 'Bahasa Indonesia',
'con_flag' => 'con_flag/id.jfif',
'shop_lang' => 'id',
'lang_en' => 'Indonesian'
],
'ga' => [
'text' => '爱尔兰语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'irish'
],
'it' => [
'text' => '意大利语',
'lang_text' => 'Lingua italiana',
'con_flag' => '',
'lang_en' => 'Italian'
],
'jw' => [
'text' => '爪哇语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Javanese'
],
'kn' => [
'text' => '卡纳达语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Kannada'
],
'kk' => [
'text' => '哈萨克语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Kazakh'
],
'km' => [
'text' => '高棉语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Khmer'
],
'rw' => [
'text' => '卢旺达语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Kinyarwanda'
],
'ku' => [
'text' => '库尔德语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Kurdish languages'
],
'ky' => [
'text' => '吉尔吉斯语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Kyrgyz language'
],
'lo' => [
'text' => '老挝文',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'LAO'
],
'la' => [
'text' => '拉丁文',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Latin'
],
'lv' => [
'text' => '拉脱维亚语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'latvian'
],
'lt' => [
'text' => '立陶宛语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Lithuanian'
],
'lb' => [
'text' => '卢森堡语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Luxembourgish'
],
'mk' => [
'text' => '马其顿语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Macedonian language'
],
'mg' => [
'text' => '马尔加什语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Malagasy'
],
'ms' => [
'text' => '马来语',
'lang_text' => 'Bahasa Melayu',
'con_flag' => 'con_flag/ms.jfif',
'shop_lang' => 'ms-my',
'lang_en' => 'Malay'
],
'ml' => [
'text' => '马拉雅拉姆文',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Malayalam script'
],
'mt' => [
'text' => '马耳他语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Maltese'
],
'mi' => [
'text' => '毛利语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Maori language'
],
'mr' => [
'text' => '马拉地语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Marathi language'
],
'mn' => [
'text' => '蒙古文',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Mongolian'
],
'my' => [
'text' => '缅甸语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Burmese'
],
'ne' => [
'text' => '尼泊尔语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Nepali'
],
'no' => [
'text' => '挪威语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Norwegian'
],
'ny' => [
'text' => '尼杨扎语(齐切瓦语)',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Nyanza language'
],
'or' => [
'text' => '奥里亚语(奥里亚)',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'oriya'
],
'ps' => [
'text' => '普什图语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Pashto'
],
'fa' => [
'text' => '波斯语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'farsi'
],
'pl' => [
'text' => '波兰语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Polish'
],
'pa' => [
'text' => '旁遮普语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Punjabi language'
],
'ro' => [
'text' => '罗马尼亚语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Romanian'
],
'sm' => [
'text' => '萨摩亚语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Samoan'
],
'gd' => [
'text' => '苏格兰盖尔语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'GAELIC'
],
'sr' => [
'text' => '塞尔维亚语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Serbian'
],
'st' => [
'text' => '塞索托语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'sesotho'
],
'sn' => [
'text' => '修纳语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Shona'
],
'sd' => [
'text' => '信德语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Sindhi language'
],
'si' => [
'text' => '僧伽罗语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Sinhalese'
],
'sk' => [
'text' => '斯洛伐克语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Slovak'
],
'sl' => [
'text' => '斯洛文尼亚语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Slovene language'
],
'so' => [
'text' => '索马里语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Somali'
],
'su' => [
'text' => '巽他语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Sundanese'
],
'sw' => [
'text' => '斯瓦希里语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Swahili'
],
'sv' => [
'text' => '瑞典语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Swedish'
],
'tl' => [
'text' => '塔加路语(菲律宾语)',
'lang_text' => 'Pilipino',
'con_flag' => 'con_flag/tl.jfif',
'shop_lang' => 'tl',
'lang_en' => 'Tagalog'
],
'tg' => [
'text' => '塔吉克语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Tajik'
],
'ta' => [
'text' => '泰米尔语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Tamil'
],
'tt' => [
'text' => '鞑靼语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Tatar language'
],
'te' => [
'text' => '泰卢固语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Telugu language'
],
'th' => [
'text' => '泰文',
'lang_text' => 'ไทย',
'con_flag' => 'con_flag/th.jfif',
'shop_lang' => 'th',
'lang_en' => 'Thai'
],
'tr' => [
'text' => '土耳其语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Turkish'
],
'tk' => [
'text' => '土库曼语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Turkmen language'
],
'uk' => [
'text' => '乌克兰语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Ukrainian'
],
'ur' => [
'text' => '乌尔都语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Urdu'
],
'ug' => [
'text' => '维吾尔语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Uyghur language'
],
'uz' => [
'text' => '乌兹别克语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Uzbek language'
],
'vi' => [
'text' => '越南语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Vietnamese'
],
'cy' => [
'text' => '威尔士语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Welsh'
],
'xh' => [
'text' => '班图语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Bantu'
],
'yi' => [
'text' => '意第绪语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Yiddish'
],
'yo' => [
'text' => '约鲁巴语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Yoruba'
],
'zu' => [
'text' => '祖鲁语',
'lang_text' => '',
'con_flag' => '',
'lang_en' => 'Zulu'
],
];
... ... @@ -713,6 +722,7 @@ class Translate
*/
public static function translate($texts, $tls)
{
$action = 'translates';
if (is_string($texts)) {
$texts = [$texts];
}
... ... @@ -724,7 +734,7 @@ class Translate
'sl' => 'auto',
'tls' => $tls,
];
return Http::post(self::$url, $data);
return Http::post(self::$url.$action, $data);
}
/**
... ... @@ -745,6 +755,24 @@ class Translate
return $retsult[0]['texts'] ?? '';
}
/**
* 翻译带源语种
* @param $message
* @param string $tl
* @return \Illuminate\Http\Client\Response
*/
public static function translateSl($message, $tl = 'en')
{
$action = 'auto_sl';
if (is_string($message)) {
$message = [$message];
}
$data = [
'texts' => $message,
'sl' => 'auto',
'tl' => $tl,
];
return Http::post(self::$url . $action, $data);
}
}
... ...
<?php
/**
* @remark :
* @name :Wechat.php
* @author :lyh
* @method :post
* @time :2023/8/23 18:18
*/
namespace App\Helper;
use \GuzzleHttp\Client;
use Illuminate\Support\Facades\Cache;
/**
* @remark :微信相关
* @name :Wechat
* @author :lyh
* @method :post
* @time :2023/8/23 18:19
*/
class Wechat
{
public $alias = '_v6';
public $appid = 'wx8253a38fd7ae78f0';
public $appSecret = '20981cca3d00c074a8886f115d19548d';
/**
* @remark :生成access_token
* @name :getAccessToken
* @author :lyh
* @method :post
* @time :2023/8/23 18:28
*/
public function getAccessToken()
{
$token = file_get_contents("http://wechat.globalso.com/api/accesstoken/v6");
return $token;
}
/**
* @remark :生成二维码
* @name :setQrcode
* @author :lyh
* @method :post
* @time :2023/8/23 18:19
*/
public function setQrcode($type,$accessToken){
$url = 'https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=' . $accessToken;
$client = new Client();
$response = $client->post($url, [
'json' => [
'expire_seconds' => 3600,
'action_name' => 'QR_STR_SCENE',
'action_info' => [
'scene' => [
'scene_str' => $type.$this->alias,
],
],
],
]);
$data = json_decode($response->getBody(), true);
return $data;
}
}
... ...
<?php
use App\Models\File\Image;
use App\Services\CosService;
use App\Utils\EncryptUtils;
use App\Utils\LogUtils;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Support\Carbon;
use App\Models\File\File;
define('HTTP_OPENAI_URL', 'http://openai.waimaoq.com/');
/**
... ... @@ -67,13 +71,14 @@ if (!function_exists('http_post')) {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
if (curl_errno($ch)) {
\Illuminate\Support\Facades\Log::info(print_r(curl_errno($ch), 1), 'debug---1');
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($res, true) . PHP_EOL, FILE_APPEND);
}
curl_close($ch);
return json_decode($res, true);
}
}
if (!function_exists('http_get')) {
/**
* 发送http get请求
... ... @@ -83,19 +88,20 @@ if (!function_exists('http_get')) {
function http_get($url, $header = [])
{
if (empty($header)) {
$header[] = "content-type: application/json;
charset = UTF-8";
$header[] = "content-type: application/json";
}
$ch1 = curl_init();
$timeout = 5;
$timeout = 0;
curl_setopt($ch1, CURLOPT_URL, $url);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch1, CURLOPT_ENCODING, '');
curl_setopt($ch1, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch1, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch1, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
$access_txt = curl_exec($ch1);
\Illuminate\Support\Facades\Log::info($access_txt);
curl_close($ch1);
return json_decode($access_txt, true);
}
... ... @@ -118,7 +124,7 @@ if (!function_exists('_get_child')) {
$new_arr[] = $v;
}
}
return $new_arr ? $new_arr : false;
return $new_arr ? $new_arr : [];
}
}
... ... @@ -404,3 +410,113 @@ if (!function_exists('getDateArray')) {
return $days;
}
}
if (!function_exists('getImageUrl')) {
/**
* @remark :获取图片链接
* @name :getImageUrl
* @author :lyh
* @method :post
* @time :2023/7/20 16:46
*/
function getImageUrl($path,$location = 1){
if(empty($path)){
return '';
}
if(is_array($path)){
foreach ($path as $v){
$url[] = getImageUrl($v);
}
}else{
if($location == 1){
$cos = config('filesystems.disks.cos');
$cosCdn = $cos['cdn'];
$url = $cosCdn.$path;
}else{
$url = url($path);
}
}
return $url;
}
}
if (!function_exists('getFileUrl')) {
/**
* @remark :获取文件链接
* @name :getImageUrl
* @author :lyh
* @method :post
* @time :2023/7/20 16:46
*/
function getFileUrl($path,$location = 1){
if(empty($path)){
return '';
}
if(is_array($path)){
foreach ($path as $v){
$url[] = getFileUrl($v);
}
}else{
if($location == 1){
$cos = config('filesystems.disks.cos');
$cosCdn = $cos['cdn'];
$url = $cosCdn.$path;
}else{
$url = url($path);
}
}
return $url;
}
}
/**
* @remark :字符串截取
* @name :characterTruncation
* @author :lyh
* @method :post
* @time :2023/6/28 17:39
*/
function characterTruncation($string,$pattern){
preg_match($pattern, $string, $matches);
if (isset($matches[0])) {
$result = $matches[0];
return $result; // 输出:这是footer标签的内容
} else {
return '';
}
}
if (!function_exists('getAutoLoginCode')) {
/**
* @remark :自动登录加密
* @name :getAutoLoginCode
* @author :lyh
* @method :post
* @time :2023/8/7 9:47
*/
function getAutoLoginCode($project_id)
{
$encrypt = new EncryptUtils();
return $encrypt->authcode(json_encode(['project_id' => $project_id]), 'ENCODE', 'autologin', 3600);
}
}
if (!function_exists('str_replace_url')) {
/**
* @remark :截取域名以外的部分
* @name :str_replace_url
* @author :lyh
* @method :post
* @time :2023/8/31 14:57
*/
function str_replace_url($url)
{
// 使用 parse_url 函数来解析 URL
$urlParts = parse_url($url);
// 检查是否存在 host(域名)部分
if (isset($urlParts['path'])) {
$urlWithoutDomain = $urlParts['path'];
return $urlWithoutDomain;
} else {
return $url;
}
}
}
... ...
... ... @@ -7,19 +7,21 @@ use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Ai\AiCommandLogic;
use App\Http\Requests\Aside\Ai\AiCommandRequest;
use App\Models\Ai\AiCommand as AiCommandModel;
use Illuminate\Http\Request;
use function App\Helper\send_openai_msg;
/**
* @name:ai指令
* @remark :ai指令
* @name :AiCommandController
* @author :lyh
* @time :2023/6/17 16:27
*/
class AiCommandController extends BaseController
{
/**
* @name :指令列表
* @return void
* @author :liyuhang
* @method
* @param AiCommandModel $aiCommandModel
* @name :lists
* @author :lyh
* @method :post
* @time :2023/6/17 16:27
*/
public function lists(AiCommandModel $aiCommandModel){
$lists = $aiCommandModel->lists($this->map,$this->page,$this->row,$this->order);
... ... @@ -27,10 +29,11 @@ class AiCommandController extends BaseController
}
/**
* @name :详情
* @return void
* @author :liyuhang
* @method
* @param AiCommandLogic $aiCommandLogic
* @name :info
* @author :lyh
* @method :post
* @time :2023/6/17 16:27
*/
public function info(AiCommandLogic $aiCommandLogic){
$this->request->validate([
... ... @@ -38,14 +41,17 @@ class AiCommandController extends BaseController
],[
'id.required' => 'ID不能为空'
]);
$aiCommandLogic->ai_info();
$this->response('success');
$info = $aiCommandLogic->ai_info();
$this->response('success',Code::SUCCESS,$info);
}
/**
* @name
* @return void
* @author :liyuhang
* @method
* @param AiCommandRequest $request
* @param AiCommandLogic $aiCommandLogic
* @name :add
* @author :lyh
* @method :post
* @time :2023/6/17 16:27
*/
public function add(AiCommandRequest $request,AiCommandLogic $aiCommandLogic){
$request->validated();
... ... @@ -54,10 +60,12 @@ class AiCommandController extends BaseController
}
/**
* @name
* @return void
* @author :liyuhang
* @method
* @param AiCommandRequest $request
* @param AiCommandLogic $aiCommandLogic
* @name :edit
* @author :lyh
* @method :post
* @time :2023/6/17 16:28
*/
public function edit(AiCommandRequest $request,AiCommandLogic $aiCommandLogic){
$request->validate([
... ... @@ -70,16 +78,18 @@ class AiCommandController extends BaseController
}
/**
* @name
* @return void
* @author :liyuhang
* @method
* @param AiCommandLogic $aiCommandLogic
* @name :del
* @author :lyh
* @method :post
* @time :2023/6/17 16:27
*/
public function del(AiCommandLogic $aiCommandLogic){
$this->request->validate([
'id'=>'required'
'id'=>['required','array'],
],[
'id.required' => 'ID不能为空'
'id.required' => 'ID不能为空',
'id.array' => 'ID为数组',
]);
$aiCommandLogic->ai_del();
$this->response('success');
... ...
... ... @@ -5,18 +5,31 @@ namespace App\Http\Controllers\Aside\Ai;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Models\Ai\AiLog as AiLogModel;
use App\Models\User\User;
/**
* @remark :ai发送记录
* @name :AiLogController
* @author :lyh
* @time :2023/6/17 16:26
*/
class AiLogController extends BaseController
{
/**
* @name :ai日志列表
* @return void
* @author :liyuhang
* @method
* @param AiLogModel $aiLogModel
* @name :(ai发送日志列表)lists
* @author :lyh
* @method :post
* @time :2023/6/17 16:25
*/
public function lists(AiLogModel $aiLogModel){
$lists = $aiLogModel->lists($this->map,$this->page,$this->row,$this->order);
if(!empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
$v['operator_name'] = (new User())->read(['id'=>$v['operator_id']])['name'];
$lists['list'][$k] = $v;
}
}
$this->response('success',Code::SUCCESS,$lists);
}
}
... ...
... ... @@ -3,12 +3,16 @@
namespace App\Http\Controllers\Aside;
use App\Enums\Common\Code;
use App\Enums\Common\Common;
use App\Http\Controllers\Controller;
use App\Models\File\File;
use App\Models\File\Image;
use App\Services\CosService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Session;
class BaseController extends Controller
{
... ... @@ -21,144 +25,129 @@ class BaseController extends Controller
protected $order = 'id';
protected $map = [];//处理后的参数
protected $uid = 0;
protected $user = [];//当前登录用户详情
protected $manage = [];//当前登录用户详情
/**
* 获取所有参数
* @param Request $request
*/
public function __construct(Request $request)
{
$this->request = $request;
$this->param = $this->request->all();
$this->token = $this->request->header('token');
if(!empty($this->token) && !empty(Cache::get($this->token))){
$info = Cache::get($this->token);
$this->user = $info;
$this->getParam();
$info = Cache::get(Common::MANAGE_TOKEN . $this->token);
if(!empty($this->token) && !empty($info)){
$this->manage = $info;
Cache::put($this->token, $info, 3600 * 6);//更新缓存时间
$this->uid = $info['id'];
//参数处理
$this->get_param();
}
}
/**
* 成功返回
* @param array $data
* @param string $code
* @param bool $objectData
* @return JsonResponse
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @remark :请求参数处理
* @name :getParam
* @author :lyh
* @method :post
* @time :2023/6/17 16:34
*/
function success(array $data = [], string $code = Code::SUCCESS, bool $objectData = false): JsonResponse
{
if ($objectData) {
$data = (object)$data;
public function getParam(){
foreach ($this->param as $k => $v){
if(is_array($v)){
$this->map[$k] = $v;
}else{
if(empty($v) && ($v == null)){
unset($this->param[$k]);
}
$this->getMap($k,$v);
}
}
$code = Code::fromValue($code);
$response = [
'code' => $code->value,
'data' => $data,
'msg' => $code->description,
];
$this->header['token'] = $this->token;
return response()->json($response,200,$this->header);
}
/**
* @name :参数过滤
* @author :liyuhang
* @method
* @remark :搜索参数处理
* @name :getMap
* @author :lyh
* @method :post
* @time :2023/8/28 10:22
*/
public function get_param(){
$param = $this->param;
foreach ($param as $k => $v){
if(is_array($v)){
continue;
}
switch ($k){
case "order":
$this->order = $v;
break;
case 'page':
$this->page = $v;
break;
case 'row':
$this->row = $v;
break;
case "name":
$this->map['name'] = ['like','%'.$v.'%'];
break;
case "start_at":
$this->_btw[0] = $v;
$this->_btw[1] = date('Y-m-d H:i:s',time());
$this->map['created_at'] = ['between', $this->_btw];
break;
case "end_at":
$this->_btw[1] = $v;
$this->map['updated_at'] = ['between', $this->_btw];
break;
default:
if (!empty($v)) {
$this->map[$k] = $v;
}
break;
}
public function getMap($k,$v){
switch ($k){
case "order":
$this->order = $v;
break;
case 'page':
$this->page = $v;
break;
case 'row':
$this->row = $v;
break;
case "name":
$this->map['name'] = ['like','%'.$v.'%'];
break;
case "start_at":
$this->_btw[0] = $v;
$this->_btw[1] = date('Y-m-d H:i:s',time());
$this->map['created_at'] = ['between', $this->_btw];
break;
case "end_at":
$this->_btw[1] = $v;
$this->map['updated_at'] = ['between', $this->_btw];
break;
default:
if ($v != null) {
$this->map[$k] = $v;
}
break;
}
}
/**
* @name 统一返回参数
* @return JsonResponse
* @author :liyuhang
* @method
* @param $msg
* @param string $code
* @param $data
* @param $result_code
* @param $type
* @remark :统一返回
* @name :response
* @author :lyh
* @method :post
* @time :2023/6/17 16:34
*/
public function response($msg = null,string $code = Code::SUCCESS,$data = [],$result_code = 200,$type = 'application/json'): JsonResponse
{
$code = Code::fromValue($code);
$result = [
'msg' => $msg == ' ' ? $code->description : $msg,
'message' => $msg == ' ' ? $code->description : $msg,
'code' => $code->value,
'data' => $this->_extents($data),
'data' => $data,
];
$this->header['Content-Type'] = $type;
$this->header['token'] = $this->token;
$response = response($result,$result_code,$this->header);;
$response = response($result,$result_code,$this->header);
throw new HttpResponseException($response);
}
/**
* @param $data
* @name :返回参数统一处理
* @return array|string
* @author :liyuhang
* @method
* @remark :返回json
* @name :success
* @author :lyh
* @method :post
* @time :2023/8/28 10:18
*/
protected function _extents($data) {
if (empty($data) || !is_array($data)) {
return empty($data) ? is_array($data) ? [] : '' : $data;
}
foreach ($data as $k => $v) {
if (is_array($v)) {
$data[$k] = $this->_extents($v);
} else {
if (is_null($v)) {
$data[$k] = '';
continue;
}
switch ((string) $k) {
case 'image':
$v['image_link'] = url('/a/image/' . $v);
break;
}
}
function success(array $data = [], string $code = Code::SUCCESS, bool $objectData = false): JsonResponse
{
if ($objectData) {
$data = (object)$data;
}
return $data;
$code = Code::fromValue($code);
$response = [
'code' => $code->value,
'data' => $data,
'message' => $code->description,
];
$this->header['token'] = $this->token;
return response()->json($response,200,$this->header);
}
}
... ...
<?php
namespace App\Http\Controllers\Aside\Com;
use App\Enums\Common\Code;
use App\Enums\Common\Common;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Manage\MenuLogic;
use App\Models\Manage\Manage;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Hash;
/**
* Class IndexController
* @package App\Http\Controllers\Aside
* @author zbj
* @date 2023/4/19
*/
class IndexController extends BaseController
{
/**
* 用户菜单
* @param MenuLogic $logic
* @return \Illuminate\Http\JsonResponse
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @author zbj
* @date 2023/6/21
*/
public function get_menu(MenuLogic $logic)
{
if($this->manage['gid'] == 0){ //超级管理员
$menus = $logic->getAllMenu();
}else{
$menus = $logic->getMenuByGroupId($this->manage['gid']);
}
$this->response('success',Code::SUCCESS,$menus);
}
/**
* @remark :修改密码
* @name :editPassword
* @author :lyh
* @method :post
* @time :2023/9/11 9:10
*/
public function editPassword(){
$this->request->validate([
'oldPassword'=>'required',
'password' => 'required',
'confirm'=>'required',
], [
'oldPassword.required' => '请输入原密码',
'password.required' => '请输入新密码',
'confirm.required' => '请再次输入新密码',
]);
//查询员密码是否正确
$managerModel = new Manage();
$info = $managerModel->read(['id'=>$this->manage['id']]);
if(!Hash::check($this->param['oldPassword'], $info['password'])){
$this->response('原密码错误',Code::USER_REGISTER_ERROE);
}
if($this->param['password'] != $this->param['confirm']){
$this->response('两次密码不一致');
}
$rs = $managerModel->edit(['password'=>Hash::make($this->param['password'])],['id'=>$this->manage['id']]);
if($rs === false){
$this->response('系统错误',Code::SYSTEM_ERROR);
}
Cache::pull(Common::MANAGE_TOKEN . $info['token']);
$this->response('success');
}
}
... ...
<?php
/**
* @remark :
* @name :UpdateController.php
* @author :lyh
* @method :post
* @time :2023/8/19 9:08
*/
namespace App\Http\Controllers\Aside\Com;
use App\Helper\Common;
use App\Http\Controllers\Bside\BaseController;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
/**
* @remark :b端网站更新相关
* @name :UpdateController
* @author :lyh
* @method :post
* @time :2023/8/19 9:08
*/
class UpdateController extends BaseController
{
/**
* @remark :一键更新所有tdk
* @name :updateSeoTdk
* @author :lyh
* @method :post
* @time :2023/8/19 9:25
*/
public function updateSeoTdk(){
$this->request->validate([
'project_id'=>'required',
],[
'project_id.required' => 'project_id不能为空',
]);
ProjectServer::useProject($this->param['project_id']);
$this->updateProduct($this->param['project_id']);
$this->updateBlogs($this->param['project_id']);
$this->updateNews($this->param['project_id']);
DB::disconnect('custom_mysql');
$this->response('success');
}
/**
* @remark :更新产品tdk
* @name :updateProduct
* @author :lyh
* @method :post
* @time :2023/8/19 9:25
*/
public function updateProduct($project_id){
$list = DB::connection('custom_mysql')->table('gl_product')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray();
if(!empty($list)){
foreach ($list as $v){
if(!empty($v['seo_mate'])){
$seo_arr = $v['seo_mate'];
//更新seo_title
if(!isset($seo_arr['title'])){
//生成seo_title
$seo_arr['title'] = $this->ai_send('product_seo_title',$v['title']);
}
//更新seo_keyword
if(!isset($seo_arr['keyword'])){
$seo_arr['keyword'] = $this->ai_send('product_seo_keyword',$v['title']);
}
//更新seo_keyword
if(!isset($seo_arr['description'])){
$seo_arr['description'] = $this->ai_send('product_seo_description',$v['title']);
}
$ser_str = json_encode($seo_arr,true);
DB::connection('custom_mysql')->table('gl_product')->where(['id'=>$v['id']])->update(['seo_mate'=>$ser_str]);
}
}
}
return true;
}
/**
* @remark :更新新闻Tdk
* @name :updateNews
* @author :lyh
* @method :post
* @time :2023/8/19 10:06
*/
public function updateNews($project_id){
$list = DB::connection('custom_mysql')->table('gl_news')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray();
if(!empty($list)){
foreach ($list as $k => $v){
$data = [];
if(empty($v['seo_title'])){
$data['seo_title'] = $this->ai_send('news_seo_title',$v['name']);
}
if(empty($v['seo_keywords'])){
$data['seo_keywords'] = $this->ai_send('news_seo_keyword',$v['name']);
}
if(empty($v['seo_description'])){
$data['seo_description'] = $this->ai_send('news_seo_description',$v['name']);
}
DB::connection('custom_mysql')->table('gl_news')->where(['id'=>$v['id']])->update($data);
}
}
return true;
}
/**
* @remark :更新blogTdk
* @name :updateBlogs
* @author :lyh
* @method :post
* @time :2023/8/19 10:07
*/
public function updateBlogs($project_id){
$list = DB::connection('custom_mysql')->table('gl_blog')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray();
if(!empty($list)){
foreach ($list as $k => $v){
$data = [];
if(empty($v['seo_title'])){
$data['seo_title'] = $this->ai_send('blog_seo_title',$v['name']);
}
if(empty($v['seo_keywords'])){
$data['seo_keywords'] = $this->ai_send('blog_seo_keyword',$v['name']);
}
if(empty($v['seo_description'])){
$data['seo_description'] = $this->ai_send('blog_seo_description',$v['name']);
}
DB::connection('custom_mysql')->table('gl_product')->where(['id'=>$v['id']])->update($data);
}
}
return true;
}
/**
* @remark :AI发送
* @name :ai_send
* @author :lyh
* @method :post
* @time :2023/8/19 10:40
*/
public function ai_send($key,$keywords){
$chat_url = 'v2/openai_chat';
$param = [
'key'=>$key,
'keywords'=>$keywords,
];
$data = Common::send_openai_msg($chat_url,$param);
return $data['text'];
}
}
... ...
... ... @@ -2,6 +2,7 @@
namespace App\Http\Controllers\Aside\Devops;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Devops\ServerConfigLogic;
... ... @@ -21,6 +22,41 @@ class ServerConfigController extends BaseController
{
/**
* @remark :服务器列表
* @name :lists
* @author :lyh
* @method :post
* @time :2023/8/2 14:48
*/
public function lists(ServerConfigLogic $logic){
if(isset($this->map['title']) && !empty($this->map['title'])){
$this->map['title'] = ['like','%'.$this->map['title'].'%'];
}
if(isset($this->map['host']) && !empty($this->map['host'])){
$this->map['host'] = ['like','%'.$this->map['host'].'%'];
}
$lists = $logic->serviceConfigList($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :获取数据详情
* @name :info
* @author :lyh
* @method :post
* @time :2023/8/2 17:52
*/
public function info(ServerConfigLogic $logic){
$this->request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
$info = $logic->getServiceConfig();
$this->response('success',Code::SUCCESS,$info);
}
/**
* 保存配置
* @param ServerConfigRequest $request
* @param ServerConfigLogic $logic
... ... @@ -28,10 +64,29 @@ class ServerConfigController extends BaseController
* @date 2023/4/23
*/
public function save(ServerConfigRequest $request, ServerConfigLogic $logic){
$data = $logic->save($this->param);
return $this->success($data);
$request->validated();
$logic->serviceConfigSave();
$this->response('success');
}
/**
* @remark :删除配置
* @name :del
* @author :lyh
* @method :post
* @time :2023/8/2 15:41
*/
public function del(ServerConfigLogic $logic){
$this->request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
$logic->delServiceConfig();
return $this->response('success');
}
/**
* 更新表结构
* @param ServerConfigLogic $logic
... ... @@ -63,26 +118,7 @@ class ServerConfigController extends BaseController
$data = $logic->updateAllTable($this->param);
break;
}
return $this->success($data);
$this->response('success',Code::SUCCESS,$data);
}
/**
* 更新代码
* @param ServerConfigLogic $logic
* @author zbj
* @date 2023/4/24
*/
public function updateCode(){
//todo
//C端
// $process = new Process(['git', 'pull']);
// $process->run();
// dump($process->getExitCodeText());
// dump($process->getExitCode());
// dump($process->getErrorOutput());
// $output = explode(PHP_EOL, $process->getOutput());
// dump($output);
// exit;
}
}
... ...