VideosService.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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\AcceptorModel;
  13. use App\Models\ActionLogModel;
  14. use App\Models\TaskModel;
  15. use App\Models\TradeModel;
  16. use App\Models\VideoModel;
  17. use App\Services\BaseService;
  18. use Illuminate\Support\Facades\DB;
  19. /**
  20. * 承兑商管理-服务类
  21. * @author laravel开发员
  22. * @since 2020/11/11
  23. * @package App\Services\Common
  24. */
  25. class VideosService extends BaseService
  26. {
  27. /**
  28. * 构造函数
  29. * @author laravel开发员
  30. * @since 2020/11/11
  31. */
  32. public function __construct()
  33. {
  34. $this->model = new VideoModel();
  35. }
  36. /**
  37. * 获取列表
  38. * @param $params 参数
  39. * @param int $pageSize 分页大小:默认 15
  40. * @return array
  41. */
  42. public function getDataList($params, $pageSize = 10, $field = [])
  43. {
  44. $where = ['a.mark' => 1];
  45. $query = $this->model->with(['member'])
  46. ->from('videos as a')
  47. ->leftJoin('member as b','b.id','a.user_id')
  48. ->where($where)
  49. ->select($field ? $field : ['a.*']);
  50. if (isset($params['member']) && $params['member'] != '') {
  51. $query->where(function($query) use($params){
  52. $kw = isset($params['member'])? trim($params['member']) : '';
  53. if($kw){
  54. $query->where('b.nickname','like',"%{$params['member']}%")
  55. ->orWhere('b.realname','like',"%{$params['member']}%")
  56. ->orWhere('b.username','like',"%{$params['member']}%")
  57. ->orWhere('b.id','like',"%{$params['member']}%");
  58. }
  59. });
  60. }
  61. if (isset($params['title']) && $params['title'] != '') {
  62. $query->where('a.title','like',"%{$params['title']}%");
  63. }
  64. if (isset($params['visible_type']) && $params['visible_type']) {
  65. if(is_array($params['visible_type'])){
  66. $query->whereIn('a.visible_type',$params['visible_type']);
  67. }else{
  68. if($params['visible_type'] != ''){
  69. $query->where('a.visible_type',$params['visible_type']);
  70. }
  71. }
  72. }
  73. if (isset($params['type']) && $params['type']) {
  74. if(is_array($params['type'])){
  75. $query->whereIn('a.type',$params['type']);
  76. }else{
  77. if($params['type'] != ''){
  78. $query->where('a.type',$params['type']);
  79. }
  80. }
  81. }
  82. if (isset($params['is_comment']) && $params['is_comment']) {
  83. if(is_array($params['is_comment'])){
  84. $query->whereIn('a.is_comment',$params['is_comment']);
  85. }else{
  86. if($params['is_comment'] != ''){
  87. $query->where('a.is_comment',$params['is_comment']);
  88. }
  89. }
  90. }
  91. if (isset($params['is_short']) && $params['is_short']) {
  92. if(is_array($params['is_short'])){
  93. $query->whereIn('a.is_short',$params['is_short']);
  94. }else{
  95. if($params['is_short'] != ''){
  96. $query->where('a.is_short',$params['is_short']);
  97. }
  98. }
  99. }
  100. if (isset($params['status']) && $params['status']) {
  101. if(is_array($params['status'])){
  102. $query->whereIn('a.status',$params['status']);
  103. }else{
  104. if($params['status'] != ''){
  105. $query->where('a.status',$params['status']);
  106. }
  107. }
  108. }
  109. $list = $query->paginate($pageSize > 0 ? $pageSize : 9999999);
  110. $list = $list ? $list->toArray() : [];
  111. if ($list) {
  112. foreach ($list['data'] as &$item) {
  113. $item['thumb'] = $item['thumb'] ? get_image_url($item['thumb']) : $item['thumb'];
  114. $item['file_url'] = $item['file_url'] ? get_image_url($item['file_url']) : $item['file_url'];
  115. $item['music_url'] = $item['music_url'] ? get_image_url($item['music_url']) : $item['music_url'];
  116. $item['albums'] =$item['albums'] ? json_decode($item['albums'],true):$item['albums'];
  117. // if(!empty($item['albums'])){
  118. // $item['albums'] = array_map("get_image_url",json_decode($item['albums']));
  119. // }
  120. }
  121. }
  122. return [
  123. 'pageSize' => $pageSize,
  124. 'total' => isset($list['total']) ? $list['total'] : 0,
  125. 'list' => isset($list['data']) ? $list['data'] : []
  126. ];
  127. }
  128. /**
  129. * 添加会编辑会员
  130. * @return array
  131. * @since 2020/11/11
  132. * @author laravel开发员
  133. */
  134. public function edit()
  135. {
  136. // 请求参数
  137. $data = request()->all();
  138. if(!empty($data['thumb'])){
  139. $data['thumb'] = $data['thumb'] ? remove_image_url($data['thumb']) : $data['thumb'];
  140. }
  141. if(!empty($data['albums'])){
  142. $data['albums'] = $data['albums'] && is_array($data['albums']) ? json_encode($data['albums']) : $data['albums'];
  143. }
  144. ActionLogModel::setTitle("新增编辑短视频");
  145. ActionLogModel::record();
  146. return parent::edit($data); // TODO: Change the autogenerated stub
  147. }
  148. /**
  149. * @return array
  150. */
  151. public function status()
  152. {
  153. ActionLogModel::setTitle("审核短视频");
  154. ActionLogModel::record();
  155. return parent::status(); // TODO: Change the autogenerated stub
  156. }
  157. }