暫無描述

JxStarVideoTaskList.php 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. class JxStarVideoTaskList extends Model
  6. {
  7. public $timestamps = false;
  8. protected $table = 'jx_star_video_task_list';
  9. protected static $unguarded = true;
  10. # 星视频任务数据入库队列
  11. const JUXING_STAR_VIDEO_TASK_INDB_LIST = 'juxingStarVideoTaskIndbList';
  12. public static function getStartVideoList($advertiserIds, $keyword, $remark, $startDate, $endDate, $page, $pageSize)
  13. {
  14. $queryModel = self::where('enable', 1)->whereIn('advertiser_id', $advertiserIds);
  15. # 关键词搜索
  16. if(is_numeric($keyword)){ // 按任务id
  17. $queryModel->where('task_id', $keyword);
  18. } elseif (is_array($keyword)) { // 按任务id集合
  19. $queryModel->whereIn('task_id', $keyword);
  20. } else { // 按任务名称或达人昵称搜索
  21. $queryModel->where('task_name', 'like', '%'.$keyword.'%');
  22. }
  23. # 备注搜索
  24. if($remark)
  25. $queryModel->where('remark', 'like', '%'.$remark.'%');
  26. # 按创建日期搜索
  27. if($startDate)
  28. $queryModel->where('create_time', '>=', $startDate . ' 00:00:00');
  29. if($endDate)
  30. $queryModel->where('create_time', '<=', $endDate . ' 23:59:59');
  31. $count = $queryModel->count();
  32. $list = $queryModel->select('advertiser_id', 'task_id', 'task_name', 'task_status', 'create_time', 'task_type', 'remark')
  33. ->offset(($page - 1) * $pageSize)->limit($pageSize)
  34. ->orderBy('create_time', 'desc')
  35. ->get();
  36. return [$list, $count];
  37. }
  38. public static function getTaskDataByIdList($taskIdList) {
  39. return JxStarVideoTaskList::query()->whereIn('task_id', $taskIdList)->get();
  40. }
  41. public static function search($keyword) {
  42. return self::query()->where('task_name', 'like', '%'.$keyword.'%')->pluck('task_id');
  43. }
  44. }