BookOrderByDay.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace App\Models\Subscribe;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Illuminate\Support\Facades\Log;
  5. /**
  6. * 书籍订阅 按日统计
  7. */
  8. class BookOrderByDay extends Model
  9. {
  10. protected $table = 'book_order_by_day';
  11. /**
  12. * 按日期查询记录
  13. * @param $Date
  14. * @param int $is_chapter
  15. * @param int $is_out
  16. * @return mixed
  17. */
  18. public static function getRecordByDate($Date, $is_chapter = -1, $is_out = -1)
  19. {
  20. $list = self::where('day', $Date);
  21. if ($is_chapter > -1)
  22. $list = $list->where('is_chapter', $is_chapter);
  23. if ($is_out > -1)
  24. $list = $list->where('is_out', $is_out);
  25. return $list->get();
  26. }
  27. /**
  28. * 按日期删除记录
  29. * @param $day
  30. * @param int $is_chapter
  31. * @param int $is_out
  32. * @return mixed
  33. */
  34. public static function deleteRecordByDay($day, $is_chapter = -1, $is_out = -1)
  35. {
  36. $list = self::where('day', $day);
  37. if ($is_chapter > -1)
  38. $list = $list->where('is_chapter', $is_chapter);
  39. if ($is_out > -1)
  40. $list = $list->where('is_out', $is_out);
  41. return $list->delete();
  42. }
  43. /**
  44. * @param $array
  45. */
  46. public static function insertRecord($array)
  47. {
  48. self::insert($array);
  49. }
  50. /**
  51. * 查询时间段内的记录
  52. * @param $dateStart
  53. * @param $dateEnd
  54. * @return mixed
  55. */
  56. public static function getRecordByDateQuantum($dateStart, $dateEnd)
  57. {
  58. try
  59. {
  60. $list = self::where('day', '>=', $dateStart)->where('day', '<', $dateEnd)->get();
  61. return $list;
  62. }
  63. catch (\Exception $e)
  64. {
  65. Log::info('------ 出错了'.$e->getMessage());
  66. }
  67. }
  68. }