1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace App\Http\Controllers;
- use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
- use Illuminate\Foundation\Bus\DispatchesJobs;
- use Illuminate\Foundation\Validation\ValidatesRequests;
- use Illuminate\Routing\Controller as BaseController;
- //
- use App\Common\Library\Easemob;
- use Illuminate\Support\Facades\DB;
- use App\Jobs\EasemobJob;
- class Controller extends BaseController
- {
- use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
- public function test(){
- /*$easemob = new Easemob();
- $rs = $easemob->push_text(1009,'标题','内容');
- dd($rs);*/
- (new EasemobJob(1))->handle();
- }
- public function plantask(){
- $list = DB::table('mt_message')->where('dispatch_status',0)->orderBy('id','asc')->get()->toArray();
- //dd($list);
- //
- if(!empty($list)){
- foreach($list as $key => $val){
- $msg_id = $val->id;
- dispatch((new EasemobJob($msg_id))->delay(0));//加入队列
- }
- }
- //更新
- $ids = array_column($list,'id');
- $update = [
- 'dispatch_status' => 1,
- ];
- DB::table('mt_message')->whereIn('id',$ids)->update($update);
- }
- }
|