作者 zhl

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

... ... @@ -89,9 +89,9 @@ class Count extends Command
DB::table('gl_count')->insert($data);
}
}catch (\Exception $e){
echo date('Y-m-d H:i:s') . ' error: ' . $v['test_domain'] . '->' . $e->getMessage() . PHP_EOL;
echo date('Y-m-d H:i:s') . ' error: ' . '->' . $e->getMessage() . PHP_EOL;
}
echo date('Y-m-d H:i:s') . ' end: ' . $v['test_domain'] . PHP_EOL;
echo date('Y-m-d H:i:s') . ' end: ' . PHP_EOL;
echo $this->error;
}
... ...
... ... @@ -171,7 +171,7 @@ class VideoTask extends Command
*/
public function getProjectKeyword($number)
{
$keyword_arr_id = Keyword::where('video', null)->whereNotNull('keyword_content')->pluck('id')->toArray();
$keyword_arr_id = Keyword::where('video', null)->where('title', 'not like', '%-tag%')->whereNotNull('keyword_content')->pluck('id')->toArray();
$keyword_id = array_rand($keyword_arr_id, $number);
$keyword = Keyword::whereIn("id", $keyword_id)->get();
return $keyword;
... ... @@ -299,9 +299,20 @@ class VideoTask extends Command
if($logoDom != null){
$logo = $logoDom->src;
}
$bgDom = $dom->find('.section-banner-wrap-block',0)->find('img', 0);
if($bgDom != null){
$bg = $bgDom->src;
$elements = $dom->find('.section-banner-wrap-block');
if (count($elements) >= 2) {
foreach ($elements as $v){
$image = $v->find('img', 0);
if($image != null){
break;
}
}
} else {
$image = $dom->find('.section-banner-wrap-block',0)->find('img', 0);
}
if($image != null){
$bg = $image->src;
}
$dom->clear();
} catch (\Exception $e) {
... ...
... ... @@ -85,7 +85,7 @@ class RecommendedSuppliers extends Command
public function savePurchaser($project_id,$keyword,$row = 10){
$url = 'https://admin.hagro.cn/api/company_list';
$data = [
'prod_desc'=>$keyword = 'led',
'prod_desc'=>$keyword,
'total'=>$row ?? 10,
];
ksort($data);
... ...
... ... @@ -266,7 +266,7 @@ class Demo extends Command
// }
public function handle(){
$domainModel = new DomainInfo();
$domainInfo = $domainModel->read(['project_id'=>1]);
$domainInfo = $domainModel->read(['project_id'=>45]);
if($domainInfo === false){
dd('11111');
}
... ... @@ -277,12 +277,25 @@ class Demo extends Command
if($logoDom != null){
$logo = $logoDom->src;
}
$bgDom = $dom->find('.section-banner-wrap-block',0)->find('img', 0);
if($bgDom != null){
$bg = $bgDom->src;
$elements = $dom->find('.section-banner-wrap-block');
if (count($elements) >= 2) {
foreach ($elements as $v){
$image = $v->find('img', 0);
if($image != null){
break;
}
}
} else {
$image = $elements->find('img', 0);
}
if($image != null){
$bg = $image->src;
}
if($image != null){
$bg = $image->src;
}
// return $logo;
dd(['logo'=>$logo ?? '','ng'=>$bg ?? '']);
dd(['logo'=>$logo ?? '','bg'=>$bg ?? '']);
// $projectModel = new Project();
// $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]);
// foreach ($list as $v1){
... ...
... ... @@ -665,23 +665,24 @@ class ProjectUpdate extends Command
foreach ($item['extend'] as $ke => $ve) {
$extend = $extend_model->read(['title' => $ke]);
if ($extend) {
$extend_info = $extend_info_model->read(['key' => $extend['key'], 'content_id' => $id]);
if (!$extend_info) {
if ($extend['type'] == 3) {
$gallery = [];
if (is_array($ve)) {
foreach ($ve as $ve_img) {
$gallery[] = ['title' => '', 'description' => '', 'url' => $this->source_download($ve_img, $project_id, $domain_arr['host'], $web_url_domain, $home_url)];
}
} else {
$gallery[] = ['title' => '', 'description' => '', 'url' => $this->source_download($ve, $project_id, $domain_arr['host'], $web_url_domain, $home_url)];
if ($extend['type'] == 3) {
$gallery = [];
if (is_array($ve)) {
foreach ($ve as $ve_img) {
$gallery[] = ['title' => '', 'description' => '', 'url' => $this->source_download($ve_img, $project_id, $domain_arr['host'], $web_url_domain, $home_url, 1)];
}
$value = Arr::a2s($gallery);
} elseif ($extend['type'] == 4) {
$value = Arr::a2s([$this->source_download($ve, $project_id, $domain_arr['host'], $web_url_domain, $home_url)]);
} else {
$value = $ve;
$gallery[] = ['title' => '', 'description' => '', 'url' => $this->source_download($ve, $project_id, $domain_arr['host'], $web_url_domain, $home_url, 1)];
}
$value = Arr::a2s($gallery);
} elseif ($extend['type'] == 4) {
$value = Arr::a2s([$this->source_download($ve, $project_id, $domain_arr['host'], $web_url_domain, $home_url, 1)]);
} else {
$value = $ve;
}
$extend_info = $extend_info_model->read(['key' => $extend['key'], 'content_id' => $id]);
if (!$extend_info) {
$extend_info_model->add([
'key' => $extend['key'],
'type' => $extend['type'],
... ... @@ -690,6 +691,8 @@ class ProjectUpdate extends Command
'module_id' => $custom_info['id'],
'values' => $value,
]);
} else {
$extend_info_model->edit(['type' => $extend['type'], 'values' => $value], ['key' => $extend['key'], 'content_id' => $id]);
}
}
}
... ... @@ -939,7 +942,7 @@ class ProjectUpdate extends Command
}
//资源下载
protected function source_download($url, $project_id, $domain, $web_url_domain, $home_url)
protected function source_download($url, $project_id, $domain, $web_url_domain, $home_url, $same_name = 0)
{
if (!$url) {
return '';
... ... @@ -961,7 +964,7 @@ class ProjectUpdate extends Command
$path = '/' . $path;
}
$url_complete = ($scheme ?: 'https') . '://' . $domain . $path;
$new_url = CosService::uploadRemote($project_id, 'image_product', $url_complete);
$new_url = CosService::uploadRemote($project_id, 'image_product', $url_complete, '', '', $same_name);
if ($new_url) {
CollectSource::insert([
... ...
... ... @@ -55,7 +55,7 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>969]);
$list = $projectModel->list(['id'=>645]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
... ...
... ... @@ -280,9 +280,11 @@ class WebTraffic extends Command
}
/**
* 引流的项目
* 非俄语站的引流的项目
*/
protected function getProjectList($type, $page){
$ru_lang_id = WebLanguage::getIdByLang('ru');
//推广项目
$list = Project::with('domainInfo')
->leftJoin('gl_project_deploy_optimize as pdo', 'pdo.project_id', '=', 'gl_project.id')
... ... @@ -291,6 +293,7 @@ class WebTraffic extends Command
->where('poc.qa_status', OnlineCheck::STATUS_ONLINE_TRUE)
->whereIn('gl_project.type', [Project::TYPE_TWO, Project::TYPE_FOUR])
->where('gl_project.is_upgrade', 0) //非升级项目
->where('gl_project.main_lang_id', '<>', $ru_lang_id) //非俄语站
->where(function ($query) use ($type) {
if($type == 1){
//1-3个月项目
... ... @@ -307,7 +310,7 @@ class WebTraffic extends Command
$startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString();
$query->where('pdo.start_date', '<', $startTime);
}
})->select(['pdo.project_id','gl_project.main_lang_id'])->forPage($page, 500)->get();
})->select(['pdo.project_id','gl_project.main_lang_id','gl_project.id'])->forPage($page, 500)->get();
//其他地方在引流的域名
$other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray();
$data = [];
... ...
<?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\Template\BCustomTemplate;
use App\Models\WebSetting\WebLanguage;
use App\Services\ProjectServer;
use Carbon\Carbon;
use GuzzleHttp\Client;
use GuzzleHttp\Promise\Utils;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
/**
* 俄语站网站引流
* Class Traffic
* @package App\Console\Commands
* @author zbj
* @date 2023/5/18
*/
class WebTrafficRussia extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'web_traffic_russia {type}';
/**
* The console command description.
*
* @var string
*/
protected $description = '俄语站网站引流';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* 国家概率
* @var array
*/
protected $country_ratio = [
'俄罗斯' => 75,
'白俄罗斯' => 6,
'哈萨克斯坦' => 6,
'乌兹别克斯坦' => 2,
'塔吉克斯坦' => 2,
'土耳其' => 2,
'吉尔吉斯坦' => 1,
'土库曼斯坦' => 1,
'乌克兰' => 1,
'亚美尼亚' => 2,
'阿塞拜疆' => 2,
'摩尔多瓦' => 2,
'格鲁吉亚' => 2,
'美国' => 1,
'德国' => 1,
'法国' => 1,
'意大利' => 1,
'加拿大' => 1,
'西班牙' => 1,
'葡萄牙' => 1,
'韩国' => 1,
'日本' => 1,
'印度' => 1,
'菲律宾' => 1,
'越南' => 1,
'荷兰' => 1,
'瑞典' => 1,
'泰国' => 1,
'英国' => 1,
];
/**
* google域名后缀
* @var string[]
*/
protected $suffix = [
'co.jp' => '日本',
'com.tr' => '土耳其',
'nl' => '荷兰',
'ru' => '俄罗斯',
'fr' => '法国',
'co.kr' => '韩国',
'fi' => '芬兰',
'be' => '比利时',
'lt' => '立陶宛',
'es' => '西班牙',
'it' => '意大利',
'com.au' => '澳大利亚',
'no' => '挪威',
'al' => '阿尔巴尼亚',
'pt' => '葡萄牙',
'lv' => '拉脱维亚',
'hu' => '匈牙利',
'cz' => '捷克',
'de' => '德国',
'ca' => '加拿大',
'co.in' => '印度',
'co.uk' => '英国',
'com.vn' => '越南',
'com.br' => '巴西',
'co.il' => '以色列',
'pl' => '波兰',
'com.eg' => '埃及',
'co.th' => '泰国',
'sk' => '斯洛伐克',
'ro' => '罗马尼亚',
'com.mx' => '墨西哥',
'com.my' => '马来西亚',
'com.pk' => '巴基斯坦',
'co.nz' => '新西兰',
'co.za' => '南非',
'com.ar' => '阿根廷',
'com.kw' => '科威特',
'com.sg' => '新加坡',
'com.co' => '哥伦比亚',
'co.id' => '印度尼西亚',
'gr' => '希腊',
'bg' => '保加利亚',
'mn' => '蒙古',
'dk' => '丹麦',
'com.sa' => '沙特阿拉伯',
'com.pe' => '秘鲁',
'com.ph' => '菲律宾',
'com.ua' => '乌克兰',
'ge' => '格鲁吉亚',
'ae' => '阿拉伯联合酋长国',
'tn' => '突尼斯',
];
/**
* 概率值
* @var int[]
*/
protected $sjjg = [360, 640];//访问间隔占比 访问|不访问 比非俄语站降一般
//访问页面类型占比 产品详情页、单页|产品分类页
protected $ymzb = [
'urls_cats' => 700,
'urls_details' => 300
];
protected $sdzb = [600, 200, 150, 50]; //访问页面深度占比 1页|2页|3-6页|7-11页
protected $yddzb = [1 => 700, 2 => 300]; //移动端占比 pc|mobile
//模拟访问来源占比 (美国)
protected $lyzb = [
'https://www.google.com/' => 630,
'http://www.google.com/' => 30,
'http://www.bing.com/' => 20,
'https://www.bing.com/' => 5,
'https://www.youtube.com/' => 5,
'https://search.yahoo.com/' => 5,
'https://www.facebook.com/' => 5,
];
//俄语
protected $eylyzb = [
'https://www.yandex.com/' => 630,
'https://www.google.com/' => 30,
'http://www.google.com/' => 30,
'http://www.bing.com/' => 20,
'https://www.bing.com/' => 5,
'https://www.youtube.com/' => 5,
'https://search.yahoo.com/' => 5,
'https://www.facebook.com/' => 5,
];
protected $otherzb = [700, 300]; //模拟访问来源占比 (非美国) google.com|google.其他后缀
protected $pc_ua = [
0 => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
1 => 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36',
2 => 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1'
];
protected $mobile_ua = [
0 => 'Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko; googleweblight) Chrome/38.0.1025.166 Mobile Safari/535.19',
];
/**
* @return bool
*/
public function handle()
{
try {
$type = $this->argument('type');
$this->sleep($type);
$page = 1;
while (true){
$project_list = $this->getProjectList($type, $page);
if(!$project_list){
break;
}
$need_project = [];
foreach ($project_list as $project) {
//随机引流间隔
$res_sjjg = $this->get_rand($this->sjjg);
if ($res_sjjg == 1) {
continue;
}
$project_urls = $this->getProductUrls($project['project_id']);
$project_urls['home'] = $project['domain'];
//随机访问页面
$project['visit_urls'] = $this->getVisitUrls($project_urls);
//随机客户端
$project['device_port'] = $this->get_rand($this->yddzb);
$project['user_agent'] = $project['device_port'] == 1 ? Arr::random($this->pc_ua) : Arr::random($this->mobile_ua);
$need_project[] = $project;
}
//随机访问ip
$ips = $this->getIpAreas(count($need_project));
//特殊日期 降访问率
foreach ($need_project as $project_key => $project){
$diff = $ips[$project_key]['diff'];
//当地时间
$w = date('w', strtotime($diff . 'hour'));
$date = date('m-d', strtotime($diff . 'hour'));
//元旦节和圣诞节按照周六的比例处理
if(in_array($date, ['01-01', '12-25'])){
$w = 6;
}
switch ($w){
case 0:
//周日降70-80%
$rate = rand(70, 80) * 10;
$res = $this->get_rand([1000-$rate, $rate]);
break;
case 5:
//周5降30-40%
$rate = rand(30, 40) * 10;
$res = $this->get_rand([1000-$rate, $rate]);
break;
case 6:
//周6降60-70%
$rate = rand(60, 70) * 10;
$res = $this->get_rand([1000-$rate, $rate]);
break;
default:
$res = 0;
}
//不访问
if($res == 1){
unset($need_project[$project_key]);
unset($ips[$project_key]);
}
}
//最多10层深度
$client = new Client(['verify' => false]);
for ($j = 0; $j < 10; $j++) {
for ($j = 0; $j < 10; $j++) {
//并发请求
$promises = [];
foreach ($need_project as $project_key => $project) {
if (empty($project['visit_urls'][$j])) {
continue;
}
$data = [
'ip' => $ips[$project_key]['ip'],
'url' => $project['visit_urls'][$j],
'device_port' => $project['device_port'],
'referrer_url' => $this->getReferer($ips[$project_key]['ip_area'], $project['lang']),
'user_agent' => $project['user_agent'],
];
Log::channel('traffic')->info('ru_traffic project_id:' . $project['project_id'], $data);
$promises[] = $client->postAsync($project['domain'] . 'api/traffic_visit', ['form_params' => $data]);
}
if($promises){
Utils::settle($promises)->wait();
//每个深度随机等待
sleep(rand(2, 10));
}
}
}
$page++;
}
}catch (\Exception $e){
Log::channel('traffic')->error("ru:line" . $e->getLine() . ',error:' . $e->getMessage());
}
}
/**
* 不同项目 休眠
*/
protected function sleep($type){
if($type == 1){ //1-3个月的项目
sleep(rand(5,480));
}elseif($type == 2){ //4-8个月的项目
sleep(rand(5,240));
}elseif($type == 3){ // 大于9个月的项目
sleep(rand(5,120));
}
}
/**
* 俄语站引流的项目
*/
protected function getProjectList($type, $page){
$ru_lang_id = WebLanguage::getIdByLang('ru');
//推广项目
$list = Project::with('domainInfo')
->leftJoin('gl_project_deploy_optimize as pdo', 'pdo.project_id', '=', 'gl_project.id')
->leftJoin('gl_project_online_check as poc', 'poc.project_id', '=', 'gl_project.id')
->where('pdo.domain', '>', 0)
->where('poc.qa_status', OnlineCheck::STATUS_ONLINE_TRUE)
->whereIn('gl_project.type', [Project::TYPE_TWO, Project::TYPE_FOUR])
->where('gl_project.is_upgrade', 0) //非升级项目
->where('gl_project.main_lang_id', $ru_lang_id)// 俄语站
->where(function ($query) use ($type) {
if($type == 1){
//1-3个月项目
$startTime = Carbon::now()->addMonths(-4)->toDateString();
$endTime = Carbon::now()->addMonths(-1)->toDateString();
$query->whereBetween('pdo.start_date', [$startTime,$endTime]);
}elseif($type == 2){
//4-8个月项目
$startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString();
$endTime = Carbon::now()->addMonths(-4)->endOfDay()->toDateTimeString();
$query->whereBetween('pdo.start_date', [$startTime,$endTime]);
}else{
//大于9个月项目
$startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString();
$query->where('pdo.start_date', '<', $startTime);
}
})->select(['pdo.project_id','gl_project.main_lang_id','gl_project.id'])->forPage($page, 500)->get();
//其他地方在引流的域名
$other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray();
$data = [];
foreach ($list as $project) {
$lang = WebLanguage::getLangById($project['main_lang_id']??1)['short'];
if(empty($project->domainInfo['domain'])){
continue;
}
//其他地方在引流就不再引流了
if(in_array($project->domainInfo['domain'], $other)){
continue;
}
$data[] = [
'project_id' => $project['project_id'],
'domain' => 'https://' . $project->domainInfo['domain'] . '/',
'lang' => $lang
];
}
return $data;
}
/**
* 获取产品分类、单页和详情链接
*/
protected function getProductUrls($project_id){
ProjectServer::useProject($project_id);
//已发布产品分类页面
$data['urls_cats'] = DB::connection('custom_mysql')->table('gl_product_category')
->where('project_id', $project_id)->where('status', Category::STATUS_ACTIVE)
->whereNull('deleted_at')
->pluck('route','id')->toArray();
//已发布单页面
$data['urls_page'] = [];
// $data['urls_page'] = DB::connection('custom_mysql')->table('gl_web_custom_template')
// ->where('project_id', $project_id)->where('url', '<>', '404')->where('status', BCustomTemplate::STATUS_ACTIVE)->pluck('url', 'id')->toArray();
//已发布产品详情页
$data['urls_details'] = DB::connection('custom_mysql')->table('gl_product')
->where('project_id', $project_id)->where('status', Product::STATUS_ON)
->whereNull('deleted_at')
->pluck('route', 'id')->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;
}
/**
* 获取地区IP
*/
protected function getIpAreas($num)
{
//本地时间为7-23点的地区
$h = date('H');
$areas = [];
$list = DB::table('gl_area_timezone')->whereIn('name', array_keys($this->country_ratio))->get();
$time_zones = [];
foreach ($list as $v) {
$v = (array)$v;
$country_hour = $h + $v['diff'];
if ($country_hour < 0) {
$country_hour = 24 + $country_hour;
}
if ($country_hour >= 7 && $country_hour < 23) {
$areas[] = $v['name'];
$time_zones[$v['name']] = $v['diff'];
}
}
//不在时区的国家概率去掉
$country_ratio = $this->country_ratio;
foreach ($country_ratio as $k => $v){
if(!in_array($k, array_keys($time_zones))){
unset($country_ratio[$k]);
}
}
$data = [];
for ($i=0;$i<$num;$i++){
//ip国家占比
$ip_area = $this->get_rand($this->country_ratio);
$res = DB::table('gl_xunpan_ipdata')->where('ip_area', $ip_area)->inRandomOrder()->first();
$res = (array)$res;
$res['diff'] = $time_zones[$res['ip_area']];
$data[] = $res;
}
return $data;
}
/**
* 概率算法
*/
protected function get_rand($proArr) {
$result = '';
$proSum = array_sum($proArr);
foreach ($proArr as $key => $proCur) {
$randNum = mt_rand(1, $proSum);
if ($randNum <= $proCur) {
$result = $key;
break;
} else {
$proSum -= $proCur;
}
}
unset ($proArr);
return $result;
}
/**
* 根据随机访问深度 随机获取访问页面
*/
protected function getVisitUrls($project_urls){
//没有分类页 就只访问首页
if(!$project_urls['urls_cats']){
$url[] = $project_urls['home'];
return $url;
}
//随机访问深度
$res_sdzb = $this->get_rand($this->sdzb);
//随机访问页面类型
$res_ymzb = $this->get_rand($this->ymzb);
$all_url = array_merge($project_urls['urls_cats'],$project_urls['urls_details']);
if(!$all_url){
$url[] = $project_urls['home'];
return $url;
}
$url = [];
if($res_sdzb == 0){//深度一页
$url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb]) : '';
}elseif($res_sdzb == 1){//深度两页
$url[] = $project_urls['home'];
$url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb]) : '';
}elseif($res_sdzb == 2){//深度3-6页
$yms = rand(2,5); //随机页面数
$url = Arr::random($all_url, $yms);
$url = Arr::prepend($url, $project_urls['home']);//首页加到最前面去
}elseif($res_sdzb == 3){//深度7-11页
$yms = rand(6,10); //随机页面数
$url = Arr::random($all_url, $yms);
$url = Arr::prepend($url, $project_urls['home']);//首页加到最前面去
}
foreach ($url as &$v){
if(!Str::contains($v, $project_urls['home'])){
if (FALSE === strpos($v, '.htm')) {
$v .= '/';
}
$v = $project_urls['home'] . $v;
}
}
return array_unique(array_filter($url));
}
/**
* 获取访问来路
*/
protected function getReferer($ip_area, $lang){
if($lang == 'ru'){
return $this->get_rand($this->eylyzb);
}
if($ip_area == '美国'){
$referer = $this->get_rand($this->lyzb);
}else{
$referer = 'https://www.google.com/';
$suffix = array_search($ip_area, $this->suffix);
if($suffix){
$res_qtzb = $this->get_rand($this->otherzb);
if($res_qtzb == 1){
$referer = 'https://www.google.'.$suffix.'/';
}
}
}
return $referer;
}
}
... ...
... ... @@ -30,6 +30,9 @@ class Kernel extends ConsoleKernel
$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分钟一次
$schedule->command('web_traffic_russia 1')->everyThirtyMinutes(); // 俄语站引流 1-3个月的项目,半小时一次
$schedule->command('web_traffic_russia 2')->cron('*/18 * * * *'); // 俄语站引流 4-8个月的项目,18分钟一次
$schedule->command('web_traffic_russia 3')->cron('*/12 * * * *'); // 俄语站引流 大于9个月的项目,12分钟一次
$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号执行月统计转发询盘记录
... ... @@ -45,7 +48,7 @@ class Kernel extends ConsoleKernel
$schedule->command('recommended_suppliers')->dailyAt('03:00')->withoutOverlapping(1); //每天凌晨1点执行一次生成推荐商
// 每日推送视频任务
$schedule->command('video_task')->dailyAt('03:30')->withoutOverlapping(1);
$schedule->command('video_task')->dailyAt('02:30')->withoutOverlapping(1);
// 每日推送已完成视频任务项目生成对应界面
$schedule->command('notice_c')->dailyAt('04:00')->withoutOverlapping(1);
}
... ...
... ... @@ -29,7 +29,7 @@ class KeywordsController extends BaseController
->orWhere('main_keywords', 'like' , '%'.$this->map['search'].'%')->pluck('project_id')->toArray();
$projectModel = new Project();
$lists = $projectModel->formatQuery(['id'=>['in',$ids]])->with('payment')->with('deploy_build')
->with('deploy_optimize')->get()->toArray();
->with('deploy_optimize')->with('domainInfo')->get()->toArray();
$this->response('success',Code::SUCCESS,$lists);
}
}
... ...
... ... @@ -239,7 +239,7 @@ class OptimizeController extends BaseController
}
if(isset($this->map['channel_id']) && !empty($this->map['channel_id'])){
$query->where(function ($subQuery) {
$subQuery->orWhere('gl_project.channel','like','%"zone_id": "'.$this->map['channel_id'].'"%')
$subQuery->orWhere('gl_project.channel','like','%"channel_id": "'.$this->map['channel_id'].'"%')
->orWhere('gl_project.channel','like','%"zone_id": '.$this->map['channel_id'].'%');
});
}
... ...
... ... @@ -30,6 +30,7 @@ class ProjectKeywordController extends BaseController
}
$data['search_keywords'] = $info['search_keywords'];
$data['customer_keywords'] = $info['customer_keywords'];
$data['brand_keyword'] = $info['brand_keyword'];
$this->response('success',Code::SUCCESS,$data);
}
... ...
... ... @@ -34,7 +34,8 @@ class SuppliersController extends BaseController
public function recommendedPurchaser(){
$purchaserModel = new Purchaser();
$data = [];
$lists = $purchaserModel->list(['project_id'=>$this->user['project_id']]);
$this->map['project_id'] = $this->user['project_id'];
$lists = $purchaserModel->list($this->map);
if(!empty($lists)){
foreach ($lists as $v){
$resultData = json_decode($v['data']);
... ... @@ -49,6 +50,19 @@ class SuppliersController extends BaseController
}
/**
* @remark :获取关键字
* @name :getKeyword
* @author :lyh
* @method :post
* @time :2024/3/14 14:46
*/
public function getKeyword(){
$purchaserModel = new Purchaser();
$keywordList = $purchaserModel->select('keyword')->groupBy('keyword')->where('project_id', $this->user['project_id'])->get()->toArray();
$this->response('success',Code::SUCCESS,$keywordList);
}
/**
* @remark :请求黑格公共方法
* @name :_action
* @author :lyh
... ... @@ -200,6 +214,8 @@ class SuppliersController extends BaseController
$action_name = 'trade_detail';
$param = [
'prod_desc'=>$this->param['prod_desc'] ?? '',
'page'=>$this->page,
'page_size'=>$this->row,
];
$res = $this->_action($api_url,$action_name,$param);
$this->response('success',Code::SUCCESS,$res);
... ...
... ... @@ -49,6 +49,10 @@ class LoginLogic extends BaseLogic
if (Manage::STATUS_DISABLE == $manage->status) {
$this->fail('帐号已被禁用');
}
$hrStatus = ManageHr::where('manage_id', $manage['id'])->value('status')?:1;
if($hrStatus != ManageHr::STATUS_ONE){
$this->fail('当前员工已离职');
}
$type = 1;//账号密码登录
if (!Hash::check($this->param['password'], $manage->password)) {
//验证验证码
... ... @@ -61,7 +65,6 @@ class LoginLogic extends BaseLogic
//生成新token
$token = md5(uniqid().$manage['id']);
unset($manage['password']);
Cache::add(Common::MANAGE_TOKEN . $token,$manage,3600 * 6);
//更新用户信息
$manage->token = $token;
$res = $manage->save();
... ... @@ -73,6 +76,7 @@ class LoginLogic extends BaseLogic
$manage['special'] = $this->getSpecialMenu($manage['id']);
//岗位
$manage['entry_position'] = ManageHr::where('manage_id', $manage['id'])->value('entry_position')?:0;
Cache::add(Common::MANAGE_TOKEN . $token,$manage,3600 * 6);
return $this->success($manage->makeVisible('token')->toArray());
}
... ...
... ... @@ -33,6 +33,15 @@ class OnlineCheckLogic extends BaseLogic
//获取项目优化人员
$optimizeModel = new DeployOptimize();
$optimizeInfo = $optimizeModel->read(['project_id'=>$this->param['id']]);
if(!empty($this->manager['special'])){
foreach ($this->manager['special'] as $value){
if($value['name'] == 'examine'){
$info['qa_mid'] = $this->manager['id'];
$optimizeInfo['optimist_mid'] = $this->manager['id'];
$optimizeInfo['assist_mid'] = $this->manager['id'];
}
}
}
//查看当前用户是否有权限审核
if($this->param['type'] == 'optimist'){
if(($optimizeInfo['optimist_mid'] != $this->manager['id']) && ($optimizeInfo['assist_mid'] != $this->manager['id'])){
... ...
... ... @@ -161,7 +161,6 @@ class ProjectLogic extends BaseLogic
DB::rollBack();
$this->fail('保存失败,请联系管理员');
}
return $this->success();
}
... ... @@ -565,6 +564,9 @@ class ProjectLogic extends BaseLogic
case Project::TYPE_ONE:
return Zone::pluck('title', 'id')->toArray();
case Project::TYPE_TWO:
if(isset($param['alias'])){
return Channel::where('alias', 'like' ,'%'.$param['alias'].'%')->pluck('alias', 'id')->toArray();
}
return Channel::where('zone_id', $param['zone_id']??0)->pluck('alias', 'id')->toArray();
case Project::TYPE_THREE:
return User::where('channel_id', $param['channel_id']??0)->pluck('name', 'id')->toArray();
... ... @@ -778,7 +780,7 @@ class ProjectLogic extends BaseLogic
$token = $common->encrypt($param);
$res = Http::withoutVerifying()->get($url, ['token' => $token])->json();
if(empty($res['code']) || $res['code'] != 200){
$this->fail('ProjectToHagro error');
$this->fail($res['msg']);
}
return true;
}
... ...
... ... @@ -46,7 +46,7 @@ class BTemplateModuleProjectLogic extends BaseLogic
public function moduleProjectSave(){
try {
$this->param['operator_id'] = $this->user['id'];
$this->param['project_id'] = $this->user['project_id'];
$this->param['project_id'] = isset($this->param['project_id']) ? $this->param['project_id'] : $this->user['project_id'];
$this->model->add($this->param);
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
... ...
... ... @@ -34,7 +34,7 @@ class TranslateLogic extends BaseLogic
if($this->param['url'] == 'All'){
$info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]);
if(!empty($info) && !empty($info['data'])){
$translateInfo = json_decode($info['data']);
$translateInfo = json_decode($info['data'],true);
foreach ($translateInfo as $k => $v){
$data[] = [$k=>$v];
}
... ... @@ -47,26 +47,18 @@ class TranslateLogic extends BaseLogic
$languageInfo = $this->getLanguage($this->param['language_id']);
// 原始校对内容
$info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]);
//获取当前URl的所有文本内容
$text_array = $this->getUrlRead($url);
// 原始校对程序
$old_key = [];//key值组成数据
if($info !== false){
$data_read = json_decode($info['data']);
$data_read = json_decode($info['data'],true);
foreach ($data_read as $k => $v){
// if(!in_array($k,$text_array)){
// $arr2[] = $k;
// }
// $old_key[] = $k;
$data[] = [$k => $v];
}
return $this->success($data);
}else{
$arr2 = array_values(array_diff($text_array, $old_key));
}
if(!empty($arr2)){
//获取当前URl的所有文本内容
$text_array = $this->getUrlRead($url);
$i = 0;
TranslateText:
$translate_list = Translate::tran($arr2, $languageInfo['short']);
$translate_list = Translate::tran($text_array, $languageInfo['short']);
if(empty($translate_list)){
if ($i < 3) {
$i++;
... ... @@ -74,21 +66,57 @@ class TranslateLogic extends BaseLogic
}
$this->fail('翻译失败,请稍后重试!');
}
if(count($arr2) == 1){
if(count($text_array) == 1){
$data[] = [
$arr2[0]=>$translate_list
$text_array[0]=>$translate_list
];
}else{
foreach ($arr2 as $k => $v){
foreach ($text_array as $k => $v){
$data[] = [
$v=>$translate_list[$k]
];
}
}
return $this->success($data);
}
return $this->success($data);
}
// $old_key = [];//key值组成数据
// if($info !== false){
// $data_read = json_decode($info['data']);
// foreach ($data_read as $k => $v){
//// if(!in_array($k,$text_array)){
//// $arr2[] = $k;
//// }
//// $old_key[] = $k;
// $data[] = [$k => $v];
// }
// }else{
// $arr2 = array_values(array_diff($text_array, $old_key));
// }
// if(!empty($arr2)){
// $i = 0;
// TranslateText:
// $translate_list = Translate::tran($arr2, $languageInfo['short']);
// if(empty($translate_list)){
// if ($i < 3) {
// $i++;
// goto TranslateText;
// }
// $this->fail('翻译失败,请稍后重试!');
// }
// if(count($arr2) == 1){
// $data[] = [
// $arr2[0]=>$translate_list
// ];
// }else{
// foreach ($arr2 as $k => $v){
// $data[] = [
// $v=>$translate_list[$k]
// ];
// }
// }
// }
/**
* @remark :获取图片列表
... ... @@ -102,7 +130,7 @@ class TranslateLogic extends BaseLogic
$info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]);
$data = [];
if(!empty($info) && !empty($info['data'])){
$translateInfo = json_decode($info['data']);
$translateInfo = json_decode($info['data'],true);
foreach ($translateInfo as $k => $v){
$data[] = [$k=>$v];
}
... ... @@ -123,7 +151,7 @@ class TranslateLogic extends BaseLogic
}
$new_list = $this->getUrlImageRead($url);
$old_list = [];
$data_read = json_decode($info['data']);
$data_read = json_decode($info['data'],true);
foreach ($data_read as $k=>$v){
$old_list[] = $k;
$data[] = [
... ... @@ -254,10 +282,10 @@ class TranslateLogic extends BaseLogic
'language_id'=>$this->param['language_id'],
'alias'=>$this->param['alias'],
];
$param['data'] = json_encode($data);
$param['data'] = json_encode($data,true);
$this->model->add($param);
}else{
$data = json_encode($data);
$data = json_encode($data,true);
$this->model->edit(['data'=>$data],['language_id'=>$this->param['language_id'],'url'=>$this->param['url'],'type'=>$this->param['type']]);
}
}catch (\Exception $e){
... ...
... ... @@ -227,9 +227,10 @@ class Project extends Base
*/
public function domainInfo()
{
return self::hasOne(\App\Models\Domain\DomainInfo::class, 'project_id', 'project_id')->select('project_id', 'domain');;
return self::hasOne(\App\Models\Domain\DomainInfo::class, 'project_id', 'id')->select('project_id', 'domain');
}
public function setLevelAttribute($value)
{
$this->attributes['level'] = Arr::arrToSet($value);
... ... @@ -321,12 +322,16 @@ class Project extends Base
$project_id = DeployBuild::where('test_domain', 'https://' . $domain . '/')->value('project_id');
//是否正式域名
if (!$project_id) {
//是否小语种域名
//是否小语种域名或amp站域名
$domainPrefix = explode(".",$domain);
if (!empty($domainPrefix)){
$isLang = Translate::getTls($domainPrefix[0]);
if ($isLang) {
if($domainPrefix[0] == 'm'){
$domain = "www.".$domainPrefix[1].".".$domainPrefix[2];
}else{
$isLang = Translate::getTls($domainPrefix[0]);
if ($isLang) {
$domain = "www.".$domainPrefix[1].".".$domainPrefix[2];
}
}
}
$project_id = \App\Models\Domain\DomainInfo::where('domain', $domain)->value('project_id');
... ...
... ... @@ -32,4 +32,20 @@ class WebLanguage extends Base
}
return $lang;
}
/**
* @param $lang
* @return mixed
* @author zbj
* @date 2023/12/11
*/
public static function getIdByLang($lang){
$cache_key = 'lang_id_'.$lang;
$id = Cache::get($cache_key);
if(!$id){
$id = self::where('short', $lang)->value('id');
Cache::put($cache_key, $id, 7200);
}
return $id;
}
}
... ...
... ... @@ -72,17 +72,24 @@ class CosService
* @param $file_url
* @param $key
* @param $body_str
* @param int $same_name 是否保持名称一直
* @return string
* @author Akun
* @date 2023/09/21 9:39
*/
public static function uploadRemote($project_id,$image_type,$file_url,$key='',$body_str='')
public static function uploadRemote($project_id,$image_type,$file_url,$key='',$body_str='',$same_name=0)
{
if(!$key){
$url_arr = parse_url($file_url);
$ext = explode('.',$url_arr['path']);
$filename = uniqid().rand(10000,99999).'.'.end($ext);
if($same_name){
$path_arr = explode('/',$url_arr['path']);
$filename = end($path_arr);
}else{
$ext = explode('.',$url_arr['path']);
$filename = uniqid().rand(10000,99999).'.'.end($ext);
}
$uploads = config('upload.default_file');
$path = $uploads['path_b'].'/'.$project_id.'/'.$image_type.'/'.date('Y-m');
... ...
... ... @@ -32,6 +32,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/trade_detail',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'trade_detail'])->name('suppliers_trade_detail');
Route::any('/bill_detail',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'bill_detail'])->name('suppliers_bill_detail');
Route::any('/import_product',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'import_product'])->name('suppliers_import_product');
Route::any('/getKeyword',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'getKeyword'])->name('suppliers_getKeyword');
});
//用户相关路由
Route::prefix('user')->group(function () {
... ...