123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace App\Console\Commands;
- use App\Modules\Statistic\Services\WapVisitStatService;
- use DB;
- use Illuminate\Console\Command;
- use Redis;
- class ChannelReaderVisitStats extends Command
- {
-
- protected $signature = 'channel_reader_visit_stats';
-
- protected $description = 'Command description';
- public function __construct()
- {
- parent::__construct();
- }
- public function handle()
- {
-
- $yesterday = date("Y-m-d", strtotime("-1 day"));
- $this->getReadVisitUvInfo($yesterday);
- }
- function getReadVisitUvInfo($date)
- {
- $channels = Redis::smembers(sprintf('recordReaderUvAndPv:date:%s', $date));
- if ($channels) {
- foreach ($channels as $channel) {
- $data = WapVisitStatService::getReaderUvAndPv($channel, $date);
- if ($data) {
- $uv = $data['uv'];
- $pv = $data['pv'];
- $distribution_channel_id = $channel;
- $created_at = date("Y-m-d H:i:s");
- $updated_at = date("Y-m-d H:i:s");
- $data = compact('date', 'uv', 'pv', 'created_at', 'updated_at', 'distribution_channel_id');
- DB::table('channel_reader_visit_stats')->insert($data);
- }
- }
- }
- WapVisitStatService::deleteReaderUvAndPvRedisKey($date);
- }
- }
|