MeetingRecordService.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 LARAVEL研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: laravel开发员 <laravel.qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Services\Common;
  12. use App\Models\MeetingRecordsModel;
  13. use App\Services\BaseService;
  14. /**
  15. * 会议签到记录管理-服务类
  16. * @author laravel开发员
  17. * @since 2020/11/11
  18. * @package App\Services\Common
  19. */
  20. class MeetingRecordService extends BaseService
  21. {
  22. public static $instance = null;
  23. /**
  24. * 构造函数
  25. * @author laravel开发员
  26. * @since 2020/11/11
  27. */
  28. public function __construct()
  29. {
  30. $this->model = new MeetingRecordsModel();
  31. }
  32. /**
  33. * 静态入口
  34. */
  35. public static function make()
  36. {
  37. if (!self::$instance) {
  38. self::$instance = new static();
  39. }
  40. return self::$instance;
  41. }
  42. /**
  43. * 列表(兼容旧方法)
  44. * @param $params
  45. * @param int $pageSize
  46. * @return array
  47. */
  48. public function getDataList($params, $pageSize = 15)
  49. {
  50. $where = ['a.mark' => 1];
  51. $status = isset($params['status']) ? $params['status'] : 0;
  52. if ($status > 0) {
  53. $where['a.status'] = $status;
  54. }
  55. $userId = isset($params['user_id']) ? $params['user_id'] : 0;
  56. if ($userId > 0) {
  57. $where['a.user_id'] = $userId;
  58. }
  59. $meetingId = isset($params['meeting_id']) ? $params['meeting_id'] : 0;
  60. if ($meetingId > 0) {
  61. $where['a.meeting_id'] = $meetingId;
  62. }
  63. $query = $this->model->with(['member','meeting'])->from('meetings_records as a')
  64. ->leftJoin('member as b','b.id','=','a.user_id')
  65. ->where($where)
  66. ->where(function ($query) use ($params) {
  67. $keyword = isset($params['keyword']) ? $params['keyword'] : '';
  68. if ($keyword) {
  69. $query->where('b.nickname', 'like', "%{$keyword}%")
  70. ->orWhere('b.mobile', 'like', "%{$keyword}%")
  71. ->orWhere('b.realname', 'like', "%{$keyword}%");
  72. }
  73. })
  74. ->select(['a.*']);
  75. $query->orderBy('a.id', 'desc');
  76. $list = $query->paginate($pageSize > 0 ? $pageSize : 9999999);
  77. $list = $list ? $list->toArray() : [];
  78. if ($list) {
  79. foreach ($list['data'] as &$item) {
  80. $item['create_time'] = $item['create_time'] ? datetime($item['create_time'], 'Y-m-d H.i.s') : '';
  81. }
  82. }
  83. return [
  84. 'msg' => '操作成功',
  85. 'code' => 0,
  86. 'data' => isset($list['data']) ? $list['data'] : [],
  87. 'count' => isset($list['total']) ? $list['total'] : 0,
  88. ];
  89. }
  90. public function delete()
  91. {
  92. $this->model->where(['mark'=>0])->where('update_time','<', time() - 600)->delete();
  93. return parent::delete(); // TODO: Change the autogenerated stub
  94. }
  95. }