作者 刘锟

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

... ... @@ -107,7 +107,9 @@ class VideoTask extends Command
'project_id' => $task_project->project_id,
'keyword_id' => $val->id,
'keyword' => $val->title,
'data' => json_encode(['url' => $keywordInfo['url'],'title' => $keywordInfo['title'], 'description' => $keywordInfo['keyword_content'], 'images' => $keywordInfo['product_list'], 'keywords' => $keywordInfo['keyword_list']]),
'data' => json_encode(['url' => $keywordInfo['url'],'title' => $keywordInfo['title'],
'description' => $keywordInfo['keyword_content'], 'images' => $keywordInfo['product_list'],
'keywords' => $keywordInfo['keyword_list']]),
'status' => KeywordVideoTaskLog::STATUS_INIT,
'updated_at' => date('Y-m-d H:i:s'),
'created_at' => date('Y-m-d H:i:s'),
... ... @@ -226,7 +228,8 @@ class VideoTask extends Command
}
}else{
$product_all_id = Product::where("project_id", $project_id)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
$product_id = array_rand($product_all_id, 40);
$number = 40;
$product_id = array_rand($product_all_id, min(count($product_all_id, $number-count($productIds))));
$products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
}
}
... ... @@ -239,6 +242,12 @@ class VideoTask extends Command
if(count($data) > 13){
break;
}
if (strpos($item->keyword_id, ','.$productKeyword->id.',') === false) {
//不包含
$productModel = new Product();
$keyword_id = $item->keyword_id . $productKeyword->id.',';
$productModel->edit(['keyword_id'=>$keyword_id],['id'=>$item->id]);
}
$data[] = ['url'=>getImageUrl($item->thumb['url']),'title'=>$item->title];
}
}
... ...
... ... @@ -48,11 +48,11 @@ class RankData extends BaseCommands
Log::channel('rank_data')->info('开始-排名数据');
//同步api_no
try {
$this->SyncApiNo();
} catch (\Exception $e) {
Log::channel('rank_data')->error('同步api_no失败:' . $e->getMessage());
}
// try {
// $this->SyncApiNo();
// } catch (\Exception $e) {
// Log::channel('rank_data')->error('同步api_no失败:' . $e->getMessage());
// }
//所有项目 今日是否达标 重置
... ... @@ -70,7 +70,7 @@ class RankData extends BaseCommands
//当日所有站点谷歌收录数据
$site_res = $api->getSiteRes();
if (!$site_res) {
return false;
Log::channel('rank_data')->error('谷歌收录数据获取失败');
}
foreach ($list as $item) {
echo $item['api_no'] . PHP_EOL;
... ...
... ... @@ -55,7 +55,7 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>206]);
$list = $projectModel->list(['id'=>969]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
... ...
... ... @@ -11,6 +11,8 @@ use App\Enums\Common\Code;
use App\Http\Controllers\Controller;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
/**
* Class BaseController
... ... @@ -18,6 +20,12 @@ use Illuminate\Http\JsonResponse;
*/
class BaseController extends Controller
{
public $param;
public function __construct(Request $request)
{
$this->request = $request;
$this->param = $this->request->all();
}
/**
* @param array $data
* @param string $message
... ...
<?php
/**
* @remark :
* @name :OptimizationReportController.php
* @author :lyh
* @method :post
* @time :2024/3/7 15:57
*/
namespace App\Http\Controllers\Api;
use App\Enums\Common\Code;
use App\Helper\Arr;
use App\Helper\FormGlobalsoApi;
use App\Models\Domain\DomainInfo;
use App\Models\HomeCount\Count;
use App\Models\Inquiry\InquiryFormData;
use App\Models\Project\Project;
use App\Models\RankData\ExternalLinks;
use App\Models\RankData\IndexedPages;
use App\Models\RankData\RankData;
use App\Models\RankData\RankWeek;
use App\Models\RankData\Speed;
use App\Models\Visit\Visit;
use App\Models\Visit\VisitItem;
use App\Services\ProjectServer;
use App\Utils\HttpUtils;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class OptimizationReportController extends BaseController
{
/**
* @remark :优化报告
* @name :getOptimizationReport
* @author :lyh
* @method :post
* @time :2024/3/7 15:54
*/
public function getOptimizationReport(){
$this->request->validate([
'project_id' => 'required',
'date'=>'required',
], [
'project_id.required' => '项目id不能为空',
'date.required' => '时间不能为空',
]);
ProjectServer::useProject($this->param['project_id']);
$data = [];
$projectModel = new Project();
$projectInfo = $projectModel->with('payment')->with('deploy_build')
->with('deploy_optimize')->with('online_check')->where(['id'=>$this->param['project_id']])->first();
$domainModel = new DomainInfo();
$domain_info = $domainModel->where('project_id', $this->param['project_id'])->first();
if(!$domain_info){
return [];
}else{
$domain_info = [
'domain' => 'https://'.$domain_info['domain'].'/',
'domain_info' => date('Y-m-d', strtotime($domain_info['domain_start_time'])) . ' - ' .date('Y-m-d', strtotime($domain_info['domain_end_time'])),
'cert_info' => date('Y-m-d', strtotime($domain_info['certificate_start_time'])) . ' - ' .date('Y-m-d', strtotime($domain_info['certificate_end_time'])),
];
}
//外链周期分析
$external_links = ExternalLinks::where('project_id', $this->param['project_id'])->first();
$data['domain'] = $domain_info;
//方案信息
$data['plan_information'] = $this->plan_information($projectInfo,$domain_info);
//排名数据
$data['first_total'] = $this->first_total($external_links);
//关键词排名分析图
$data['rank_chat'] = $this->rank_chat();
//关键词排名明细
$data['keywords_rank_list'] = $this->keywords_rank_list($this->param['project_id'],$projectInfo);
//pv_ip统计
$data['pv_ip'] = $this->pv_ip($domain_info['domain']);
//30天统计
$data['count_30'] = $this->count_30_total();
//访问国家前10
$data['access_country_count'] = $this->access_country_count();
//SEO数据周期分析图 外链数
$data['external_links_chat'] = [
'labels' => array_keys($external_links['data'] ?? []),
'data' => array_values($external_links['data'] ?? []),
];
$indexed_pages = IndexedPages::where('project_id', $this->param['project_id'])->first();
//SEO数据周期分析图 收录数
$data['indexed_pages_chat'] = [
'labels' => array_keys($indexed_pages['data'] ?? []),
'data' => array_values($indexed_pages['data'] ?? []),
];
//月统计报告
$data['month_count'] = $this->currentMonthCount($domain_info['domain'],$this->param['project_id']);
//测速
$speed = Speed::where('project_id', $this->param['project_id'])->first();
$data['speed'] = $speed['data'] ?? [];
//询盘
$data['inquiry'] = $this->getApiList($projectInfo);
DB::disconnect('custom_mysql');
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :获取当前月数据统计
* @name :currentMonth
* @author :lyh
* @method :post
* @time :2023/7/3 9:55
*/
public function currentMonthCount($domain,$project_id){
// 获取当前月的开始时间
$startTime = date('Y-m-01', strtotime($this->param['date']));
// 获取当前月的结束时间
$endTime = date('Y-m-t', strtotime($this->param['date']));
$arr = [];
$arr = $this->inquiryCount($arr,$startTime,$endTime,$domain);
$arr = $this->flowCount($arr,$startTime,$endTime,$project_id);
$arr = $this->sourceCount($arr,$startTime,$endTime,$domain);
$arr['month'] = date('Y-m',time());
return $arr;
}
/**
* @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);
if(!empty($inquiry_list)){
//总数
$arr['total'] = $inquiry_list['data']['total'] ?? 0;
//数据详情
$data = $inquiry_list['data']['data'] ?? '';
$arr['month_total'] = 0;
$countryArr = [];
if(isset($data) && !empty($data)){
foreach ($data as $v){
if(($startTime.' 00:00:00' <= $v['submit_time']) && $v['submit_time'] <= $endTime.' 23:59:59'){
$arr['month_total']++;
if(isset($countryArr[$v['country']])){
$countryArr[$v['country']]++;
}else{
$countryArr[$v['country']] = 1;
}
}
}
}
}
//加上其他询盘
$arr['total'] += InquiryFormData::getCount();
$arr['month_total'] += InquiryFormData::getCount([$startTime, $endTime]);
$countryData = InquiryFormData::getCountryCount([$startTime, $endTime]);
foreach ($countryData as $v1){
if(isset($countryArr[$v1['country']])){
$countryArr[$v1['country']] += $v1['count'];
}else{
$countryArr[$v1['country']] = $v1['count'];
}
}
arsort($countryArr);
$top20 = array_slice($countryArr, 0, 15, true);
$arr['country'] = $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])
->whereBetween('date', [$startTime,$endTime])
->select(DB::raw('SUM(pv_num) as pv_num'), DB::raw('SUM(ip_num) as ip_num'))
->orderBy('id','desc')
->first();
$arr['pv'] = $pv_ip->pv_num;
$arr['ip'] = $pv_ip->ip_num;
$arr['rate'] = 0;
if($arr['ip'] != 0){
$arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 100,2);
}
return $arr;
}
/**
* @remark :来源访问前8
* @name :sourceCount
* @author :lyh
* @method :post
* @time :2023/6/30 16:14
*/
public function sourceCount(&$arr,$startTime,$endTime,$domain){
//访问来源前10
$source = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('referrer_url', DB::raw('COUNT(*) as count'))
->groupBy('referrer_url')
->where('referrer_url','!=','')
->whereBetween('updated_date', [$startTime,$endTime])
->orderByDesc('count')->limit(10)->get()->toArray();
$arr['source'] = $source;
//访问国家前15
$query = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
->groupBy('country');
$query->where('country','<>','中国');
$source_country = $query->whereBetween('updated_date', [$startTime,$endTime])
->orderBy('ip','desc')->limit(15)->get()->toArray();
$arr['source_country'] = $source_country;
//受访界面前15
$referrer_url = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('url',DB::raw('COUNT(*) as num'))
->orderBy('num','desc')
->whereBetween('updated_date', [$startTime,$endTime])
->groupBy('url')
->limit(15)->get()->toArray();
$arr['referrer_url'] = $referrer_url;
//访问断后
$referrer_port = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('device_port',DB::raw('COUNT(*) as num'))
->orderBy('num','desc')
->whereBetween('updated_date', [$startTime,$endTime])
->groupBy('device_port')
->limit(15)->get()->toArray();
$arr['referrer_port'] = $referrer_port;
return $arr;
}
public function getApiList($projectInfo,$export = false)
{
$this->form_globalso_api = new FormGlobalsoApi();
if(isset($this->request['row'])){
$page_size = $this->request['row'];
}else{
$page_size = $export ? 1000 : 20;
}
$search = $this->request['search'] ?: '';
$page = $this->request['page'] ?: 1;
$domain = (!empty($projectInfo['deploy_optimize']['domain']) ? ((new DomainInfo())->getDomain($projectInfo['deploy_optimize']['domain'])) : '');
$list = $this->form_globalso_api->getInquiryList($domain, $search, $page, $page_size);
//处理格式 免得前端又改
$data = [
"list" => [],
"total" => 0,
"page" => $page,
"total_page" => 1,
"size" => $page_size
];
if (!empty($list['status']) && $list['status'] == 200) {
foreach ($list['data']['data'] as $item) {
$data['list'][] = $item;
}
$data['total'] = $list['data']['total'];
$data['total_page'] = $list['data']['last_page'];
}
return $data;
}
/**
* @remark :方案信息
* @name :plan_information
* @author :lyh
* @method :post
* @time :2024/3/7 17:00
*/
public function plan_information($projectInfo,$domain_info){
return [
'company' => $projectInfo['company'],
'domain' => $domain_info['domain'] ?? '',
'domain_info' => $domain_info['domain_info'] ?? '',
'cert_info' => $domain_info['cert_info'] ?? '',
'plan' => Project::planMap()[$projectInfo['deploy_build']['plan']],
'keyword_num' => $projectInfo['deploy_build']['keyword_num'],
'compliance_day' => $projectInfo['finish_remain_day'] ?? 0,
'start_time' => $projectInfo['deploy_optimize']['start_date'] ?? '',
'remain_day' => $projectInfo['deploy_build']['service_duration'] - ($projectInfo['finish_remain_day'] ?? 0),
];
}
/**
* @remark :排名数据
* @name :ce
* @author :lyh
* @method :post
* @time :2024/3/7 16:58
*/
public function first_total($external_links){
$rank = RankData::where('project_id', $this->param['project_id'])->first();
return [
'first_num' => $rank['first_num'] ?? 0,
'first_page_num' => $rank['first_page_num'] ?? 0,
'first_three_pages_num' => $rank['first_three_pages_num'] ?? 0,
'first_five_pages_num' => $rank['first_five_pages_num'] ?? 0,
'first_ten_pages_num' => $rank['first_ten_pages_num'] ?? 0,
'indexed_pages_num' => $rank['indexed_pages_num'] ?? 0,
'external_links_num' => $external_links['total'] ?? 0,
];
}
/**
* @remark :关键词排名分析图
* @name :ceshi
* @author :lyh
* @method :post
* @time :2024/3/7 17:39
*/
public function rank_chat(){
//关键词排名分析图
$rank_week = RankWeek::where('project_id', $this->param['project_id'])->first();
return [
'data' => $rank_week['data'] ?? [],
'labels' => $rank_week['date'] ?? [],
];
}
/**
* @remark :30天统计
* @name :count_30_total
* @author :lyh
* @method :post
* @time :2024/3/7 16:56
*/
public function count_30_total(){
$count_param = [
'date' => ['between',[now()->subDays(30)->startOfDay()->toDateString(),now()->startOfDay()->toDateString()]],
'project_id' => $this->param['project_id']
];
return (new Count())->list($count_param,'date',['id','pv_num','ip_num','date']);
}
/**
* @remark :pv_ip
* @name :visit_data
* @author :lyh
* @method :post
* @time :2024/3/7 16:53
*/
public function pv_ip($domain){
$pv = (new VisitItem())->count();
$ip = (new Visit())->count();
$inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
if(!empty($inquiry_list)){
$total = $inquiry_list['data']['total'] ?? 0;
}
return [
'total_pv'=>$pv,
'total_ip'=>$ip,
'conversion_rate' => (isset($total) && !empty($total) && ($ip != 0)) ? round(($total / $ip) * 10,2) : 0,
];
}
/**
* @name :(访问国家统计)access_country_count
* @author :lyh
* @method :post
* @time :2023/5/24 15:56
*/
public function access_country_count(){
$customerVisitModel = new Visit();
$data = $customerVisitModel->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
->groupBy('country')
->orderBy('ip','desc')->limit(11)->get()->toArray();
$result =array();
if(!empty($data)){
foreach ($data as $k => $v){
$v['pv'] = (int)$v['pv'];
$result[] = $v;
}
}
return $result;
}
public function keywords_rank_list($project_id,$projectInfo,$export = false)
{
$page = 1;
$lang = $this->request['lang'] ?: '';
$api_no = $projectInfo['deploy_optimize']['api_no'] ?? '';
$domain = (!empty($projectInfo['deploy_optimize']['domain']) ? ((new DomainInfo())->getDomain($projectInfo['deploy_optimize']['domain'])) : '');
$domain_arr = parse_url($domain);
$domain = $domain_arr['host'] ?? $domain_arr['path'];
//复制站点域名
$ext_projects = $this->getExtendProjects();
$flg_ext = $this->getExtFlag($ext_projects, $domain, $api_no);
$ext_domain = str_replace('www.', '', $this->getExtendProjects($api_no)['ext'] ?? '');
//AI站点域名
$ai_projects = $this->getAiProjects()['data'] ?? [];
$flg_ai = $this->getAiFlag($ai_projects, $domain);
$ai_domain = str_replace('www.', '', $this->getAiProjects($domain)['domain'] ?? '');
$list = RankData::where('project_id', $project_id)->where('lang', $lang)->value('data') ?: [];
$list30 = []; //排名前三十的
$list30_0 = []; //排名前三十且近三天没有排名的
$list100 = []; //排名前100的
$list0 = [];//排名为0的
foreach ($list as $key => $v) {
$last = Arr::last($v);
$data = [];
//处理日期
foreach ($v as $date => $position) {
$data[date('m-d', strtotime($date . '+ 1 day'))] = $position['position'];
}
//域名类型
$domain_text = '主域名:' . str_replace('www.', '', $domain);
if (!empty($last['r'])) {
$domain_text = 'AI域名:' . $last['r'];
if (in_array($flg_ext, [1, 2]) || $flg_ai == 1) {
if ($last['r'] == $ai_domain) {
$domain_text = '星链域名:' . $ai_domain;
} else if ($last['r'] == $ext_domain) {
$domain_text = '主域名2:' . $ext_domain;
} else {
$domain_text = 'AI域名:' . $last['r'];
}
}
}
$domain_arr = explode(':', $domain_text);
$v = [
'keyword' => $key,
'domain_type' => $domain_arr[0],
'domain' => $domain_arr[1],
'domain_text' => $domain_text,
'g' => $last['g'], //1核心关键词
'position' => $data,
];
//图片排名
if(isset($last['p_img'])){
$v['img_position'] = $last['p_img'];
}
//视频排名
if(isset($last['p_vid'])){
$v['video_position'] = $last['p_vid'];
}
if ($last['position'] == 0) {
$list0[] = $v;
} elseif ($last['position'] <= 30) {
if (($v['position'][date('m-d', strtotime('-1day'))] ?? '') == 0 ||
($v['position'][date('m-d', strtotime('-2day'))] ?? '') == 0) {
$list30_0[] = $v;
} else {
$list30[] = $v;
}
} else {
$list100[] = $v;
}
}
//排序 排名前30的 按关键词长短排序 最近三天无排名的排后; 后30名的按排名排序
$list30 = collect($list30)->sortBy(function ($item) {
return strlen($item['keyword']);
})->values()->all();
$list30_0 = collect($list30_0)->sortBy(function ($item) {
return strlen($item['keyword']);
})->values()->all();
$list100 = collect($list100)->sortBy(function ($item) {
return Arr::last($item['position']);
})->values()->all();
$list = collect($list30)->merge($list30_0)->merge($list100)->merge($list0)->filter(function ($item) {
//搜索
if ($this->request['search']) {
return strpos($item['keyword'], $this->request['search']) !== false;
}
//前几名
if ($this->request['first']) {
$position = Arr::last($item['position']);
return $position > 0 && $position <= $this->request['first'];
}
//核心词
if ($this->request['g']) {
return $item['g'] == $this->request['g'];
}
return true;
})->values();
if($export){
return $list->toArray();
}
$data = [
"list" => $list->forPage($page, 100)->toArray(),
"total" => $list->count(),
"page" => $page,
"total_page" => ceil($list->count() / 100),
"size" => 100
];
return $data;
}
/**
* 获取复制站点项目
* @author zbj
* @date 2023/5/12
*/
public function getExtendProjects($api_no = null)
{
$key = 'extend_projects_list';
$data = Cache::get($key);
if (!$data) {
$api_url = 'http://api.quanqiusou.cn/google-rank/api/extend_projects.php';
try {
$data = HttpUtils::get($api_url, []);
if ($data) {
$data = Arr::s2a($data);
Cache::put($key, $data, 4 * 3600);
}
} catch (\Exception | GuzzleException $e) {
errorLog('复制站点项目获取失败', [], $e);
return false;
}
}
if ($api_no !== null) {
$data = collect($data)->where('apino', $api_no)->first();
return $data ?: [];
}
return $data;
}
/**
* 获取AI站点项目
* @author zbj
* @date 2023/5/12
*/
public function getAiProjects($domain = null)
{
$key = 'ai_projects_list';
$data = Cache::get($key);
if (!$data) {
$api_url = 'https://demosite5.globalso.com/api/domain';
try {
$data = HttpUtils::get($api_url, []);
if ($data) {
$data = Arr::s2a($data);
Cache::put($key, $data, 4 * 3600);
}
} catch (\Exception | GuzzleException $e) {
errorLog('AI站点项目获取失败', [], $e);
return false;
}
}
if ($domain !== null) {
$domain = parse_url($domain);
$data = collect($data['data'])->where('bind_domain', $domain['host'] ?? $domain['path'])->first();
return $data ?: [];
}
return $data;
}
/**
* 获取复制项目标识
* @author zbj
* @date 2023/5/15
*/
protected function getExtFlag($ext_projects, $domain, $api_no)
{
//复制站点标识
$flg_ext = 0;
if ($ext_projects) {
$ext_urls = array_column($ext_projects, 'ext');
$api_nos = array_column($ext_projects, 'apino');
if (in_array($api_no, $api_nos)) {
$flg_ext = 1;
}
if (in_array($domain, $ext_urls)) {
$flg_ext = 2;
}
}
return $flg_ext;
}
/**
* 获取AI项目标识
* @author zbj
* @date 2023/5/15
*/
protected function getAiFlag($ai_projects, $domain)
{
$flg_ai = 0;
foreach ($ai_projects as $ai_project) {
if ($ai_project['bind_domain'] == $domain) {
$flg_ai = 1;
}
}
return $flg_ai;
}
}
... ...
... ... @@ -211,7 +211,7 @@ class OptimizeController extends BaseController
$query = $query->whereRaw("FIND_IN_SET(?, gl_project.level) > 0", [$this->map['level']]);
}
if(isset($this->map['online_updated_at']) && !empty($this->map['online_updated_at']) && is_array($this->map['online_updated_at'])){
$query = $query->whereBetween('gl_project_deploy_optimize.start_date', $this->map['online_updated_at']);
$query = $query->where('gl_project_deploy_optimize.start_date','>=' ,$this->map['online_updated_at'][0])->where('gl_project_deploy_optimize.start_date','<' ,$this->map['online_updated_at'][1]);
}
if(isset($this->map['special'])){
$query = $query->whereRaw("FIND_IN_SET(?, gl_project_deploy_optimize.special) > 0", [$this->map['special']]);
... ...
... ... @@ -6,6 +6,7 @@ use App\Enums\Common\Code;
use App\Helper\Arr;
use App\Helper\Common;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Aside\Project\ProjectLogic;
use App\Http\Logic\Bside\User\UserLogic;
use App\Jobs\PurchaserJob;
use App\Models\Com\Purchaser;
... ... @@ -328,5 +329,4 @@ class ComController extends BaseController
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -29,7 +29,7 @@ class WebSettingReceivingController extends BaseController
* @time :2023/5/8 16:23
*/
public function save(WebSettingReceivingLogic $webSettingReceivingLogic){
$webSettingReceivingLogic->setting_receiving_save();
$this->response('success');
$result = $webSettingReceivingLogic->setting_receiving_save();
$this->response('success',Code::SUCCESS,$result);
}
}
... ...
... ... @@ -39,6 +39,8 @@ class SuppliersController extends BaseController
foreach ($lists as $v){
$resultData = json_decode($v['data']);
foreach ($resultData as $value){
$value = (array)$value;
$value['keyword'] = $v['keyword'];
$data[] = $value;
}
}
... ... @@ -59,7 +61,13 @@ class SuppliersController extends BaseController
$token = $action_name. '+' .date('Y-m-d'). '+' .http_build_query($param);
$param['token'] = md5($token);
$res = http_post($url,json_encode($param));
return $this->success($res);
if(isset($res['code']) && $res['code'] != 200){
$this->response($res['message'],Code::SYSTEM_ERROR);
}
if(isset($res['status_code']) && $res['status_code'] != 200){
$this->response($res['message'],Code::SYSTEM_ERROR);
}
return $this->success($res['data']);
}
/**
* @remark :按名字搜索公司
... ... @@ -74,7 +82,7 @@ class SuppliersController extends BaseController
$param = [
'search'=>$this->param['search'],
];
$res = $this->_action($api_url,$action_name,$param);
$res = $this->_action($api_url,$action_name,$param ?? []);
$this->response('success',Code::SUCCESS,$res);
}
... ... @@ -107,11 +115,15 @@ class SuppliersController extends BaseController
$action_name = 'company_linked';
$param = [
'domain'=>$this->param['domain'],
'keyword'=>$this->param['keyword'],
'position'=>$this->param['position'],
'page'=>$this->page,
'page_size'=>$this->row,
];
if(isset($this->param['keyword'])){
$param['keyword'] = $this->param['keyword'];
}
if(isset($this->param['position'])){
$param['position'] = $this->param['position'];
}
$res = $this->_action($api_url,$action_name,$param);
$this->response('success',Code::SUCCESS,$res);
}
... ... @@ -127,7 +139,7 @@ class SuppliersController extends BaseController
$api_url = 'api/trade_trend';
$action_name = 'trade_trend';
$param = [
'prod_desc'=>$this->param['prod_desc'],
'prod_desc'=>$this->param['prod_desc'] ?? '',
];
$res = $this->_action($api_url,$action_name,$param);
$this->response('success',Code::SUCCESS,$res);
... ... @@ -144,10 +156,14 @@ class SuppliersController extends BaseController
$api_url = 'api/supplier_area';
$action_name = 'supplier_area';
$param = [
'prod_desc'=>$this->param['prod_desc'],
'start_date'=>$this->param['start_date'],
'end_date'=>$this->param['end_date'],
'prod_desc'=>$this->param['prod_desc'] ?? '',
];
if(isset($this->param['start_date'] )){
$param['start_date'] = $this->param['start_date'] ?? '';
}
if(isset($this->param['end_date'] )){
$param['end_date'] = $this->param['end_date'] ?? '';
}
$res = $this->_action($api_url,$action_name,$param);
$this->response('success',Code::SUCCESS,$res);
}
... ... @@ -163,9 +179,11 @@ class SuppliersController extends BaseController
$api_url = 'api/trade_partner';
$action_name = 'trade_partner';
$param = [
'com_id'=>$this->param['com_id'],
'com_role'=>$this->param['com_role'],
'com_id'=>$this->param['com_id'] ?? '',
];
if(isset($this->param['com_role'] )){
$param['com_role'] = $this->param['com_role'] ?? '';
}
$res = $this->_action($api_url,$action_name,$param);
$this->response('success',Code::SUCCESS,$res);
}
... ... @@ -181,7 +199,7 @@ class SuppliersController extends BaseController
$api_url = 'api/trade_detail';
$action_name = 'trade_detail';
$param = [
'prod_desc'=>$this->param['prod_desc'],
'prod_desc'=>$this->param['prod_desc'] ?? '',
];
$res = $this->_action($api_url,$action_name,$param);
$this->response('success',Code::SUCCESS,$res);
... ... @@ -198,7 +216,7 @@ class SuppliersController extends BaseController
$api_url = 'api/bill_detail';
$action_name = 'bill_detail';
$param = [
'prod_desc'=>$this->param['prod_desc'],
'prod_desc'=>$this->param['prod_desc'] ?? '',
'page'=>$this->page,
'page_size'=>$this->row,
];
... ... @@ -217,8 +235,8 @@ class SuppliersController extends BaseController
$api_url = 'api/import_product';
$action_name = 'import_product';
$param = [
'com_id'=>$this->param['com_id'],
'com_role'=>$this->param['com_role'],
'com_id'=>$this->param['com_id'] ?? '',
'com_role'=>$this->param['com_role'] ?? '',
];
$res = $this->_action($api_url,$action_name,$param);
$this->response('success',Code::SUCCESS,$res);
... ...
... ... @@ -58,7 +58,7 @@ class InquiryLogic extends BaseLogic
$data['total'] = $list['data']['total'];
$data['total_page'] = $list['data']['last_page'];
}
return $this->success($data);
return $data;
}
public function getOtherList($export = false){
... ...
... ... @@ -83,10 +83,28 @@ class TranslateLogic extends BaseLogic
}
}
$data = $this->unique_multidimensional_array($data);
return $this->success($data);
}
/**
* @remark :多维数组去重
* @name :unique_multidimensional_array
* @author :lyh
* @method :post
* @time :2024/3/8 16:38
*/
public function unique_multidimensional_array($array) {
// 将多维数组转换为字符串并进行去重
$uniqueArray = array_map('json_encode', $array);
// 去除重复项
$uniqueArray = array_unique($uniqueArray);
// 将字符串转换回多维数组
$uniqueArray = array_map('json_decode', $uniqueArray);
return $uniqueArray;
}
/**
* @remark :获取图片列表
* @name :imageList
* @author :lyh
... ...
... ... @@ -6,6 +6,7 @@ use App\Http\Logic\Bside\BaseLogic;
use App\Models\WebSetting\WebSettingReceiving;
use App\Models\WebSetting\WebSettingText;
use App\Services\SyncService;
use Illuminate\Support\Facades\DB;
class WebSettingReceivingLogic extends BaseLogic
{
... ... @@ -34,24 +35,37 @@ class WebSettingReceivingLogic extends BaseLogic
* @time :2023/5/8 16:26
*/
public function setting_receiving_save(){
$data = [];
foreach ($this->param['data'] as $v){
if($v['type'] == 1){
// 使用正则表达式匹配中国大陆手机号
$pattern = '/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/';
if (!preg_match($pattern, $v['values'])) {
$this->fail('当前数据不符合规则:'.$v['values']);
}
}
if($v['type'] == 2){
// 使用正则表达式匹配中国大陆手机号
$pattern = '/^1[3456789]\d{9}$/';
if (!preg_match($pattern, $v['values'])) {
$this->fail('当前数据不符合规则:'.$v['values']);
}
}
$v['project_id'] = $this->user['project_id'];
$v['created_at'] = date('Y-m-d H:i:s');
$v['updated_at'] = date('Y-m-d H:i:s');
$data[] = $v;
}
DB::connection('custom_mysql')->beginTransaction();
try {
$this->model->del(['project_id'=>$this->user['project_id']]);
foreach ($this->param['data'] as $k => $v){
if($v['type'] == 2){
// 使用正则表达式匹配中国大陆手机号
$pattern = '/^1[3456789]\d{9}$/';
if (!preg_match($pattern, $v['values'])) {
continue;
}
}
$v['project_id'] = $this->user['project_id'];
$v['created_at'] = date('Y-m-d H:i:s');
$v['updated_at'] = date('Y-m-d H:i:s');
$this->param['data'][$k] = $v;
if(!empty($data)){
$this->model->insert($data);
}
$this->model->insert($this->param['data']);
DB::connection('custom_mysql')->commit();
}catch (\Exception $e){
$this->fail('error');
DB::connection('custom_mysql')->rollBack();
$this->fail('编辑失败,请联系管理员');
}
(new SyncService())->projectAcceptAddress($this->user['project_id']);
return $this->success();
... ...
... ... @@ -37,14 +37,14 @@ class WebSettingServiceLogic extends BaseLogic
* @time :2023/5/4 11:10
*/
public function setting_service_save(){
DB::beginTransaction();
DB::connection('custom_mysql')->beginTransaction();
try {
$this->param['data'] = Common::uniqueMultiArray($this->param['data']);
//删除以前的数据
$this->model->del(['project_id'=>$this->user['project_id']]);
$data = [];
foreach ($this->param['data'] as $k => $v){
if(isset($v['values']) && empty($v['values'])){
if(isset($v['values']) && !empty($v['values'])){
$v['project_id'] = $this->user['project_id'];
$v['created_at'] = date('Y-m-d H:i:s');
$v['updated_at'] = date('Y-m-d H:i:s');
... ... @@ -54,10 +54,9 @@ class WebSettingServiceLogic extends BaseLogic
if(!empty($data)){
$this->model->insert($data);
}
DB::commit();
DB::connection('custom_mysql')->commit();
}catch (\Exception $e){
DB::rollBack();
DB::connection('custom_mysql')->rollBack();
$this->fail('系统错误,请联系管理员');
}
return $this->success();
... ...
... ... @@ -30,10 +30,10 @@ class KeywordRequest extends FormRequest
public function rules()
{
return [
'title'=>'required|max:50',
'seo_title'=>'max:200',
'seo_keywords'=>'max:200',
'seo_description'=>'max:200',
'title'=>'required|max:200',
'seo_title'=>'max:255',
'seo_keywords'=>'max:500',
'seo_description'=>'max:500',
'related_news_ids'=>'array|max:2',
'related_blog_ids'=>'array|max:2',
];
... ... @@ -43,10 +43,10 @@ class KeywordRequest extends FormRequest
{
return [
'title.required' => '请输入关键词',
'title.max' => '关键词不能超过50个字符',
'seo_title.max' => 'SEO标题不能超过200个字符',
'seo_keywords.max' => 'SEO关键词不能超过200个字符',
'seo_description.max' => 'SEO描述不能超过200个字符',
'title.max' => '关键词不能超过200个字符',
'seo_title.max' => 'SEO标题不能超过255个字符',
'seo_keywords.max' => 'SEO关键词不能超过500个字符',
'seo_description.max' => 'SEO描述不能超过500个字符',
'related_news_ids.max' => '关联新闻不能超过两条',
'related_blog_ids.max' => '关联博客不能超过两条',
];
... ...
... ... @@ -23,5 +23,5 @@ Route::get('optimize_project_list', [\App\Http\Controllers\Api\PrivateController
Route::get('get_project_route', [\App\Http\Controllers\Api\PrivateController::class, 'getProjectRoute'])->name('api.get_project_route');
Route::any('get_product_images', [\App\Http\Controllers\Api\ProductController::class, 'getImages'])->name('api.get_product_images');
Route::post('inquiry_submit', [\App\Http\Controllers\Api\InquiryController::class, 'submit'])->name('api.inquiry_submit');
Route::post('video_task_callback', [\App\Http\Controllers\Api\NoticeController::class, 'videoTaskCallback'])->name('api.video_task_callback');
\ No newline at end of file
Route::any('getOptimizationReport', [\App\Http\Controllers\Api\OptimizationReportController::class, 'getOptimizationReport'])->name('api.getOptimizationReport');
Route::post('video_task_callback', [\App\Http\Controllers\Api\NoticeController::class, 'videoTaskCallback'])->name('api.video_task_callback');
... ...