作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

... ... @@ -11,6 +11,7 @@ namespace App\Console\Commands\DeleteTemplate;
use App\Models\Project\Project;
use App\Models\Template\BTemplateLog;
use App\Models\User\UserLog;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
... ... @@ -48,6 +49,7 @@ class TemplateLog extends Command
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
$this->deleteTemplate();
$this->deleteUserLog();
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
... ... @@ -65,4 +67,17 @@ class TemplateLog extends Command
$templateLogModel = new BTemplateLog();
return $templateLogModel->del(['created_at'=>['<=',$date]]);
}
/**
* @remark :清除用户日志
* @name :deleteUserLog
* @author :lyh
* @method :post
* @time :2024/11/13 16:19
*/
public function deleteUserLog(){
$date = date('Y-m-d H:i:s', strtotime('-60 days'));
$userLogModel = new UserLog();
return $userLogModel->del(['created_at'=>['<=',$date]]);
}
}
... ...
... ... @@ -36,6 +36,7 @@ class RemainDay extends Command
*/
protected $ceaseProjectId = [
354,
649,
1283
];//需要单独处理的项目
/**
... ... @@ -70,7 +71,7 @@ class RemainDay extends Command
if($item['type'] != Project::TYPE_THREE){
$item->pause_days = $item->pause_days + 1;
}
}
}else{
if(in_array($item->id,$this->projectId)){//已开始优化的时间结算
$optimizeModel = new DeployOptimize();
$opInfo = $optimizeModel->read(['project_id'=>$item->id],['start_date']);
... ... @@ -94,6 +95,8 @@ class RemainDay extends Command
}
}
$item->remain_day = ($remain_day > 0 ? $remain_day : 0);
}
$item->save();
// if($item->remain_day == 0){
// $item->extend_type = Project::TYPE_FIVE;
// $item->site_status = Project::TYPE_ONE;//关闭站点
... ... @@ -104,7 +107,6 @@ class RemainDay extends Command
// curl_get('https://'.$domainInfos['domain'].'/api/stop_or_start_website/');
// }
// }
$item->save();
}
}
}
... ...
... ... @@ -165,6 +165,12 @@ class RelayInquiry extends Command
protected $otherzb = [700, 300]; //模拟访问来源占比 (非美国) google.com|google.其他后缀
/**
* 手机号过滤 0去掉+ 1不转发手机 2不处理
* @var int[]
*/
protected $filter_phone = [30,12,58];
/**
* @return bool
*/
public function handle()
... ... @@ -307,6 +313,15 @@ class RelayInquiry extends Command
}
foreach ($random_data as $item) {
//手机号过滤
$phone = $form->phone;
$filter_phone = $this->get_rand($this->filter_phone);
if($filter_phone == 0){
$phone = trim(str_replace("+", '', $phone));
}elseif($filter_phone == 1){
$phone = '';
}
// 推送站点
$domain = $item['url'];
$is_v6 = $item['is_v6'];
... ... @@ -370,11 +385,7 @@ class RelayInquiry extends Command
$this->output('获取转发ip');
// TODO 获取IP:如果是简码,查询数据库获取对应的国家, 如果是国家使用翻译, 再转化成IP
if (strlen($form->country) == 2) {
$country = $this->getCountry($form->country);
} else {
$country = Translate::tran($form->country, 'zh');
}
$country = $form->country_name;
// 有国家 通过国家查询, 如果没有获取到就随机获取
$where = [];
$country && $where['ip_area'] = $country;
... ... @@ -446,7 +457,7 @@ class RelayInquiry extends Command
continue;
}
// 写入推送详情
$re_detail = ReInquiryDetail::createInquiry($task['id'], $form->id, $domain, $country_name, $ip, $form->full_name, $form->email, $form->phone, $message, $message_id, $device_port,
$re_detail = ReInquiryDetail::createInquiry($task['id'], $form->id, $domain, $country_name, $ip, $form->full_name, $form->email, $phone, $message, $message_id, $device_port,
$user_agent, $referrer, $urls, $is_v6, date('Y-m-d H:i:s', $start_time + $seconds));
foreach ($urls as $k=>$v){
$pre++;
... ... @@ -499,22 +510,6 @@ class RelayInquiry extends Command
}
/**
* 通过国家简码获取国家名称
* @param $code
* @return string
*/
public function getCountry($code)
{
$cache_key = 'inquiry_world_country';
$country_code = Cache::get($cache_key, function () use ($cache_key) {
$country_code = DB::table('gl_world_country_city')->where(['pid' => 0])->pluck('chinese_name', 'iso2')->toArray();
Cache::put($cache_key, $country_code, 86400);
return $country_code;
});
return empty($country_code[$code]) ? '' : $country_code[$code];
}
/**
* 获取头信息
* @param $ip_area
* @param $lang
... ... @@ -598,7 +593,7 @@ class RelayInquiry extends Command
}
$translateSl = Translate::translateSl($incontent);
$lang = $translateSl['texts']['sl'] ?? 'en';
if ($lang == 'en' || Str::contains($lang, 'zh')) {
if ($lang == 'en' || $lang == 'ja' || $lang == 'ko' || Str::contains($lang, 'zh')) {
$language = '英文';
$lang = 'en';
}else{
... ...
... ... @@ -6,6 +6,7 @@ use App\Models\Inquiry\ReInquiryDetail;
use App\Models\Inquiry\ReInquiryDetailLog;
use App\Models\Inquiry\ReInquiryForm;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;
... ... @@ -115,11 +116,16 @@ class postInquiry extends Command
}
}else{
//v4 v5分离项目 往测试链接推
$split_api_cache_key = 'quanqiusou_split_site_array';
$site_array = Cache::get($split_api_cache_key);
if(!$site_array){
$client = new \GuzzleHttp\Client();
$site_array = $client->request('GET', "https://www.quanqiusou.cn/extend_api/saas/split.php", [
'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号
])->getBody()->getContents();
$site_array = json_decode($site_array, true);
Cache::put($split_api_cache_key, $site_array, 7200);
}
$mail_urls = array_column($site_array, 'main_url');
$key = array_search($website, $mail_urls);
if ($key !== false) {
... ... @@ -195,6 +201,7 @@ class postInquiry extends Command
//兼容接口返回格式
if(!empty($res['data'][0]['status'])){
$res['data'][0]['code'] = $res['data'][0]['status'] == 'success' ? 200 : 400;
!empty($res['data'][0]['msg']) && $res['message'] = $res['data'][0]['msg'];
}
if(empty($res['data'][0]['code']) || !in_array($res['data'][0]['code'], [200,300])){
$log->status = ReInquiryDetailLog::STATUS_FAIL;
... ...
<?php
/**
* @remark :
* @name :CountAllProject.php
* @author :lyh
* @method :post
* @time :2024/11/9 10:03
*/
namespace App\Console\Commands\Project;
use App\Models\Channel\Channel;
use App\Models\Domain\DomainInfo;
use App\Models\Manage\ManageHr;
use App\Models\Project\Project;
use Illuminate\Console\Command;
use App\Models\Project\CountAllProject as AllProject;
class CountAllProject extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'count_all_project';
/**
* The console command description.
*
* @var string
*/
protected $description = '统计所有项目设置';
public function handle(){
AllProject::truncate();
$noSixCount = $this->NoSixProject();
echo 'success:' .$noSixCount . PHP_EOL . date('Y-m-d H:i:s');
$sixCount = $this->sixProject();
echo 'success:' .$sixCount . PHP_EOL . date('Y-m-d H:i:s');
$data = $noSixCount + $sixCount;
echo 'success:' .$data . PHP_EOL . date('Y-m-d H:i:s');
return true;
}
/**
* @remark :5.0数据
* @name :NoSixProject
* @author :lyh
* @method :post
* @time :2024/11/11 15:21
*/
public function NoSixProject(){
$count = 0;
$i = 1;
while (true) {
$url = 'https://quanqiusou.cn/extend_api/api/projects.php?page=' . $i . '&pagesize=500';
$result = $this->httpGetProxy($url);
// 检查结果是否成功,并且结构符合预期
if (isset($result['data']['data']) && is_array($result['data']['data'])) {
$data = $result['data']['data'];
// 如果当前页没有数据,跳出循环
if (empty($data)) {
break;
}
foreach ($data as $k => $v){
if(empty($v['online_date'])){
$v['online_date'] = null;
}
if($v['is_admin5'] == 5){
$v['version'] = 2;
}else{
$v['version'] = 3;
}
$v['is_upgrade'] = 0;
$v['status'] = 0;
$v['created_at'] = $v['updated_at'] = date('Y-m-d H:i:s');
$data[$k] = $v;
}
echo '执行页数:' . $i . PHP_EOL . date('Y-m-d H:i:s') . PHP_EOL;
$count = $count + count($data);
$countAllModel = new AllProject;
$countAllModel->insert($data);
$i++;
// 每次请求后增加 1 秒延迟,防止请求过于频繁
sleep(1);
} else {
// 如果数据结构不符合预期,输出错误信息并跳出循环
echo '数据结构不符合预期或请求失败,停止执行。' . PHP_EOL . json_encode($result);
break;
}
}
return $count;
}
public function httpGetProxy($url){
$ch1 = curl_init();
$timeout = 0;
curl_setopt($ch1, CURLOPT_URL, $url);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch1, CURLOPT_PROXY, 'http://69.90.188.183:51395');
curl_setopt($ch1, CURLOPT_ENCODING, '');
curl_setopt($ch1, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch1, CURLOPT_HTTPHEADER, array());
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);
$content = curl_exec($ch1);
curl_close($ch1);
return json_decode($content, true);
}
public function sixProject(){
$count = 0;
$projectModel = new Project();
$manageModel = new ManageHr();
$i = 1;
while (true){
$query = $projectModel->leftJoin('gl_project_payment', 'gl_project.id', '=', 'gl_project_payment.project_id')
->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')
->where('gl_project.delete_status',Project::TYPE_ZERO);
$lists = $query->paginate(500, $this->selectParam(), 'page', $i)->toArray();
if(empty($lists) || empty($lists['list'])){
break;
}
$data = [];
echo '执行页数:' . $i . PHP_EOL . date('Y-m-d H:i:s') . PHP_EOL;
foreach ($lists['list'] as $k => $v){
$data[] = [
'project_id'=>$v['id'],
'version'=>1,//代表6.0
'is_upgrade'=>$v['is_upgrade'],
'title'=>$v['title'],
'company'=>$v['company'],
'channel'=>Channel::getChannelText($v['channel']['user_id'] ?? 0),
'join_date'=>$v['cooperate_date'],
'online_date'=>$v['uptime'],
'keywords_num'=>$v['key'],
'service_num'=>$v['day'],
'production_num'=>intval(abs((empty($v['uptime']) ? time() : strtotime($v['uptime'])) - strtotime($v['created_at'])) / 86400),
'plan'=>Project::planMap()[$v['plan']],
'status'=>0,
'test_domain'=>$v['test_domain'],
'product_domain'=>!empty($v['domain']) ? (new DomainInfo())->getDomain($v['domain']) : '',
'project_manager'=>$manageModel->getName($v['manager_mid'] ?? ''),
'project_group'=>$manageModel->getName($v['leader_mid'] ?? ''),
'project_design'=>$manageModel->getName($v['designer_mid'] ?? ''),
'project_assistant'=>$manageModel->getName($v['tech_mid'] ?? ''),
'service_manager'=>$manageModel->getName($v['optimize_manager_mid'] ??''),
'service_optimize'=>$manageModel->getName($v['optimize_optimist_mid'] ??''),
'service_assistant'=>$manageModel->getName($v['optimize_assist_mid'] ??''),
'qa'=>$manageModel->getName($v['quality_mid'] ??''),
'created_at'=>date('Y-m-d H:i:s'),
'updated_at'=>date('Y-m-d H:i:s'),
];
}
$count = $count + count($data);
$countAllModel = new AllProject;
$countAllModel->insert($data);
sleep(1);
$i++;
}
return $count;
}
/**
* 需要查询的字段
* @return array
*/
public function selectParam(){
$select = [
'gl_project.id AS id',
'gl_project.title AS title',
'gl_project.channel AS channel',
'gl_project.company AS company',
'gl_project.type AS type',
'gl_project.status AS status',
'gl_project.extend_type AS extend_type',
'gl_project.uptime AS uptime',
'gl_project.is_upgrade AS is_upgrade',
'gl_project.created_at AS created_at',
'gl_project.cooperate_date AS cooperate_date',
'gl_project.site_status AS site_status',
'gl_project_deploy_build.keyword_num AS key',
'gl_project_deploy_build.service_duration AS day',
'gl_project_deploy_build.is_comment AS is_comment',
'gl_project_deploy_build.leader_mid AS leader_mid',
'gl_project_deploy_build.manager_mid AS manager_mid',
'gl_project_deploy_build.designer_mid AS designer_mid',
'gl_project_deploy_build.tech_mid AS tech_mid',
'gl_project_deploy_build.test_domain AS test_domain',
'gl_project_deploy_build.plan AS plan',
'gl_project_deploy_optimize.dept_id AS optimize_dept_id',
'gl_project_deploy_optimize.manager_mid AS optimize_manager_mid',
'gl_project_deploy_optimize.optimist_mid AS optimize_optimist_mid',
'gl_project_deploy_optimize.assist_mid AS optimize_assist_mid',
'gl_project_deploy_optimize.tech_mid AS optimize_tech_mid',
'gl_project_deploy_optimize.tech_leader AS tech_leader',
'gl_project_deploy_optimize.domain AS domain',
'gl_project_deploy_optimize.api_no AS api_no',
];
return $select;
}
public function end_channel($channel){
$parts = explode("-", $channel);
return end($parts);
}
}
... ...
... ... @@ -56,30 +56,44 @@ class UpdateRoute extends Command
* @time :2023/11/20 15:13
*/
public function handle(){
$recordModel = new ProcessRecords();
$lists = $recordModel->list();
foreach ($lists as $k => $v){
$date = $v['record'][0]['date'];
$recordModel->edit(['date'=>$date],['id'=>$v['id']]);
}
// $projectModel = new Project();
// $list = $projectModel->list(['delete_status'=>['=',0]]);
// $data = [];
// foreach ($list as $v){
// echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
// ProjectServer::useProject($v['id']);
//// $this->getProduct();
//// $this->setProductKeyword();
//// $this->getBlog();
//// $this->setCustomRoute($v['id']);
// $this->editProductAlt();
//// $this->custom_to_blogs();
// DB::disconnect('custom_mysql');
// }
$projectModel = new Project();
$list = $projectModel->list(['id'=>['=',2503]]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
$this->getProduct();
// $this->updateProduct();
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
/**
* @remark :更新产品
* @name :updateProduct
* @author :lyh
* @method :post
* @time :2024/11/11 13:59
*/
public function updateProduct(){
$productModel = new Product();
$list = $productModel->list(['created_at'=>['like','2024-11-11%']],'id',['id']);
$productModel->edit(['category_id'=>',14,'],['created_at'=>['like','2024-11-11%']]);
$data = [];
foreach ($list as $k => $v){
$data[] = [
'product_id'=>$v['id'],
'cate_id'=>14,
'created_at'=>date('Y-m-d H:i:s'),
'updated_at'=>date('Y-m-d H:i:s')
];
}
$relaModel = new CategoryRelated();
$relaModel->insert($data);
}
/**
* @remark :同步擴展模塊數據到blogs
* @name :custom_to_blogs
* @author :lyh
... ...
... ... @@ -9,7 +9,9 @@ namespace App\Http\Controllers\Api;
use App\Enums\Common\Code;
use App\Http\Logic\Bside\User\UserLoginLogic;
use App\Models\Blog\Blog;
use App\Models\Domain\DomainInfo;
use App\Models\News\News;
use App\Models\Product\Category;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Keyword;
... ... @@ -283,4 +285,54 @@ class PrivateController extends BaseController
}
return $this->success($projects);
}
/**
* 获取有效时间内 新增有效URL
* 用于自动提交Google收录
* @param Request $request
* @return false|string
*/
public function projectNewUrl(Request $request)
{
$domain = trim($request->input('domain'));
$domain_parse = parse_url($domain);
$domain = $domain_parse['host'] ?? $domain;
$date = trim($request->input('date'));
if (empty($domain) || empty($date)) {
return $this->error('非法参数!');
}
$project = Project::getProjectByDomain($domain);
if (empty($project)) {
return $this->error('未找到当前域名对应的项目!');
}
ProjectServer::useProject($project->id);
$result = [];
// 查询有效时间后 有效的产品、新闻、博客、聚合页 链接
$product = Product::where(['status' => Product::STATUS_ON])->where('created_at', '>=', $date)->pluck('route');
$news = News::where(['status' => News::STATUS_ONE])->where('release_at', '>', $date)->pluck('url');
$blog = Blog::where(['status' => Blog::STATUS_ONE])->where('release_at', '>', $date)->pluck('url');
$keyword = Keyword::where('created_at', '>', $date)->pluck('route');
// 组装链接
foreach ($product as $item) {
$url = 'https://' . $domain . '/' . $item;
array_push($result, $url);
}
foreach ($keyword as $item) {
$url = 'https://' . $domain . '/' . $item;
array_push($result, $url);
}
foreach ($news as $item) {
$url = 'https://' . $domain . '/news/' . $item;
array_push($result, $url);
}
foreach ($blog as $item) {
$url = 'https://' . $domain . '/blogs/' . $item;
array_push($result, $url);
}
return $this->success($result);
}
}
... ...
... ... @@ -223,6 +223,9 @@ class OptimizeController extends BaseController
if(isset($this->map['site_status'])){
$query = $query->where('gl_project.site_status',$this->map['site_status']);
}
if(isset($this->map['main_lang_id'])){
$query = $query->where('gl_project.main_lang_id',$this->map['main_lang_id']);
}
if(isset($this->map['ai_video']) && !empty($this->map['ai_video'])){
$query = $query->where('gl_project_deploy_optimize.ai_video',$this->map['ai_video']);
}
... ...
<?php
/**
* @remark :
* @name :AllProjectController.php
* @author :lyh
* @method :post
* @time :2024/11/12 9:34
*/
namespace App\Http\Controllers\Aside\Project;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Models\Project\CountAllProject;
/**
* @remark :统计所有项目(4.0,5.0,6.0)
* @name :AllProjectController
* @author :lyh
* @method :post
* @time :2024/11/12 9:34
*/
class AllProjectController extends BaseController
{
/**
* @remark :统计所有项目列表
* @name :lists
* @author :lyh
* @method :post
* @time :2024/11/12 9:35
*/
public function lists(CountAllProject $allProject){
$data = $allProject->lists($this->map,$this->page,$this->row);
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
<?php
/**
* @remark :
* @name :DetailController.php
* @author :lyh
* @method :post
* @time :2024/11/12 14:55
*/
namespace App\Http\Controllers\Bside\Product;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Product\DetailLogic;
use App\Models\Product\Column;
use App\Models\Product\Detail;
use Illuminate\Support\Facades\DB;
class DetailController extends BaseController
{
/**
* @remark :获取当前产品的描述详情
* @name :getDetail
* @author :lyh
* @method :post
* @time :2024/11/13 9:53
*/
public function getDetail(Detail $detail){
$this->request->validate([
'product_id'=>'required',
'column_id'=>'required'
],[
'product_id.required' => '产品id不能为空',
'column_id.required' => '栏目id不能为空',
]);
$data = $detail->list($this->map,'sort',['*'],'asc');
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :获取产品描述页所有详情
* @name :getType
* @author :lyh
* @method :post
* @time :2024/11/12 14:57
*/
public function getType(Detail $detail){
$data = [
'text_type' => $detail->text_type(),
'line_two_type' => $detail->line_two_type(),
'image_two_type' => $detail->image_two_type(),
'three_type' => $detail->three_type(),
'image_three_type' => $detail->image_three_type(),
];
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :获取产品描述栏目
* @name :getColumn
* @author :lyh
* @method :post
* @time :2024/11/12 15:07
*/
public function getColumn(Column $column){
$data = $column->list($this->map,'id',['*'],'asc');
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :保存切换栏
* @name :saveColumn
* @author :lyh
* @method :post
* @time :2024/11/12 15:13
*/
public function saveColumn(DetailLogic $logic){
$this->request->validate([
'column_name'=>'required'
],[
'column_name.required' => '栏目名称不能为空'
]);
$data = $logic->saveColumn();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :保存数据
* @name :saveDetail
* @author :lyh
* @method :post
* @time :2024/11/12 16:24
*/
public function saveDetail(DetailLogic $logic){
$this->request->validate([
'product_id'=>'required',
'data'=>'required',
],[
'product_id.required' => '产品id不能为空',
'data.required' => 'data不能为空',
]);
$data = $logic->saveDetail();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :删除切换栏
* @name :delColumn
* @author :lyh
* @method :post
* @time :2024/11/13 10:40
*/
public function delColumn(Column $column,Detail $detail){
$this->request->validate([
'id'=>'required',
],[
'id.required' => 'id不能为空',
]);
$info = $column->read($this->map);
if($info === false){
$this->fail('当前数据不存在或已被删除');
}
if($info['id'] == 1){
$this->fail('当前默认模块不允许删除');
}
DB::beginTransaction();
try {
$column->del(['id'=>$this->param['id']]);
$detail->del(['column_id'=>$info['id']]);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('删除失败,请联系管理员');
}
$this->response('success');
}
/***
* @remark :删除模块
* @name :delDetail
* @author :lyh
* @method :post
* @time :2024/11/13 10:24
*/
public function delDetail(Detail $detail){
$this->request->validate([
'id'=>'required',
],[
'id.required' => 'id不能为空',
]);
$detail->del($this->map);
$this->response('success');
}
}
... ...
... ... @@ -11,50 +11,159 @@ namespace App\Http\Controllers\Bside;
use App\Enums\Common\Code;
use App\Http\Logic\Bside\News\NewsLogic;
use App\Models\Channel\Channel;
use App\Models\CustomModule\CustomModuleContent;
use App\Models\Domain\DomainInfo;
use App\Models\Manage\ManageHr;
use App\Models\Project\CountAllProject as AllProject;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
class TestController extends BaseController
{
/**
* @remark :非6.0拉取数据
* @name :NoSixProject
* @author :lyh
* @method :post
* @time :2024/11/11 14:51
*/
public function ceshi(){
$test = '';
$pattern = '/<img\s+[^>]*src=["\']([^"\']+)["\']/i';
$matches = [];
preg_match_all($pattern, $test, $matches);
$updatedSources = $this->saveBase64Images($matches[1]);
foreach($updatedSources as $k => $v){
$test = str_replace($v, $k, $test);
$data = $this->NoSixProject();
$this->response('success',Code::SUCCESS,$data);
}
public function NoSixProject(){
$res_data = [];
// $i = 1;
// while (true){
$url = 'https://quanqiusou.cn/extend_api/api/projects.php?page=1&pagesize=1';
$result = http_get($url);
$data = $result['data'];
// if(empty($data)){
// break;
// }
// $res_data = array_merge($res_data,$data['data']);
// $i++;
// }
return $data;
}
public function SixProject(){
$projectModel = new Project();
$query = $projectModel->leftJoin('gl_project_payment', 'gl_project.id', '=', 'gl_project_payment.project_id')
->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')
->where('gl_project.delete_status',Project::TYPE_ZERO);
$lists = $query->paginate(100000, $this->selectParam(), 'page', 1)->toArray();
$manageModel = new ManageHr();
foreach ($lists as $k => $v){
$allProjectModel = new AllProject();
$info = $allProjectModel->read(['version'=>1,'project_id'=>$v['id']],['id']);
if($info === false){
$channel = Channel::getChannelText($v['channel']['user_id'] ?? 0);
$data[] = [
'project_id'=>$v['id'],
'version'=>1,//代表6.0
'is_upgrade'=>$v['is_upgrade'],
'title'=>$v['title'],
'company'=>$v['company'],
'channel'=>$channel,
'sale'=>$this->end_channel($channel),
'join_date'=>$v['cooperate_date'],
'online_date'=>$v['uptime'],
'keywords_num'=>$v['key'],
'service_num'=>$v['day'],
'production_num'=>intval(abs(strtotime((empty($v['uptime']) ? date('Y-m-d H:i:s') : $v['uptime'])) - $v['created_at']) / 86400),
'plan'=>Project::planMap()[$v['plan']],
'status'=>$v['status'],
'test_domain'=>$v['test_domain'],
'product_domain'=>!empty($v['domain']) ? (new DomainInfo())->getDomain($v['domain']) : '',
'project_manager'=>$manageModel->getName($v['manager_mid'] ?? ''),
'project_group'=>$manageModel->getName($v['leader_mid'] ?? ''),
'project_design'=>$manageModel->getName($v['designer_mid'] ?? ''),
'project_assistant'=>$manageModel->getName($v['tech_mid'] ?? ''),
'service_manager'=>$manageModel->getName($v['optimize_manager_mid'] ??''),
'service_optimize'=>$manageModel->getName($v['optimize_optimist_mid'] ??''),
'service_assistant'=>$manageModel->getName($v['optimize_assist_mid'] ??''),
'qa'=>$manageModel->getName($v['quality_mid'] ??''),
];
$allProjectModel->add($data);
}else{
$data_edit = [
'title'=>$v['title'],
'company'=>$v['company'],
'channel'=>Channel::getChannelText($v['channel']['user_id'] ?? 0),
'sale'=>$this->end_channel($channel),
'join_date'=>$v['cooperate_date'],
'online_date'=>$v['uptime'],
'keywords_num'=>$v['key'],
'service_num'=>$v['day'],
'production_num'=>intval(abs(strtotime((empty($v['uptime']) ? date('Y-m-d H:i:s') : $v['uptime'])) - $v['created_at']) / 86400),
'plan'=>Project::planMap()[$v['plan']],
'status'=>$v['status'],
'test_domain'=>$v['test_domain'],
'product_domain'=>!empty($v['domain']) ? (new DomainInfo())->getDomain($v['domain']) : '',
'project_manager'=>$manageModel->getName($v['manager_mid'] ?? ''),
'project_group'=>$manageModel->getName($v['leader_mid'] ?? ''),
'project_design'=>$manageModel->getName($v['designer_mid'] ?? ''),
'project_assistant'=>$manageModel->getName($v['tech_mid'] ?? ''),
'service_manager'=>$manageModel->getName($v['optimize_manager_mid'] ??''),
'service_optimize'=>$manageModel->getName($v['optimize_optimist_mid'] ??''),
'service_assistant'=>$manageModel->getName($v['optimize_assist_mid'] ??''),
'qa'=>$manageModel->getName($v['quality_mid'] ??''),
];
$allProjectModel->edit($data_edit,['id'=>$info['id']]);
}
}
$this->response('success',Code::SUCCESS,$test);
}
/**
* @remark :解码图片
* @name :saveBase64Images
* @author :lyh
* @method :post
* @time :2024/11/7 16:52
* 需要查询的字段
* @return array
*/
public function saveBase64Images($imageSources) {
$updatedSources = [];
foreach ($imageSources as $src) {
// Check if src is a base64 image
if (preg_match('/^data:image\/(png|jpg|jpeg|gif);base64,/', $src, $match)) {
$imageType = $match[1]; // Image type (png, jpg, etc.)
$base64Data = preg_replace('/^data:image\/(png|jpg|jpeg|gif);base64,/', '', $src);
$decodedData = base64_decode($base64Data);
if ($decodedData === false) {
$updatedSources[] = $src; // If decoding fails, keep original src
continue;
}
$outputFile = 'images' . uniqid() . '.' . $imageType;
$imageUrl = 'http://your-domain.com/' . $outputFile;
$updatedSources[$imageUrl] = $src;
}
}
return $updatedSources;
}
public function selectParam(){
$select = [
'gl_project.id AS id',
'gl_project.title AS title',
'gl_project.channel AS channel',
'gl_project.company AS company',
'gl_project.type AS type',
'gl_project.extend_type AS extend_type',
'gl_project.uptime AS uptime',
'gl_project.is_upgrade AS is_upgrade',
'gl_project.created_at AS created_at',
'gl_project.cooperate_date AS cooperate_date',
'gl_project.site_status AS site_status',
'gl_project_deploy_build.keyword_num AS key',
'gl_project_deploy_build.service_duration AS day',
'gl_project_deploy_build.is_comment AS is_comment',
'gl_project_deploy_build.leader_mid AS leader_mid',
'gl_project_deploy_build.manager_mid AS manager_mid',
'gl_project_deploy_build.designer_mid AS designer_mid',
'gl_project_deploy_build.tech_mid AS tech_mid',
'gl_project_deploy_build.test_domain AS test_domain',
'gl_project_deploy_build.plan AS plan',
'gl_project_deploy_optimize.dept_id AS optimize_dept_id',
'gl_project_deploy_optimize.manager_mid AS optimize_manager_mid',
'gl_project_deploy_optimize.optimist_mid AS optimize_optimist_mid',
'gl_project_deploy_optimize.assist_mid AS optimize_assist_mid',
'gl_project_deploy_optimize.tech_mid AS optimize_tech_mid',
'gl_project_deploy_optimize.tech_leader AS tech_leader',
'gl_project_deploy_optimize.domain AS domain',
'gl_project_deploy_optimize.api_no AS api_no',
];
return $select;
}
public function end_channel($channel){
if(!empty($channel)){
$parts = explode("-", $channel);
return end($parts);
}
return $channel;
}
}
... ...
... ... @@ -160,6 +160,9 @@ class FileController
$suffix = array_pop($nameArr) ?? 'jpg';
$nameStr = implode('-', $nameArr);
$enName = generateRoute(Translate::tran($nameStr, 'en'));
if(substr($enName, 0, 1) === '-'){
$enName = md5(uniqid().$project_id.rand(1,1000));
}
$fileName = $enName;
$i=1;
while($this->onlyName($enName.'.'.$suffix,$project_id)){
... ...
... ... @@ -229,9 +229,13 @@ class ImageController extends Controller
$nameArr = explode('.',$name);
$suffix = array_pop($nameArr) ?? 'jpg';
$nameStr = implode('-', $nameArr);
$enName = generateRoute(Translate::tran($nameStr, 'en'));
$tran_name = Translate::tran($nameStr, 'en');
if(is_array($tran_name)){
$tran_name = $tran_name[0];
}
$enName = generateRoute($tran_name);
if(substr($enName, 0, 1) === '-'){
$enName = $nameStr;
$enName = md5(uniqid().$project_id.rand(1,1000));;
}
$fileName = $enName;
$i=1;
... ...
... ... @@ -209,6 +209,9 @@ class NewsLogic extends BaseLogic
if(isset($param['related_news_id'])){
$param['related_news_id'] = implode(',',$param['related_news_id']);
}
if(isset($param['related_product_id'])){
$param['related_product_id'] = implode(',',$param['related_product_id']);
}
return $this->success($param);
}
... ...
<?php
/**
* @remark :
* @name :DetailLogic.php
* @author :lyh
* @method :post
* @time :2024/11/12 15:14
*/
namespace App\Http\Logic\Bside\Product;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Product\Column;
use App\Models\Product\Detail;
class DetailLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
$this->model = new Detail();
}
/**
* @remark :保存栏目
* @name :saveColumn
* @author :lyh
* @method :post
* @time :2024/11/12 15:15
*/
public function saveColumn(){
$columnModel = new Column();
if(isset($this->param['id']) && !empty($this->param['id'])){
$id = $this->param['id'];
$rs = $columnModel->edit(['column_name'=>$this->param['column_name']],['id'=>$this->param['id']]);
if($rs === false){
$this->fail('保存失败,请联系管理员');
}
}else{
$id = $columnModel->addReturnId($this->param);
}
return $this->success(['id'=>$id]);
}
/**
* @remark :保存数据
* @name :saveDetail
* @author :lyh
* @method :post
* @time :2024/11/13 9:30
*/
public function saveDetail(){
try {
foreach ($this->param['data'] as $data){
foreach ($data as $v){
$save_data = [
'sort'=>$v['sort'],
'column_id'=>$v['column_id'],
'product_id'=>$this->param['product_id'],
'text_type'=>$v['text_type'],
'title'=>$v['title'] ?? '',
'content'=>json_encode($v['content'] ?? []),
'css'=>json_encode($v['css'] ?? []),
];
if(isset($v['id']) && !empty($v['id'])){
$this->edit($save_data,['id'=>$v['id']]);
}else{
$this->model->add($save_data);
}
}
}
}catch (\Exception $e){
$this->fail('保存失败,请联系管理员.错误:'.$e->getMessage());
}
return $this->success(['product_id'=>$this->param['product_id']]);
}
}
... ...
... ... @@ -560,7 +560,7 @@ class ProductLogic extends BaseLogic
'related_product_id'=>Arr::arrToSet($info['related_product_id']),
'sort'=>$info['sort'],
'status'=>0,
'route'=>$info['route'],
'route'=>$info['title'],
'product_type'=>$info['product_type'],
'created_uid'=>$this->user['id'],
'created_at'=>date('Y-m-d H:i:s'),
... ...
... ... @@ -277,6 +277,7 @@ class UserLoginLogic
$info['service_duration'] = $project['deploy_build']['service_duration'] ?? 0;
$info['is_comment'] = $project['deploy_build']['is_comment'] ?? 0;
$info['remain_day'] = $project['remain_day'] ?? 0;
$info['type'] = $project['type'] ?? 1;
if($info['is_customized'] == 1){
$info['is_visualization'] = json_decode($project['is_visualization']);
}
... ...
... ... @@ -20,7 +20,6 @@ class Blog extends Base
if(!$value){
return date('Y-m-d H:i:s', strtotime($this->getAttribute('created_at')));
}
return $value;
}
}
... ...
... ... @@ -7,7 +7,10 @@
*/
namespace App\Models\Inquiry;
use App\Helper\Translate;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
/**
* 广告询盘表单内容
... ... @@ -62,6 +65,10 @@ class ReInquiryForm extends Model
*/
public static function createInquiry($id, $origin_id, $ad_set_id, $ad_set_name, $ad_id, $ad_name, $full_name, $email, $phone, $whatsapp, $message, $country, $inquiry_date)
{
if($country){
$country_name = self::getCountryName($country);
}
$self = self::where(['id' => $id])->first();
if (empty($self)) {
$self = new self();
... ... @@ -80,8 +87,29 @@ class ReInquiryForm extends Model
$self->message = $message;
$self->inquiry_date = $inquiry_date;
$self->country = $country;
$self->country_name = $country_name??'';
$self->save();
return $self;
}
public static function getCountryName($country){
if (strlen($country) == 2) {
$country = self::getCountry($country);
} else {
$country = Translate::tran($country, 'zh');
}
return $country;
}
public static function getCountry($code)
{
$cache_key = 'inquiry_world_country';
$country_code = Cache::get($cache_key, function () use ($cache_key) {
$country_code = DB::table('gl_world_country_city')->where(['pid' => 0])->pluck('chinese_name', 'iso2')->toArray();
Cache::put($cache_key, $country_code, 86400);
return $country_code;
});
return empty($country_code[$code]) ? '' : $country_code[$code];
}
}
... ...
... ... @@ -28,4 +28,8 @@ class News extends Base
public function getRelatedNewsIdAttribute($value){
return Arr::setToArr($value);
}
public function getRelatedProductIdAttribute($value){
return Arr::setToArr($value);
}
}
... ...
<?php
/**
* @remark :
* @name :Column.php
* @author :lyh
* @method :post
* @time :2024/11/12 14:14
*/
namespace App\Models\Product;
use App\Models\Base;
class Column extends Base
{
//设置关联表名
protected $table = 'gl_product_column';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
<?php
/**
* @remark :
* @name :Detail.php
* @author :lyh
* @method :post
* @time :2024/11/12 14:13
*/
namespace App\Models\Product;
use App\Helper\Arr;
use App\Models\Base;
class Detail extends Base
{
//设置关联表名
protected $table = 'gl_product_detail';
//连接数据库
protected $connection = 'custom_mysql';
public function getCssAttribute($value){
return Arr::s2a($value);
}
public function getContentAttribute($value){
return Arr::s2a($value);
}
/**
* @remark :文本框类型
* @name :text_box
* @author :lyh
* @method :post
* @time :2024/11/12 14:15
*/
public function text_type(){
return [
1=>'富文本框',
2=>'多图模块',
3=>'单图文案',
];
}
/**
* @remark :多图框类型
* @name :line_number
* @author :lyh
* @method :post
* @time :2024/11/12 14:15
*/
public function line_two_type(){
return [
1=>'1行',
2=>'2行',
3=>'3行',
4=>'4行',
5=>'5行',
];
}
/**
* @remark :图片框类型
* @name :line_number
* @author :lyh
* @method :post
* @time :2024/11/12 14:15
*/
public function image_two_type(){
return [
1=>'1张图',
2=>'2张图',
3=>'3张图',
4=>'4张图',
5=>'5张图',
];
}
/**
* @remark :图片文本框类型
* @name :line_number
* @author :lyh
* @method :post
* @time :2024/11/12 14:15
*/
public function three_type(){
return [
1=>'左图右文',
2=>'右图左文',
];
}
/**
* @remark :图片文本框类型
* @name :line_number
* @author :lyh
* @method :post
* @time :2024/11/12 14:15
*/
public function image_three_type(){
return [
1=>'图片悬浮',
2=>'图片固定',
];
}
}
... ...
<?php
/**
* @remark :
* @name :CountAllProject.php
* @author :lyh
* @method :post
* @time :2024/11/11 10:36
*/
namespace App\Models\Project;
use App\Models\Base;
class CountAllProject extends Base
{
protected $table = 'gl_all_project';
}
... ...
... ... @@ -56,10 +56,12 @@ class MessagePush extends Base
return false;
}
//特殊处理, 要求任何时候收到询盘都要及时推送到群里面
$special_project_ids = [650];
//9-21 点,每条消息及时通知
//21-第二天 9 点,整合一起通知
$hour = date('H', strtotime($submit_at));
if($hour >= 9 && $hour < 21) {
if(($hour >= 9 && $hour < 21) || in_array($project_id, $special_project_ids)) {
$model = new self();
$model->project_id = $project_id;
$model->friend_id = $friend_id;
... ...
... ... @@ -136,6 +136,8 @@ class ProjectServer
self::init404Page($project_id);
//初始化模块数据
self::initModule($project_id);
//初始化切换栏
self::initColumn();
//初始化search页面
// self::initSearchPage($project_id);
DB::disconnect('custom_mysql');
... ... @@ -163,6 +165,27 @@ class ProjectServer
}
return true;
}
/**
* @remark :初始化产品切换栏
* @name :initColumn
* @author :lyh
* @method :post
* @time :2024/11/12 11:39
*/
public static function initColumn(){
$info = DB::connection('custom_mysql')->table('gl_product_column')->first();
if(empty($info)){
$data = [
'column_name'=>'Product Details',
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s')
];
DB::connection('custom_mysql')->table('gl_product_column')->insert($data);
}
return true;
}
/**
* @remark :菜单
* @name :initGroup
... ...
... ... @@ -39,6 +39,9 @@ Route::any('valid_user', [\App\Http\Controllers\Api\PrivateController::class, 'v
Route::any('getAutoToken', [\App\Http\Controllers\Api\PrivateController::class, 'getAutoToken'])->name('api.getAutoToken');
// 特殊项目 有效产品路由
Route::any('valid_product_route', [\App\Http\Controllers\Api\PrivateController::class, 'getProductRoute'])->name('api.valid_product_route');
// 6.0项目新增有效链接 - 提交Google
Route::any('project_new_url', [\App\Http\Controllers\Api\PrivateController::class, 'projectNewUrl'])->name('api.project_new_url');
// --------------------- 站群服务 ------------------------------------------
// 获取项目信息
... ...
... ... @@ -493,6 +493,12 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/fb_relay_detail_list', [Aside\Task\AdsController::class, 'fbRelayDetail'])->name('admin.fb_ads_relay_detail_list');
Route::any('/fb_relay_count', [Aside\Task\AdsController::class, 'fbRelayCount'])->name('admin.fb_relay_count');
});
//统计所有项目相关
Route::prefix('all_project')->group(function () {
Route::any('/', [Aside\Project\AllProjectController::class, 'lists'])->name('admin.all_project_lists');
});
});
//无需登录验证的路由组
... ...
... ... @@ -300,6 +300,14 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('extend/save', [\App\Http\Controllers\Bside\Product\ExtendController::class, 'save'])->name('product_extend_save');
Route::any('extend/del', [\App\Http\Controllers\Bside\Product\ExtendController::class, 'del'])->name('product_extend_del');
Route::any('extend/search_filed', [\App\Http\Controllers\Bside\Product\ExtendController::class, 'search_filed'])->name('product_extend_search_filed');
//产品描述
Route::any('detail/getColumn', [\App\Http\Controllers\Bside\Product\DetailController::class, 'getColumn'])->name('product_detail_getColumn');
Route::any('detail/getDetail', [\App\Http\Controllers\Bside\Product\DetailController::class, 'getDetail'])->name('product_detail_getDetail');
Route::any('detail/getType', [\App\Http\Controllers\Bside\Product\DetailController::class, 'getType'])->name('product_detail_getType');
Route::any('detail/saveColumn', [\App\Http\Controllers\Bside\Product\DetailController::class, 'saveColumn'])->name('product_detail_saveColumn');
Route::any('detail/saveDetail', [\App\Http\Controllers\Bside\Product\DetailController::class, 'saveDetail'])->name('product_detail_saveDetail');
Route::any('detail/delDetail', [\App\Http\Controllers\Bside\Product\DetailController::class, 'delDetail'])->name('product_detail_delDetail');
Route::any('detail/delColumn', [\App\Http\Controllers\Bside\Product\DetailController::class, 'delColumn'])->name('product_detail_delColumn');
});
... ...