123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <?php
- namespace App\Console\Commands\Book;
- use Illuminate\Console\Command;
- use App\Modules\Statistic\Services\WapVisitStatService;
- use DB;
- class NewBookTestData extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'new_book_test_data';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '新书测试数据填充';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- $this->oneDayDataFill();
- $this->threeDayDataFill();
- $this->sixDayDataFill();
- $this->sevenDayDataFill();
- }
- function oneDayDataFill(){
- $one_day_before = date('Y-m-d H:i:s',strtotime('-1 day'));
- $new_book_tests = DB::table('new_book_tests')
- ->where('test_end_time','<=',$one_day_before)
- // ->where('status',2)
- ->whereNull('uv_in_one_day')
- ->whereNull('sub_amount_in_one_day')
- ->get();
- if(!$new_book_tests){return;}
- foreach ($new_book_tests as $item) {
- $data = array();
- $book_statistics = WapVisitStatService::smartPushTestBookStats($item->bid);
- $data['uv_in_one_day'] = $book_statistics['uv'];
- $data['sub_amount_in_one_day'] = $book_statistics['book_amount'];
- DB::table('new_book_tests')
- ->where('id',$item->id)
- ->update($data);
- }
- }
- function threeDayDataFill(){
- $three_day_before = date('Y-m-d H:i:s',strtotime('-3 day'));
- $new_book_tests = DB::table('new_book_tests')
- ->where('test_end_time','<=',$three_day_before)
- // ->where('status',2)
- ->whereNull('uv_in_three_day')
- ->whereNull('sub_amount_in_three_day')
- ->get();
- if(!$new_book_tests){return;}
- foreach ($new_book_tests as $item) {
- $data = array();
- $book_statistics = WapVisitStatService::smartPushTestBookStats($item->bid);
- $data['uv_in_three_day'] = $book_statistics['uv'];
- $data['sub_amount_in_three_day'] = $book_statistics['book_amount'];
- DB::table('new_book_tests')
- ->where('id',$item->id)
- ->update($data);
- }
- }
- function sevenDayDataFill(){
- $seven_day_before = date('Y-m-d H:i:s',strtotime('-7 day'));
- $seven_day_before_limit = date('Y-m-d H:i:s',strtotime('-7 day -1hour'));
- $new_book_tests = DB::table('new_book_tests')
- ->where('test_end_time','<=',$seven_day_before)
- ->where('test_end_time','>=',$seven_day_before_limit)
- ->whereNull('uv_in_seven_day')
- ->whereNull('sub_amount_in_seven_day')
- ->get();
- if(!$new_book_tests){return;}
- foreach ($new_book_tests as $item) {
- $data = array();
- $book_statistics = WapVisitStatService::smartPushTestBookStats($item->bid);
- $data['uv_in_seven_day'] = $book_statistics['uv'];
- $data['sub_amount_in_seven_day'] = $book_statistics['book_amount'];
- DB::table('new_book_tests')
- ->where('id',$item->id)
- ->update($data);
- }
- }
- function sixDayDataFill(){
- $six_day_before = date('Y-m-d H:i:s',strtotime('-6 day'));
- $six_day_before_limit = date('Y-m-d H:i:s',strtotime('-6 day -1hour'));
- $new_book_tests = DB::table('new_book_tests')
- ->where('test_end_time','<=',$six_day_before)
- ->where('test_end_time','>=',$six_day_before_limit)
- ->whereNull('uv_in_six_day')
- ->whereNull('sub_amount_in_six_day')
- ->get();
- if(!$new_book_tests){return;}
- foreach ($new_book_tests as $item) {
- $data = array();
- $book_statistics = WapVisitStatService::smartPushTestBookStats($item->bid);
- $data['uv_in_six_day'] = $book_statistics['uv'];
- $data['sub_amount_in_six_day'] = $book_statistics['book_amount'];
- DB::table('new_book_tests')
- ->where('id',$item->id)
- ->update($data);
- }
- }
- }
|