QueueAutoRefreshRepository.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: wuzhenke
  5. * Date: 2018/12/12
  6. * Time: 9:58
  7. */
  8. namespace App\Repositories;
  9. use App\Models\QueueAutoRefresh;
  10. use Prettus\Repository\Criteria\RequestCriteria;
  11. use Prettus\Repository\Eloquent\BaseRepository;
  12. class QueueAutoRefreshRepository extends BaseRepository
  13. {
  14. public function model()
  15. {
  16. return QueueAutoRefresh::class;
  17. }
  18. public function boot()
  19. {
  20. $this->pushCriteria(app(RequestCriteria::class));
  21. }
  22. public function findData($where)
  23. {
  24. return $this->model->where($where)->first();
  25. }
  26. public function getRefreshList($where)
  27. {
  28. return $this->model->where($where)->get();
  29. }
  30. public function resumeAutoRefresh()
  31. {
  32. $timeSpace = config('aix.personal_set.per_set.per_set.refresh_resume_space')*60;
  33. return $this->model->whereHas('resume',function ($query) use ($timeSpace) {
  34. $query->where('display',1)->whereIn('audit',getResumeStatus())->where('updated_at','<',date('Y-m-d H:i:s',time()-$timeSpace));
  35. })->where('type',2)->where('refreshtime','>=',time())->where('start_time','>=',strtotime(date('Y-m-d 00:00:00')))->where('start_time','<',strtotime(date('Y-m-d 23:59:59')))->get()->toArray();
  36. }
  37. public function delRefreshResume($where)
  38. {
  39. return $this->model->where($where)->delete();
  40. }
  41. public function getCrmRefreshs($where, $group_by = '')
  42. {
  43. $rst = $this->model->where($where);
  44. if ($group_by) {
  45. $rst->groupBy($group_by);
  46. }
  47. return $rst->get();
  48. }
  49. }