OneHourController.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace App\Http\Controllers\Api\Crontab;
  3. use App\Http\Controllers\Api\ApiBaseController;
  4. use App\Models\TalentHouse;
  5. use App\Models\TalentHouseApply;
  6. use App\Models\TalentHousePeople;
  7. class OneHourController extends ApiBaseController
  8. {
  9. public function index()
  10. {
  11. $this->clearSock();
  12. $this->removeBlacklist();
  13. }
  14. /**
  15. * 人才购房 - 清除名额锁定
  16. */
  17. private function clearSock()
  18. {
  19. $list = TalentHouse::where('is_end', 2)->where('supply_time', '<=', date('Y-m-d H:i:s'))->get();
  20. if ($list->isEmpty()) {
  21. return true;
  22. }
  23. foreach ($list as $v) {
  24. TalentHouseApply::where('house_id', $v['id'])->where('status', '<>', 2)->update(['is_sock' => 2]);
  25. $v->is_end = 1;
  26. $v->save();
  27. }
  28. return true;
  29. }
  30. /**
  31. * 人才购房 - 解除黑名单
  32. */
  33. private function removeBlacklist()
  34. {
  35. TalentHousePeople::where('end_time', '<', date('Y-m-d H:i:s'))
  36. ->where('status', 2)
  37. ->update(['status' => 1, 'end_time' => null, 'comment' => '']);
  38. return true;
  39. }
  40. }