1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace App\Console\Commands;
- use Illuminate\Console\Command;
- use DB;
- class SendOrderBreakevenForceUser extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'sendorderbreadforceuser';
- /**
- * 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->start();
- }
- public function start(){
- DB::table('send_order_breakeven_stats')->select('id','official_account_id','date')->where('date','=',date('Y-m-d',time()-86400))->orderBy('id')->chunk(1000,function ($res){
- foreach ($res as $v){
- $appid = DB::table('official_accounts')->where('id',$v->official_account_id)->select('appid')->first();
- if($appid && isset($appid->appid)){
- $total = DB::table('force_subscribe_users')->where('is_subscribed',1)->where('appid',$appid->appid)->count();
- $today = DB::table('force_subscribe_users')
- ->where('appid',$appid->appid)
- ->where('created_at','>=',$v->date)
- ->where('created_at','<=',$v->date.' 23:59:59')
- ->count();
- DB::table('send_order_breakeven_stats')->where('id',$v->id)->update(['total_force_user_num'=>$total,'force_user_num'=>$today]);
- }
- }
- });
- }
- }
|