作者 刘锟

update

... ... @@ -11,7 +11,6 @@ namespace App\Console\Commands\Domain;
use Illuminate\Console\Command;
use App\Models\Domain\DomainInfo as DomainInfoModel;
use Illuminate\Support\Facades\Log;
class DomainInfo extends Command
{
... ... @@ -47,7 +46,7 @@ class DomainInfo extends Command
//AMP站证书到期更新
$this->startUpdateAmpCert();
return 1;
return true;
}
/**
... ...
... ... @@ -16,6 +16,8 @@ use App\Models\Manage\BelongingGroup;
use App\Models\Manage\Dept;
use App\Models\Manage\EntryPosition;
use App\Models\Manage\ManageHr;
use App\Models\Project\Project;
use App\Models\WebSetting\WebSettingService;
use App\Services\ProjectServer;
use App\Services\SyncService;
use GuzzleHttp\Client;
... ... @@ -76,187 +78,200 @@ class Demo extends Command
/**
* @return bool
*/
public function handle()
{
return $this->domain();
$result = app(SyncService::class)->projectAcceptAddress(1);
dd($result);
$data = [
'key' => 'productkey_keyword',
'keywords' => 'apple watch'
];
$result = Common::send_openai_msg('v2/openai_chat', $data);
dd();
$string = 'demo.globalso.site/';
$domain_array = parse_url($string);
$domain = $domain_array['host'] ?? $domain_array['path'];
dd($domain);
$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;
// public function handle()
// {
// return $this->domain();
// $result = app(SyncService::class)->projectAcceptAddress(1);
// dd($result);
// $data = [
// 'key' => 'productkey_keyword',
// 'keywords' => 'apple watch'
// ];
// $result = Common::send_openai_msg('v2/openai_chat', $data);
// dd();
// $string = 'demo.globalso.site/';
// $domain_array = parse_url($string);
// $domain = $domain_array['host'] ?? $domain_array['path'];
// dd($domain);
// $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);
//
// print_r($include);
// }
if (($handle = fopen($filename, 'r')) !== false) {
while (($data = fgetcsv($handle, 1000, ',')) !== false) {
// 处理每行数据
Log::info(var_export($data, true));
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['delete_status'=>0]);
foreach ($list as $v){
ProjectServer::useProject($v['id']);
$webSettingServiceModel = new WebSettingService();
$info = $webSettingServiceModel->read(['values'=>['like','%+86%']]);
if($info !== false){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
}
fclose($handle);
DB::disconnect('custom_mysql');
}
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);
print_r($include);
}
public function printMessage()
{
$client = new Client();
... ...
... ... @@ -149,9 +149,9 @@ class QuanqiusouApi
*/
public function getHistoryCount($api_no, $lang = '')
{
$key = "quanqiusou_api_history_count_{$api_no}_{$lang}_" . date('Y-m-d');
$res = Cache::get($key);
if (!$res) {
// $key = "quanqiusou_api_history_count_{$api_no}_{$lang}_" . date('Y-m-d');
// $res = Cache::get($key);
// if (!$res) {
$api_url = $this->url . '/google-rank/history_count.php';
$param = [
'apino' => $api_no,
... ... @@ -163,13 +163,13 @@ class QuanqiusouApi
$res = HttpUtils::get($api_url, $param);
if($res){
$res = Arr::s2a($res);
Cache::put($key, $res, 2 * 3600);
// Cache::put($key, $res, 2 * 3600);
}
} catch (\Exception | GuzzleException $e) {
errorLog('获取历史排名统计数据失败', [], $e);
return false;
}
}
// }
return $res;
}
... ...
... ... @@ -6,9 +6,16 @@ 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\Domain\DomainInfo;
use App\Models\Inquiry\InquiryData;
use App\Models\Manage\Manage;
use App\Models\Product\Keyword;
use App\Models\Product\Product;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
/**
... ... @@ -96,4 +103,59 @@ class IndexController extends BaseController
$this->response('success');
}
/**
* @remark :根据关键字获取产品主图
* @name :getKeywordList
* @author :lyh
* @method :post
* @time :2024/2/23 16:28
*/
public function getKeywordImage(){
$arr = explode('/',trim(str_replace('https://', '', $this->param['url']),'/'));
if(empty($arr) || !is_array($arr)){
$this->response('当前项目不存在..',Code::SYSTEM_ERROR);
}
$domainModel = new DomainInfo();
$domainInfo = $domainModel->read(['domain'=>$arr[0]]);
if($domainInfo === false){
$this->response('当前项目不存在.',Code::SYSTEM_ERROR);
}
ProjectServer::useProject($domainInfo['project_id']);
$routeMapModel = new RouteMap();
$routeInfo = $routeMapModel->read(['route'=>$arr[1]]);
if($domainInfo === false){
$this->response('当前路由不存在.',Code::SYSTEM_ERROR);
}
$keywordModel = new Keyword();
$keywordInfo = $keywordModel->read(['id'=>$routeInfo['source_id']]);
$count = Product::where('keyword_id','like' ,'%,'.$keywordInfo['id'].',%')->count();
$productModel = new Product();
if($count < 5){
$productList = $productModel->list([],'sort',['thumb','title']);
//获取7个产品主图
}else{
$productList = $productModel->list(['keyword_id'=>['like','%,'.$keywordInfo['id'].',%']],['thumb','title']);
}
$product_image = [];
foreach ($productList as $k => $v){
$image = [];
if(!empty($v['thumb']) && !empty($v['thumb']['url'])){
$image['image'] = getImageUrl($v['thumb']['url']);
$image['title'] = $v['title'];
$product_image[] = $image;
}
if(count($product_image) > 6){
break;
}
}
$data = [
'title'=>$keywordInfo['title'],
'keyword_title'=>$keywordInfo['keyword_title'],
'keyword_content'=>$keywordInfo['keyword_content'],
'product_list'=>$product_image
];
DB::disconnect('custom_mysql');
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
<?php
/**
* @remark :
* @name :KeywordController.php
* @author :lyh
* @method :post
* @time :2024/2/26 9:23
*/
namespace App\Http\Controllers\Aside\Com;
use App\Http\Controllers\Aside\BaseController;
class KeywordController extends BaseController
{
/**
* @remark :创建关键字任务池子
* @name :saveKeyword
* @author :lyh
* @method :post
* @time :2024/2/26 9:24
*/
public function savePromotionKeyword(){
$this->request->validate([
'data' => 'required|array',
'project_id'=>'required',
], [
'data.required' => '自定义询盘数据不为空',
'data.array' => '必须为数组',
'project_id.required' => '项目唯一标识不为空',
]);
foreach ($this->param['data'] as $v){
$param['keyword'] = $v;
$param['project_id'] = $this->param['project_id'];
}
}
}
... ...
... ... @@ -52,6 +52,12 @@ class UserLogic extends BaseLogic
//验证一个项目是否只有一个超级管理员
$this->verifyRole($this->param);
if (isset($this->param['id']) && !empty($this->param['id'])) {
$info = $this->model->read(['id'=>$this->param['id']]);
if($info['role_id'] == 0){
//更新项目信息
$projectModel = new Project();
$projectModel->edit(['lead_name'=>$this->param['name'],'mobile'=>$this->param['mobile']],['id'=>$info['project_id']]);
}
$this->param = $this->editPassword($this->param);
$rs = $this->model->edit($this->param, ['id' => $this->param['id']]);
} else {
... ...
... ... @@ -57,7 +57,7 @@ class CopyProjectJob implements ShouldQueue
$data = $data->getAttributes();
$type = $data['type'];
$data['type'] = 0;
$data['old_project_id'] = $this->param['project_id'];
$data['status'] = 0;
$data['title'] = $data['title'].'-copy';
unset($data['id']);
$project_id = $projectModel->insertGetId($data);
... ... @@ -160,7 +160,7 @@ class CopyProjectJob implements ShouldQueue
$sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE {$table}");
DB::connection('custom_mysql')->statement(get_object_vars($sql[0])['Create Table']);
}
DB::connection('custom_mysql')->table($table)->truncate(); // 清空目标表数据
// DB::connection('custom_mysql')->table($table)->truncate(); // 清空目标表数据
DB::connection('custom_mysql')->table($table)->insertUsing(
[], // 列名数组,留空表示插入所有列
function ($query) use ($table,$project_id) {
... ...
<?php
/**
* @remark :
* @name :PromotionKeyword.php
* @author :lyh
* @method :post
* @time :2024/2/26 9:33
*/
namespace App\Models\Com;
use App\Models\Base;
class PromotionKeyword extends Base
{
protected $table = 'gl_promotion_keyword';
}
... ...
... ... @@ -380,6 +380,7 @@ Route::group([], function () {
Route::any('/collect', [Aside\Collect\CollectController::class, 'index'])->name('admin.collect');
//同步询盘
Route::any('/sync_inquiry', [Aside\Com\IndexController::class, 'sync_inquiry'])->name('admin.sync_inquiry');
Route::any('/getKeywordImage', [Aside\Com\IndexController::class, 'getKeywordImage'])->name('admin.getKeywordImage');
});
... ...