MediaPushDetailRecord.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace App\Modules\PersonalOp\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. use DB;
  5. class MediaPushDetailRecord extends Model
  6. {
  7. protected $table = 'media_push_detail_records';
  8. protected $fillable = ['uid', 'distribution_channel_id', 'appid', 'bid', 'date', 'hour', 'batch_id', 'push_time', 'user_num', 'origin_source_url',
  9. 'media_push_channel_user_id', 'seq', 'headline', 'media_push_record_id', 'promotion_id'];
  10. static function getInfos($params = [])
  11. {
  12. $search_obj = self::orderBy('id', 'desc');
  13. if (isset($params['start_time']) && $params['start_time']) {
  14. $search_obj->where('push_time', '>=', $params['start_time']);
  15. }
  16. if (isset($params['end_time']) && $params['end_time']) {
  17. $search_obj->where('push_time', '<=', $params['end_time']);
  18. }
  19. if (isset($params['appid']) && $params['appid']) {
  20. $search_obj->where('appid', $params['appid']);
  21. }
  22. return $search_obj->get();
  23. }
  24. static function getAppids($start_time, $end_time)
  25. {
  26. return self::where('push_time', '>=', $start_time)->where('push_time', '<=', $end_time)->select('appid')->distinct()->get();
  27. }
  28. static function updateInfos($id, $params = [])
  29. {
  30. return self::where('id', $id)->update($params);
  31. }
  32. static function getUnUpdatedInfos($params = [])
  33. {
  34. $search_obj = self::orderBy('id', 'desc');
  35. if (isset($params['start_time']) && $params['start_time']) {
  36. $search_obj->where('push_time', '<=', $params['start_time']);
  37. }
  38. if (isset($params['is_one_day']) && $params['is_one_day']) {
  39. $search_obj->whereNull('recharge_in_one_day');
  40. }
  41. if (isset($params['is_three_day']) && $params['is_three_day']) {
  42. $search_obj->whereNull('recharge_in_three_days');
  43. }
  44. return $search_obj->get();
  45. }
  46. }