UpVipStatus.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Models\Users;
  4. use Illuminate\Console\Command;
  5. use Illuminate\Support\Arr;
  6. use Illuminate\Support\Facades\DB;
  7. use Illuminate\Support\Carbon;
  8. use App\Models\UserWallet as UserWalletM;
  9. use App\Api\Util\IM;
  10. class UpVipStatus extends Command
  11. {
  12. /**
  13. * The name and signature of the console command.
  14. *
  15. * @var string
  16. */
  17. protected $signature = 'love:UpVipStatus';
  18. /**
  19. * The console command description.
  20. *
  21. * @var string
  22. */
  23. protected $description = 'VIP到期自动更新状态每天0点3分执行 待进钱包数据进钱包T+1';
  24. /**
  25. * Create a new command instance.
  26. *
  27. * @return void
  28. */
  29. public function __construct()
  30. {
  31. parent::__construct();
  32. }
  33. /**
  34. * Execute the console command.
  35. *
  36. * @return mixed
  37. */
  38. public function handle()
  39. {
  40. //1.vip过期Im同步
  41. // $list=Users::where('vip_time','<=',time())->where('vip',1)->get();
  42. // foreach ($list as $k=>$v){
  43. // $this->portrait_set($v->id,['Tag'=>'Tag_Profile_IM_Level','Value'=>0]);
  44. // }
  45. //2.vip过期用户重置
  46. Users::where('vip_time','<=',time())->where('vip',1)->update(['vip'=>0,'vip_time'=>0]);
  47. //3.处理用户钱包
  48. $startOfMonth = Carbon::now()->subDays(2)->startOfday();
  49. $endOfMonth = Carbon::now()->yesterday()->startOfday();
  50. UserWalletM::whereBetween('created_at', [$startOfMonth,$endOfMonth])->update(['status'=>1]);
  51. $this->info($startOfMonth."==".$endOfMonth);
  52. //4.用户状态处理
  53. // Users::where('status',2)->select('id')->chunk(490, function ($users) {
  54. // $this->info("start");
  55. // $r=[];
  56. // foreach ($users as $K=>$v) {
  57. // $r[]=$v->id.'';
  58. // }
  59. // $all=Arr::flatten($r);
  60. // $list=$this->querystate($all);
  61. // if($list['ActionStatus']=='OK'){
  62. // foreach ($list['QueryResult'] as $k=>$v){
  63. // $this->info("tim->id=".$v['To_Account'].' State='.$v['State']);
  64. // if($v['State']=='Offline'){
  65. // Users::where('id',$v['To_Account'])->update(['status'=>3]);
  66. // }
  67. // }
  68. // }else{
  69. // ding()->text('检查用户不在线状态TIM提醒['.$list['ErrorInfo']);
  70. // }
  71. // $this->info("over");
  72. // });
  73. }
  74. }