正在显示
5 个修改的文件
包含
58 行增加
和
71 行删除
| @@ -5,7 +5,7 @@ namespace App\Console\Commands\DayCount; | @@ -5,7 +5,7 @@ namespace App\Console\Commands\DayCount; | ||
| 5 | use App\Helper\Common; | 5 | use App\Helper\Common; |
| 6 | use App\Helper\FormGlobalsoApi; | 6 | use App\Helper\FormGlobalsoApi; |
| 7 | use App\Models\Domain\DomainInfo; | 7 | use App\Models\Domain\DomainInfo; |
| 8 | -use App\Models\Inquiry\InquiryOther; | 8 | +use App\Models\Inquiry\InquiryFormData; |
| 9 | use App\Models\Project\DeployBuild; | 9 | use App\Models\Project\DeployBuild; |
| 10 | use App\Models\Project\DeployOptimize; | 10 | use App\Models\Project\DeployOptimize; |
| 11 | use App\Models\Project\Project; | 11 | use App\Models\Project\Project; |
| @@ -146,8 +146,8 @@ class Count extends Command | @@ -146,8 +146,8 @@ class Count extends Command | ||
| 146 | 146 | ||
| 147 | //加上其他询盘 | 147 | //加上其他询盘 |
| 148 | ProjectServer::useProject($project_id); | 148 | ProjectServer::useProject($project_id); |
| 149 | - $arr['inquiry_num'] = InquiryOther::count(); | ||
| 150 | - $countryData = InquiryOther::select("country",DB::raw('COUNT(*) as count'))->groupBy('country')->get()->toArray(); | 149 | + $arr['inquiry_num'] += InquiryFormData::count(); |
| 150 | + $countryData = InquiryFormData::select("country",DB::raw('COUNT(*) as count'))->groupBy('country')->get()->toArray(); | ||
| 151 | foreach ($countryData as $v1){ | 151 | foreach ($countryData as $v1){ |
| 152 | if(isset($countryArr[$v1['country']])){ | 152 | if(isset($countryArr[$v1['country']])){ |
| 153 | $countryArr[$v1['country']] += $v1['count']; | 153 | $countryArr[$v1['country']] += $v1['count']; |
| @@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
| 3 | namespace App\Console\Commands; | 3 | namespace App\Console\Commands; |
| 4 | 4 | ||
| 5 | use App\Helper\FormGlobalsoApi; | 5 | use App\Helper\FormGlobalsoApi; |
| 6 | -use App\Models\Inquiry\InquiryOther; | 6 | +use App\Models\Inquiry\InquiryFormData; |
| 7 | use App\Models\Project\Project; | 7 | use App\Models\Project\Project; |
| 8 | use App\Services\ProjectServer; | 8 | use App\Services\ProjectServer; |
| 9 | use Illuminate\Console\Command; | 9 | use Illuminate\Console\Command; |
| @@ -56,7 +56,7 @@ class LastInquiry extends Command | @@ -56,7 +56,7 @@ class LastInquiry extends Command | ||
| 56 | $last_time = $res['data']['data'][0] ?? ''; | 56 | $last_time = $res['data']['data'][0] ?? ''; |
| 57 | //其他询盘的最新时间 | 57 | //其他询盘的最新时间 |
| 58 | ProjectServer::useProject($item['id']); | 58 | ProjectServer::useProject($item['id']); |
| 59 | - $other_last_time = InquiryOther::orderBy('id', 'desc')->value('submit_time'); | 59 | + $other_last_time = InquiryFormData::orderBy('id', 'desc')->value('submit_time'); |
| 60 | 60 | ||
| 61 | $last_inquiry_time = $last_time > $other_last_time ? $last_time : $other_last_time; | 61 | $last_inquiry_time = $last_time > $other_last_time ? $last_time : $other_last_time; |
| 62 | 62 |
| @@ -4,7 +4,7 @@ namespace App\Console\Commands\MonthlyCount; | @@ -4,7 +4,7 @@ namespace App\Console\Commands\MonthlyCount; | ||
| 4 | 4 | ||
| 5 | use App\Helper\FormGlobalsoApi; | 5 | use App\Helper\FormGlobalsoApi; |
| 6 | use App\Models\Domain\DomainInfo; | 6 | use App\Models\Domain\DomainInfo; |
| 7 | -use App\Models\Inquiry\InquiryOther; | 7 | +use App\Models\Inquiry\InquiryFormData; |
| 8 | use App\Models\Project\Project; | 8 | use App\Models\Project\Project; |
| 9 | use App\Services\ProjectServer; | 9 | use App\Services\ProjectServer; |
| 10 | use Carbon\Carbon; | 10 | use Carbon\Carbon; |
| @@ -107,9 +107,9 @@ class InquiryMonthlyCount extends Command | @@ -107,9 +107,9 @@ class InquiryMonthlyCount extends Command | ||
| 107 | } | 107 | } |
| 108 | //加上其他询盘 | 108 | //加上其他询盘 |
| 109 | ProjectServer::useProject($project_id); | 109 | ProjectServer::useProject($project_id); |
| 110 | - $arr['total'] += InquiryOther::count(); | ||
| 111 | - $arr['month_total'] += InquiryOther::whereBetween('submit_time',[$startTime, $endTime])->count(); | ||
| 112 | - $countryData = InquiryOther::whereBetween('submit_time',[$startTime, $endTime]) | 110 | + $arr['total'] += InquiryFormData::count(); |
| 111 | + $arr['month_total'] += InquiryFormData::whereBetween('submit_time',[$startTime, $endTime])->count(); | ||
| 112 | + $countryData = InquiryFormData::whereBetween('submit_time',[$startTime, $endTime]) | ||
| 113 | ->select("country",DB::raw('COUNT(*) as count')) | 113 | ->select("country",DB::raw('COUNT(*) as count')) |
| 114 | ->groupBy('country')->get()->toArray(); | 114 | ->groupBy('country')->get()->toArray(); |
| 115 | foreach ($countryData as $v1){ | 115 | foreach ($countryData as $v1){ |
| @@ -2,30 +2,21 @@ | @@ -2,30 +2,21 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Console\Commands; | 3 | namespace App\Console\Commands; |
| 4 | 4 | ||
| 5 | -use App\Http\Logic\Aside\Project\DomainInfoLogic; | ||
| 6 | -use App\Models\Com\UpdateNotify; | ||
| 7 | -use App\Models\Devops\DevopsTask as DevopsTaskModel; | ||
| 8 | -use App\Models\Devops\DevopsTaskLog; | 5 | + |
| 6 | + | ||
| 9 | use App\Models\Domain\DomainInfo; | 7 | use App\Models\Domain\DomainInfo; |
| 10 | -use App\Models\File\File; | ||
| 11 | -use App\Models\File\Image; | ||
| 12 | -use App\Models\Product\CategoryRelated; | ||
| 13 | -use App\Models\Product\Product; | 8 | +use App\Models\HomeCount\Count; |
| 14 | use App\Models\Project\Project; | 9 | use App\Models\Project\Project; |
| 15 | -use App\Models\RouteMap\RouteMap; | ||
| 16 | -use App\Models\Template\BCustomTemplate; | ||
| 17 | use App\Services\ProjectServer; | 10 | use App\Services\ProjectServer; |
| 18 | use Illuminate\Console\Command; | 11 | use Illuminate\Console\Command; |
| 19 | -use Illuminate\Database\QueryException; | ||
| 20 | use Illuminate\Support\Facades\DB; | 12 | use Illuminate\Support\Facades\DB; |
| 21 | -use Illuminate\Support\Str; | 13 | +use mysql_xdevapi\Exception; |
| 22 | 14 | ||
| 23 | /** | 15 | /** |
| 24 | - * 测试 | ||
| 25 | - * Class Traffic | 16 | + * Class Test |
| 26 | * @package App\Console\Commands | 17 | * @package App\Console\Commands |
| 27 | * @author zbj | 18 | * @author zbj |
| 28 | - * @date 2023/5/18 | 19 | + * @date 2023/4/25 |
| 29 | */ | 20 | */ |
| 30 | class Test extends Command | 21 | class Test extends Command |
| 31 | { | 22 | { |
| @@ -41,7 +32,7 @@ class Test extends Command | @@ -41,7 +32,7 @@ class Test extends Command | ||
| 41 | * | 32 | * |
| 42 | * @var string | 33 | * @var string |
| 43 | */ | 34 | */ |
| 44 | - protected $description = '测试'; | 35 | + protected $description = ''; |
| 45 | 36 | ||
| 46 | /** | 37 | /** |
| 47 | * Create a new command instance. | 38 | * Create a new command instance. |
| @@ -58,52 +49,48 @@ class Test extends Command | @@ -58,52 +49,48 @@ class Test extends Command | ||
| 58 | */ | 49 | */ |
| 59 | public function handle() | 50 | public function handle() |
| 60 | { | 51 | { |
| 61 | - $domains = DB::table('gl_customer_visit')->groupBy('domain')->select('domain')->pluck('domain')->toArray(); | ||
| 62 | - foreach($domains as $domain){ | ||
| 63 | - if(!Str::contains($domain, 'globalso.site')){ | ||
| 64 | - $this->sync($domain); | 52 | + $projects = Project::all(); |
| 53 | + foreach ($projects as $project){ | ||
| 54 | + echo "project " . $project->id; | ||
| 55 | + if(!ProjectServer::useProject($project->id)){ | ||
| 56 | + echo '未配置数据库' . PHP_EOL; | ||
| 57 | + continue; | ||
| 58 | + } | ||
| 59 | + try { | ||
| 60 | + $list = Count::where('pv_num', 0)->get(); | ||
| 61 | + foreach ($list as $v){ | ||
| 62 | + $v->pv_num = $this->pv_num($v['date']); | ||
| 63 | + //ip统计 | ||
| 64 | + $v->ip_num = $this->ip_num($v['date']); | ||
| 65 | + $v->save(); | ||
| 66 | + echo $v['date'] . ':' . $v->pv_num .':'. $v->ip_num . PHP_EOL; | ||
| 67 | + } | ||
| 68 | + }catch (\Exception $e){ | ||
| 69 | + echo '保存失败' . $e->getMessage() . PHP_EOL; | ||
| 65 | } | 70 | } |
| 66 | } | 71 | } |
| 72 | + echo "finish"; | ||
| 67 | } | 73 | } |
| 68 | 74 | ||
| 69 | - public function sync($domain){ | ||
| 70 | - echo date('Y-m-d H:i:s') . "同步项目{$domain}" . PHP_EOL; | ||
| 71 | - if(!Str::startsWith($domain,'www.')){ | ||
| 72 | - $domain = 'www.'.$domain; | ||
| 73 | - } | ||
| 74 | - $project_id = DomainInfo::where('domain', $domain)->value('project_id'); | ||
| 75 | - if(!$project_id){ | ||
| 76 | - echo date('Y-m-d H:i:s') . "项目{$domain}不存在" . PHP_EOL; | ||
| 77 | - return true; | ||
| 78 | - } | ||
| 79 | - if(!ProjectServer::useProject($project_id)){ | ||
| 80 | - echo date('Y-m-d H:i:s') . "项目{$domain}数据库配置无效" . PHP_EOL; | ||
| 81 | - return true; | ||
| 82 | - } | ||
| 83 | - $visit = 0; | ||
| 84 | - $visit_item = 0; | ||
| 85 | - $list = DB::table('gl_customer_visit')->whereIn('domain', [$domain, str_replace('www.','',$domain)])->get(); | ||
| 86 | - foreach ($list as $v){ | ||
| 87 | - $v = (array) $v; | ||
| 88 | - | ||
| 89 | - $items = DB::table('gl_customer_visit_item')->where('customer_visit_id', $v['id'])->get(); | ||
| 90 | - | ||
| 91 | - unset($v['id']); | ||
| 92 | - $id = DB::connection('custom_mysql')->table('gl_customer_visit')->insertGetId($v); | ||
| 93 | - | ||
| 94 | - $visit++; | ||
| 95 | - | ||
| 96 | - $data = []; | ||
| 97 | - foreach ($items as $item){ | ||
| 98 | - $item = (array) $item; | ||
| 99 | - unset($item['id']); | ||
| 100 | - $item['customer_visit_id'] = $id; | ||
| 101 | - $data[] = $item; | ||
| 102 | - $visit_item++; | ||
| 103 | - } | ||
| 104 | - DB::connection('custom_mysql')->table('gl_customer_visit_item')->insert($data); | ||
| 105 | - } | ||
| 106 | - echo date('Y-m-d H:i:s') . "visit:{$visit};item:{$visit_item}" . PHP_EOL;exit; | 75 | + /** |
| 76 | + * @name :(统计pv)pv_num | ||
| 77 | + * @author :lyh | ||
| 78 | + * @method :post | ||
| 79 | + * @time :2023/6/14 15:40 | ||
| 80 | + */ | ||
| 81 | + public function pv_num($yesterday){ | ||
| 82 | + $pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $yesterday)->count(); | ||
| 83 | + return $pv; | ||
| 107 | } | 84 | } |
| 108 | 85 | ||
| 86 | + /** | ||
| 87 | + * @name :(统计ip)ip_num | ||
| 88 | + * @author :lyh | ||
| 89 | + * @method :post | ||
| 90 | + * @time :2023/6/14 15:40 | ||
| 91 | + */ | ||
| 92 | + public function ip_num($yesterday){ | ||
| 93 | + $ip = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $yesterday)->count(); | ||
| 94 | + return $ip; | ||
| 95 | + } | ||
| 109 | } | 96 | } |
| @@ -6,7 +6,7 @@ use App\Helper\FormGlobalsoApi; | @@ -6,7 +6,7 @@ use App\Helper\FormGlobalsoApi; | ||
| 6 | use App\Http\Logic\Bside\BaseLogic; | 6 | use App\Http\Logic\Bside\BaseLogic; |
| 7 | use App\Models\HomeCount\Count; | 7 | use App\Models\HomeCount\Count; |
| 8 | use App\Models\HomeCount\MonthCount; | 8 | use App\Models\HomeCount\MonthCount; |
| 9 | -use App\Models\Inquiry\InquiryOther; | 9 | +use App\Models\Inquiry\InquiryFormData; |
| 10 | use App\Models\Project\DeployOptimize; | 10 | use App\Models\Project\DeployOptimize; |
| 11 | use App\Services\ProjectServer; | 11 | use App\Services\ProjectServer; |
| 12 | use Carbon\Carbon; | 12 | use Carbon\Carbon; |
| @@ -86,9 +86,9 @@ class MonthCountLogic extends BaseLogic | @@ -86,9 +86,9 @@ class MonthCountLogic extends BaseLogic | ||
| 86 | } | 86 | } |
| 87 | } | 87 | } |
| 88 | //加上其他询盘 | 88 | //加上其他询盘 |
| 89 | - $arr['total'] += InquiryOther::count(); | ||
| 90 | - $arr['month_total'] += InquiryOther::whereBetween('submit_time',[$startTime, $endTime])->count(); | ||
| 91 | - $countryData = InquiryOther::whereBetween('submit_time',[$startTime, $endTime]) | 89 | + $arr['total'] += InquiryFormData::count(); |
| 90 | + $arr['month_total'] += InquiryFormData::whereBetween('submit_time',[$startTime, $endTime])->count(); | ||
| 91 | + $countryData = InquiryFormData::whereBetween('submit_time',[$startTime, $endTime]) | ||
| 92 | ->select("country",DB::raw('COUNT(*) as count')) | 92 | ->select("country",DB::raw('COUNT(*) as count')) |
| 93 | ->groupBy('country')->get()->toArray(); | 93 | ->groupBy('country')->get()->toArray(); |
| 94 | foreach ($countryData as $v1){ | 94 | foreach ($countryData as $v1){ |
-
请 注册 或 登录 后发表评论