Merge remote-tracking branch 'origin/master' into akun
正在显示
15 个修改的文件
包含
709 行增加
和
49 行删除
| @@ -107,7 +107,9 @@ class VideoTask extends Command | @@ -107,7 +107,9 @@ class VideoTask extends Command | ||
| 107 | 'project_id' => $task_project->project_id, | 107 | 'project_id' => $task_project->project_id, |
| 108 | 'keyword_id' => $val->id, | 108 | 'keyword_id' => $val->id, |
| 109 | 'keyword' => $val->title, | 109 | 'keyword' => $val->title, |
| 110 | - 'data' => json_encode(['url' => $keywordInfo['url'],'title' => $keywordInfo['title'], 'description' => $keywordInfo['keyword_content'], 'images' => $keywordInfo['product_list'], 'keywords' => $keywordInfo['keyword_list']]), | 110 | + 'data' => json_encode(['url' => $keywordInfo['url'],'title' => $keywordInfo['title'], |
| 111 | + 'description' => $keywordInfo['keyword_content'], 'images' => $keywordInfo['product_list'], | ||
| 112 | + 'keywords' => $keywordInfo['keyword_list']]), | ||
| 111 | 'status' => KeywordVideoTaskLog::STATUS_INIT, | 113 | 'status' => KeywordVideoTaskLog::STATUS_INIT, |
| 112 | 'updated_at' => date('Y-m-d H:i:s'), | 114 | 'updated_at' => date('Y-m-d H:i:s'), |
| 113 | 'created_at' => date('Y-m-d H:i:s'), | 115 | 'created_at' => date('Y-m-d H:i:s'), |
| @@ -226,7 +228,8 @@ class VideoTask extends Command | @@ -226,7 +228,8 @@ class VideoTask extends Command | ||
| 226 | } | 228 | } |
| 227 | }else{ | 229 | }else{ |
| 228 | $product_all_id = Product::where("project_id", $project_id)->where("status",Product::STATUS_ON)->pluck('id')->toArray(); | 230 | $product_all_id = Product::where("project_id", $project_id)->where("status",Product::STATUS_ON)->pluck('id')->toArray(); |
| 229 | - $product_id = array_rand($product_all_id, 40); | 231 | + $number = 40; |
| 232 | + $product_id = array_rand($product_all_id, min(count($product_all_id, $number-count($productIds)))); | ||
| 230 | $products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get(); | 233 | $products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get(); |
| 231 | } | 234 | } |
| 232 | } | 235 | } |
| @@ -239,6 +242,12 @@ class VideoTask extends Command | @@ -239,6 +242,12 @@ class VideoTask extends Command | ||
| 239 | if(count($data) > 13){ | 242 | if(count($data) > 13){ |
| 240 | break; | 243 | break; |
| 241 | } | 244 | } |
| 245 | + if (strpos($item->keyword_id, ','.$productKeyword->id.',') === false) { | ||
| 246 | + //不包含 | ||
| 247 | + $productModel = new Product(); | ||
| 248 | + $keyword_id = $item->keyword_id . $productKeyword->id.','; | ||
| 249 | + $productModel->edit(['keyword_id'=>$keyword_id],['id'=>$item->id]); | ||
| 250 | + } | ||
| 242 | $data[] = ['url'=>getImageUrl($item->thumb['url']),'title'=>$item->title]; | 251 | $data[] = ['url'=>getImageUrl($item->thumb['url']),'title'=>$item->title]; |
| 243 | } | 252 | } |
| 244 | } | 253 | } |
| @@ -48,11 +48,11 @@ class RankData extends BaseCommands | @@ -48,11 +48,11 @@ class RankData extends BaseCommands | ||
| 48 | 48 | ||
| 49 | Log::channel('rank_data')->info('开始-排名数据'); | 49 | Log::channel('rank_data')->info('开始-排名数据'); |
| 50 | //同步api_no | 50 | //同步api_no |
| 51 | - try { | ||
| 52 | - $this->SyncApiNo(); | ||
| 53 | - } catch (\Exception $e) { | ||
| 54 | - Log::channel('rank_data')->error('同步api_no失败:' . $e->getMessage()); | ||
| 55 | - } | 51 | +// try { |
| 52 | +// $this->SyncApiNo(); | ||
| 53 | +// } catch (\Exception $e) { | ||
| 54 | +// Log::channel('rank_data')->error('同步api_no失败:' . $e->getMessage()); | ||
| 55 | +// } | ||
| 56 | 56 | ||
| 57 | 57 | ||
| 58 | //所有项目 今日是否达标 重置 | 58 | //所有项目 今日是否达标 重置 |
| @@ -70,7 +70,7 @@ class RankData extends BaseCommands | @@ -70,7 +70,7 @@ class RankData extends BaseCommands | ||
| 70 | //当日所有站点谷歌收录数据 | 70 | //当日所有站点谷歌收录数据 |
| 71 | $site_res = $api->getSiteRes(); | 71 | $site_res = $api->getSiteRes(); |
| 72 | if (!$site_res) { | 72 | if (!$site_res) { |
| 73 | - return false; | 73 | + Log::channel('rank_data')->error('谷歌收录数据获取失败'); |
| 74 | } | 74 | } |
| 75 | foreach ($list as $item) { | 75 | foreach ($list as $item) { |
| 76 | echo $item['api_no'] . PHP_EOL; | 76 | echo $item['api_no'] . PHP_EOL; |
| @@ -55,7 +55,7 @@ class UpdateRoute extends Command | @@ -55,7 +55,7 @@ class UpdateRoute extends Command | ||
| 55 | */ | 55 | */ |
| 56 | public function handle(){ | 56 | public function handle(){ |
| 57 | $projectModel = new Project(); | 57 | $projectModel = new Project(); |
| 58 | - $list = $projectModel->list(['id'=>206]); | 58 | + $list = $projectModel->list(['id'=>969]); |
| 59 | $data = []; | 59 | $data = []; |
| 60 | foreach ($list as $v){ | 60 | foreach ($list as $v){ |
| 61 | echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; | 61 | echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; |
| @@ -11,6 +11,8 @@ use App\Enums\Common\Code; | @@ -11,6 +11,8 @@ use App\Enums\Common\Code; | ||
| 11 | use App\Http\Controllers\Controller; | 11 | use App\Http\Controllers\Controller; |
| 12 | use Illuminate\Http\Exceptions\HttpResponseException; | 12 | use Illuminate\Http\Exceptions\HttpResponseException; |
| 13 | use Illuminate\Http\JsonResponse; | 13 | use Illuminate\Http\JsonResponse; |
| 14 | +use Illuminate\Http\Request; | ||
| 15 | +use Illuminate\Support\Facades\Cache; | ||
| 14 | 16 | ||
| 15 | /** | 17 | /** |
| 16 | * Class BaseController | 18 | * Class BaseController |
| @@ -18,6 +20,12 @@ use Illuminate\Http\JsonResponse; | @@ -18,6 +20,12 @@ use Illuminate\Http\JsonResponse; | ||
| 18 | */ | 20 | */ |
| 19 | class BaseController extends Controller | 21 | class BaseController extends Controller |
| 20 | { | 22 | { |
| 23 | + public $param; | ||
| 24 | + public function __construct(Request $request) | ||
| 25 | + { | ||
| 26 | + $this->request = $request; | ||
| 27 | + $this->param = $this->request->all(); | ||
| 28 | + } | ||
| 21 | /** | 29 | /** |
| 22 | * @param array $data | 30 | * @param array $data |
| 23 | * @param string $message | 31 | * @param string $message |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :OptimizationReportController.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2024/3/7 15:57 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Controllers\Api; | ||
| 11 | + | ||
| 12 | +use App\Enums\Common\Code; | ||
| 13 | +use App\Helper\Arr; | ||
| 14 | +use App\Helper\FormGlobalsoApi; | ||
| 15 | +use App\Models\Domain\DomainInfo; | ||
| 16 | +use App\Models\HomeCount\Count; | ||
| 17 | +use App\Models\Inquiry\InquiryFormData; | ||
| 18 | +use App\Models\Project\Project; | ||
| 19 | +use App\Models\RankData\ExternalLinks; | ||
| 20 | +use App\Models\RankData\IndexedPages; | ||
| 21 | +use App\Models\RankData\RankData; | ||
| 22 | +use App\Models\RankData\RankWeek; | ||
| 23 | +use App\Models\RankData\Speed; | ||
| 24 | +use App\Models\Visit\Visit; | ||
| 25 | +use App\Models\Visit\VisitItem; | ||
| 26 | +use App\Services\ProjectServer; | ||
| 27 | +use App\Utils\HttpUtils; | ||
| 28 | +use GuzzleHttp\Exception\GuzzleException; | ||
| 29 | +use Illuminate\Support\Facades\Cache; | ||
| 30 | +use Illuminate\Support\Facades\DB; | ||
| 31 | + | ||
| 32 | +class OptimizationReportController extends BaseController | ||
| 33 | +{ | ||
| 34 | + /** | ||
| 35 | + * @remark :优化报告 | ||
| 36 | + * @name :getOptimizationReport | ||
| 37 | + * @author :lyh | ||
| 38 | + * @method :post | ||
| 39 | + * @time :2024/3/7 15:54 | ||
| 40 | + */ | ||
| 41 | + public function getOptimizationReport(){ | ||
| 42 | + $this->request->validate([ | ||
| 43 | + 'project_id' => 'required', | ||
| 44 | + 'date'=>'required', | ||
| 45 | + ], [ | ||
| 46 | + 'project_id.required' => '项目id不能为空', | ||
| 47 | + 'date.required' => '时间不能为空', | ||
| 48 | + ]); | ||
| 49 | + ProjectServer::useProject($this->param['project_id']); | ||
| 50 | + $data = []; | ||
| 51 | + $projectModel = new Project(); | ||
| 52 | + $projectInfo = $projectModel->with('payment')->with('deploy_build') | ||
| 53 | + ->with('deploy_optimize')->with('online_check')->where(['id'=>$this->param['project_id']])->first(); | ||
| 54 | + $domainModel = new DomainInfo(); | ||
| 55 | + $domain_info = $domainModel->where('project_id', $this->param['project_id'])->first(); | ||
| 56 | + if(!$domain_info){ | ||
| 57 | + return []; | ||
| 58 | + }else{ | ||
| 59 | + $domain_info = [ | ||
| 60 | + 'domain' => 'https://'.$domain_info['domain'].'/', | ||
| 61 | + 'domain_info' => date('Y-m-d', strtotime($domain_info['domain_start_time'])) . ' - ' .date('Y-m-d', strtotime($domain_info['domain_end_time'])), | ||
| 62 | + 'cert_info' => date('Y-m-d', strtotime($domain_info['certificate_start_time'])) . ' - ' .date('Y-m-d', strtotime($domain_info['certificate_end_time'])), | ||
| 63 | + ]; | ||
| 64 | + } | ||
| 65 | + //外链周期分析 | ||
| 66 | + $external_links = ExternalLinks::where('project_id', $this->param['project_id'])->first(); | ||
| 67 | + $data['domain'] = $domain_info; | ||
| 68 | + //方案信息 | ||
| 69 | + $data['plan_information'] = $this->plan_information($projectInfo,$domain_info); | ||
| 70 | + //排名数据 | ||
| 71 | + $data['first_total'] = $this->first_total($external_links); | ||
| 72 | + //关键词排名分析图 | ||
| 73 | + $data['rank_chat'] = $this->rank_chat(); | ||
| 74 | + //关键词排名明细 | ||
| 75 | + $data['keywords_rank_list'] = $this->keywords_rank_list($this->param['project_id'],$projectInfo); | ||
| 76 | + //pv_ip统计 | ||
| 77 | + $data['pv_ip'] = $this->pv_ip($domain_info['domain']); | ||
| 78 | + //30天统计 | ||
| 79 | + $data['count_30'] = $this->count_30_total(); | ||
| 80 | + //访问国家前10 | ||
| 81 | + $data['access_country_count'] = $this->access_country_count(); | ||
| 82 | + | ||
| 83 | + //SEO数据周期分析图 外链数 | ||
| 84 | + $data['external_links_chat'] = [ | ||
| 85 | + 'labels' => array_keys($external_links['data'] ?? []), | ||
| 86 | + 'data' => array_values($external_links['data'] ?? []), | ||
| 87 | + ]; | ||
| 88 | + $indexed_pages = IndexedPages::where('project_id', $this->param['project_id'])->first(); | ||
| 89 | + //SEO数据周期分析图 收录数 | ||
| 90 | + $data['indexed_pages_chat'] = [ | ||
| 91 | + 'labels' => array_keys($indexed_pages['data'] ?? []), | ||
| 92 | + 'data' => array_values($indexed_pages['data'] ?? []), | ||
| 93 | + ]; | ||
| 94 | + //月统计报告 | ||
| 95 | + $data['month_count'] = $this->currentMonthCount($domain_info['domain'],$this->param['project_id']); | ||
| 96 | + //测速 | ||
| 97 | + $speed = Speed::where('project_id', $this->param['project_id'])->first(); | ||
| 98 | + $data['speed'] = $speed['data'] ?? []; | ||
| 99 | + //询盘 | ||
| 100 | + $data['inquiry'] = $this->getApiList($projectInfo); | ||
| 101 | + DB::disconnect('custom_mysql'); | ||
| 102 | + $this->response('success',Code::SUCCESS,$data); | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + /** | ||
| 106 | + * @remark :获取当前月数据统计 | ||
| 107 | + * @name :currentMonth | ||
| 108 | + * @author :lyh | ||
| 109 | + * @method :post | ||
| 110 | + * @time :2023/7/3 9:55 | ||
| 111 | + */ | ||
| 112 | + public function currentMonthCount($domain,$project_id){ | ||
| 113 | + // 获取当前月的开始时间 | ||
| 114 | + $startTime = date('Y-m-01', strtotime($this->param['date'])); | ||
| 115 | + // 获取当前月的结束时间 | ||
| 116 | + $endTime = date('Y-m-t', strtotime($this->param['date'])); | ||
| 117 | + $arr = []; | ||
| 118 | + $arr = $this->inquiryCount($arr,$startTime,$endTime,$domain); | ||
| 119 | + $arr = $this->flowCount($arr,$startTime,$endTime,$project_id); | ||
| 120 | + $arr = $this->sourceCount($arr,$startTime,$endTime,$domain); | ||
| 121 | + $arr['month'] = date('Y-m',time()); | ||
| 122 | + return $arr; | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + /** | ||
| 126 | + * @param $domain | ||
| 127 | + * @param $project_id | ||
| 128 | + * @remark :询盘按月统计 | ||
| 129 | + * @name :inquiryCount | ||
| 130 | + * @author :lyh | ||
| 131 | + * @method :post | ||
| 132 | + * @time :2023/6/30 14:29 | ||
| 133 | + */ | ||
| 134 | + public function inquiryCount(&$arr,&$startTime,&$endTime,$domain){ | ||
| 135 | + $inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000); | ||
| 136 | + if(!empty($inquiry_list)){ | ||
| 137 | + //总数 | ||
| 138 | + $arr['total'] = $inquiry_list['data']['total'] ?? 0; | ||
| 139 | + //数据详情 | ||
| 140 | + $data = $inquiry_list['data']['data'] ?? ''; | ||
| 141 | + $arr['month_total'] = 0; | ||
| 142 | + $countryArr = []; | ||
| 143 | + if(isset($data) && !empty($data)){ | ||
| 144 | + foreach ($data as $v){ | ||
| 145 | + if(($startTime.' 00:00:00' <= $v['submit_time']) && $v['submit_time'] <= $endTime.' 23:59:59'){ | ||
| 146 | + $arr['month_total']++; | ||
| 147 | + if(isset($countryArr[$v['country']])){ | ||
| 148 | + $countryArr[$v['country']]++; | ||
| 149 | + }else{ | ||
| 150 | + $countryArr[$v['country']] = 1; | ||
| 151 | + } | ||
| 152 | + } | ||
| 153 | + } | ||
| 154 | + } | ||
| 155 | + } | ||
| 156 | + //加上其他询盘 | ||
| 157 | + $arr['total'] += InquiryFormData::getCount(); | ||
| 158 | + $arr['month_total'] += InquiryFormData::getCount([$startTime, $endTime]); | ||
| 159 | + $countryData = InquiryFormData::getCountryCount([$startTime, $endTime]); | ||
| 160 | + foreach ($countryData as $v1){ | ||
| 161 | + if(isset($countryArr[$v1['country']])){ | ||
| 162 | + $countryArr[$v1['country']] += $v1['count']; | ||
| 163 | + }else{ | ||
| 164 | + $countryArr[$v1['country']] = $v1['count']; | ||
| 165 | + } | ||
| 166 | + } | ||
| 167 | + arsort($countryArr); | ||
| 168 | + $top20 = array_slice($countryArr, 0, 15, true); | ||
| 169 | + $arr['country'] = $top20; | ||
| 170 | + return $arr; | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + /** | ||
| 174 | + * @remark :流量统计 | ||
| 175 | + * @name :flowCount | ||
| 176 | + * @author :lyh | ||
| 177 | + * @method :post | ||
| 178 | + * @time :2023/6/30 14:31 | ||
| 179 | + */ | ||
| 180 | + public function flowCount(&$arr,&$startTime,&$endTime,$project_id){ | ||
| 181 | + $pv_ip = DB::table('gl_count') | ||
| 182 | + ->where(['project_id'=>$project_id]) | ||
| 183 | + ->whereBetween('date', [$startTime,$endTime]) | ||
| 184 | + ->select(DB::raw('SUM(pv_num) as pv_num'), DB::raw('SUM(ip_num) as ip_num')) | ||
| 185 | + ->orderBy('id','desc') | ||
| 186 | + ->first(); | ||
| 187 | + $arr['pv'] = $pv_ip->pv_num; | ||
| 188 | + $arr['ip'] = $pv_ip->ip_num; | ||
| 189 | + $arr['rate'] = 0; | ||
| 190 | + if($arr['ip'] != 0){ | ||
| 191 | + $arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 100,2); | ||
| 192 | + } | ||
| 193 | + return $arr; | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + /** | ||
| 197 | + * @remark :来源访问前8 | ||
| 198 | + * @name :sourceCount | ||
| 199 | + * @author :lyh | ||
| 200 | + * @method :post | ||
| 201 | + * @time :2023/6/30 16:14 | ||
| 202 | + */ | ||
| 203 | + public function sourceCount(&$arr,$startTime,$endTime,$domain){ | ||
| 204 | + //访问来源前10 | ||
| 205 | + $source = DB::connection('custom_mysql')->table('gl_customer_visit') | ||
| 206 | + ->select('referrer_url', DB::raw('COUNT(*) as count')) | ||
| 207 | + ->groupBy('referrer_url') | ||
| 208 | + ->where('referrer_url','!=','') | ||
| 209 | + ->whereBetween('updated_date', [$startTime,$endTime]) | ||
| 210 | + ->orderByDesc('count')->limit(10)->get()->toArray(); | ||
| 211 | + $arr['source'] = $source; | ||
| 212 | + //访问国家前15 | ||
| 213 | + $query = DB::connection('custom_mysql')->table('gl_customer_visit') | ||
| 214 | + ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv')) | ||
| 215 | + ->groupBy('country'); | ||
| 216 | + | ||
| 217 | + $query->where('country','<>','中国'); | ||
| 218 | + | ||
| 219 | + $source_country = $query->whereBetween('updated_date', [$startTime,$endTime]) | ||
| 220 | + ->orderBy('ip','desc')->limit(15)->get()->toArray(); | ||
| 221 | + $arr['source_country'] = $source_country; | ||
| 222 | + //受访界面前15 | ||
| 223 | + $referrer_url = DB::connection('custom_mysql')->table('gl_customer_visit') | ||
| 224 | + ->select('url',DB::raw('COUNT(*) as num')) | ||
| 225 | + ->orderBy('num','desc') | ||
| 226 | + ->whereBetween('updated_date', [$startTime,$endTime]) | ||
| 227 | + ->groupBy('url') | ||
| 228 | + ->limit(15)->get()->toArray(); | ||
| 229 | + $arr['referrer_url'] = $referrer_url; | ||
| 230 | + //访问断后 | ||
| 231 | + $referrer_port = DB::connection('custom_mysql')->table('gl_customer_visit') | ||
| 232 | + ->select('device_port',DB::raw('COUNT(*) as num')) | ||
| 233 | + ->orderBy('num','desc') | ||
| 234 | + ->whereBetween('updated_date', [$startTime,$endTime]) | ||
| 235 | + ->groupBy('device_port') | ||
| 236 | + ->limit(15)->get()->toArray(); | ||
| 237 | + $arr['referrer_port'] = $referrer_port; | ||
| 238 | + return $arr; | ||
| 239 | + } | ||
| 240 | + | ||
| 241 | + public function getApiList($projectInfo,$export = false) | ||
| 242 | + { | ||
| 243 | + $this->form_globalso_api = new FormGlobalsoApi(); | ||
| 244 | + if(isset($this->request['row'])){ | ||
| 245 | + $page_size = $this->request['row']; | ||
| 246 | + }else{ | ||
| 247 | + $page_size = $export ? 1000 : 20; | ||
| 248 | + } | ||
| 249 | + $search = $this->request['search'] ?: ''; | ||
| 250 | + $page = $this->request['page'] ?: 1; | ||
| 251 | + $domain = (!empty($projectInfo['deploy_optimize']['domain']) ? ((new DomainInfo())->getDomain($projectInfo['deploy_optimize']['domain'])) : ''); | ||
| 252 | + $list = $this->form_globalso_api->getInquiryList($domain, $search, $page, $page_size); | ||
| 253 | + //处理格式 免得前端又改 | ||
| 254 | + $data = [ | ||
| 255 | + "list" => [], | ||
| 256 | + "total" => 0, | ||
| 257 | + "page" => $page, | ||
| 258 | + "total_page" => 1, | ||
| 259 | + "size" => $page_size | ||
| 260 | + ]; | ||
| 261 | + if (!empty($list['status']) && $list['status'] == 200) { | ||
| 262 | + foreach ($list['data']['data'] as $item) { | ||
| 263 | + $data['list'][] = $item; | ||
| 264 | + } | ||
| 265 | + $data['total'] = $list['data']['total']; | ||
| 266 | + $data['total_page'] = $list['data']['last_page']; | ||
| 267 | + } | ||
| 268 | + return $data; | ||
| 269 | + } | ||
| 270 | + | ||
| 271 | + /** | ||
| 272 | + * @remark :方案信息 | ||
| 273 | + * @name :plan_information | ||
| 274 | + * @author :lyh | ||
| 275 | + * @method :post | ||
| 276 | + * @time :2024/3/7 17:00 | ||
| 277 | + */ | ||
| 278 | + public function plan_information($projectInfo,$domain_info){ | ||
| 279 | + return [ | ||
| 280 | + 'company' => $projectInfo['company'], | ||
| 281 | + 'domain' => $domain_info['domain'] ?? '', | ||
| 282 | + 'domain_info' => $domain_info['domain_info'] ?? '', | ||
| 283 | + 'cert_info' => $domain_info['cert_info'] ?? '', | ||
| 284 | + 'plan' => Project::planMap()[$projectInfo['deploy_build']['plan']], | ||
| 285 | + 'keyword_num' => $projectInfo['deploy_build']['keyword_num'], | ||
| 286 | + 'compliance_day' => $projectInfo['finish_remain_day'] ?? 0, | ||
| 287 | + 'start_time' => $projectInfo['deploy_optimize']['start_date'] ?? '', | ||
| 288 | + 'remain_day' => $projectInfo['deploy_build']['service_duration'] - ($projectInfo['finish_remain_day'] ?? 0), | ||
| 289 | + ]; | ||
| 290 | + } | ||
| 291 | + | ||
| 292 | + /** | ||
| 293 | + * @remark :排名数据 | ||
| 294 | + * @name :ce | ||
| 295 | + * @author :lyh | ||
| 296 | + * @method :post | ||
| 297 | + * @time :2024/3/7 16:58 | ||
| 298 | + */ | ||
| 299 | + public function first_total($external_links){ | ||
| 300 | + $rank = RankData::where('project_id', $this->param['project_id'])->first(); | ||
| 301 | + return [ | ||
| 302 | + 'first_num' => $rank['first_num'] ?? 0, | ||
| 303 | + 'first_page_num' => $rank['first_page_num'] ?? 0, | ||
| 304 | + 'first_three_pages_num' => $rank['first_three_pages_num'] ?? 0, | ||
| 305 | + 'first_five_pages_num' => $rank['first_five_pages_num'] ?? 0, | ||
| 306 | + 'first_ten_pages_num' => $rank['first_ten_pages_num'] ?? 0, | ||
| 307 | + 'indexed_pages_num' => $rank['indexed_pages_num'] ?? 0, | ||
| 308 | + 'external_links_num' => $external_links['total'] ?? 0, | ||
| 309 | + ]; | ||
| 310 | + } | ||
| 311 | + | ||
| 312 | + /** | ||
| 313 | + * @remark :关键词排名分析图 | ||
| 314 | + * @name :ceshi | ||
| 315 | + * @author :lyh | ||
| 316 | + * @method :post | ||
| 317 | + * @time :2024/3/7 17:39 | ||
| 318 | + */ | ||
| 319 | + public function rank_chat(){ | ||
| 320 | + //关键词排名分析图 | ||
| 321 | + $rank_week = RankWeek::where('project_id', $this->param['project_id'])->first(); | ||
| 322 | + return [ | ||
| 323 | + 'data' => $rank_week['data'] ?? [], | ||
| 324 | + 'labels' => $rank_week['date'] ?? [], | ||
| 325 | + ]; | ||
| 326 | + } | ||
| 327 | + | ||
| 328 | + /** | ||
| 329 | + * @remark :30天统计 | ||
| 330 | + * @name :count_30_total | ||
| 331 | + * @author :lyh | ||
| 332 | + * @method :post | ||
| 333 | + * @time :2024/3/7 16:56 | ||
| 334 | + */ | ||
| 335 | + public function count_30_total(){ | ||
| 336 | + $count_param = [ | ||
| 337 | + 'date' => ['between',[now()->subDays(30)->startOfDay()->toDateString(),now()->startOfDay()->toDateString()]], | ||
| 338 | + 'project_id' => $this->param['project_id'] | ||
| 339 | + ]; | ||
| 340 | + return (new Count())->list($count_param,'date',['id','pv_num','ip_num','date']); | ||
| 341 | + } | ||
| 342 | + | ||
| 343 | + /** | ||
| 344 | + * @remark :pv_ip | ||
| 345 | + * @name :visit_data | ||
| 346 | + * @author :lyh | ||
| 347 | + * @method :post | ||
| 348 | + * @time :2024/3/7 16:53 | ||
| 349 | + */ | ||
| 350 | + public function pv_ip($domain){ | ||
| 351 | + $pv = (new VisitItem())->count(); | ||
| 352 | + $ip = (new Visit())->count(); | ||
| 353 | + $inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000); | ||
| 354 | + if(!empty($inquiry_list)){ | ||
| 355 | + $total = $inquiry_list['data']['total'] ?? 0; | ||
| 356 | + } | ||
| 357 | + return [ | ||
| 358 | + 'total_pv'=>$pv, | ||
| 359 | + 'total_ip'=>$ip, | ||
| 360 | + 'conversion_rate' => (isset($total) && !empty($total) && ($ip != 0)) ? round(($total / $ip) * 10,2) : 0, | ||
| 361 | + ]; | ||
| 362 | + } | ||
| 363 | + | ||
| 364 | + /** | ||
| 365 | + * @name :(访问国家统计)access_country_count | ||
| 366 | + * @author :lyh | ||
| 367 | + * @method :post | ||
| 368 | + * @time :2023/5/24 15:56 | ||
| 369 | + */ | ||
| 370 | + public function access_country_count(){ | ||
| 371 | + $customerVisitModel = new Visit(); | ||
| 372 | + $data = $customerVisitModel->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv')) | ||
| 373 | + ->groupBy('country') | ||
| 374 | + ->orderBy('ip','desc')->limit(11)->get()->toArray(); | ||
| 375 | + $result =array(); | ||
| 376 | + if(!empty($data)){ | ||
| 377 | + foreach ($data as $k => $v){ | ||
| 378 | + $v['pv'] = (int)$v['pv']; | ||
| 379 | + $result[] = $v; | ||
| 380 | + } | ||
| 381 | + } | ||
| 382 | + return $result; | ||
| 383 | + } | ||
| 384 | + | ||
| 385 | + public function keywords_rank_list($project_id,$projectInfo,$export = false) | ||
| 386 | + { | ||
| 387 | + $page = 1; | ||
| 388 | + $lang = $this->request['lang'] ?: ''; | ||
| 389 | + $api_no = $projectInfo['deploy_optimize']['api_no'] ?? ''; | ||
| 390 | + $domain = (!empty($projectInfo['deploy_optimize']['domain']) ? ((new DomainInfo())->getDomain($projectInfo['deploy_optimize']['domain'])) : ''); | ||
| 391 | + $domain_arr = parse_url($domain); | ||
| 392 | + $domain = $domain_arr['host'] ?? $domain_arr['path']; | ||
| 393 | + //复制站点域名 | ||
| 394 | + $ext_projects = $this->getExtendProjects(); | ||
| 395 | + $flg_ext = $this->getExtFlag($ext_projects, $domain, $api_no); | ||
| 396 | + $ext_domain = str_replace('www.', '', $this->getExtendProjects($api_no)['ext'] ?? ''); | ||
| 397 | + //AI站点域名 | ||
| 398 | + $ai_projects = $this->getAiProjects()['data'] ?? []; | ||
| 399 | + $flg_ai = $this->getAiFlag($ai_projects, $domain); | ||
| 400 | + $ai_domain = str_replace('www.', '', $this->getAiProjects($domain)['domain'] ?? ''); | ||
| 401 | + $list = RankData::where('project_id', $project_id)->where('lang', $lang)->value('data') ?: []; | ||
| 402 | + $list30 = []; //排名前三十的 | ||
| 403 | + $list30_0 = []; //排名前三十且近三天没有排名的 | ||
| 404 | + $list100 = []; //排名前100的 | ||
| 405 | + $list0 = [];//排名为0的 | ||
| 406 | + foreach ($list as $key => $v) { | ||
| 407 | + $last = Arr::last($v); | ||
| 408 | + $data = []; | ||
| 409 | + //处理日期 | ||
| 410 | + foreach ($v as $date => $position) { | ||
| 411 | + $data[date('m-d', strtotime($date . '+ 1 day'))] = $position['position']; | ||
| 412 | + } | ||
| 413 | + //域名类型 | ||
| 414 | + $domain_text = '主域名:' . str_replace('www.', '', $domain); | ||
| 415 | + if (!empty($last['r'])) { | ||
| 416 | + $domain_text = 'AI域名:' . $last['r']; | ||
| 417 | + if (in_array($flg_ext, [1, 2]) || $flg_ai == 1) { | ||
| 418 | + if ($last['r'] == $ai_domain) { | ||
| 419 | + $domain_text = '星链域名:' . $ai_domain; | ||
| 420 | + } else if ($last['r'] == $ext_domain) { | ||
| 421 | + $domain_text = '主域名2:' . $ext_domain; | ||
| 422 | + } else { | ||
| 423 | + $domain_text = 'AI域名:' . $last['r']; | ||
| 424 | + } | ||
| 425 | + } | ||
| 426 | + } | ||
| 427 | + $domain_arr = explode(':', $domain_text); | ||
| 428 | + $v = [ | ||
| 429 | + 'keyword' => $key, | ||
| 430 | + 'domain_type' => $domain_arr[0], | ||
| 431 | + 'domain' => $domain_arr[1], | ||
| 432 | + 'domain_text' => $domain_text, | ||
| 433 | + 'g' => $last['g'], //1核心关键词 | ||
| 434 | + 'position' => $data, | ||
| 435 | + ]; | ||
| 436 | + //图片排名 | ||
| 437 | + if(isset($last['p_img'])){ | ||
| 438 | + $v['img_position'] = $last['p_img']; | ||
| 439 | + } | ||
| 440 | + //视频排名 | ||
| 441 | + if(isset($last['p_vid'])){ | ||
| 442 | + $v['video_position'] = $last['p_vid']; | ||
| 443 | + } | ||
| 444 | + | ||
| 445 | + if ($last['position'] == 0) { | ||
| 446 | + $list0[] = $v; | ||
| 447 | + } elseif ($last['position'] <= 30) { | ||
| 448 | + if (($v['position'][date('m-d', strtotime('-1day'))] ?? '') == 0 || | ||
| 449 | + ($v['position'][date('m-d', strtotime('-2day'))] ?? '') == 0) { | ||
| 450 | + $list30_0[] = $v; | ||
| 451 | + } else { | ||
| 452 | + $list30[] = $v; | ||
| 453 | + } | ||
| 454 | + } else { | ||
| 455 | + $list100[] = $v; | ||
| 456 | + } | ||
| 457 | + } | ||
| 458 | + //排序 排名前30的 按关键词长短排序 最近三天无排名的排后; 后30名的按排名排序 | ||
| 459 | + $list30 = collect($list30)->sortBy(function ($item) { | ||
| 460 | + return strlen($item['keyword']); | ||
| 461 | + })->values()->all(); | ||
| 462 | + $list30_0 = collect($list30_0)->sortBy(function ($item) { | ||
| 463 | + return strlen($item['keyword']); | ||
| 464 | + })->values()->all(); | ||
| 465 | + $list100 = collect($list100)->sortBy(function ($item) { | ||
| 466 | + return Arr::last($item['position']); | ||
| 467 | + })->values()->all(); | ||
| 468 | + $list = collect($list30)->merge($list30_0)->merge($list100)->merge($list0)->filter(function ($item) { | ||
| 469 | + //搜索 | ||
| 470 | + if ($this->request['search']) { | ||
| 471 | + return strpos($item['keyword'], $this->request['search']) !== false; | ||
| 472 | + } | ||
| 473 | + //前几名 | ||
| 474 | + if ($this->request['first']) { | ||
| 475 | + $position = Arr::last($item['position']); | ||
| 476 | + return $position > 0 && $position <= $this->request['first']; | ||
| 477 | + } | ||
| 478 | + //核心词 | ||
| 479 | + if ($this->request['g']) { | ||
| 480 | + return $item['g'] == $this->request['g']; | ||
| 481 | + } | ||
| 482 | + return true; | ||
| 483 | + })->values(); | ||
| 484 | + | ||
| 485 | + if($export){ | ||
| 486 | + return $list->toArray(); | ||
| 487 | + } | ||
| 488 | + $data = [ | ||
| 489 | + "list" => $list->forPage($page, 100)->toArray(), | ||
| 490 | + "total" => $list->count(), | ||
| 491 | + "page" => $page, | ||
| 492 | + "total_page" => ceil($list->count() / 100), | ||
| 493 | + "size" => 100 | ||
| 494 | + ]; | ||
| 495 | + return $data; | ||
| 496 | + } | ||
| 497 | + | ||
| 498 | + /** | ||
| 499 | + * 获取复制站点项目 | ||
| 500 | + * @author zbj | ||
| 501 | + * @date 2023/5/12 | ||
| 502 | + */ | ||
| 503 | + public function getExtendProjects($api_no = null) | ||
| 504 | + { | ||
| 505 | + $key = 'extend_projects_list'; | ||
| 506 | + $data = Cache::get($key); | ||
| 507 | + if (!$data) { | ||
| 508 | + $api_url = 'http://api.quanqiusou.cn/google-rank/api/extend_projects.php'; | ||
| 509 | + try { | ||
| 510 | + $data = HttpUtils::get($api_url, []); | ||
| 511 | + if ($data) { | ||
| 512 | + $data = Arr::s2a($data); | ||
| 513 | + Cache::put($key, $data, 4 * 3600); | ||
| 514 | + } | ||
| 515 | + } catch (\Exception | GuzzleException $e) { | ||
| 516 | + errorLog('复制站点项目获取失败', [], $e); | ||
| 517 | + return false; | ||
| 518 | + } | ||
| 519 | + } | ||
| 520 | + if ($api_no !== null) { | ||
| 521 | + $data = collect($data)->where('apino', $api_no)->first(); | ||
| 522 | + return $data ?: []; | ||
| 523 | + } | ||
| 524 | + return $data; | ||
| 525 | + } | ||
| 526 | + | ||
| 527 | + /** | ||
| 528 | + * 获取AI站点项目 | ||
| 529 | + * @author zbj | ||
| 530 | + * @date 2023/5/12 | ||
| 531 | + */ | ||
| 532 | + public function getAiProjects($domain = null) | ||
| 533 | + { | ||
| 534 | + $key = 'ai_projects_list'; | ||
| 535 | + $data = Cache::get($key); | ||
| 536 | + if (!$data) { | ||
| 537 | + $api_url = 'https://demosite5.globalso.com/api/domain'; | ||
| 538 | + try { | ||
| 539 | + $data = HttpUtils::get($api_url, []); | ||
| 540 | + if ($data) { | ||
| 541 | + $data = Arr::s2a($data); | ||
| 542 | + Cache::put($key, $data, 4 * 3600); | ||
| 543 | + } | ||
| 544 | + } catch (\Exception | GuzzleException $e) { | ||
| 545 | + errorLog('AI站点项目获取失败', [], $e); | ||
| 546 | + return false; | ||
| 547 | + } | ||
| 548 | + } | ||
| 549 | + if ($domain !== null) { | ||
| 550 | + $domain = parse_url($domain); | ||
| 551 | + $data = collect($data['data'])->where('bind_domain', $domain['host'] ?? $domain['path'])->first(); | ||
| 552 | + return $data ?: []; | ||
| 553 | + } | ||
| 554 | + return $data; | ||
| 555 | + } | ||
| 556 | + | ||
| 557 | + /** | ||
| 558 | + * 获取复制项目标识 | ||
| 559 | + * @author zbj | ||
| 560 | + * @date 2023/5/15 | ||
| 561 | + */ | ||
| 562 | + protected function getExtFlag($ext_projects, $domain, $api_no) | ||
| 563 | + { | ||
| 564 | + //复制站点标识 | ||
| 565 | + $flg_ext = 0; | ||
| 566 | + if ($ext_projects) { | ||
| 567 | + $ext_urls = array_column($ext_projects, 'ext'); | ||
| 568 | + $api_nos = array_column($ext_projects, 'apino'); | ||
| 569 | + if (in_array($api_no, $api_nos)) { | ||
| 570 | + $flg_ext = 1; | ||
| 571 | + } | ||
| 572 | + if (in_array($domain, $ext_urls)) { | ||
| 573 | + $flg_ext = 2; | ||
| 574 | + } | ||
| 575 | + } | ||
| 576 | + return $flg_ext; | ||
| 577 | + } | ||
| 578 | + | ||
| 579 | + /** | ||
| 580 | + * 获取AI项目标识 | ||
| 581 | + * @author zbj | ||
| 582 | + * @date 2023/5/15 | ||
| 583 | + */ | ||
| 584 | + protected function getAiFlag($ai_projects, $domain) | ||
| 585 | + { | ||
| 586 | + $flg_ai = 0; | ||
| 587 | + foreach ($ai_projects as $ai_project) { | ||
| 588 | + if ($ai_project['bind_domain'] == $domain) { | ||
| 589 | + $flg_ai = 1; | ||
| 590 | + } | ||
| 591 | + } | ||
| 592 | + return $flg_ai; | ||
| 593 | + } | ||
| 594 | +} |
| @@ -211,7 +211,7 @@ class OptimizeController extends BaseController | @@ -211,7 +211,7 @@ class OptimizeController extends BaseController | ||
| 211 | $query = $query->whereRaw("FIND_IN_SET(?, gl_project.level) > 0", [$this->map['level']]); | 211 | $query = $query->whereRaw("FIND_IN_SET(?, gl_project.level) > 0", [$this->map['level']]); |
| 212 | } | 212 | } |
| 213 | if(isset($this->map['online_updated_at']) && !empty($this->map['online_updated_at']) && is_array($this->map['online_updated_at'])){ | 213 | if(isset($this->map['online_updated_at']) && !empty($this->map['online_updated_at']) && is_array($this->map['online_updated_at'])){ |
| 214 | - $query = $query->whereBetween('gl_project_deploy_optimize.start_date', $this->map['online_updated_at']); | 214 | + $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]); |
| 215 | } | 215 | } |
| 216 | if(isset($this->map['special'])){ | 216 | if(isset($this->map['special'])){ |
| 217 | $query = $query->whereRaw("FIND_IN_SET(?, gl_project_deploy_optimize.special) > 0", [$this->map['special']]); | 217 | $query = $query->whereRaw("FIND_IN_SET(?, gl_project_deploy_optimize.special) > 0", [$this->map['special']]); |
| @@ -6,6 +6,7 @@ use App\Enums\Common\Code; | @@ -6,6 +6,7 @@ use App\Enums\Common\Code; | ||
| 6 | use App\Helper\Arr; | 6 | use App\Helper\Arr; |
| 7 | use App\Helper\Common; | 7 | use App\Helper\Common; |
| 8 | use App\Http\Controllers\Bside\BaseController; | 8 | use App\Http\Controllers\Bside\BaseController; |
| 9 | +use App\Http\Logic\Aside\Project\ProjectLogic; | ||
| 9 | use App\Http\Logic\Bside\User\UserLogic; | 10 | use App\Http\Logic\Bside\User\UserLogic; |
| 10 | use App\Jobs\PurchaserJob; | 11 | use App\Jobs\PurchaserJob; |
| 11 | use App\Models\Com\Purchaser; | 12 | use App\Models\Com\Purchaser; |
| @@ -328,5 +329,4 @@ class ComController extends BaseController | @@ -328,5 +329,4 @@ class ComController extends BaseController | ||
| 328 | $this->response('success',Code::SUCCESS,$data); | 329 | $this->response('success',Code::SUCCESS,$data); |
| 329 | } | 330 | } |
| 330 | 331 | ||
| 331 | - | ||
| 332 | } | 332 | } |
| @@ -29,7 +29,7 @@ class WebSettingReceivingController extends BaseController | @@ -29,7 +29,7 @@ class WebSettingReceivingController extends BaseController | ||
| 29 | * @time :2023/5/8 16:23 | 29 | * @time :2023/5/8 16:23 |
| 30 | */ | 30 | */ |
| 31 | public function save(WebSettingReceivingLogic $webSettingReceivingLogic){ | 31 | public function save(WebSettingReceivingLogic $webSettingReceivingLogic){ |
| 32 | - $webSettingReceivingLogic->setting_receiving_save(); | ||
| 33 | - $this->response('success'); | 32 | + $result = $webSettingReceivingLogic->setting_receiving_save(); |
| 33 | + $this->response('success',Code::SUCCESS,$result); | ||
| 34 | } | 34 | } |
| 35 | } | 35 | } |
| @@ -39,6 +39,8 @@ class SuppliersController extends BaseController | @@ -39,6 +39,8 @@ class SuppliersController extends BaseController | ||
| 39 | foreach ($lists as $v){ | 39 | foreach ($lists as $v){ |
| 40 | $resultData = json_decode($v['data']); | 40 | $resultData = json_decode($v['data']); |
| 41 | foreach ($resultData as $value){ | 41 | foreach ($resultData as $value){ |
| 42 | + $value = (array)$value; | ||
| 43 | + $value['keyword'] = $v['keyword']; | ||
| 42 | $data[] = $value; | 44 | $data[] = $value; |
| 43 | } | 45 | } |
| 44 | } | 46 | } |
| @@ -59,7 +61,13 @@ class SuppliersController extends BaseController | @@ -59,7 +61,13 @@ class SuppliersController extends BaseController | ||
| 59 | $token = $action_name. '+' .date('Y-m-d'). '+' .http_build_query($param); | 61 | $token = $action_name. '+' .date('Y-m-d'). '+' .http_build_query($param); |
| 60 | $param['token'] = md5($token); | 62 | $param['token'] = md5($token); |
| 61 | $res = http_post($url,json_encode($param)); | 63 | $res = http_post($url,json_encode($param)); |
| 62 | - return $this->success($res); | 64 | + if(isset($res['code']) && $res['code'] != 200){ |
| 65 | + $this->response($res['message'],Code::SYSTEM_ERROR); | ||
| 66 | + } | ||
| 67 | + if(isset($res['status_code']) && $res['status_code'] != 200){ | ||
| 68 | + $this->response($res['message'],Code::SYSTEM_ERROR); | ||
| 69 | + } | ||
| 70 | + return $this->success($res['data']); | ||
| 63 | } | 71 | } |
| 64 | /** | 72 | /** |
| 65 | * @remark :按名字搜索公司 | 73 | * @remark :按名字搜索公司 |
| @@ -74,7 +82,7 @@ class SuppliersController extends BaseController | @@ -74,7 +82,7 @@ class SuppliersController extends BaseController | ||
| 74 | $param = [ | 82 | $param = [ |
| 75 | 'search'=>$this->param['search'], | 83 | 'search'=>$this->param['search'], |
| 76 | ]; | 84 | ]; |
| 77 | - $res = $this->_action($api_url,$action_name,$param); | 85 | + $res = $this->_action($api_url,$action_name,$param ?? []); |
| 78 | $this->response('success',Code::SUCCESS,$res); | 86 | $this->response('success',Code::SUCCESS,$res); |
| 79 | } | 87 | } |
| 80 | 88 | ||
| @@ -107,11 +115,15 @@ class SuppliersController extends BaseController | @@ -107,11 +115,15 @@ class SuppliersController extends BaseController | ||
| 107 | $action_name = 'company_linked'; | 115 | $action_name = 'company_linked'; |
| 108 | $param = [ | 116 | $param = [ |
| 109 | 'domain'=>$this->param['domain'], | 117 | 'domain'=>$this->param['domain'], |
| 110 | - 'keyword'=>$this->param['keyword'], | ||
| 111 | - 'position'=>$this->param['position'], | ||
| 112 | 'page'=>$this->page, | 118 | 'page'=>$this->page, |
| 113 | 'page_size'=>$this->row, | 119 | 'page_size'=>$this->row, |
| 114 | ]; | 120 | ]; |
| 121 | + if(isset($this->param['keyword'])){ | ||
| 122 | + $param['keyword'] = $this->param['keyword']; | ||
| 123 | + } | ||
| 124 | + if(isset($this->param['position'])){ | ||
| 125 | + $param['position'] = $this->param['position']; | ||
| 126 | + } | ||
| 115 | $res = $this->_action($api_url,$action_name,$param); | 127 | $res = $this->_action($api_url,$action_name,$param); |
| 116 | $this->response('success',Code::SUCCESS,$res); | 128 | $this->response('success',Code::SUCCESS,$res); |
| 117 | } | 129 | } |
| @@ -127,7 +139,7 @@ class SuppliersController extends BaseController | @@ -127,7 +139,7 @@ class SuppliersController extends BaseController | ||
| 127 | $api_url = 'api/trade_trend'; | 139 | $api_url = 'api/trade_trend'; |
| 128 | $action_name = 'trade_trend'; | 140 | $action_name = 'trade_trend'; |
| 129 | $param = [ | 141 | $param = [ |
| 130 | - 'prod_desc'=>$this->param['prod_desc'], | 142 | + 'prod_desc'=>$this->param['prod_desc'] ?? '', |
| 131 | ]; | 143 | ]; |
| 132 | $res = $this->_action($api_url,$action_name,$param); | 144 | $res = $this->_action($api_url,$action_name,$param); |
| 133 | $this->response('success',Code::SUCCESS,$res); | 145 | $this->response('success',Code::SUCCESS,$res); |
| @@ -144,10 +156,14 @@ class SuppliersController extends BaseController | @@ -144,10 +156,14 @@ class SuppliersController extends BaseController | ||
| 144 | $api_url = 'api/supplier_area'; | 156 | $api_url = 'api/supplier_area'; |
| 145 | $action_name = 'supplier_area'; | 157 | $action_name = 'supplier_area'; |
| 146 | $param = [ | 158 | $param = [ |
| 147 | - 'prod_desc'=>$this->param['prod_desc'], | ||
| 148 | - 'start_date'=>$this->param['start_date'], | ||
| 149 | - 'end_date'=>$this->param['end_date'], | 159 | + 'prod_desc'=>$this->param['prod_desc'] ?? '', |
| 150 | ]; | 160 | ]; |
| 161 | + if(isset($this->param['start_date'] )){ | ||
| 162 | + $param['start_date'] = $this->param['start_date'] ?? ''; | ||
| 163 | + } | ||
| 164 | + if(isset($this->param['end_date'] )){ | ||
| 165 | + $param['end_date'] = $this->param['end_date'] ?? ''; | ||
| 166 | + } | ||
| 151 | $res = $this->_action($api_url,$action_name,$param); | 167 | $res = $this->_action($api_url,$action_name,$param); |
| 152 | $this->response('success',Code::SUCCESS,$res); | 168 | $this->response('success',Code::SUCCESS,$res); |
| 153 | } | 169 | } |
| @@ -163,9 +179,11 @@ class SuppliersController extends BaseController | @@ -163,9 +179,11 @@ class SuppliersController extends BaseController | ||
| 163 | $api_url = 'api/trade_partner'; | 179 | $api_url = 'api/trade_partner'; |
| 164 | $action_name = 'trade_partner'; | 180 | $action_name = 'trade_partner'; |
| 165 | $param = [ | 181 | $param = [ |
| 166 | - 'com_id'=>$this->param['com_id'], | ||
| 167 | - 'com_role'=>$this->param['com_role'], | 182 | + 'com_id'=>$this->param['com_id'] ?? '', |
| 168 | ]; | 183 | ]; |
| 184 | + if(isset($this->param['com_role'] )){ | ||
| 185 | + $param['com_role'] = $this->param['com_role'] ?? ''; | ||
| 186 | + } | ||
| 169 | $res = $this->_action($api_url,$action_name,$param); | 187 | $res = $this->_action($api_url,$action_name,$param); |
| 170 | $this->response('success',Code::SUCCESS,$res); | 188 | $this->response('success',Code::SUCCESS,$res); |
| 171 | } | 189 | } |
| @@ -181,7 +199,7 @@ class SuppliersController extends BaseController | @@ -181,7 +199,7 @@ class SuppliersController extends BaseController | ||
| 181 | $api_url = 'api/trade_detail'; | 199 | $api_url = 'api/trade_detail'; |
| 182 | $action_name = 'trade_detail'; | 200 | $action_name = 'trade_detail'; |
| 183 | $param = [ | 201 | $param = [ |
| 184 | - 'prod_desc'=>$this->param['prod_desc'], | 202 | + 'prod_desc'=>$this->param['prod_desc'] ?? '', |
| 185 | ]; | 203 | ]; |
| 186 | $res = $this->_action($api_url,$action_name,$param); | 204 | $res = $this->_action($api_url,$action_name,$param); |
| 187 | $this->response('success',Code::SUCCESS,$res); | 205 | $this->response('success',Code::SUCCESS,$res); |
| @@ -198,7 +216,7 @@ class SuppliersController extends BaseController | @@ -198,7 +216,7 @@ class SuppliersController extends BaseController | ||
| 198 | $api_url = 'api/bill_detail'; | 216 | $api_url = 'api/bill_detail'; |
| 199 | $action_name = 'bill_detail'; | 217 | $action_name = 'bill_detail'; |
| 200 | $param = [ | 218 | $param = [ |
| 201 | - 'prod_desc'=>$this->param['prod_desc'], | 219 | + 'prod_desc'=>$this->param['prod_desc'] ?? '', |
| 202 | 'page'=>$this->page, | 220 | 'page'=>$this->page, |
| 203 | 'page_size'=>$this->row, | 221 | 'page_size'=>$this->row, |
| 204 | ]; | 222 | ]; |
| @@ -217,8 +235,8 @@ class SuppliersController extends BaseController | @@ -217,8 +235,8 @@ class SuppliersController extends BaseController | ||
| 217 | $api_url = 'api/import_product'; | 235 | $api_url = 'api/import_product'; |
| 218 | $action_name = 'import_product'; | 236 | $action_name = 'import_product'; |
| 219 | $param = [ | 237 | $param = [ |
| 220 | - 'com_id'=>$this->param['com_id'], | ||
| 221 | - 'com_role'=>$this->param['com_role'], | 238 | + 'com_id'=>$this->param['com_id'] ?? '', |
| 239 | + 'com_role'=>$this->param['com_role'] ?? '', | ||
| 222 | ]; | 240 | ]; |
| 223 | $res = $this->_action($api_url,$action_name,$param); | 241 | $res = $this->_action($api_url,$action_name,$param); |
| 224 | $this->response('success',Code::SUCCESS,$res); | 242 | $this->response('success',Code::SUCCESS,$res); |
| @@ -58,7 +58,7 @@ class InquiryLogic extends BaseLogic | @@ -58,7 +58,7 @@ class InquiryLogic extends BaseLogic | ||
| 58 | $data['total'] = $list['data']['total']; | 58 | $data['total'] = $list['data']['total']; |
| 59 | $data['total_page'] = $list['data']['last_page']; | 59 | $data['total_page'] = $list['data']['last_page']; |
| 60 | } | 60 | } |
| 61 | - return $this->success($data); | 61 | + return $data; |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | public function getOtherList($export = false){ | 64 | public function getOtherList($export = false){ |
| @@ -83,10 +83,28 @@ class TranslateLogic extends BaseLogic | @@ -83,10 +83,28 @@ class TranslateLogic extends BaseLogic | ||
| 83 | 83 | ||
| 84 | } | 84 | } |
| 85 | } | 85 | } |
| 86 | + $data = $this->unique_multidimensional_array($data); | ||
| 86 | return $this->success($data); | 87 | return $this->success($data); |
| 87 | } | 88 | } |
| 88 | 89 | ||
| 89 | /** | 90 | /** |
| 91 | + * @remark :多维数组去重 | ||
| 92 | + * @name :unique_multidimensional_array | ||
| 93 | + * @author :lyh | ||
| 94 | + * @method :post | ||
| 95 | + * @time :2024/3/8 16:38 | ||
| 96 | + */ | ||
| 97 | + public function unique_multidimensional_array($array) { | ||
| 98 | + // 将多维数组转换为字符串并进行去重 | ||
| 99 | + $uniqueArray = array_map('json_encode', $array); | ||
| 100 | + // 去除重复项 | ||
| 101 | + $uniqueArray = array_unique($uniqueArray); | ||
| 102 | + // 将字符串转换回多维数组 | ||
| 103 | + $uniqueArray = array_map('json_decode', $uniqueArray); | ||
| 104 | + return $uniqueArray; | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + /** | ||
| 90 | * @remark :获取图片列表 | 108 | * @remark :获取图片列表 |
| 91 | * @name :imageList | 109 | * @name :imageList |
| 92 | * @author :lyh | 110 | * @author :lyh |
| @@ -6,6 +6,7 @@ use App\Http\Logic\Bside\BaseLogic; | @@ -6,6 +6,7 @@ use App\Http\Logic\Bside\BaseLogic; | ||
| 6 | use App\Models\WebSetting\WebSettingReceiving; | 6 | use App\Models\WebSetting\WebSettingReceiving; |
| 7 | use App\Models\WebSetting\WebSettingText; | 7 | use App\Models\WebSetting\WebSettingText; |
| 8 | use App\Services\SyncService; | 8 | use App\Services\SyncService; |
| 9 | +use Illuminate\Support\Facades\DB; | ||
| 9 | 10 | ||
| 10 | class WebSettingReceivingLogic extends BaseLogic | 11 | class WebSettingReceivingLogic extends BaseLogic |
| 11 | { | 12 | { |
| @@ -34,24 +35,37 @@ class WebSettingReceivingLogic extends BaseLogic | @@ -34,24 +35,37 @@ class WebSettingReceivingLogic extends BaseLogic | ||
| 34 | * @time :2023/5/8 16:26 | 35 | * @time :2023/5/8 16:26 |
| 35 | */ | 36 | */ |
| 36 | public function setting_receiving_save(){ | 37 | public function setting_receiving_save(){ |
| 37 | - try { | ||
| 38 | - $this->model->del(['project_id'=>$this->user['project_id']]); | ||
| 39 | - foreach ($this->param['data'] as $k => $v){ | 38 | + $data = []; |
| 39 | + foreach ($this->param['data'] as $v){ | ||
| 40 | + if($v['type'] == 1){ | ||
| 41 | + // 使用正则表达式匹配中国大陆手机号 | ||
| 42 | + $pattern = '/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/'; | ||
| 43 | + if (!preg_match($pattern, $v['values'])) { | ||
| 44 | + $this->fail('当前数据不符合规则:'.$v['values']); | ||
| 45 | + } | ||
| 46 | + } | ||
| 40 | if($v['type'] == 2){ | 47 | if($v['type'] == 2){ |
| 41 | // 使用正则表达式匹配中国大陆手机号 | 48 | // 使用正则表达式匹配中国大陆手机号 |
| 42 | $pattern = '/^1[3456789]\d{9}$/'; | 49 | $pattern = '/^1[3456789]\d{9}$/'; |
| 43 | if (!preg_match($pattern, $v['values'])) { | 50 | if (!preg_match($pattern, $v['values'])) { |
| 44 | - continue; | 51 | + $this->fail('当前数据不符合规则:'.$v['values']); |
| 45 | } | 52 | } |
| 46 | } | 53 | } |
| 47 | $v['project_id'] = $this->user['project_id']; | 54 | $v['project_id'] = $this->user['project_id']; |
| 48 | $v['created_at'] = date('Y-m-d H:i:s'); | 55 | $v['created_at'] = date('Y-m-d H:i:s'); |
| 49 | $v['updated_at'] = date('Y-m-d H:i:s'); | 56 | $v['updated_at'] = date('Y-m-d H:i:s'); |
| 50 | - $this->param['data'][$k] = $v; | 57 | + $data[] = $v; |
| 58 | + } | ||
| 59 | + DB::connection('custom_mysql')->beginTransaction(); | ||
| 60 | + try { | ||
| 61 | + $this->model->del(['project_id'=>$this->user['project_id']]); | ||
| 62 | + if(!empty($data)){ | ||
| 63 | + $this->model->insert($data); | ||
| 51 | } | 64 | } |
| 52 | - $this->model->insert($this->param['data']); | 65 | + DB::connection('custom_mysql')->commit(); |
| 53 | }catch (\Exception $e){ | 66 | }catch (\Exception $e){ |
| 54 | - $this->fail('error'); | 67 | + DB::connection('custom_mysql')->rollBack(); |
| 68 | + $this->fail('编辑失败,请联系管理员'); | ||
| 55 | } | 69 | } |
| 56 | (new SyncService())->projectAcceptAddress($this->user['project_id']); | 70 | (new SyncService())->projectAcceptAddress($this->user['project_id']); |
| 57 | return $this->success(); | 71 | return $this->success(); |
| @@ -37,14 +37,14 @@ class WebSettingServiceLogic extends BaseLogic | @@ -37,14 +37,14 @@ class WebSettingServiceLogic extends BaseLogic | ||
| 37 | * @time :2023/5/4 11:10 | 37 | * @time :2023/5/4 11:10 |
| 38 | */ | 38 | */ |
| 39 | public function setting_service_save(){ | 39 | public function setting_service_save(){ |
| 40 | - DB::beginTransaction(); | 40 | + DB::connection('custom_mysql')->beginTransaction(); |
| 41 | try { | 41 | try { |
| 42 | $this->param['data'] = Common::uniqueMultiArray($this->param['data']); | 42 | $this->param['data'] = Common::uniqueMultiArray($this->param['data']); |
| 43 | //删除以前的数据 | 43 | //删除以前的数据 |
| 44 | $this->model->del(['project_id'=>$this->user['project_id']]); | 44 | $this->model->del(['project_id'=>$this->user['project_id']]); |
| 45 | $data = []; | 45 | $data = []; |
| 46 | foreach ($this->param['data'] as $k => $v){ | 46 | foreach ($this->param['data'] as $k => $v){ |
| 47 | - if(isset($v['values']) && empty($v['values'])){ | 47 | + if(isset($v['values']) && !empty($v['values'])){ |
| 48 | $v['project_id'] = $this->user['project_id']; | 48 | $v['project_id'] = $this->user['project_id']; |
| 49 | $v['created_at'] = date('Y-m-d H:i:s'); | 49 | $v['created_at'] = date('Y-m-d H:i:s'); |
| 50 | $v['updated_at'] = date('Y-m-d H:i:s'); | 50 | $v['updated_at'] = date('Y-m-d H:i:s'); |
| @@ -54,10 +54,9 @@ class WebSettingServiceLogic extends BaseLogic | @@ -54,10 +54,9 @@ class WebSettingServiceLogic extends BaseLogic | ||
| 54 | if(!empty($data)){ | 54 | if(!empty($data)){ |
| 55 | $this->model->insert($data); | 55 | $this->model->insert($data); |
| 56 | } | 56 | } |
| 57 | - | ||
| 58 | - DB::commit(); | 57 | + DB::connection('custom_mysql')->commit(); |
| 59 | }catch (\Exception $e){ | 58 | }catch (\Exception $e){ |
| 60 | - DB::rollBack(); | 59 | + DB::connection('custom_mysql')->rollBack(); |
| 61 | $this->fail('系统错误,请联系管理员'); | 60 | $this->fail('系统错误,请联系管理员'); |
| 62 | } | 61 | } |
| 63 | return $this->success(); | 62 | return $this->success(); |
| @@ -30,10 +30,10 @@ class KeywordRequest extends FormRequest | @@ -30,10 +30,10 @@ class KeywordRequest extends FormRequest | ||
| 30 | public function rules() | 30 | public function rules() |
| 31 | { | 31 | { |
| 32 | return [ | 32 | return [ |
| 33 | - 'title'=>'required|max:50', | ||
| 34 | - 'seo_title'=>'max:200', | ||
| 35 | - 'seo_keywords'=>'max:200', | ||
| 36 | - 'seo_description'=>'max:200', | 33 | + 'title'=>'required|max:200', |
| 34 | + 'seo_title'=>'max:255', | ||
| 35 | + 'seo_keywords'=>'max:500', | ||
| 36 | + 'seo_description'=>'max:500', | ||
| 37 | 'related_news_ids'=>'array|max:2', | 37 | 'related_news_ids'=>'array|max:2', |
| 38 | 'related_blog_ids'=>'array|max:2', | 38 | 'related_blog_ids'=>'array|max:2', |
| 39 | ]; | 39 | ]; |
| @@ -43,10 +43,10 @@ class KeywordRequest extends FormRequest | @@ -43,10 +43,10 @@ class KeywordRequest extends FormRequest | ||
| 43 | { | 43 | { |
| 44 | return [ | 44 | return [ |
| 45 | 'title.required' => '请输入关键词', | 45 | 'title.required' => '请输入关键词', |
| 46 | - 'title.max' => '关键词不能超过50个字符', | ||
| 47 | - 'seo_title.max' => 'SEO标题不能超过200个字符', | ||
| 48 | - 'seo_keywords.max' => 'SEO关键词不能超过200个字符', | ||
| 49 | - 'seo_description.max' => 'SEO描述不能超过200个字符', | 46 | + 'title.max' => '关键词不能超过200个字符', |
| 47 | + 'seo_title.max' => 'SEO标题不能超过255个字符', | ||
| 48 | + 'seo_keywords.max' => 'SEO关键词不能超过500个字符', | ||
| 49 | + 'seo_description.max' => 'SEO描述不能超过500个字符', | ||
| 50 | 'related_news_ids.max' => '关联新闻不能超过两条', | 50 | 'related_news_ids.max' => '关联新闻不能超过两条', |
| 51 | 'related_blog_ids.max' => '关联博客不能超过两条', | 51 | 'related_blog_ids.max' => '关联博客不能超过两条', |
| 52 | ]; | 52 | ]; |
| @@ -23,5 +23,5 @@ Route::get('optimize_project_list', [\App\Http\Controllers\Api\PrivateController | @@ -23,5 +23,5 @@ Route::get('optimize_project_list', [\App\Http\Controllers\Api\PrivateController | ||
| 23 | Route::get('get_project_route', [\App\Http\Controllers\Api\PrivateController::class, 'getProjectRoute'])->name('api.get_project_route'); | 23 | Route::get('get_project_route', [\App\Http\Controllers\Api\PrivateController::class, 'getProjectRoute'])->name('api.get_project_route'); |
| 24 | Route::any('get_product_images', [\App\Http\Controllers\Api\ProductController::class, 'getImages'])->name('api.get_product_images'); | 24 | Route::any('get_product_images', [\App\Http\Controllers\Api\ProductController::class, 'getImages'])->name('api.get_product_images'); |
| 25 | Route::post('inquiry_submit', [\App\Http\Controllers\Api\InquiryController::class, 'submit'])->name('api.inquiry_submit'); | 25 | Route::post('inquiry_submit', [\App\Http\Controllers\Api\InquiryController::class, 'submit'])->name('api.inquiry_submit'); |
| 26 | - | 26 | +Route::any('getOptimizationReport', [\App\Http\Controllers\Api\OptimizationReportController::class, 'getOptimizationReport'])->name('api.getOptimizationReport'); |
| 27 | Route::post('video_task_callback', [\App\Http\Controllers\Api\NoticeController::class, 'videoTaskCallback'])->name('api.video_task_callback'); | 27 | Route::post('video_task_callback', [\App\Http\Controllers\Api\NoticeController::class, 'videoTaskCallback'])->name('api.video_task_callback'); |
-
请 注册 或 登录 后发表评论