CompleteInfoRemind.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace App\Console\Commands\User;
  3. use App\Models\PartnerModel;
  4. use App\Models\User\UserModel;
  5. use Illuminate\Console\Command;
  6. use Illuminate\Support\Facades\Redis;
  7. /**
  8. * 补全信息提醒-运营端
  9. * Class CompleteInfoRemind
  10. * @package App\Console\Commands\User
  11. */
  12. class CompleteInfoRemind extends Command
  13. {
  14. /**
  15. * The name and signature of the console command.
  16. *
  17. * @var string
  18. */
  19. protected $signature = 'operate:remindComplteInfo';
  20. /**
  21. * The console command description.
  22. *
  23. * @var string
  24. */
  25. protected $description = '运营:提醒补全信息';
  26. /**
  27. * Create a new command instance.
  28. *
  29. * @return void
  30. */
  31. public function __construct()
  32. {
  33. parent::__construct();
  34. }
  35. /**
  36. * Execute the console command.
  37. *
  38. * @return mixed
  39. */
  40. public function handle()
  41. {
  42. $key = "fpdx:completeinfo:remind";
  43. $ids = Redis::smembers($key);
  44. $partners = PartnerModel::whereNotIn('id', $ids)->where([['feed_push_type', 5], ['score', 0]])->take(rand(
  45. 1,
  46. 3
  47. ))->get();
  48. $nicknames = UserModel::where('partner_id', '>', 0)->skip(rand(
  49. 10,
  50. 500
  51. ))->take(3)->get(['nickname'])->pluck('nickname');
  52. foreach ($partners as $partner) {
  53. try {
  54. /** @var UserModel $user */
  55. $user = UserModel::findOrFail($partner->uid);
  56. /** @var PartnerModel $partner */
  57. event(new \App\Events\CompleteInfoRemind($user, $nicknames[rand(0, count($nicknames) - 1)]));
  58. Redis::sadd($key, [$partner->id]);
  59. } catch (\Exception $exception) {
  60. }
  61. }
  62. }
  63. }