MeetingRecordService.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. use App\Services\RedisService;
  15. /**
  16. * 会议签到记录管理-服务类
  17. * @author laravel开发员
  18. * @since 2020/11/11
  19. * @package App\Services\Common
  20. */
  21. class MeetingRecordService extends BaseService
  22. {
  23. public static $instance = null;
  24. /**
  25. * 构造函数
  26. * @author laravel开发员
  27. * @since 2020/11/11
  28. */
  29. public function __construct()
  30. {
  31. $this->model = new MeetingRecordsModel();
  32. }
  33. /**
  34. * 静态入口
  35. */
  36. public static function make()
  37. {
  38. if (!self::$instance) {
  39. self::$instance = new static();
  40. }
  41. return self::$instance;
  42. }
  43. /**
  44. * 列表(兼容旧方法)
  45. * @param $params
  46. * @param int $pageSize
  47. * @return array
  48. */
  49. public function getDataList($params, $pageSize = 15)
  50. {
  51. $where = ['a.mark' => 1];
  52. $status = isset($params['status']) ? $params['status'] : 0;
  53. if ($status > 0) {
  54. $where['a.status'] = $status;
  55. }
  56. $userId = isset($params['user_id']) ? $params['user_id'] : 0;
  57. if ($userId > 0) {
  58. $where['a.user_id'] = $userId;
  59. }
  60. $meetingId = isset($params['meeting_id']) ? $params['meeting_id'] : 0;
  61. if ($meetingId > 0) {
  62. $where['a.meeting_id'] = $meetingId;
  63. }
  64. $query = $this->model->with(['member','meeting'])->from('meetings_records as a')
  65. ->leftJoin('member as b','b.id','=','a.user_id')
  66. ->where($where)
  67. ->where(function ($query) use ($params) {
  68. $keyword = isset($params['keyword']) ? $params['keyword'] : '';
  69. if ($keyword) {
  70. $query->where('b.nickname', 'like', "%{$keyword}%")
  71. ->orWhere('b.mobile', 'like', "%{$keyword}%")
  72. ->orWhere('b.realname', 'like', "%{$keyword}%");
  73. }
  74. })
  75. ->select(['a.*']);
  76. $query->orderBy('a.id', 'desc');
  77. $list = $query->paginate($pageSize > 0 ? $pageSize : 9999999);
  78. $list = $list ? $list->toArray() : [];
  79. if ($list) {
  80. foreach ($list['data'] as &$item) {
  81. $item['create_time'] = $item['create_time'] ? datetime($item['create_time'], 'Y-m-d H.i.s') : '';
  82. }
  83. }
  84. return [
  85. 'msg' => '操作成功',
  86. 'code' => 0,
  87. 'data' => isset($list['data']) ? $list['data'] : [],
  88. 'count' => isset($list['total']) ? $list['total'] : 0,
  89. ];
  90. }
  91. public function status()
  92. {
  93. $id = request()->post('id',0);
  94. $ids = request()->post('ids');
  95. if($ids){
  96. $this->model->whereIn('id', $ids)->update(['status'=>1,'update_time'=>time()]);
  97. foreach ($ids as $id){
  98. RedisService::keyDel("caches:meeting:info_{$id}*");
  99. }
  100. return message();
  101. }else{
  102. $result = parent::status(); // TODO: Change the autogenerated stub
  103. RedisService::keyDel("caches:meeting:info_{$id}*");
  104. return $result;
  105. }
  106. }
  107. public function delete()
  108. {
  109. $this->model->where(['mark'=>0])->where('update_time','<', time() - 600)->delete();
  110. return parent::delete(); // TODO: Change the autogenerated stub
  111. }
  112. }