Merge branch 'develop' into lms
正在显示
37 个修改的文件
包含
1197 行增加
和
143 行删除
app/Console/Commands/WebTraffic.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Console\Commands; | ||
| 4 | + | ||
| 5 | +use App\Helper\Arr; | ||
| 6 | +use App\Models\Product\Category; | ||
| 7 | +use App\Models\Product\Product; | ||
| 8 | +use App\Models\RouteMap; | ||
| 9 | +use GuzzleHttp\Client; | ||
| 10 | +use GuzzleHttp\Promise\Utils; | ||
| 11 | +use Illuminate\Console\Command; | ||
| 12 | +use Illuminate\Support\Facades\DB; | ||
| 13 | +use Illuminate\Support\Str; | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * 网站引流 | ||
| 17 | + * Class Traffic | ||
| 18 | + * @package App\Console\Commands | ||
| 19 | + * @author zbj | ||
| 20 | + * @date 2023/5/18 | ||
| 21 | + */ | ||
| 22 | +class WebTraffic extends Command | ||
| 23 | +{ | ||
| 24 | + /** | ||
| 25 | + * The name and signature of the console command. | ||
| 26 | + * | ||
| 27 | + * @var string | ||
| 28 | + */ | ||
| 29 | + protected $signature = 'web_traffic {type}'; | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * The console command description. | ||
| 33 | + * | ||
| 34 | + * @var string | ||
| 35 | + */ | ||
| 36 | + protected $description = '网站引流'; | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * Create a new command instance. | ||
| 40 | + * | ||
| 41 | + * @return void | ||
| 42 | + */ | ||
| 43 | + public function __construct() | ||
| 44 | + { | ||
| 45 | + parent::__construct(); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * google域名后缀 | ||
| 50 | + * @var string[] | ||
| 51 | + */ | ||
| 52 | + protected $suffix = [ | ||
| 53 | + 'co.jp' => '日本', | ||
| 54 | + 'com.tr' => '土耳其', | ||
| 55 | + 'nl' => '荷兰', | ||
| 56 | + 'ru' => '俄罗斯', | ||
| 57 | + 'fr' => '法国', | ||
| 58 | + 'co.kr' => '韩国', | ||
| 59 | + 'fi' => '芬兰', | ||
| 60 | + 'be' => '比利时', | ||
| 61 | + 'lt' => '立陶宛', | ||
| 62 | + 'es' => '西班牙', | ||
| 63 | + 'it' => '意大利', | ||
| 64 | + 'com.au' => '澳大利亚', | ||
| 65 | + 'no' => '挪威', | ||
| 66 | + 'al' => '阿尔巴尼亚', | ||
| 67 | + 'pt' => '葡萄牙', | ||
| 68 | + 'lv' => '拉脱维亚', | ||
| 69 | + 'hu' => '匈牙利', | ||
| 70 | + 'cz' => '捷克', | ||
| 71 | + 'de' => '德国', | ||
| 72 | + 'ca' => '加拿大', | ||
| 73 | + 'co.in' => '印度', | ||
| 74 | + 'co.uk' => '英国', | ||
| 75 | + 'com.vn' => '越南', | ||
| 76 | + 'com.br' => '巴西', | ||
| 77 | + 'co.il' => '以色列', | ||
| 78 | + 'pl' => '波兰', | ||
| 79 | + 'com.eg' => '埃及', | ||
| 80 | + 'co.th' => '泰国', | ||
| 81 | + 'sk' => '斯洛伐克', | ||
| 82 | + 'ro' => '罗马尼亚', | ||
| 83 | + 'com.mx' => '墨西哥', | ||
| 84 | + 'com.my' => '马来西亚', | ||
| 85 | + 'com.pk' => '巴基斯坦', | ||
| 86 | + 'co.nz' => '新西兰', | ||
| 87 | + 'co.za' => '南非', | ||
| 88 | + 'com.ar' => '阿根廷', | ||
| 89 | + 'com.kw' => '科威特', | ||
| 90 | + 'com.sg' => '新加坡', | ||
| 91 | + 'com.co' => '哥伦比亚', | ||
| 92 | + 'co.id' => '印度尼西亚', | ||
| 93 | + 'gr' => '希腊', | ||
| 94 | + 'bg' => '保加利亚', | ||
| 95 | + 'mn' => '蒙古', | ||
| 96 | + 'dk' => '丹麦', | ||
| 97 | + 'com.sa' => '沙特阿拉伯', | ||
| 98 | + 'com.pe' => '秘鲁', | ||
| 99 | + 'com.ph' => '菲律宾', | ||
| 100 | + 'com.ua' => '乌克兰', | ||
| 101 | + 'ge' => '格鲁吉亚', | ||
| 102 | + 'ae' => '阿拉伯联合酋长国', | ||
| 103 | + 'tn' => '突尼斯', | ||
| 104 | + ]; | ||
| 105 | + | ||
| 106 | + /** | ||
| 107 | + * 概率值 | ||
| 108 | + * @var int[] | ||
| 109 | + */ | ||
| 110 | + protected $sjjg = [720, 280];//访问间隔占比 访问|不访问 | ||
| 111 | + //访问页面类型占比 产品详情页、单页|产品分类页 | ||
| 112 | + protected $ymzb = [ | ||
| 113 | + 'urls_cats' => 700, | ||
| 114 | + 'urls_details' => 300 | ||
| 115 | + ]; | ||
| 116 | + protected $sdzb = [600, 200, 150, 50]; //访问页面深度占比 1页|2页|3-6页|7-11页 | ||
| 117 | + protected $yddzb = [1 => 700, 2 => 300]; //移动端占比 pc|mobile | ||
| 118 | + //模拟访问来源占比 (美国) | ||
| 119 | + protected $lyzb = [ | ||
| 120 | + 'https://www.google.com/' => 630, | ||
| 121 | + 'http://www.google.com/' => 30, | ||
| 122 | + 'http://www.bing.com/' => 20, | ||
| 123 | + 'https://www.bing.com/' => 5, | ||
| 124 | + 'https://www.youtube.com/' => 5, | ||
| 125 | + 'https://search.yahoo.com/' => 5, | ||
| 126 | + 'https://www.facebook.com/' => 5, | ||
| 127 | + ]; | ||
| 128 | + protected $otherzb = [700, 300]; //模拟访问来源占比 (非美国) google.com|google.其他后缀 | ||
| 129 | + | ||
| 130 | + protected $pc_ua = [ | ||
| 131 | + 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', | ||
| 132 | + 1 => 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36', | ||
| 133 | + 2 => 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1' | ||
| 134 | + ]; | ||
| 135 | + | ||
| 136 | + protected $mobile_ua = [ | ||
| 137 | + 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', | ||
| 138 | + ]; | ||
| 139 | + | ||
| 140 | + /** | ||
| 141 | + * @return bool | ||
| 142 | + */ | ||
| 143 | + public function handle() | ||
| 144 | + { | ||
| 145 | + $type = $this->argument('type'); | ||
| 146 | + | ||
| 147 | + $this->sleep($type); | ||
| 148 | + | ||
| 149 | + $project_list = $this->getProjectList($type); | ||
| 150 | + $project_chunk = array_chunk($project_list,500,true); | ||
| 151 | + | ||
| 152 | + foreach ($project_chunk as $chunk) { | ||
| 153 | + $need_project = []; | ||
| 154 | + foreach ($chunk as $project) { | ||
| 155 | + //随机引流间隔 | ||
| 156 | + $res_sjjg = $this->get_rand($this->sjjg); | ||
| 157 | + if ($res_sjjg == 1) { | ||
| 158 | + continue; | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + $project_urls = $this->getProductUrls($project['project_id']); | ||
| 162 | + $project_urls['home'] = $project['domain']; | ||
| 163 | + //随机访问页面 | ||
| 164 | + $project['visit_urls'] = $this->getVisitUrls($project_urls); | ||
| 165 | + //随机客户端 | ||
| 166 | + $project['device_port'] = $this->get_rand($this->yddzb); | ||
| 167 | + $project['user_agent'] = $project['device_port'] == 1 ? Arr::random($this->pc_ua) : Arr::random($this->mobile_ua); | ||
| 168 | + | ||
| 169 | + $need_project[] = $project; | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + //随机访问ip | ||
| 173 | + $ips = $this->getIpAreas(count($need_project)); | ||
| 174 | + //最多10层深度 | ||
| 175 | + $client = new Client(['verify' => false]); | ||
| 176 | + for ($j = 0; $j < 10; $j++) { | ||
| 177 | + for ($j = 0; $j < 10; $j++) { | ||
| 178 | + //并发请求 | ||
| 179 | + $promises = []; | ||
| 180 | + foreach ($need_project as $project_key => $project) { | ||
| 181 | + if (empty($project['visit_urls'][$j])) { | ||
| 182 | + continue; | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | + $data = [ | ||
| 186 | + 'ip' => $ips[$project_key]['ip'], | ||
| 187 | + 'referer' => $this->getReferer($ips[$project_key]['ip_area']), | ||
| 188 | + 'url' => $project['visit_urls'][$j], | ||
| 189 | + 'device_port' => $this->get_rand($this->yddzb) | ||
| 190 | + ]; | ||
| 191 | + $promises[] = $client->postAsync($project['domain'] . 'api/customerVisit', ['form_params' => $data]); | ||
| 192 | + } | ||
| 193 | + Utils::settle($promises)->wait(); | ||
| 194 | + | ||
| 195 | + //每个深度随机等待 | ||
| 196 | + sleep(rand(2, 10)); | ||
| 197 | + } | ||
| 198 | + } | ||
| 199 | + } | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + /** | ||
| 203 | + * 不同项目 休眠 | ||
| 204 | + */ | ||
| 205 | + protected function sleep($type){ | ||
| 206 | + if($type == 1){ //1-3个月的项目 | ||
| 207 | + sleep(rand(5,480)); | ||
| 208 | + }elseif($type == 2){ //4-8个月的项目 | ||
| 209 | + sleep(rand(5,240)); | ||
| 210 | + }elseif($type == 3){ // 大于9个月的项目 | ||
| 211 | + sleep(rand(5,120)); | ||
| 212 | + } | ||
| 213 | + } | ||
| 214 | + | ||
| 215 | + /** | ||
| 216 | + * 引流的项目 | ||
| 217 | + */ | ||
| 218 | + protected function getProjectList($type){ | ||
| 219 | + //todo 根据type获取需要引流的项目 | ||
| 220 | + return [ | ||
| 221 | + [ | ||
| 222 | + 'project_id' => 1, | ||
| 223 | + 'domain' => 'https://demomark.globalso.com/', | ||
| 224 | + ] | ||
| 225 | + ]; | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + /** | ||
| 229 | + * 获取产品分类、单页和详情链接 | ||
| 230 | + */ | ||
| 231 | + protected function getProductUrls($project_id){ | ||
| 232 | + //产品分类页面 | ||
| 233 | + $product_cate_ids = Category::where('project_id', $project_id)->where('status', Category::STATUS_ACTIVE)->pluck('id')->toArray(); | ||
| 234 | + $data['urls_cats'] = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PRODUCT_CATE)->whereIn('source_id', $product_cate_ids)->get()->toArray(); | ||
| 235 | + //单页面 | ||
| 236 | + //todo 发布状态的单页面id | ||
| 237 | + $data['urls_page'] = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PAGE)->get()->toArray(); | ||
| 238 | + //产品详情页 | ||
| 239 | + $product_ids = Product::where('project_id', $project_id)->where('status', Product::STATUS_ON)->pluck('id')->toArray(); | ||
| 240 | + $data['urls_details'] = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PRODUCT)->whereIn('source_id', $product_ids)->get()->toArray(); | ||
| 241 | + | ||
| 242 | + $data['urls_cats'] = array_merge($data['urls_cats'], $data['urls_page']); | ||
| 243 | + if(empty($data['urls_cats'])){ | ||
| 244 | + $data['urls_cats'] = $data['urls_details']; | ||
| 245 | + } | ||
| 246 | + | ||
| 247 | + return $data; | ||
| 248 | + } | ||
| 249 | + | ||
| 250 | + /** | ||
| 251 | + * 获取地区IP | ||
| 252 | + */ | ||
| 253 | + protected function getIpAreas($num) | ||
| 254 | + { | ||
| 255 | + //本地时间为7-23点的地区 | ||
| 256 | + $h = date('H'); | ||
| 257 | + $areas = []; | ||
| 258 | + $list = DB::table('gl_area_timezone')->get(); | ||
| 259 | + foreach ($list as $v) { | ||
| 260 | + $v = (array)$v; | ||
| 261 | + $country_hour = $h + $v['diff']; | ||
| 262 | + if ($country_hour < 0) { | ||
| 263 | + $country_hour = 24 + $country_hour; | ||
| 264 | + } | ||
| 265 | + if ($country_hour >= 7 && $country_hour < 23) { | ||
| 266 | + $areas[] = $v['name']; | ||
| 267 | + } | ||
| 268 | + } | ||
| 269 | + //根据地区随机取该地区的IP | ||
| 270 | + $data = DB::table('gl_xunpan_ipdata')->whereIn('ip_area', $areas)->inRandomOrder()->limit($num)->get(); | ||
| 271 | + return Arr::s2a(Arr::a2s($data)); | ||
| 272 | + } | ||
| 273 | + | ||
| 274 | + /** | ||
| 275 | + * 概率算法 | ||
| 276 | + */ | ||
| 277 | + protected function get_rand($proArr) { | ||
| 278 | + $result = ''; | ||
| 279 | + $proSum = array_sum($proArr); | ||
| 280 | + foreach ($proArr as $key => $proCur) { | ||
| 281 | + $randNum = mt_rand(1, $proSum); | ||
| 282 | + if ($randNum <= $proCur) { | ||
| 283 | + $result = $key; | ||
| 284 | + break; | ||
| 285 | + } else { | ||
| 286 | + $proSum -= $proCur; | ||
| 287 | + } | ||
| 288 | + } | ||
| 289 | + unset ($proArr); | ||
| 290 | + return $result; | ||
| 291 | + } | ||
| 292 | + | ||
| 293 | + /** | ||
| 294 | + * 根据随机访问深度 随机获取访问页面 | ||
| 295 | + */ | ||
| 296 | + protected function getVisitUrls($project_urls){ | ||
| 297 | + //没有分类页 就只访问首页 | ||
| 298 | + if(!$project_urls['urls_cats']){ | ||
| 299 | + $url[] = $project_urls['home']; | ||
| 300 | + return $url; | ||
| 301 | + } | ||
| 302 | + //随机访问深度 | ||
| 303 | + $res_sdzb = $this->get_rand($this->sdzb); | ||
| 304 | + //随机访问页面类型 | ||
| 305 | + $res_ymzb = $this->get_rand($this->ymzb); | ||
| 306 | + | ||
| 307 | + $all_url = array_merge($project_urls['urls_cats'],$project_urls['urls_details']); | ||
| 308 | + if(!$all_url){ | ||
| 309 | + $url[] = $project_urls['home']; | ||
| 310 | + return $url; | ||
| 311 | + } | ||
| 312 | + | ||
| 313 | + $url = []; | ||
| 314 | + if($res_sdzb == 0){//深度一页 | ||
| 315 | + $url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb])['route'] : ''; | ||
| 316 | + }elseif($res_sdzb == 1){//深度两页 | ||
| 317 | + $url[] = $project_urls['home']; | ||
| 318 | + $url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb])['route'] : ''; | ||
| 319 | + }elseif($res_sdzb == 2){//深度3-6页 | ||
| 320 | + $yms = rand(2,5); //随机页面数 | ||
| 321 | + $url = Arr::pluck(Arr::random($all_url, $yms), 'route'); | ||
| 322 | + $url = Arr::prepend($url, $project_urls['home']);//首页加到最前面去 | ||
| 323 | + }elseif($res_sdzb == 3){//深度7-11页 | ||
| 324 | + $yms = rand(6,10); //随机页面数 | ||
| 325 | + $url = Arr::pluck(Arr::random($all_url, $yms), 'route'); | ||
| 326 | + $url = Arr::prepend($url, $project_urls['home']);//首页加到最前面去 | ||
| 327 | + } | ||
| 328 | + foreach ($url as &$v){ | ||
| 329 | + if(!Str::contains($v, $project_urls['home'])){ | ||
| 330 | + $v = $project_urls['home'] . $v; | ||
| 331 | + } | ||
| 332 | + } | ||
| 333 | + return array_unique(array_filter($url)); | ||
| 334 | + } | ||
| 335 | + | ||
| 336 | + /** | ||
| 337 | + * 获取访问来路 | ||
| 338 | + */ | ||
| 339 | + protected function getReferer($ip_area){ | ||
| 340 | + if($ip_area == '美国'){ | ||
| 341 | + $referer = $this->get_rand($this->lyzb); | ||
| 342 | + }else{ | ||
| 343 | + $referer = 'https://www.google.com/'; | ||
| 344 | + | ||
| 345 | + $suffix = array_search($ip_area, $this->suffix); | ||
| 346 | + if($suffix){ | ||
| 347 | + $res_qtzb = $this->get_rand($this->otherzb); | ||
| 348 | + if($res_qtzb == 1){ | ||
| 349 | + $referer = 'https://www.google.'.$suffix.'/'; | ||
| 350 | + } | ||
| 351 | + } | ||
| 352 | + } | ||
| 353 | + return $referer; | ||
| 354 | + } | ||
| 355 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Console\Commands\YesterdayCount; | ||
| 4 | + | ||
| 5 | +use App\Helper\Common; | ||
| 6 | +use App\Helper\FormGlobalsoApi; | ||
| 7 | +use App\Models\CustomerVisit\CustomerVisitItem; | ||
| 8 | +use App\Models\Project\DeployBuild; | ||
| 9 | +use Carbon\Carbon; | ||
| 10 | +use Illuminate\Console\Command; | ||
| 11 | +use Illuminate\Support\Facades\DB; | ||
| 12 | + | ||
| 13 | +class Yesterday extends Command | ||
| 14 | +{ | ||
| 15 | + const STATUS_ERROR = 400; | ||
| 16 | + public $error = 0; | ||
| 17 | + /** | ||
| 18 | + * The name and signature of the console command. | ||
| 19 | + * | ||
| 20 | + * @var string | ||
| 21 | + */ | ||
| 22 | + protected $signature = 'yesterday_count'; | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * The console command description. | ||
| 26 | + * | ||
| 27 | + * @var string | ||
| 28 | + */ | ||
| 29 | + protected $description = '统计昨日数据'; | ||
| 30 | + /** | ||
| 31 | + * @name :(定时执行生成昨日数据统计)handle | ||
| 32 | + * @author :lyh | ||
| 33 | + * @method :post | ||
| 34 | + * @time :2023/5/12 14:48 | ||
| 35 | + */ | ||
| 36 | + public function handle() | ||
| 37 | + { | ||
| 38 | + $deployModel = new DeployBuild(); | ||
| 39 | + $list = $deployModel->list(); | ||
| 40 | + $data = []; | ||
| 41 | + $yesterday = Carbon::yesterday()->toDateString(); | ||
| 42 | + foreach ($list as $v){ | ||
| 43 | + $arr = []; | ||
| 44 | + $arr['yesterday_pv_num'] = DB::table('gl_customer_visit_item')->whereDate('date', $yesterday)->where('domain',$v['test_domain'])->count(); | ||
| 45 | + $arr['yesterday_ip_num'] = DB::table('gl_customer_visit')->whereDate('date', $yesterday)->where('domain',$v['test_domain'])->count(); | ||
| 46 | + $inquiry_list = (new FormGlobalsoApi())->getInquiryList($v['test_domain']); | ||
| 47 | + if($inquiry_list['status'] == self::STATUS_ERROR){ | ||
| 48 | + $arr['inquiry_num'] = 0; | ||
| 49 | + }else{ | ||
| 50 | + $arr['inquiry_num'] = count($inquiry_list['data']['total']); | ||
| 51 | + } | ||
| 52 | + $arr['date'] = $yesterday; | ||
| 53 | + $rank_info = DB::table('gl_rank_data')->where(['updated_date'=>$yesterday,'lang'=>''])->select(['compliance_day'])->first(); | ||
| 54 | + if(empty($rank_info)){ | ||
| 55 | + $arr['compliance_day'] = 0; | ||
| 56 | + }else{ | ||
| 57 | + $arr['compliance_day'] = $rank_info->compliance_day; | ||
| 58 | + } | ||
| 59 | + $arr['service_day'] = $v['service_duration'] - Common::getDaysToTargetDate($v['created_at']); | ||
| 60 | + $arr['project_id'] = $v['project_id']; | ||
| 61 | + $arr['created_at'] = date('Y-m-d H:i:s'); | ||
| 62 | + $arr['updated_at'] = date('Y-m-d H:i:s'); | ||
| 63 | + $data[] = $arr; | ||
| 64 | + } | ||
| 65 | + DB::table('gl_count')->insert($data); | ||
| 66 | + echo $this->error; | ||
| 67 | + } | ||
| 68 | +} |
| @@ -23,9 +23,10 @@ class Kernel extends ConsoleKernel | @@ -23,9 +23,10 @@ class Kernel extends ConsoleKernel | ||
| 23 | $schedule->command('rank_data_recomm_domain')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-引荐域名,每周一凌晨执行一次 | 23 | $schedule->command('rank_data_recomm_domain')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-引荐域名,每周一凌晨执行一次 |
| 24 | $schedule->command('rank_data_week')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次 | 24 | $schedule->command('rank_data_week')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次 |
| 25 | $schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次 | 25 | $schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次 |
| 26 | - $schedule->command('visit', ['type' => 1])->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次 | ||
| 27 | - $schedule->command('visit', ['type' => 2])->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次 | ||
| 28 | - $schedule->command('visit', ['type' => 3])->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次 | 26 | + $schedule->command('yesterday_count')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次 |
| 27 | + $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次 | ||
| 28 | + $schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次 | ||
| 29 | + $schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次 | ||
| 29 | } | 30 | } |
| 30 | 31 | ||
| 31 | /** | 32 | /** |
| @@ -133,4 +133,19 @@ class Common | @@ -133,4 +133,19 @@ class Common | ||
| 133 | $arr = array_map('unserialize', $arr); | 133 | $arr = array_map('unserialize', $arr); |
| 134 | return $arr; | 134 | return $arr; |
| 135 | } | 135 | } |
| 136 | + | ||
| 137 | + /** | ||
| 138 | + * @param $targetDateTime | ||
| 139 | + * @name :(获取时间差,精确时分秒,返回天数)getDaysToTargetDate | ||
| 140 | + * @author :lyh | ||
| 141 | + * @method :post | ||
| 142 | + * @time :2023/5/24 9:38 | ||
| 143 | + */ | ||
| 144 | + public static function getDaysToTargetDate($targetDateTime) | ||
| 145 | + { | ||
| 146 | + $currentTimestamp = time(); | ||
| 147 | + $targetTimestamp = strtotime($targetDateTime); | ||
| 148 | + $days = floor(($currentTimestamp - $targetTimestamp) / (60 * 60 * 24)); | ||
| 149 | + return (int)$days; | ||
| 150 | + } | ||
| 136 | } | 151 | } |
| @@ -223,3 +223,24 @@ if (!function_exists('getThisWeekStarDate')) { | @@ -223,3 +223,24 @@ if (!function_exists('getThisWeekStarDate')) { | ||
| 223 | return Carbon::now()->startOfWeek()->toDateString(); | 223 | return Carbon::now()->startOfWeek()->toDateString(); |
| 224 | } | 224 | } |
| 225 | } | 225 | } |
| 226 | + | ||
| 227 | +if (!function_exists('object_to_array')) { | ||
| 228 | + /** | ||
| 229 | + * 获取本周一的日期 | ||
| 230 | + * @return mixed | ||
| 231 | + * @author zbj | ||
| 232 | + * @date 2023/5/11 | ||
| 233 | + */ | ||
| 234 | + function object_to_array($data) | ||
| 235 | + { | ||
| 236 | + if(is_object($data)){ | ||
| 237 | + $data = (array)$data; | ||
| 238 | + }else{ | ||
| 239 | + foreach ($data as $k => $v){ | ||
| 240 | + $data[$k] = object_to_array($v); | ||
| 241 | + } | ||
| 242 | + } | ||
| 243 | + return $data; | ||
| 244 | + } | ||
| 245 | +} | ||
| 246 | + |
| @@ -127,53 +127,53 @@ class ComController extends BaseController | @@ -127,53 +127,53 @@ class ComController extends BaseController | ||
| 127 | * @method :post | 127 | * @method :post |
| 128 | * @time :2023/5/12 14:55 | 128 | * @time :2023/5/12 14:55 |
| 129 | */ | 129 | */ |
| 130 | -// protected function ceShi(){ | ||
| 131 | -// $this->error = 0; | ||
| 132 | -// //获取所有ayr_share用户 | ||
| 133 | -// $ayr_share_model = new AyrShareModel(); | ||
| 134 | -// $ayr_share_list = $ayr_share_model->list($this->map); | ||
| 135 | -// if(!empty($ayr_share_list)){ | ||
| 136 | -// foreach ($ayr_share_list as $k => $v){ | ||
| 137 | -// //查询当前用户是否有未推送的博文 | ||
| 138 | -// $ayr_release = new AyrReleaseModel(); | ||
| 139 | -// $release_info = $ayr_release->read(['schedule_date'=>['>',date('Y-m-d H:i:s',time())],'share_id'=>$v['id']]); | ||
| 140 | -// //有推文时,直接跳出循环 | ||
| 141 | -// if($release_info !== false){ | ||
| 142 | -// continue; | ||
| 143 | -// } | ||
| 144 | -// //查看用户是否在一周内有发送博客 | ||
| 145 | -// $start_at = Carbon::now()->modify('-7 days')->toDateString(); | ||
| 146 | -// $end_at = Carbon::now()->toDateString(); | ||
| 147 | -// $release_info = $ayr_release->read(['created_at'=>['between',[$start_at,$end_at]]]); | ||
| 148 | -// //有发送博文,则跳出循环 | ||
| 149 | -// if($release_info == false){ | ||
| 150 | -// continue; | ||
| 151 | -// } | ||
| 152 | -// //删除用户第三方配置 | ||
| 153 | -// $ayr_share_helper = new AyrShareHelper(); | ||
| 154 | -// $data_profiles = [ | ||
| 155 | -// 'title'=>$v['title'], | ||
| 156 | -// 'profileKey'=>$v['profile_key'] | ||
| 157 | -// ]; | ||
| 158 | -// $res = $ayr_share_helper->deleted_profiles($data_profiles); | ||
| 159 | -// if($res['status'] == 'fail'){ | ||
| 160 | -// $this->error++; | ||
| 161 | -// continue; | ||
| 162 | -// } | ||
| 163 | -// //更新数据库 | ||
| 164 | -// $data = [ | ||
| 165 | -// 'title'=>null, | ||
| 166 | -// 'bind_plat_from'=>null, | ||
| 167 | -// 'profile_key'=>null, | ||
| 168 | -// 'ref_id'=>null, | ||
| 169 | -// ]; | ||
| 170 | -// $res = $ayr_share_model->edit($data,['id'=>$v['id']]); | ||
| 171 | -// if($res == false){ | ||
| 172 | -// $this->error++; | ||
| 173 | -// } | ||
| 174 | -// } | ||
| 175 | -// } | ||
| 176 | -// return $this->error; | ||
| 177 | -// } | 130 | + protected function ceShi(){ |
| 131 | + $this->error = 0; | ||
| 132 | + //获取所有ayr_share用户 | ||
| 133 | + $ayr_share_model = new AyrShareModel(); | ||
| 134 | + $ayr_share_list = $ayr_share_model->list($this->map); | ||
| 135 | + if(!empty($ayr_share_list)){ | ||
| 136 | + foreach ($ayr_share_list as $k => $v){ | ||
| 137 | + //查询当前用户是否有未推送的博文 | ||
| 138 | + $ayr_release = new AyrReleaseModel(); | ||
| 139 | + $release_info = $ayr_release->read(['schedule_date'=>['>',date('Y-m-d H:i:s',time())],'share_id'=>$v['id']]); | ||
| 140 | + //有推文时,直接跳出循环 | ||
| 141 | + if($release_info !== false){ | ||
| 142 | + continue; | ||
| 143 | + } | ||
| 144 | + //查看用户是否在一周内有发送博客 | ||
| 145 | + $start_at = Carbon::now()->modify('-7 days')->toDateString(); | ||
| 146 | + $end_at = Carbon::now()->toDateString(); | ||
| 147 | + $release_info = $ayr_release->read(['created_at'=>['between',[$start_at,$end_at]]]); | ||
| 148 | + //有发送博文,则跳出循环 | ||
| 149 | + if($release_info == false){ | ||
| 150 | + continue; | ||
| 151 | + } | ||
| 152 | + //删除用户第三方配置 | ||
| 153 | + $ayr_share_helper = new AyrShareHelper(); | ||
| 154 | + $data_profiles = [ | ||
| 155 | + 'title'=>$v['title'], | ||
| 156 | + 'profileKey'=>$v['profile_key'] | ||
| 157 | + ]; | ||
| 158 | + $res = $ayr_share_helper->deleted_profiles($data_profiles); | ||
| 159 | + if($res['status'] == 'fail'){ | ||
| 160 | + $this->error++; | ||
| 161 | + continue; | ||
| 162 | + } | ||
| 163 | + //更新数据库 | ||
| 164 | + $data = [ | ||
| 165 | + 'title'=>null, | ||
| 166 | + 'bind_plat_from'=>null, | ||
| 167 | + 'profile_key'=>null, | ||
| 168 | + 'ref_id'=>null, | ||
| 169 | + ]; | ||
| 170 | + $res = $ayr_share_model->edit($data,['id'=>$v['id']]); | ||
| 171 | + if($res == false){ | ||
| 172 | + $this->error++; | ||
| 173 | + } | ||
| 174 | + } | ||
| 175 | + } | ||
| 176 | + return $this->error; | ||
| 177 | + } | ||
| 178 | 178 | ||
| 179 | } | 179 | } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Bside\HomeCount; | ||
| 4 | + | ||
| 5 | +use App\Enums\Common\Code; | ||
| 6 | +use App\Helper\Common; | ||
| 7 | +use App\Helper\FormGlobalsoApi; | ||
| 8 | +use App\Http\Controllers\Bside\BaseController; | ||
| 9 | +use App\Http\Logic\Bside\HomeCount\CountLogic; | ||
| 10 | +use App\Models\Project\DeployBuild; | ||
| 11 | +use Carbon\Carbon; | ||
| 12 | +use Illuminate\Support\Facades\DB; | ||
| 13 | + | ||
| 14 | +class CountController extends BaseController | ||
| 15 | +{ | ||
| 16 | + const STATUS_ERROR = 400; | ||
| 17 | + /** | ||
| 18 | + * @name :(昨日统计数据)yesterday_count | ||
| 19 | + * @author :lyh | ||
| 20 | + * @method :post | ||
| 21 | + * @time :2023/5/23 17:23 | ||
| 22 | + */ | ||
| 23 | + public function count(CountLogic $countLogic){ | ||
| 24 | + $data = []; | ||
| 25 | + //TODO::昨日数据统计 | ||
| 26 | + $data['yesterday'] = $countLogic->yesterday_count(); | ||
| 27 | + //TODO::全球搜方案信息 | ||
| 28 | + $data['scheme_info'] = $countLogic->scheme_info(); | ||
| 29 | + //TODO::网站访问量统计 | ||
| 30 | + $data['total_visit'] = $countLogic->total_count($data['yesterday']['inquiry_num']); | ||
| 31 | + //TODO::关键字排名数据 | ||
| 32 | + $data['keyword_data'] = $countLogic->keyword_data_count(); | ||
| 33 | + //TODO::相关数据统计 | ||
| 34 | + $data['with_data'] = $countLogic->with_data_count(); | ||
| 35 | + //TODO::30天pv,ip统计 | ||
| 36 | + $data['visit_data'] = $countLogic->visit_data_count(); | ||
| 37 | + //TODO::询盘国家统计 | ||
| 38 | + $data['country_data'] = $countLogic->inquiry_country_count(); | ||
| 39 | + //TODO::来源排名 | ||
| 40 | + $data['country_data'] = $countLogic->referrer_count(); | ||
| 41 | + //TODO::访问国家前10 | ||
| 42 | + $data['access_country_count'] = $countLogic->access_country_count(); | ||
| 43 | + return $this->response('success',Code::SUCCESS,$data); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + /*** | ||
| 47 | + * @name :(手动获取昨日数据统计)yesterday | ||
| 48 | + * @author :lyh | ||
| 49 | + * @method :post | ||
| 50 | + * @time :2023/5/24 9:13 | ||
| 51 | + */ | ||
| 52 | + public function yesterday(){ | ||
| 53 | + $deployModel = new DeployBuild(); | ||
| 54 | + $list = $deployModel->list(); | ||
| 55 | + $data = []; | ||
| 56 | + $yesterday = Carbon::yesterday()->toDateString(); | ||
| 57 | + foreach ($list as $v){ | ||
| 58 | + $arr = []; | ||
| 59 | + $arr['yesterday_pv_num'] = DB::table('gl_customer_visit_item')->whereDate('date', $yesterday)->where('domain',$v['test_domain'])->count(); | ||
| 60 | + $arr['yesterday_ip_num'] = DB::table('gl_customer_visit')->whereDate('date', $yesterday)->where('domain',$v['test_domain'])->count(); | ||
| 61 | + $inquiry_list = (new FormGlobalsoApi())->getInquiryList($v['test_domain']); | ||
| 62 | + if($inquiry_list['status'] == self::STATUS_ERROR){ | ||
| 63 | + $arr['inquiry_num'] = 0; | ||
| 64 | + }else{ | ||
| 65 | + $arr['inquiry_num'] = count($inquiry_list['data']['total']); | ||
| 66 | + } | ||
| 67 | + $arr['date'] = $yesterday; | ||
| 68 | + $rank_info = DB::table('gl_rank_data')->where(['updated_date'=>$yesterday,'lang'=>''])->select(['compliance_day'])->first(); | ||
| 69 | + if(empty($rank_info)){ | ||
| 70 | + $arr['compliance_day'] = 0; | ||
| 71 | + }else{ | ||
| 72 | + $arr['compliance_day'] = $rank_info->compliance_day; | ||
| 73 | + } | ||
| 74 | + $arr['service_day'] = $v['service_duration'] - Common::getDaysToTargetDate($v['created_at']); | ||
| 75 | + $arr['project_id'] = $v['project_id']; | ||
| 76 | + $arr['created_at'] = date('Y-m-d H:i:s'); | ||
| 77 | + $arr['updated_at'] = date('Y-m-d H:i:s'); | ||
| 78 | + $data[] = $arr; | ||
| 79 | + } | ||
| 80 | + DB::table('gl_count')->insert($data); | ||
| 81 | + $this->response('success'); | ||
| 82 | + } | ||
| 83 | +} |
| @@ -25,13 +25,7 @@ class CategoryController extends BaseController | @@ -25,13 +25,7 @@ class CategoryController extends BaseController | ||
| 25 | $map[] = ['title', 'like', "%{$this->param['search']}%"]; | 25 | $map[] = ['title', 'like', "%{$this->param['search']}%"]; |
| 26 | } | 26 | } |
| 27 | $sort = ['id' => 'desc']; | 27 | $sort = ['id' => 'desc']; |
| 28 | - $data = $logic->getList($map, $sort, ['id', 'pid', 'title', 'image', 'keywords', 'describe', 'status','created_at'],0); | ||
| 29 | - foreach ($data as &$v){ | ||
| 30 | - $v['product_num'] = $logic->getProductNum($v['id']); | ||
| 31 | - } | ||
| 32 | - if(!$map){ | ||
| 33 | - $data = Arr::listToTree($data); | ||
| 34 | - } | 28 | + $data = $logic->getList($map, $sort, ['id', 'project_id', 'pid', 'title', 'image', 'keywords', 'describe', 'status','created_at'],0); |
| 35 | return $this->success($data); | 29 | return $this->success($data); |
| 36 | } | 30 | } |
| 37 | 31 | ||
| @@ -42,7 +36,7 @@ class CategoryController extends BaseController | @@ -42,7 +36,7 @@ class CategoryController extends BaseController | ||
| 42 | 'id.required' => 'ID不能为空' | 36 | 'id.required' => 'ID不能为空' |
| 43 | ]); | 37 | ]); |
| 44 | $data = $logic->getInfo($this->param['id']); | 38 | $data = $logic->getInfo($this->param['id']); |
| 45 | - return $this->success(Arr::twoKeepKeys($data, ['id', 'pid', 'title', 'image', 'keywords', 'describe', 'status'])); | 39 | + return $this->success(Arr::twoKeepKeys($data, ['id', 'project_id', 'pid', 'title', 'image', 'keywords', 'describe', 'status', 'route', 'url'])); |
| 46 | } | 40 | } |
| 47 | 41 | ||
| 48 | public function save(CategoryRequest $request, CategoryLogic $logic) | 42 | public function save(CategoryRequest $request, CategoryLogic $logic) |
| @@ -26,13 +26,7 @@ class KeywordController extends BaseController | @@ -26,13 +26,7 @@ class KeywordController extends BaseController | ||
| 26 | $map[] = ['title', 'like', "%{$this->param['search']}%"]; | 26 | $map[] = ['title', 'like', "%{$this->param['search']}%"]; |
| 27 | } | 27 | } |
| 28 | $sort = ['id' => 'desc']; | 28 | $sort = ['id' => 'desc']; |
| 29 | - $data = $logic->getList($map, $sort, ['id', 'title', 'seo_title', 'seo_keywords', 'seo_description', 'status', 'created_at']); | ||
| 30 | - foreach ($data['list'] as &$v){ | ||
| 31 | - $v['product_num'] = $logic->getProductNum($v['id']); | ||
| 32 | - $v['tdk'] = boolval($v['seo_title']) * boolval($v['seo_keywords']) * boolval($v['seo_description']); | ||
| 33 | - //todo 获取域名 拼接链接 | ||
| 34 | - $v['url'] = $v['route']; | ||
| 35 | - } | 29 | + $data = $logic->getList($map, $sort, ['id', 'project_id', 'title', 'seo_title', 'seo_keywords', 'seo_description', 'status', 'created_at']); |
| 36 | return $this->success($data); | 30 | return $this->success($data); |
| 37 | } | 31 | } |
| 38 | 32 | ||
| @@ -43,7 +37,7 @@ class KeywordController extends BaseController | @@ -43,7 +37,7 @@ class KeywordController extends BaseController | ||
| 43 | 'id.required' => 'ID不能为空' | 37 | 'id.required' => 'ID不能为空' |
| 44 | ]); | 38 | ]); |
| 45 | $data = $logic->getInfo($this->param['id']); | 39 | $data = $logic->getInfo($this->param['id']); |
| 46 | - return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'seo_title', 'seo_keywords', 'seo_description', 'created_at'])); | 40 | + return $this->success(Arr::twoKeepKeys($data, ['id', 'project_id', 'title', 'seo_title', 'seo_keywords', 'seo_description', 'created_at', 'route', 'url'])); |
| 47 | } | 41 | } |
| 48 | 42 | ||
| 49 | public function save(KeywordRequest $request, KeywordLogic $logic) | 43 | public function save(KeywordRequest $request, KeywordLogic $logic) |
| @@ -55,7 +55,7 @@ class ProductController extends BaseController | @@ -55,7 +55,7 @@ class ProductController extends BaseController | ||
| 55 | $map[] = ['status', $this->param['status']]; | 55 | $map[] = ['status', $this->param['status']]; |
| 56 | } | 56 | } |
| 57 | $sort = ['id' => 'desc']; | 57 | $sort = ['id' => 'desc']; |
| 58 | - $data = $logic->getList($map, $sort, ['id', 'title', 'thumb', 'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at']); | 58 | + $data = $logic->getList($map, $sort, ['id', 'project_id', 'title', 'thumb', 'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at']); |
| 59 | return $this->success($data); | 59 | return $this->success($data); |
| 60 | } | 60 | } |
| 61 | 61 | ||
| @@ -66,8 +66,8 @@ class ProductController extends BaseController | @@ -66,8 +66,8 @@ class ProductController extends BaseController | ||
| 66 | 'id.required' => 'ID不能为空' | 66 | 'id.required' => 'ID不能为空' |
| 67 | ]); | 67 | ]); |
| 68 | $data = $logic->getInfo($this->param['id']); | 68 | $data = $logic->getInfo($this->param['id']); |
| 69 | - return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'gallery', 'attrs', 'category_id', 'keyword_id', 'attr_id', 'describe_id', 'intro', 'content', | ||
| 70 | - 'describe', 'seo_mate', 'related_product_id', 'status', 'category_id_text', 'keyword_id_text', 'status_text', 'created_uid', 'created_uid_text', 'route'])); | 69 | + return $this->success(Arr::twoKeepKeys($data, ['id', 'project_id', 'title', 'gallery', 'attrs', 'category_id', 'keyword_id', 'attr_id', 'describe_id', 'intro', 'content', |
| 70 | + 'describe', 'seo_mate', 'related_product_id', 'status', 'category_id_text', 'keyword_id_text', 'status_text', 'created_uid', 'created_uid_text', 'route', 'url'])); | ||
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | public function save(ProductRequest $request, ProductLogic $logic) | 73 | public function save(ProductRequest $request, ProductLogic $logic) |
| @@ -77,10 +77,8 @@ class RankDataController extends BaseController | @@ -77,10 +77,8 @@ class RankDataController extends BaseController | ||
| 77 | public function export(RankDataLogic $logic){ | 77 | public function export(RankDataLogic $logic){ |
| 78 | $lang = $this->request['lang'] ??''; | 78 | $lang = $this->request['lang'] ??''; |
| 79 | $data = $logic->keywords_rank_list(true); | 79 | $data = $logic->keywords_rank_list(true); |
| 80 | - | ||
| 81 | $img_position = $video_position= false; | 80 | $img_position = $video_position= false; |
| 82 | foreach ($data as &$item){ | 81 | foreach ($data as &$item){ |
| 83 | - $item['domain'] = explode(':', $item['domain'])[1]; | ||
| 84 | $item['lang'] = $this->request['lang'] ?: 'en'; | 82 | $item['lang'] = $this->request['lang'] ?: 'en'; |
| 85 | $item['g_text'] = RankData::gMap()[$item['g']]??''; | 83 | $item['g_text'] = RankData::gMap()[$item['g']]??''; |
| 86 | $item['img_position'] = $item['img_position'] ?? ''; | 84 | $item['img_position'] = $item['img_position'] ?? ''; |
| @@ -88,10 +86,10 @@ class RankDataController extends BaseController | @@ -88,10 +86,10 @@ class RankDataController extends BaseController | ||
| 88 | foreach ($item['position'] as $date => $position){ | 86 | foreach ($item['position'] as $date => $position){ |
| 89 | $item[$date] = $position; | 87 | $item[$date] = $position; |
| 90 | } | 88 | } |
| 91 | - if(isset($item['img_position'])){ | 89 | + if(!empty($item['img_position'])){ |
| 92 | $img_position = true; | 90 | $img_position = true; |
| 93 | } | 91 | } |
| 94 | - if(isset($item['video_position'])){ | 92 | + if(!empty($item['video_position'])){ |
| 95 | $video_position = true; | 93 | $video_position = true; |
| 96 | } | 94 | } |
| 97 | } | 95 | } |
| @@ -199,7 +197,7 @@ class RankDataController extends BaseController | @@ -199,7 +197,7 @@ class RankDataController extends BaseController | ||
| 199 | $promises['video_position'] = $client->getAsync('/google_video?'.Arr::query($param)); | 197 | $promises['video_position'] = $client->getAsync('/google_video?'.Arr::query($param)); |
| 200 | 198 | ||
| 201 | // 等待所有请求响应完成 | 199 | // 等待所有请求响应完成 |
| 202 | - $results = Utils:: settle($promises)->wait(); | 200 | + $results = Utils::settle($promises)->wait(); |
| 203 | foreach ($results as $key => $result) { | 201 | foreach ($results as $key => $result) { |
| 204 | if ($result['state'] == 'fulfilled') { | 202 | if ($result['state'] == 'fulfilled') { |
| 205 | $res = Arr::s2a($result['value']->getBody()->getContents()); | 203 | $res = Arr::s2a($result['value']->getBody()->getContents()); |
| @@ -122,8 +122,90 @@ class TemplateController extends BaseController | @@ -122,8 +122,90 @@ class TemplateController extends BaseController | ||
| 122 | 122 | ||
| 123 | $data = TemplateLogic::instance()->first($source,$source_id); | 123 | $data = TemplateLogic::instance()->first($source,$source_id); |
| 124 | 124 | ||
| 125 | - | ||
| 126 | - return $this->response('',Code::SUCCESS,$data['html']); | 125 | + $def = '<div class=" d-flex align-items-center justify-content-between py-md-4"> |
| 126 | + <div class="logo w-25 w-sm-auto"><a href="#"><img class="img-fluid" src="img/logo.png" alt=""></a></div> | ||
| 127 | + <nav class="navbar navbar-expand-md navbar-dark flex-fill justify-content-end mx-2 pe-md-5"> | ||
| 128 | + <button class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#navMenu" | ||
| 129 | + aria-controls="navMenu"> | ||
| 130 | + <span class="navbar-toggler-icon"></span> | ||
| 131 | + </button> | ||
| 132 | + <ul class="nav column-gap-5 justify-content-end text-white d-none d-md-flex"> | ||
| 133 | + <li><a href="#">Home</a></li> | ||
| 134 | + <li class="dropdown"> | ||
| 135 | + <a href="#" class="dropdown-toggle" data-bs-toggle="dropdown">Products</a> | ||
| 136 | + <ul class="dropdown-menu fs-6 text-body shadow-sm border-0"> | ||
| 137 | + <li><a href="#" class="dropdown-item py-2">Product Information</a></li> | ||
| 138 | + <li><a href="#" class="dropdown-item py-2">Change of Insurance</a></li> | ||
| 139 | + <li><a href="#" class="dropdown-item py-2">Traveling Oxygen Program</a></li> | ||
| 140 | + <li><a href="#" class="dropdown-item py-2">Contact</a></li> | ||
| 141 | + </ul> | ||
| 142 | + </li> | ||
| 143 | + <li><a href="#">News</a></li> | ||
| 144 | + <li><a href="#">Download</a></li> | ||
| 145 | + <li><a href="#">FAQ</a></li> | ||
| 146 | + <li><a href="#">Contact</a></li> | ||
| 147 | + </ul> | ||
| 148 | + </nav> | ||
| 149 | + <div class="d-flex align-items-center justify-content-end"> | ||
| 150 | + <div class="search"> | ||
| 151 | + <button type="button" class="btn border-0" data-bs-toggle="dropdown"> | ||
| 152 | + <svg viewBox="0 0 24 24" width="18" height="18" stroke="#ffffff" stroke-width="2" | ||
| 153 | + fill="none" stroke-linecap="round" stroke-linejoin="round" class="css-i6dzq1"> | ||
| 154 | + <circle cx="11" cy="11" r="8"></circle> | ||
| 155 | + <line x1="21" y1="21" x2="16.65" y2="16.65"></line> | ||
| 156 | + </svg> | ||
| 157 | + </button> | ||
| 158 | + <div class="dropdown-menu p-3 shadow-sm border-0"> | ||
| 159 | + <form action=""> | ||
| 160 | + <div class="d-flex mb-2"> | ||
| 161 | + <input type="text" class="form-control" name="search" placeholder="Start Typing..."> | ||
| 162 | + <button class="btn btn-search border-0" type="submit"> | ||
| 163 | + <svg viewBox="0 0 24 24" width="18" height="18" stroke="#333333" | ||
| 164 | + stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round" | ||
| 165 | + class="css-i6dzq1"> | ||
| 166 | + <circle cx="11" cy="11" r="8"></circle> | ||
| 167 | + <line x1="21" y1="21" x2="16.65" y2="16.65"></line> | ||
| 168 | + </svg> | ||
| 169 | + </button> | ||
| 170 | + </div> | ||
| 171 | + <p class="search-attr">Hit enter to search or ESC to close</p> | ||
| 172 | + </form> | ||
| 173 | + </div> | ||
| 174 | + </div> | ||
| 175 | + <div class="change-language ms-md-4"> | ||
| 176 | + <div role="button" class="dropdown-toggle text-white d-flex align-items-center" | ||
| 177 | + data-bs-toggle="dropdown"> | ||
| 178 | + <b class="country-flag language-flag-en"></b> <span>English</span> | ||
| 179 | + </div> | ||
| 180 | + <div class="dropdown-menu shadow-sm border-0"> | ||
| 181 | + <div class="d-flex flex-wrap p-3 text-body"> | ||
| 182 | + <a href="#" class="col-4 mb-3 pe-2 d-flex align-items-center" title="English"> | ||
| 183 | + <b class="country-flag language-flag-en"></b> | ||
| 184 | + <span>English</span> | ||
| 185 | + </a> | ||
| 186 | + <a href="#" class="col-4 mb-3 pe-2 d-flex align-items-center" title="Françai"> | ||
| 187 | + <b class="country-flag language-flag-fr"></b> | ||
| 188 | + <span>Françai</span> | ||
| 189 | + </a> | ||
| 190 | + <a href="#" class="col-4 mb-3 pe-2 d-flex align-items-center" title="Español"> | ||
| 191 | + <b class="country-flag language-flag-es"></b> | ||
| 192 | + <span>Español</span> | ||
| 193 | + </a> | ||
| 194 | + <a href="#" class="col-4 mb-3 pe-2 d-flex align-items-center" title="Deutsch"> | ||
| 195 | + <b class="country-flag language-flag-de"></b> | ||
| 196 | + <span>Deutsch</span> | ||
| 197 | + </a> | ||
| 198 | + <a href="#" class="col-4 mb-3 pe-2 d-flex align-items-center" title="Română"> | ||
| 199 | + <b class="country-flag language-flag-ro"></b> | ||
| 200 | + <span>Română</span> | ||
| 201 | + </a> | ||
| 202 | + </div> | ||
| 203 | + </div> | ||
| 204 | + </div> | ||
| 205 | + </div> | ||
| 206 | + </div>'; | ||
| 207 | + | ||
| 208 | + return $this->response('',Code::SUCCESS,$data?$data['html']:$def); | ||
| 127 | 209 | ||
| 128 | } | 210 | } |
| 129 | 211 | ||
| @@ -174,33 +256,33 @@ class TemplateController extends BaseController | @@ -174,33 +256,33 @@ class TemplateController extends BaseController | ||
| 174 | * @time 2023/5/10 14:55 | 256 | * @time 2023/5/10 14:55 |
| 175 | */ | 257 | */ |
| 176 | public function customChunk(){ | 258 | public function customChunk(){ |
| 177 | - | ||
| 178 | - $html = $this->param['html']??[]; | ||
| 179 | - // 那个页面 的 | ||
| 180 | - $type = $this->param['type']??''; | ||
| 181 | - | ||
| 182 | - if(!is_array($html)){ | ||
| 183 | - return $this->response('参数异常',Code::SYSTEM_ERROR); | ||
| 184 | - } | ||
| 185 | - | ||
| 186 | - // 项目id | ||
| 187 | - $project_id = $this->user['project_id']; | ||
| 188 | - // 当前模板 | ||
| 189 | - $template_id = BSetting::_get($project_id)['template_id']; | ||
| 190 | - | ||
| 191 | - // 验证这个模板是否存在 | ||
| 192 | - if(!$type || !ATemplateHtml::_typeExist($template_id,$type)){ | ||
| 193 | - return $this->response('页面类型错误',Code::SYSTEM_ERROR); | ||
| 194 | - } | ||
| 195 | - | ||
| 196 | - | ||
| 197 | - $html = view("template.{$template_id}.{$type}")->render(); | ||
| 198 | - | ||
| 199 | - | ||
| 200 | - return $this->response('',Code::SUCCESS,$html); | ||
| 201 | -// $data = BTemplateData::_insert(); | ||
| 202 | - | ||
| 203 | - | 259 | +// |
| 260 | +// $html = $this->param['html']??[]; | ||
| 261 | +// // 那个页面 的 | ||
| 262 | +// $type = $this->param['type']??''; | ||
| 263 | +// | ||
| 264 | +// if(!is_array($html)){ | ||
| 265 | +// return $this->response('参数异常',Code::SYSTEM_ERROR); | ||
| 266 | +// } | ||
| 267 | +// | ||
| 268 | +// // 项目id | ||
| 269 | +// $project_id = $this->user['project_id']; | ||
| 270 | +// // 当前模板 | ||
| 271 | +// $template_id = BSetting::_get($project_id)['template_id']; | ||
| 272 | +// | ||
| 273 | +// // 验证这个模板是否存在 | ||
| 274 | +// if(!$type || !ATemplateHtml::_typeExist($template_id,$type)){ | ||
| 275 | +// return $this->response('页面类型错误',Code::SYSTEM_ERROR); | ||
| 276 | +// } | ||
| 277 | +// | ||
| 278 | +// | ||
| 279 | +// $html = view("template.{$template_id}.{$type}")->render(); | ||
| 280 | +// | ||
| 281 | +// | ||
| 282 | +// return $this->response('',Code::SUCCESS,$html); | ||
| 283 | +//// $data = BTemplateData::_insert(); | ||
| 284 | +// | ||
| 285 | +// | ||
| 204 | 286 | ||
| 205 | 287 | ||
| 206 | } | 288 | } |
| @@ -25,9 +25,6 @@ class UserController extends BaseController | @@ -25,9 +25,6 @@ class UserController extends BaseController | ||
| 25 | //TODO::搜索参数统一处理 | 25 | //TODO::搜索参数统一处理 |
| 26 | $this->map['project_id'] = $this->user['project_id']; | 26 | $this->map['project_id'] = $this->user['project_id']; |
| 27 | $lists = $userModel->lists($this->map,$this->page,$this->row,$this->order,['id','name','mobile','created_at','wechat','status']); | 27 | $lists = $userModel->lists($this->map,$this->page,$this->row,$this->order,['id','name','mobile','created_at','wechat','status']); |
| 28 | - if(empty($lists)){ | ||
| 29 | - $this->response('error',Code::USER_ERROR,[]); | ||
| 30 | - } | ||
| 31 | $this->response('success',Code::SUCCESS,$lists); | 28 | $this->response('success',Code::SUCCESS,$lists); |
| 32 | } | 29 | } |
| 33 | 30 |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Bside; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +use App\Http\Logic\Bside\VisitLogic; | ||
| 7 | +use Illuminate\Http\Request; | ||
| 8 | + | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 访问明细 | ||
| 12 | + * Class VisitController | ||
| 13 | + * @package App\Http\Controllers\Bside | ||
| 14 | + * @author zbj | ||
| 15 | + * @date 2023/5/22 | ||
| 16 | + */ | ||
| 17 | +class VisitController extends BaseController | ||
| 18 | +{ | ||
| 19 | + | ||
| 20 | + public function index(VisitLogic $logic) | ||
| 21 | + { | ||
| 22 | + $data = $logic->getList(); | ||
| 23 | + return $this->success($data); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + public function item(Request $request, VisitLogic $logic){ | ||
| 27 | + $request->validate([ | ||
| 28 | + 'id'=>'required' | ||
| 29 | + ],[ | ||
| 30 | + 'id.required' => 'ID不能为空' | ||
| 31 | + ]); | ||
| 32 | + $map = [ | ||
| 33 | + ['customer_visit_id' => $this->param['id']] | ||
| 34 | + ]; | ||
| 35 | + $data = $logic->getItemList($map); | ||
| 36 | + return $this->success($data); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | +} |
| @@ -40,7 +40,9 @@ class AyrReleaseLogic extends BaseLogic | @@ -40,7 +40,9 @@ class AyrReleaseLogic extends BaseLogic | ||
| 40 | public function release_add(){ | 40 | public function release_add(){ |
| 41 | $this->param['project_id'] = $this->user['project_id']; | 41 | $this->param['project_id'] = $this->user['project_id']; |
| 42 | $this->param['operator_id'] = $this->user['id']; | 42 | $this->param['operator_id'] = $this->user['id']; |
| 43 | - $this->param['images'] = implode(',',$this->param['images']); | 43 | + if(isset($this->param['images']) && !empty($this->param['images'])){ |
| 44 | + $this->param['images'] = implode(',',$this->param['images']); | ||
| 45 | + } | ||
| 44 | $this->param['platforms'] = json_encode($this->param['platforms']); | 46 | $this->param['platforms'] = json_encode($this->param['platforms']); |
| 45 | $rs = $this->model->add($this->param); | 47 | $rs = $this->model->add($this->param); |
| 46 | if($rs === false){ | 48 | if($rs === false){ |
| @@ -213,9 +213,11 @@ class AyrShareLogic extends BaseLogic | @@ -213,9 +213,11 @@ class AyrShareLogic extends BaseLogic | ||
| 213 | $this->fail('不支持视频'); | 213 | $this->fail('不支持视频'); |
| 214 | } | 214 | } |
| 215 | //验证图片数 | 215 | //验证图片数 |
| 216 | - $img_num = count($this->param['images']); | ||
| 217 | - if($img_num > $this->send_num[$v]){ | ||
| 218 | - $this->fail('发布图片数量超过最大限制,'.$v.'只允许'.$this->send_num[$v].'张图'); | 216 | + if(isset($this->param['images']) && !empty($this->param['images'])){ |
| 217 | + $img_num = count($this->param['images']); | ||
| 218 | + if($img_num > $this->send_num[$v]){ | ||
| 219 | + $this->fail('发布图片数量超过最大限制,'.$v.'只允许'.$this->send_num[$v].'张图'); | ||
| 220 | + } | ||
| 219 | } | 221 | } |
| 220 | //验证图片数 | 222 | //验证图片数 |
| 221 | // $img_num = count($this->param['video']); | 223 | // $img_num = count($this->param['video']); |
| @@ -7,6 +7,7 @@ use App\Enums\Common\Code; | @@ -7,6 +7,7 @@ use App\Enums\Common\Code; | ||
| 7 | use App\Enums\Common\Common; | 7 | use App\Enums\Common\Common; |
| 8 | use App\Exceptions\BsideGlobalException; | 8 | use App\Exceptions\BsideGlobalException; |
| 9 | use App\Http\Controllers\File\ImageController; | 9 | use App\Http\Controllers\File\ImageController; |
| 10 | +use App\Http\Logic\Aside\Project\ProjectLogic; | ||
| 10 | use App\Http\Logic\Logic; | 11 | use App\Http\Logic\Logic; |
| 11 | use App\Models\File\Image as ImageModel; | 12 | use App\Models\File\Image as ImageModel; |
| 12 | use Illuminate\Support\Facades\Cache; | 13 | use Illuminate\Support\Facades\Cache; |
| @@ -25,6 +26,8 @@ class BaseLogic extends Logic | @@ -25,6 +26,8 @@ class BaseLogic extends Logic | ||
| 25 | 26 | ||
| 26 | protected $user; | 27 | protected $user; |
| 27 | 28 | ||
| 29 | + protected $project; | ||
| 30 | + | ||
| 28 | protected $side = Common::B; | 31 | protected $side = Common::B; |
| 29 | 32 | ||
| 30 | public function __construct() | 33 | public function __construct() |
| @@ -32,6 +35,7 @@ class BaseLogic extends Logic | @@ -32,6 +35,7 @@ class BaseLogic extends Logic | ||
| 32 | $this->request = request(); | 35 | $this->request = request(); |
| 33 | $this->requestAll = request()->all(); | 36 | $this->requestAll = request()->all(); |
| 34 | $this->user = Cache::get(request()->header('token')); | 37 | $this->user = Cache::get(request()->header('token')); |
| 38 | + $this->project = (new ProjectLogic())->getInfo($this->user['project_id']); | ||
| 35 | } | 39 | } |
| 36 | 40 | ||
| 37 | 41 | ||
| @@ -152,4 +156,14 @@ class BaseLogic extends Logic | @@ -152,4 +156,14 @@ class BaseLogic extends Logic | ||
| 152 | } | 156 | } |
| 153 | return $rs; | 157 | return $rs; |
| 154 | } | 158 | } |
| 159 | + | ||
| 160 | + public function getProjectDomain(){ | ||
| 161 | + if(!empty($this->project['deploy_optimize']['domain'])){ | ||
| 162 | + return $this->project['deploy_optimize']['domain']; | ||
| 163 | + } | ||
| 164 | + if(!empty($this->project['deploy_build']['test_domain'])){ | ||
| 165 | + return $this->project['deploy_build']['test_domain']; | ||
| 166 | + } | ||
| 167 | + return ''; | ||
| 168 | + } | ||
| 155 | } | 169 | } |
| @@ -34,15 +34,12 @@ class CustomLogic extends BaseLogic | @@ -34,15 +34,12 @@ class CustomLogic extends BaseLogic | ||
| 34 | */ | 34 | */ |
| 35 | public function save($param) | 35 | public function save($param) |
| 36 | { | 36 | { |
| 37 | + $param['html'] = ''; | ||
| 38 | + | ||
| 37 | $id = parent::save($param); | 39 | $id = parent::save($param); |
| 38 | 40 | ||
| 39 | $data = $this->getInfo($id['id']); | 41 | $data = $this->getInfo($id['id']); |
| 40 | 42 | ||
| 41 | - try { | ||
| 42 | - RouteMap::setRoute($data['url'],RouteMap::SOURCE_CUSTOM,$data['id'],$this->user['project_id']); | ||
| 43 | - }catch (\Throwable $e){ | ||
| 44 | - | ||
| 45 | - } | ||
| 46 | 43 | ||
| 47 | return $data; | 44 | return $data; |
| 48 | } | 45 | } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Logic\Bside\HomeCount; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +use App\Http\Logic\Bside\BaseLogic; | ||
| 7 | +use App\Models\HomeCount\Count; | ||
| 8 | +use App\Models\RankData\RankData as RankDataModel; | ||
| 9 | +use Carbon\Carbon; | ||
| 10 | +use Illuminate\Support\Facades\DB; | ||
| 11 | + | ||
| 12 | +class CountLogic extends BaseLogic | ||
| 13 | +{ | ||
| 14 | + public function __construct() | ||
| 15 | + { | ||
| 16 | + parent::__construct(); | ||
| 17 | + $this->model = new Count(); | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * @name :(昨日统计数据)yesterday_count | ||
| 22 | + * @author :lyh | ||
| 23 | + * @method :post | ||
| 24 | + * @time :2023/5/23 17:30 | ||
| 25 | + */ | ||
| 26 | + public function yesterday_count(){ | ||
| 27 | + $yesterday = Carbon::yesterday()->toDateString(); | ||
| 28 | + $param = [ | ||
| 29 | + 'date' => $yesterday, | ||
| 30 | + 'project_id' => $this->user['project_id'] | ||
| 31 | + ]; | ||
| 32 | + $info = $this->model->read($param,['pv_num','ip_num','inquiry_num','date','compliance_day','service_day']); | ||
| 33 | + return $this->success($info); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * @name :(方案信息)scheme_info | ||
| 38 | + * @author :lyh | ||
| 39 | + * @method :post | ||
| 40 | + * @time :2023/5/24 11:48 | ||
| 41 | + */ | ||
| 42 | + public function scheme_info(){ | ||
| 43 | + $data = [ | ||
| 44 | + 'company'=>$this->project['company'], | ||
| 45 | + 'scheme'=>$this->project['deploy_build']['plan'], | ||
| 46 | + 'service_duration'=>$this->project['deploy_build']['service_duration'], | ||
| 47 | + ]; | ||
| 48 | + return $this->success($data); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * @name :(总访问量)total_count | ||
| 53 | + * @author :lyh | ||
| 54 | + * @method :post | ||
| 55 | + * @time :2023/5/24 13:33 | ||
| 56 | + */ | ||
| 57 | + public function total_count($inquiry_num){ | ||
| 58 | + $pv = DB::table('gl_customer_visit_item')->where(['domain'=>$this->project['deploy_build']['test_domain']])->count(); | ||
| 59 | + $ip = DB::table('gl_customer_visit')->where(['domain'=>$this->project['deploy_build']['test_domain']])->count(); | ||
| 60 | + $data = [ | ||
| 61 | + 'total_pv'=>$pv, | ||
| 62 | + 'total_ip'=>$ip, | ||
| 63 | + 'conversion_rate' => ($inquiry_num / $ip) * 100, | ||
| 64 | + ]; | ||
| 65 | + return $this->success($data); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + /** | ||
| 69 | + * @name :(前一天关键字排名统计)keyword_data | ||
| 70 | + * @author :lyh | ||
| 71 | + * @method :post | ||
| 72 | + * @time :2023/5/24 14:03 | ||
| 73 | + */ | ||
| 74 | + public function keyword_data_count(){ | ||
| 75 | + $yesterday = Carbon::yesterday()->toDateString(); | ||
| 76 | + $rankDataModel = new RankDataModel(); | ||
| 77 | + $param = [ | ||
| 78 | + 'updated_date' => $yesterday, | ||
| 79 | + 'project_id' => $this->user['project_id'] | ||
| 80 | + ]; | ||
| 81 | + $data = $rankDataModel->read($param,['first_num','first_page_num','first_three_pages_num','first_five_pages_num','first_ten_pages_num']); | ||
| 82 | + return $this->success($data); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + /** | ||
| 86 | + * @name :(相关数据统计)with_data_count | ||
| 87 | + * @author :lyh | ||
| 88 | + * @method :post | ||
| 89 | + * @time :2023/5/24 14:12 | ||
| 90 | + */ | ||
| 91 | + public function with_data_count(){ | ||
| 92 | + $product_count = DB::table('gl_product')->where(['project_id' => $this->user['project_id']])->count(); | ||
| 93 | + $news_count = DB::table('gl_news')->where(['project_id' => $this->user['project_id']])->count(); | ||
| 94 | + $page_count = DB::table('gl_web_template')->where(['project_id' => $this->user['project_id']])->count(); | ||
| 95 | + $data = [ | ||
| 96 | + 'product_count' => $product_count, | ||
| 97 | + 'news_count' => $news_count, | ||
| 98 | + 'page_count' => $page_count, | ||
| 99 | + ]; | ||
| 100 | + return $this->success($data); | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + /** | ||
| 104 | + * @name :(30天数据统计)visit_data_count | ||
| 105 | + * @author :lyh | ||
| 106 | + * @method :post | ||
| 107 | + * @time :2023/5/24 14:18 | ||
| 108 | + */ | ||
| 109 | + public function visit_data_count(){ | ||
| 110 | + $param = [ | ||
| 111 | + 'date' => ['between',[now()->subDays(30)->startOfDay()->toDateString(),now()->startOfDay()->toDateString()]], | ||
| 112 | + 'project_id' => $this->user['project_id'] | ||
| 113 | + ]; | ||
| 114 | + $data = $this->model->list($param,'id',['id','pv_num','ip_num','date']); | ||
| 115 | + return $this->success($data); | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + /** | ||
| 119 | + * @name :(询盘国家统计)inquiry_country_count | ||
| 120 | + * @author :lyh | ||
| 121 | + * @method :post | ||
| 122 | + * @time :2023/5/24 14:58 | ||
| 123 | + */ | ||
| 124 | + public function inquiry_country_count(){ | ||
| 125 | + $data = DB::table('gl_xunpan_ipdata') | ||
| 126 | + ->select('ip_area', DB::raw('COUNT(ip_area) as count')) | ||
| 127 | + ->groupBy('ip_area')->orderBy('count','desc')->limit(20)->get()->toArray(); | ||
| 128 | + $data = object_to_array($data); | ||
| 129 | + $total = DB::table('gl_xunpan_ipdata')->count(); | ||
| 130 | + foreach ($data as $k=>$v){ | ||
| 131 | + $data[$k]['proportion'] = ($v['count']/$total) * 100; | ||
| 132 | + } | ||
| 133 | + return $this->success($data); | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + /** | ||
| 137 | + * @name :(访问来源统计)referrer_count | ||
| 138 | + * @author :lyh | ||
| 139 | + * @method :post | ||
| 140 | + * @time :2023/5/24 15:32 | ||
| 141 | + */ | ||
| 142 | + public function referrer_count(){ | ||
| 143 | + $data = DB::table('gl_customer_visit') | ||
| 144 | + ->select('referrer_url', DB::raw('COUNT(*) as count'))->groupBy('referrer_url') | ||
| 145 | + ->orderBy('count','desc')->limit(8)->get()->toArray(); | ||
| 146 | + $total = DB::table('gl_customer_visit')->count(); | ||
| 147 | + $data = object_to_array($data); | ||
| 148 | + foreach ($data as $k=>$v){ | ||
| 149 | + $data[$k]['proportion'] = ($v['count']/$total) * 100; | ||
| 150 | + } | ||
| 151 | + return $this->success($data); | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + /** | ||
| 155 | + * @name :(访问国家统计)access_country_count | ||
| 156 | + * @author :lyh | ||
| 157 | + * @method :post | ||
| 158 | + * @time :2023/5/24 15:56 | ||
| 159 | + */ | ||
| 160 | + public function access_country_count(){ | ||
| 161 | + $data = DB::table('gl_customer_visit') | ||
| 162 | + ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv')) | ||
| 163 | + ->groupBy('country')->orderBy('ip','desc')->limit(20)->get()->toArray(); | ||
| 164 | + $data = object_to_array($data); | ||
| 165 | + foreach ($data as $k => $v){ | ||
| 166 | + $v['pv'] = (int)$v['pv']; | ||
| 167 | + $data[$k] = $v; | ||
| 168 | + } | ||
| 169 | + return $this->success($data); | ||
| 170 | + } | ||
| 171 | +} |
| @@ -2,11 +2,15 @@ | @@ -2,11 +2,15 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Http\Logic\Bside\Product; | 3 | namespace App\Http\Logic\Bside\Product; |
| 4 | 4 | ||
| 5 | +use App\Exceptions\BsideGlobalException; | ||
| 5 | use App\Helper\Arr; | 6 | use App\Helper\Arr; |
| 6 | use App\Http\Logic\Bside\BaseLogic; | 7 | use App\Http\Logic\Bside\BaseLogic; |
| 7 | use App\Models\Product\Category; | 8 | use App\Models\Product\Category; |
| 8 | use App\Models\Product\CategoryRelated; | 9 | use App\Models\Product\CategoryRelated; |
| 10 | +use App\Models\Product\KeywordRelated; | ||
| 9 | use App\Models\Product\Product; | 11 | use App\Models\Product\Product; |
| 12 | +use App\Models\RouteMap; | ||
| 13 | +use Illuminate\Support\Facades\DB; | ||
| 10 | 14 | ||
| 11 | /** | 15 | /** |
| 12 | * Class CategoryLogic | 16 | * Class CategoryLogic |
| @@ -23,6 +27,26 @@ class CategoryLogic extends BaseLogic | @@ -23,6 +27,26 @@ class CategoryLogic extends BaseLogic | ||
| 23 | $this->model = new Category(); | 27 | $this->model = new Category(); |
| 24 | } | 28 | } |
| 25 | 29 | ||
| 30 | + public function getList(array $map = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $limit = 20) | ||
| 31 | + { | ||
| 32 | + $data = parent::getList($map, $sort, $columns, $limit); | ||
| 33 | + foreach ($data as &$v){ | ||
| 34 | + $v['url'] = $this->getProjectDomain() . $v['route'] ; | ||
| 35 | + $v['product_num'] = $this->getProductNum($v['id']); | ||
| 36 | + } | ||
| 37 | + if(!$map){ | ||
| 38 | + $data = Arr::listToTree($data); | ||
| 39 | + } | ||
| 40 | + return $this->success($data); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + public function getInfo($id) | ||
| 44 | + { | ||
| 45 | + $info = parent::getInfo($id); | ||
| 46 | + $info['url'] = $this->getProjectDomain() . $info['route'] ; | ||
| 47 | + return $this->success($info); | ||
| 48 | + } | ||
| 49 | + | ||
| 26 | public function save($param){ | 50 | public function save($param){ |
| 27 | $param['pid'] = $param['pid'] ?? 0; | 51 | $param['pid'] = $param['pid'] ?? 0; |
| 28 | if(!empty($param['pid'])){ | 52 | if(!empty($param['pid'])){ |
| @@ -34,26 +58,53 @@ class CategoryLogic extends BaseLogic | @@ -34,26 +58,53 @@ class CategoryLogic extends BaseLogic | ||
| 34 | $this->fail('上级分类不存在'); | 58 | $this->fail('上级分类不存在'); |
| 35 | } | 59 | } |
| 36 | } | 60 | } |
| 37 | - return parent::save($param); | 61 | + DB::beginTransaction(); |
| 62 | + try { | ||
| 63 | + $res = parent::save($param); | ||
| 64 | + //路由映射 | ||
| 65 | + RouteMap::setRoute($param['title'], RouteMap::SOURCE_PRODUCT_CATE, $res['id'], $this->user['project_id']); | ||
| 66 | + DB::commit(); | ||
| 67 | + } catch (\Exception $e){ | ||
| 68 | + DB::rollBack(); | ||
| 69 | + errorLog('产品分类保存失败', $param, $e); | ||
| 70 | + $this->fail('保存失败'); | ||
| 71 | + } | ||
| 72 | + return $this->success(); | ||
| 38 | } | 73 | } |
| 39 | 74 | ||
| 40 | public function delete($ids, $map = []){ | 75 | public function delete($ids, $map = []){ |
| 41 | $ids= array_filter(Arr::splitFilterToArray($ids), 'intval'); | 76 | $ids= array_filter(Arr::splitFilterToArray($ids), 'intval'); |
| 42 | - foreach ($ids as $id){ | ||
| 43 | - $info = $this->getCacheInfo($id); | ||
| 44 | - if(!$info){ | ||
| 45 | - continue; | ||
| 46 | - } | ||
| 47 | - //是否有子分类 | ||
| 48 | - if(Category::where('project_id', $this->user['project_id'])->where('pid', $id)->count()){ | ||
| 49 | - $this->fail("分类{$info['title']}存在子分类,不能删除"); | ||
| 50 | - } | ||
| 51 | - //是否有对应商品 | ||
| 52 | - if(CategoryRelated::where('cate_id', $id)->count()){ | ||
| 53 | - $this->fail("分类{$info['title']}存在产品,不能删除"); | 77 | + |
| 78 | + DB::beginTransaction(); | ||
| 79 | + try { | ||
| 80 | + foreach ($ids as $id){ | ||
| 81 | + $info = $this->getCacheInfo($id); | ||
| 82 | + if(!$info){ | ||
| 83 | + continue; | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + //是否有子分类 | ||
| 87 | + if(Category::where('project_id', $this->user['project_id'])->where('pid', $id)->count()){ | ||
| 88 | + $this->fail("分类{$info['title']}存在子分类,不能删除"); | ||
| 89 | + } | ||
| 90 | + //是否有对应商品 | ||
| 91 | + if(CategoryRelated::where('cate_id', $id)->count()){ | ||
| 92 | + $this->fail("分类{$info['title']}存在产品,不能删除"); | ||
| 93 | + } | ||
| 94 | + //删除路由映射 | ||
| 95 | + RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']); | ||
| 54 | } | 96 | } |
| 97 | + parent::delete($ids); | ||
| 98 | + | ||
| 99 | + DB::commit(); | ||
| 100 | + } catch (BsideGlobalException $e){ | ||
| 101 | + DB::rollBack(); | ||
| 102 | + $this->fail($e->getMessage()); | ||
| 103 | + } catch (\Exception $e){ | ||
| 104 | + DB::rollBack(); | ||
| 105 | + $this->fail('删除失败'); | ||
| 55 | } | 106 | } |
| 56 | - return parent::delete($ids); | 107 | + return $this->success(); |
| 57 | } | 108 | } |
| 58 | 109 | ||
| 59 | /** | 110 | /** |
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Http\Logic\Bside\Product; | 3 | namespace App\Http\Logic\Bside\Product; |
| 4 | 4 | ||
| 5 | +use App\Exceptions\BsideGlobalException; | ||
| 5 | use App\Helper\Arr; | 6 | use App\Helper\Arr; |
| 6 | use App\Http\Logic\Bside\BaseLogic; | 7 | use App\Http\Logic\Bside\BaseLogic; |
| 7 | use App\Models\Product\KeywordRelated; | 8 | use App\Models\Product\KeywordRelated; |
| @@ -24,6 +25,24 @@ class KeywordLogic extends BaseLogic | @@ -24,6 +25,24 @@ class KeywordLogic extends BaseLogic | ||
| 24 | $this->model = new Keyword(); | 25 | $this->model = new Keyword(); |
| 25 | } | 26 | } |
| 26 | 27 | ||
| 28 | + public function getList(array $map = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $limit = 20) | ||
| 29 | + { | ||
| 30 | + $data = parent::getList($map, $sort, $columns, $limit); | ||
| 31 | + foreach ($data['list'] as &$v){ | ||
| 32 | + $v['product_num'] = $this->getProductNum($v['id']); | ||
| 33 | + $v['tdk'] = boolval($v['seo_title']) * boolval($v['seo_keywords']) * boolval($v['seo_description']); | ||
| 34 | + $v['url'] = $this->getProjectDomain() . $v['route']; | ||
| 35 | + } | ||
| 36 | + return $this->success($data); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + public function getInfo($id) | ||
| 40 | + { | ||
| 41 | + $info = parent::getInfo($id); | ||
| 42 | + $info['url'] = $this->getProjectDomain() . $info['route']; | ||
| 43 | + return $this->success($info); | ||
| 44 | + } | ||
| 45 | + | ||
| 27 | public function save($param){ | 46 | public function save($param){ |
| 28 | DB::beginTransaction(); | 47 | DB::beginTransaction(); |
| 29 | try { | 48 | try { |
| @@ -44,8 +63,6 @@ class KeywordLogic extends BaseLogic | @@ -44,8 +63,6 @@ class KeywordLogic extends BaseLogic | ||
| 44 | 63 | ||
| 45 | DB::beginTransaction(); | 64 | DB::beginTransaction(); |
| 46 | try { | 65 | try { |
| 47 | - parent::delete($ids); | ||
| 48 | - | ||
| 49 | foreach ($ids as $id){ | 66 | foreach ($ids as $id){ |
| 50 | $info = $this->getCacheInfo($id); | 67 | $info = $this->getCacheInfo($id); |
| 51 | if(!$info){ | 68 | if(!$info){ |
| @@ -60,8 +77,12 @@ class KeywordLogic extends BaseLogic | @@ -60,8 +77,12 @@ class KeywordLogic extends BaseLogic | ||
| 60 | //删除路由映射 | 77 | //删除路由映射 |
| 61 | RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); | 78 | RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); |
| 62 | } | 79 | } |
| 80 | + parent::delete($ids); | ||
| 63 | 81 | ||
| 64 | DB::commit(); | 82 | DB::commit(); |
| 83 | + } catch (BsideGlobalException $e){ | ||
| 84 | + DB::rollBack(); | ||
| 85 | + $this->fail($e->getMessage()); | ||
| 65 | }catch (\Exception $e){ | 86 | }catch (\Exception $e){ |
| 66 | DB::rollBack(); | 87 | DB::rollBack(); |
| 67 | $this->fail('删除失败'); | 88 | $this->fail('删除失败'); |
| @@ -53,6 +53,7 @@ class ProductLogic extends BaseLogic | @@ -53,6 +53,7 @@ class ProductLogic extends BaseLogic | ||
| 53 | $info['keyword_id_text'] = Arr::arrToSet($info['keyword_id_text'], 'trim'); | 53 | $info['keyword_id_text'] = Arr::arrToSet($info['keyword_id_text'], 'trim'); |
| 54 | $info['status_text'] = Product::statusMap()[$info['status']] ?? ''; | 54 | $info['status_text'] = Product::statusMap()[$info['status']] ?? ''; |
| 55 | $info['created_uid_text'] = (new UserLogic())->getCacheInfo($info['created_uid'])['name'] ?? ''; | 55 | $info['created_uid_text'] = (new UserLogic())->getCacheInfo($info['created_uid'])['name'] ?? ''; |
| 56 | + $info['url'] = $this->getProjectDomain() . $info['route'] ; | ||
| 56 | return $info; | 57 | return $info; |
| 57 | } | 58 | } |
| 58 | 59 | ||
| @@ -85,8 +86,6 @@ class ProductLogic extends BaseLogic | @@ -85,8 +86,6 @@ class ProductLogic extends BaseLogic | ||
| 85 | 86 | ||
| 86 | DB::beginTransaction(); | 87 | DB::beginTransaction(); |
| 87 | try { | 88 | try { |
| 88 | - parent::delete($ids); | ||
| 89 | - | ||
| 90 | foreach ($ids as $id){ | 89 | foreach ($ids as $id){ |
| 91 | //删除路由映射 | 90 | //删除路由映射 |
| 92 | RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']); | 91 | RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']); |
| @@ -97,6 +96,7 @@ class ProductLogic extends BaseLogic | @@ -97,6 +96,7 @@ class ProductLogic extends BaseLogic | ||
| 97 | //删除关键词关联 | 96 | //删除关键词关联 |
| 98 | KeywordRelated::where('product_id', $id)->delete(); | 97 | KeywordRelated::where('product_id', $id)->delete(); |
| 99 | } | 98 | } |
| 99 | + parent::delete($ids); | ||
| 100 | 100 | ||
| 101 | DB::commit(); | 101 | DB::commit(); |
| 102 | }catch (\Exception $e){ | 102 | }catch (\Exception $e){ |
| @@ -23,7 +23,7 @@ class DeptUserLogic extends BaseLogic | @@ -23,7 +23,7 @@ class DeptUserLogic extends BaseLogic | ||
| 23 | */ | 23 | */ |
| 24 | public function dept_user_save(){ | 24 | public function dept_user_save(){ |
| 25 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 25 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 26 | - $rs = $this->dept_user_edit($this->param); | 26 | + $rs = $this->dept_user_edit(); |
| 27 | }else{ | 27 | }else{ |
| 28 | $rs = $this->dept_user_add(); | 28 | $rs = $this->dept_user_add(); |
| 29 | } | 29 | } |
| @@ -60,8 +60,8 @@ class DeptUserLogic extends BaseLogic | @@ -60,8 +60,8 @@ class DeptUserLogic extends BaseLogic | ||
| 60 | * @method :post | 60 | * @method :post |
| 61 | * @time :2023/5/17 17:54 | 61 | * @time :2023/5/17 17:54 |
| 62 | */ | 62 | */ |
| 63 | - public function dept_user_edit($param){ | ||
| 64 | - $rs = $this->model->edit($param,['id'=>$this->param['id']]); | 63 | + public function dept_user_edit(){ |
| 64 | + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 65 | if($rs === false){ | 65 | if($rs === false){ |
| 66 | $this->fail('error'); | 66 | $this->fail('error'); |
| 67 | } | 67 | } |
app/Http/Logic/Bside/VisitLogic.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Logic\Bside; | ||
| 4 | + | ||
| 5 | +use App\Http\Logic\Logic; | ||
| 6 | +use App\Models\Visit\Visit; | ||
| 7 | +use App\Models\Visit\VisitItem; | ||
| 8 | + | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * Class VisitLogic | ||
| 12 | + * @package App\Http\Logic\Bside | ||
| 13 | + * @author zbj | ||
| 14 | + * @date 2023/5/22 | ||
| 15 | + */ | ||
| 16 | +class VisitLogic extends BaseLogic | ||
| 17 | +{ | ||
| 18 | + public function __construct() | ||
| 19 | + { | ||
| 20 | + parent::__construct(); | ||
| 21 | + | ||
| 22 | + $this->model = new Visit(); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + public function getList(array $map = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $limit = 20) | ||
| 26 | + { | ||
| 27 | + return Logic::getList($map, $sort, ['id', 'url', 'referrer_url', 'device_port', 'country', 'ip', 'depth', 'created_at'], $limit); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + public function getItemList(array $map = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $limit = 20){ | ||
| 31 | + $this->model = new VisitItem(); | ||
| 32 | + return Logic::getList($map, $sort, ['url', 'created_at'], 0); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | +} |
| @@ -24,12 +24,9 @@ class AyrReleaseRequest extends FormRequest | @@ -24,12 +24,9 @@ class AyrReleaseRequest extends FormRequest | ||
| 24 | { | 24 | { |
| 25 | return [ | 25 | return [ |
| 26 | 'title'=>'required', | 26 | 'title'=>'required', |
| 27 | -// 'images'=>'required|array', | ||
| 28 | -// 'video'=>'required', | ||
| 29 | 'content'=>'required', | 27 | 'content'=>'required', |
| 30 | 'share_id'=>'required', | 28 | 'share_id'=>'required', |
| 31 | 'platforms'=>'required|array', | 29 | 'platforms'=>'required|array', |
| 32 | -// 'schedule_date'=>'required', | ||
| 33 | ]; | 30 | ]; |
| 34 | } | 31 | } |
| 35 | 32 |
| @@ -36,7 +36,7 @@ class CustomRequest extends FormRequest | @@ -36,7 +36,7 @@ class CustomRequest extends FormRequest | ||
| 36 | 'keywords' => ['required','max:200'], | 36 | 'keywords' => ['required','max:200'], |
| 37 | 'description' => ['required','max:250'], | 37 | 'description' => ['required','max:250'], |
| 38 | // 'html' => ['required'], | 38 | // 'html' => ['required'], |
| 39 | - 'url' => ['required','max:200'], | 39 | + 'url' => ['required','max:200','url'], |
| 40 | 'status' => ['required','in:0,1'], | 40 | 'status' => ['required','in:0,1'], |
| 41 | ]; | 41 | ]; |
| 42 | 42 | ||
| @@ -70,6 +70,7 @@ class CustomRequest extends FormRequest | @@ -70,6 +70,7 @@ class CustomRequest extends FormRequest | ||
| 70 | 70 | ||
| 71 | 'url.required' => '链接必须', | 71 | 'url.required' => '链接必须', |
| 72 | 'url.max' => '链接不能超过200个字符', | 72 | 'url.max' => '链接不能超过200个字符', |
| 73 | + 'url.url' => '链接不符合规则', | ||
| 73 | 74 | ||
| 74 | 'status.required' => '状态选择错误', | 75 | 'status.required' => '状态选择错误', |
| 75 | 'status.in' => '状态必须是显示/隐藏' | 76 | 'status.in' => '状态必须是显示/隐藏' |
app/Models/CustomerVisit/CustomerVisit.php
0 → 100644
app/Models/HomeCount/Count.php
0 → 100644
| @@ -4,6 +4,7 @@ namespace App\Models\Product; | @@ -4,6 +4,7 @@ namespace App\Models\Product; | ||
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | use App\Models\Base; | 6 | use App\Models\Base; |
| 7 | +use App\Models\RouteMap; | ||
| 7 | use App\Services\Facades\Upload; | 8 | use App\Services\Facades\Upload; |
| 8 | use Illuminate\Database\Eloquent\SoftDeletes; | 9 | use Illuminate\Database\Eloquent\SoftDeletes; |
| 9 | 10 | ||
| @@ -14,12 +15,21 @@ class Category extends Base | @@ -14,12 +15,21 @@ class Category extends Base | ||
| 14 | //设置关联表名 | 15 | //设置关联表名 |
| 15 | protected $table = 'gl_product_category'; | 16 | protected $table = 'gl_product_category'; |
| 16 | 17 | ||
| 18 | + const STATUS_ACTIVE = 1; | ||
| 19 | + | ||
| 17 | /** | 20 | /** |
| 18 | * 子分类 | 21 | * 子分类 |
| 19 | * @var array | 22 | * @var array |
| 20 | */ | 23 | */ |
| 21 | protected $child_ids_arr = []; | 24 | protected $child_ids_arr = []; |
| 22 | 25 | ||
| 26 | + | ||
| 27 | + protected $appends = ['route']; | ||
| 28 | + | ||
| 29 | + public function getRouteAttribute(){ | ||
| 30 | + return RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_CATE, $this->id, $this->project_id); | ||
| 31 | + } | ||
| 32 | + | ||
| 23 | public function getImageAttribute($value) | 33 | public function getImageAttribute($value) |
| 24 | { | 34 | { |
| 25 | return Upload::path2url($value); | 35 | return Upload::path2url($value); |
| @@ -22,6 +22,7 @@ class RouteMap extends Model | @@ -22,6 +22,7 @@ class RouteMap extends Model | ||
| 22 | const SOURCE_PRODUCT = 'product'; | 22 | const SOURCE_PRODUCT = 'product'; |
| 23 | const SOURCE_PRODUCT_CATE = 'product_category'; | 23 | const SOURCE_PRODUCT_CATE = 'product_category'; |
| 24 | const SOURCE_PRODUCT_KEYWORD = 'product_keyword'; | 24 | const SOURCE_PRODUCT_KEYWORD = 'product_keyword'; |
| 25 | + const SOURCE_PAGE = 'page'; //单页面 | ||
| 25 | 26 | ||
| 26 | //路由类型 | 27 | //路由类型 |
| 27 | const SOURCE_BLOG = 'blog'; | 28 | const SOURCE_BLOG = 'blog'; |
app/Models/Visit/Visit.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Visit; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +use App\Models\Base; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * Class Visit | ||
| 10 | + * @package App\Models | ||
| 11 | + * @author zbj | ||
| 12 | + * @date 2023/5/22 | ||
| 13 | + */ | ||
| 14 | +class Visit extends Base | ||
| 15 | +{ | ||
| 16 | + | ||
| 17 | + //设置关联表名 | ||
| 18 | + protected $table = 'gl_customer_visit'; | ||
| 19 | + | ||
| 20 | + protected $appends = ['device_text']; | ||
| 21 | + | ||
| 22 | + public static function deviceMap(){ | ||
| 23 | + return [ | ||
| 24 | + 1 => 'PC', | ||
| 25 | + 2 => '移动端' | ||
| 26 | + ]; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * @return string | ||
| 31 | + * @author zbj | ||
| 32 | + * @date 2023/5/22 | ||
| 33 | + */ | ||
| 34 | + public function getDeviceTextAttribute(){ | ||
| 35 | + return self::deviceMap()[$this->device_port] ?? ''; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + | ||
| 39 | +} |
app/Models/Visit/VisitItem.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Visit; | ||
| 4 | + | ||
| 5 | +use App\Models\Base; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * Class VisitItem | ||
| 9 | + * @package App\Models | ||
| 10 | + * @author zbj | ||
| 11 | + * @date 2023/5/22 | ||
| 12 | + */ | ||
| 13 | +class VisitItem extends Base | ||
| 14 | +{ | ||
| 15 | + | ||
| 16 | + //设置关联表名 | ||
| 17 | + protected $table = 'gl_customer_visit_item'; | ||
| 18 | + | ||
| 19 | + | ||
| 20 | +} |
| @@ -6,9 +6,11 @@ use App\Models\Base; | @@ -6,9 +6,11 @@ use App\Models\Base; | ||
| 6 | 6 | ||
| 7 | class WebSetting extends Base | 7 | class WebSetting extends Base |
| 8 | { | 8 | { |
| 9 | + //锚文本常量配置在settingTextModel中 | ||
| 9 | protected $table = 'gl_web_setting'; | 10 | protected $table = 'gl_web_setting'; |
| 10 | 11 | ||
| 11 | //连接数据库 | 12 | //连接数据库 |
| 12 | // protected $connection = 'custom_mysql'; | 13 | // protected $connection = 'custom_mysql'; |
| 13 | 14 | ||
| 15 | + | ||
| 14 | } | 16 | } |
| @@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
| 6 | use Illuminate\Support\Facades\Route; | 6 | use Illuminate\Support\Facades\Route; |
| 7 | 7 | ||
| 8 | //必须登录验证的路由组 | 8 | //必须登录验证的路由组 |
| 9 | -Route::middleware(['bloginauth'])->group(function () { | 9 | +Route::middleware(['bloginauth','accesstoken'])->group(function () { |
| 10 | //登录用户编辑个人资料 | 10 | //登录用户编辑个人资料 |
| 11 | Route::any('/edit_info', [\App\Http\Controllers\Bside\ComController::class, 'edit_info'])->name('edit_info'); | 11 | Route::any('/edit_info', [\App\Http\Controllers\Bside\ComController::class, 'edit_info'])->name('edit_info'); |
| 12 | Route::any('/logout', [\App\Http\Controllers\Bside\ComController::class, 'logout'])->name('logout'); | 12 | Route::any('/logout', [\App\Http\Controllers\Bside\ComController::class, 'logout'])->name('logout'); |
| @@ -262,6 +262,18 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -262,6 +262,18 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 262 | Route::any('/get_google_rank', [\App\Http\Controllers\Bside\RankDataController::class, 'get_google_rank'])->name('rank_data_get_google_rank'); | 262 | Route::any('/get_google_rank', [\App\Http\Controllers\Bside\RankDataController::class, 'get_google_rank'])->name('rank_data_get_google_rank'); |
| 263 | }); | 263 | }); |
| 264 | 264 | ||
| 265 | + //首页统计数据 | ||
| 266 | + Route::prefix('home')->group(function () { | ||
| 267 | + Route::any('/count', [\App\Http\Controllers\Bside\HomeCount\CountController::class, 'count'])->name('home_count'); | ||
| 268 | + Route::any('/yesterday', [\App\Http\Controllers\Bside\HomeCount\CountController::class, 'yesterday'])->name('home_yesterday'); | ||
| 269 | + }); | ||
| 270 | + | ||
| 271 | + //访问数据 | ||
| 272 | + Route::prefix('visit')->group(function () { | ||
| 273 | + Route::any('/', [\App\Http\Controllers\Bside\VisitController::class, 'index'])->name('visit_list'); | ||
| 274 | + Route::any('/item', [\App\Http\Controllers\Bside\VisitController::class, 'item'])->name('visit_item'); | ||
| 275 | + }); | ||
| 276 | + | ||
| 265 | 277 | ||
| 266 | }); | 278 | }); |
| 267 | //无需登录验证的路由组 | 279 | //无需登录验证的路由组 |
-
请 注册 或 登录 后发表评论