| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- namespace App\Console\Commands;
- use App\Models\Users;
- use Illuminate\Console\Command;
- use Illuminate\Support\Arr;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Carbon;
- use App\Models\UserWallet as UserWalletM;
- use App\Api\Util\IM;
- class UpVipStatus extends Command
- {
-
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'love:UpVipStatus';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = 'VIP到期自动更新状态每天0点3分执行 待进钱包数据进钱包T+1';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- //1.vip过期Im同步
- // $list=Users::where('vip_time','<=',time())->where('vip',1)->get();
- // foreach ($list as $k=>$v){
- // $this->portrait_set($v->id,['Tag'=>'Tag_Profile_IM_Level','Value'=>0]);
- // }
- //2.vip过期用户重置
- Users::where('vip_time','<=',time())->where('vip',1)->update(['vip'=>0,'vip_time'=>0]);
- //3.处理用户钱包
- $startOfMonth = Carbon::now()->subDays(2)->startOfday();
- $endOfMonth = Carbon::now()->yesterday()->startOfday();
- UserWalletM::whereBetween('created_at', [$startOfMonth,$endOfMonth])->update(['status'=>1]);
- $this->info($startOfMonth."==".$endOfMonth);
- //4.用户状态处理
- // Users::where('status',2)->select('id')->chunk(490, function ($users) {
- // $this->info("start");
- // $r=[];
- // foreach ($users as $K=>$v) {
- // $r[]=$v->id.'';
- // }
- // $all=Arr::flatten($r);
- // $list=$this->querystate($all);
- // if($list['ActionStatus']=='OK'){
- // foreach ($list['QueryResult'] as $k=>$v){
- // $this->info("tim->id=".$v['To_Account'].' State='.$v['State']);
- // if($v['State']=='Offline'){
- // Users::where('id',$v['To_Account'])->update(['status'=>3]);
- // }
- // }
- // }else{
- // ding()->text('检查用户不在线状态TIM提醒['.$list['ErrorInfo']);
- // }
- // $this->info("over");
- // });
- }
-
- }
|