NoticeCommand.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace App\Console\Commands\Welfare;
  3. use App\Services\Welfare\NoticeService;
  4. use Illuminate\Console\Command;
  5. use App\Models\Welfare\LotteryModel;
  6. use App\Models\Welfare\TicketModel;
  7. class NoticeCommand extends Command
  8. {
  9. /**
  10. * The name and signature of the console command.
  11. *
  12. * @var string
  13. */
  14. protected $signature = 'welfare:notice';
  15. /**
  16. * The console command description.
  17. *
  18. * @var string
  19. */
  20. protected $description = '开奖通知';
  21. /**
  22. * Create a new command instance.
  23. *
  24. * @return void
  25. */
  26. public function __construct()
  27. {
  28. parent::__construct();
  29. }
  30. /**
  31. * Execute the console command.
  32. *
  33. * @return mixed
  34. */
  35. public function handle()
  36. {
  37. $lottery = LotteryModel::whereRaw("from_unixtime(`drawed_at`, '%Y-%m-%d %H:00:00') = ?", [
  38. date('Y-m-d H:00:00')
  39. ])->first();
  40. if (!$lottery) {
  41. dd('活动不存在');
  42. }
  43. $ns = new NoticeService();
  44. $users = TicketModel::where('lottery_id', $lottery->id)->whereNotIn('uid', [20000001, 20010000])
  45. ->distinct()
  46. ->pluck('uid');
  47. foreach ($users as $uid) {
  48. $ns->beforeLottery($uid, $lottery->id);
  49. }
  50. }
  51. }