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]); } } }); } }