isAjax()) return $this->list(); // 类型获取 $type = VideoType::where(['pid' => 0, 'type' => 'video', 'root_id' => request()->employee->root_id])->column('*', 'id'); $label = VideoType::where([['pid', '>', 0], ['type', '=', 'video'], ['root_id', '=', request()->employee->root_id]])->select()->toArray(); $joinlabel = []; foreach ($label as $val) { $joinlabel[$val['pid']][$val['id']] = $val['name']; } $eid = VideoModel::where([['delete_time', '=', 0], ['root_id', '=', request()->employee->root_id], ['employee_id', '>', 0]])->group('employee_id')->column('employee_id'); $w[] = ['id', 'in', $eid]; $w[] = ['grant_id', '>', 0]; $w[] = ['root_id', '=', request()->employee->root_id]; // 运营人员列表 $employee = Employee::where($w)->field(['id', 'opt_name as name'])->select()->toArray(); View::assign('employee', $employee); View::assign('type', $type); View::assign('label', json_encode($joinlabel)); return View::fetch(); } /** * 列表 */ public function list() { // 请求参数获取 $param = Request::param(); // 请求条件初始化 $where = [ ['delete_time', '=', 0], ['root_id', '=', request()->employee->root_id] ]; // 查询条件付值 if (!empty($param['title'])) { $where[] = ['title', 'like', '%' . $param['title'] . '%']; } if (!empty($param['type'])) { $where[] = ['type', '=', $param['type']]; } if (!empty($param['label'])) { $where[] = ['label', '=', $param['label']]; } if (!empty($param['employee_id'])) { $where[] = ['employee_id', '=', $param['employee_id']]; } //上传时间筛选 if (!empty($param['add_time'])) { $newtime=explode(' - ', $param['add_time']); $start_time=$newtime[0].' 00:00:00'; $end_time=$newtime[1].' 23:59:59'; $where[] = ['uploadtime', 'between', [$start_time, $end_time]]; } $order='uploadtime desc'; if (!empty($param['order']) && in_array($param['order'], ['visit_due_time desc','visit_due_time asc','view_times asc','view_times desc','shared_times asc','shared_times desc'])) { $order = $param['order']; } // 获取数据 $list = VideoModel::with('employee')->where($where)->page($param['page'], $param['limit'])->order($order)->select()->toArray(); $count = VideoModel::where($where)->count(); //增加查询转发次数浏览时长 // if(!empty($list)){ // $statismod=new MaterialLogic; // $selorder=!empty($param['order'])?$param['order']:''; // $list=$statismod->sel_case_share($list,'Video',$selorder); // } return json(['code' => 0, 'data' => $list, 'count' => $count, 'msg' => '获取成功']); } /** * 添加 */ public function add() { $type = (new VideoType)->where(['pid' => 0, 'type' => 'video', 'root_id' => request()->employee->root_id])->column('*', 'id'); $label = (new VideoType)->where([['pid', '>', 0], ['type', '=', 'video'], ['root_id', '=', request()->employee->root_id]])->select()->toArray(); $joinlabel = []; foreach ($label as $val) { $joinlabel[$val['pid']][$val['id']] = $val['name']; } View::assign('type', $type); View::assign('label', json_encode($joinlabel)); $adding = input('adding', 0); view::assign('adding', $adding); return View::fetch(); } /** * 添加视频保存 */ public function addSave() { $data = Request::only(['title', 'type', 'label', 'description', 'video_url', 'douyin_url', 'id', 'cover','video_type', 'cover_share_img']); // 如果是抓取到抖音文件,先将抓取到文件地址进行更改,后保存 if (!empty($data['douyin_url'])) { $file = '.' . $data['douyin_url']; $path = 'video' . DIRECTORY_SEPARATOR . pathinfo($file, PATHINFO_BASENAME); $data['video_url'] = $path; } unset($data['douyin_url']); if (!empty($data['video_url'])) { $arr = explode(',', $data['video_url']); $data['video_url'] = end($arr); } if (!empty($data['id'])) { VideoModel::where(['id' => $data['id'], 'root_id' => request()->employee->root_id])->update($data); $msg = '编辑成功'; } else { $data['employee_id'] = request()->employee->id; $data['root_id'] = request()->employee->root_id; VideoModel::create($data); $msg = '添加成功'; } if (isset($file) && ossUpload($path, $file)) { unlink($file); } return json(['code' => 0, 'msg' => $msg]); } /** * 视频修改 */ public function edit($id) { $data = VideoModel::where(['id' => $id, 'root_id' => request()->employee->root_id])->find(); $data['cover_url'] = $data->getData('cover'); $data['video_urls'] = $data->video_url; $cover = $data->cover; $cover_share_img = $data->cover_share_img; $data = $data->getData(); $data['cover'] = $cover; $data['cover_share_img'] = $cover_share_img; // 类型获取 $type = VideoType::where(['pid' => 0, 'type' => 'video', 'root_id' => request()->employee->root_id])->column('*', 'id'); $label = VideoType::where([['pid', '>', 0], ['type', '=', 'video'], ['root_id', '=', request()->employee->root_id]])->select()->toArray(); $joinlabel = []; foreach ($label as $val) { $joinlabel[$val['pid']][$val['id']] = $val['name']; } View::assign('type', $type); View::assign('label', json_encode($joinlabel)); // 参数设置 View::assign('checked', $joinlabel[$data['type']] ?? []); View::assign('data', $data); return View::fetch(); } /** * 视频删除 */ public function del($id) { VideoModel::where(['id' => $id, 'root_id' => request()->employee->root_id])->update(['delete_time' => time()]); return json(['code' => 0, 'msg' => '删除成功']); } /** * 抖音内容抓取 */ public function catch($link) { // 抓取内容 preg_match('/https:\/\/[\w\/\.]*/', $link, $match); if (!isset($match[0])) return json(['code' => 1, 'msg' => '未检测到链接地址']); $url = parse_url($match[0]); if ($url['scheme'] . '://' . $url['host'] != 'https://v.douyin.com') return json(['code' => 1, 'msg' => '请输入有效的抖音链接']); $crawler = new VideoCrawler(); $data = $crawler->crawByUrl($match[0]); if ($data == false) return json(['code' => 1, 'msg' => '抓取失败,请手动上传视频']); // 定义配置参数 ini_set("user_agent", "Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)"); // 将视频文件下载 $r = file_get_contents($data['play']); $filename = './upload' . DIRECTORY_SEPARATOR . uniqid() . '.mp4'; file_put_contents($filename, $r); $data['video'] = ltrim($filename, '.'); return json(['code' => 0, 'msg' => '获取成功', 'data' => $data]); } /* * 添加分类 */ public function addtype($value, $id = null) { $array = [ 'name' => $value, 'root_id' => request()->employee->root_id, 'type' => 'video' ]; if (!empty($id)) $array['pid'] = $id; $insertGetId = VideoType::insertGetId($array); $data = ['id' => $insertGetId, 'value' => $value]; return json(['code' => 0, 'msg' => '添加成功', 'data' => $data]); } /** * 是否展示 */ public function publish($id) { $obj = VideoModel::where(['id' => $id, 'root_id' => request()->employee->root_id])->find(); if (empty($obj)) return json(['code' => 1, 'msg' => '数据不存在']); $obj->publish = $obj->publish == 1 ? 0 : 1; $obj->save(); return json(['code' => 0, 'msg' => '修改成功']); } /* * 分类管理 */ function cate_video() { return View::fetch(); } /* * 分类管理列表 */ function cate_video_list() { $param = Request::param(); $condition[] = ['root_id', '=', request()->employee->root_id]; $condition[] = ['type', '=', 'video']; $condition[] = ['pid', '=', 0]; $list = VideoType::where($condition)->page($param['page'], $param['limit'])->order(['show' => 'asc', 'id' => 'desc'])->field('id,name,show')->select()->toarray(); $count = VideoType::where($condition)->count(); return json(['code' => 0, 'data' => $list, 'count' => $count]); } /* * 分类管理添加 */ function cate_video_add() { $param = Request::param(); $condition[] = ['name', '=', $param['name']]; $condition[] = ['root_id', '=', request()->employee->root_id]; $condition[] = ['type', '=', 'video']; $data['name'] = $param['name']; $model = VideoType::where($condition); $models = new VideoType; $info = $model->find(); if ($info) { return json(['code' => 1, 'msg' => '名称已存在']); } $models->name = $param['name']; $models->type = 'video'; $models->root_id = request()->employee->root_id; $models->save(); return json(['code' => 0, 'msg' => '保存成功', 'data' => '']); } /* * 分类管理编辑 */ function cate_video_edit() { $param = Request::param(); $conditions = [['id', '=', $param['id']]]; $condition[] = ['name', '=', $param['name']]; $condition[] = ['root_id', '=', request()->employee->root_id]; $condition[] = ['type', '=', 'video']; $data['name'] = $param['name']; $model = VideoType::where($condition); $models = VideoType::where($conditions); $info = $model->find(); if ($info) { return json(['code' => 1, 'msg' => '名称已存在']); } $models->update($data); return json(['code' => 0, 'msg' => '保存成功', 'data' => '']); } /* * 删除标签或分类前,查询关联的内容数量 */ public function with_type_count() { $param = Request::param(); if ($param['type'] == 'type') { $field = 'type'; } else { $field = 'label'; } $where = [ ['root_id', '=', request()->employee->root_id], ['delete_time', '=', 0], [$field, '=', $param['id']] ]; $count = VideoModel::where($where)->count(); if ($count > 0) { $type = $field == 'type' ? '分类' : '标签'; $msg = '该' . $type . '有' . $count . '个' . '拓客视频,删除后该内容将归为其它分类。'; } else { $msg = '确定删除该分类吗?'; } return $msg; } /* * 分类、标签删除 */ public function delete_type_or_label() { $param = Request::param(); $videoType = VideoType::where(['root_id' => request()->employee->root_id, 'type' => 'video', 'id' => $param['id']])->find(); if (empty($videoType)) return json(['code' => 1, 'msg' => '数据不存在']); Db::startTrans(); try { if ($param['type'] == 'type') { //查询是否存在其它分类 $type_id = VideoType::where(['root_id' => request()->employee->root_id, 'pid' => 0, 'type' => 'video', 'show' => 1])->value('id'); if (empty($type_id)) $type_id = VideoType::insertGetId(['pid' => 0, 'name' => '其它', 'type' => 'video', 'root_id' => request()->employee->root_id, 'show' => 1]); //更新关联内容 VideoType::where(['root_id' => request()->employee->root_id, 'pid' => $param['id'], 'type' => 'video'])->update(['pid' => $type_id]); VideoModel::where(['root_id' => request()->employee->root_id, 'type' => $param['id']])->update(['type' => $type_id]); $more_other_id = VideoType::where(['root_id' => request()->employee->root_id, 'pid' => $type_id, 'type' => 'video', 'show' => 1])->column('id'); if (count($more_other_id) >= 2) { $first_id = $more_other_id[0]; VideoModel::where([['root_id', '=', request()->employee->root_id], ['type', '=', $type_id], ['label', 'in', $more_other_id]])->update(['label' => $first_id]); unset($more_other_id[0]); VideoType::where([['root_id', '=', request()->employee->root_id], ['id', 'in', $more_other_id]])->delete(); } //删除分类 $videoType->delete(); } else { $label_id = VideoType::where(['root_id' => request()->employee->root_id, 'pid' => $param['pid'], 'type' => 'video', 'show' => 1])->value('id'); if (empty($label_id)) $label_id = VideoType::insertGetId(['pid' => $param['pid'], 'name' => '其它', 'type' => 'video', 'root_id' => request()->employee->root_id, 'show' => 1]); //更新关联内容 VideoModel::where(['root_id' => request()->employee->root_id, 'label' => $param['id']])->update(['label' => $label_id]); //删除分类 $videoType->delete(); } Db::commit(); return json(['code' => 0, 'msg' => '删除成功']); } catch (\Exception $e) { Db::rollback(); return json(['code' => 1, 'msg' => '删除失败']); } } /* * 标签管理 */ function cate_video_labels() { return View::fetch(); } /* * 新标签管理列表 */ function cate_video_list_labels() { $param = Request::param(); $condition[] = ['root_id', '=', request()->employee->root_id]; $condition[] = ['type', '=', 'video']; $condition[] = ['pid', '>', 0]; $parents = VideoType::where([['pid', '=', 0]])->column('name', 'id'); $list = VideoType::where($condition)->page($param['page'], $param['limit'])->order(['show' => 'asc', 'id' => 'desc'])->field('id,name,pid,show')->select()->toarray(); foreach ($list as $k => $v) { $list[$k]['pname'] = isset($parents[$v['pid']]) ? $parents[$v['pid']] : ''; } $count = VideoType::where($condition)->count(); return json(['code' => 0, 'data' => $list, 'count' => $count]); } /* * 新分类标签管理编辑 */ function cate_video_edit_labels() { $param = Request::param(); $conditions = [['id', '=', $param['id']]]; $condition[] = ['name', '=', $param['name']]; $condition[] = ['root_id', '=', request()->employee->root_id]; $condition[] = ['pid', '=', $param['pid']]; $condition[] = ['type', '=', 'video']; $data['name'] = $param['name']; $model = VideoType::where($condition); $models = VideoType::where($conditions); $info = $model->find(); if ($info) { return json(['code' => 1, 'msg' => '名称已存在']); } $models->update($data); return json(['code' => 0, 'msg' => '保存成功', 'data' => '']); } /* * 新标签添加 */ function cate_video_labels_add() { if (request()->isAjax()) { $param = Request::param(); if (!$param['id'] || !$param['name']) { return json(['code' => 1, 'msg' => '缺少参数', 'data']); } isset($param['label_id']) ? $condition[] = ['id', '<>', $param['label_id']] : ''; $condition[] = ['name', '=', $param['name']]; $condition[] = ['root_id', '=', request()->employee->root_id]; $condition[] = ['pid', '=', $param['id']]; $condition[] = ['type', '=', 'video']; $info = VideoType::where($condition)->find(); if ($info) { return json(['code' => 1, 'msg' => '名称已存在']); } if (isset($param['label_id'])) { VideoType::where(['root_id' => request()->employee->root_id, 'type' => 'video', 'id' => $param['label_id']])->update(['pid' => $param['id'], 'name' => $param['name']]); VideoModel::where(['root_id' => request()->employee->root_id, 'label' => $param['label_id']])->update(['type' => $param['id']]); } else { $model = new VideoType; $model->name = $param['name']; $model->pid = $param['id']; $model->type = 'video'; $model->root_id = request()->employee->root_id; $model->save(); } return json(['code' => 0, 'msg' => '保存成功', 'data' => '']); } //编辑 if (Request::param('id')) { $data = Request::param(); view::assign('data', $data); } $condition[] = ['root_id', '=', request()->employee->root_id]; $condition[] = ['type', '=', 'video']; $condition[] = ['pid', '=', 0]; $list = VideoType::where($condition)->order('id desc')->field('id,name')->select()->toArray(); view::assign('list', $list); return view::fetch(); } /** * 预览详情 */ public function preview_read() { $id = input('id', 0); $data = VideoModel::where(['id' => $id, 'root_id' => request()->employee->root_id])->find(); //公司信息 $where[] = ['root_id', '=', request()->employee->root_id]; $data['company_info'] = Company::where($where)->field('company_name,logo,company_address')->find(); return json(['code' => 0, 'msg' => '获取成功', 'data' => $data]); } /** * 文件上传 */ public function fileupload() { $ali_oss_bindurl = config('app.ali_oss_bindurl'); $url = 'https://' . $ali_oss_bindurl . '/' . Request::param('file'); return json(['code' => 0, 'data' => ['src' => $url]]); } //数据统计 public function statistics_data_list() { $request = request(); $param=$request->only(['page'=>1,'limit'=>10,'org_id','time']); if (!request()->isAjax()) { $list=orgSubIds(request()->employee->root_id); $xins=[]; foreach($list as $key=>$val){ if(Org::where([['pid','=',$val],['status','=',1]])->value('id')){ $xins[]=$val; } } $orglist=Org::where([['id','in',$xins]])->field('id,name,pid')->select()->toArray(); view::assign('orglist', $orglist); return view::fetch(); } if(!empty($param['org_id'])){ $list=orgSubIds($param['org_id']); }else{ $list=orgSubIds(request()->employee->root_id); } $xin=[]; foreach($list as $key=>$val){ if(!Org::where([['pid','=',$val],['status','=',1]])->value('id')){ $xin[]=$val; } } $newlist=Org::with(['employee' => function ($sql) { $sql->where([['state', '=', '在职'], ['uid', '<>', 0]])->field('id,org_id'); }])->where([['id','in',$xin]])->field('id,name,pid')->page($param['page'],$param['limit'])->select()->toArray(); $orgid = array_column($newlist, 'id'); $empid = Employee::where([['org_id', 'in', $orgid], ['state', '=', '在职'], ['uid', '<>', 0]])->column('id'); $clue_type = 'video'; $share_type = 'Video'; //转发人数 if(!empty($param['time'])){ $newtime=explode(' - ', $param['time']); $start_time=$newtime[0].' 00:00:00'; $end_time=$newtime[1].' 23:59:59'; $where[] = ['share_time', 'between', [$start_time, $end_time]]; $clue_where[] = ['addtime', 'between', [$start_time, $end_time]]; $foot_where[] = ['addtime', 'between', [$start_time, $end_time]]; } $where[] = ['type', '=', $share_type]; $where[] = ['employee_id', 'in', $empid]; $clue_where[] = ['employee_id', 'in', $empid]; $clue_where[] = ['pipe_type', '=', $clue_type]; $foot_where[] = ['employee_id', 'in', $empid]; $foot_where[] = ['pipe_type', '=', $clue_type]; $shared_employee = ShareLog::where($where)->column('employee_id'); $clue_count = CustomerClue::where($clue_where)->column('employee_id'); $foot_data = Footprints::where($foot_where)->field('id,employee_id,uid,visit_due_time')->select()->toArray(); $new = []; foreach ($foot_data as $key => $val) { $new[$val['employee_id']][] = $val; } foreach ($newlist as $key => $val) { $empids = array_column($val['employee'], 'id'); $newlist[$key]['share_count'] = count(array_intersect($shared_employee, $empids)); $yes_share_count = count(array_unique(array_intersect($shared_employee, $empids))); $newlist[$key]['share_employee_count'] = $yes_share_count; $newlist[$key]['clue_count'] = count(array_intersect($clue_count, $empids)); $cont = $visit_due_time = $uid = 0; foreach ($new as $k => $v) { if (in_array($k, $empids)) { $cont += count($v); $visit_due_time += array_sum(array_column($v, 'visit_due_time')); $uid += count(array_unique(array_column($v, 'uid'))); } } $newlist[$key]['footprints_count'] = $cont; $newlist[$key]['visit_long'] = $visit_due_time; $newlist[$key]['footprints_user_count'] = $uid; $un_share_employee = count($empids) - $yes_share_count; $newlist[$key]['un_share_employee_count'] = $un_share_employee; } $count = Org::where([['id', 'in', $xin]])->count(); $all = $this->top_statistics_data($xin, !empty($param['time']) ? $param['time'] : 0); $data = ['list' => $newlist, 'all' => $all]; return json(['code' => 0, 'msg' => '获取成功', 'data' => $data, 'count' => $count]); } public function top_statistics_data($xin,$time=0) { $video_cont=VideoModel::where([['delete_time', '=', 0],['root_id', '=', request()->employee->root_id]])->count(); $all=['video_cont'=>$video_cont,'share_employee_count'=>0,'share_count'=>0,'clue_count'=>0,'footprints_count'=>0,'visit_long'=>0,'footprints_user_count'=>0,'un_share_employee_count'=>0]; $sub_employee_ids = Employee::where([['org_id', 'in', $xin], ['state', '=', '在职'], ['uid', '<>', 0]])->column('id'); $clue_type = 'video'; $share_type = 'Video'; //转发人数 if(!empty($time)){ $newtime=explode(' - ', $time); $start_time=$newtime[0].' 00:00:00'; $end_time=$newtime[1].' 23:59:59'; $where[] = ['share_time', 'between', [$start_time, $end_time]]; $clue_where[] = ['addtime', 'between', [$start_time, $end_time]]; $foot_where[] = ['addtime', 'between', [$start_time, $end_time]]; } $where[] = ['type', '=', $share_type]; $where[] = ['employee_id', 'in', $sub_employee_ids]; $shared_employee = ShareLog::where($where)->column('employee_id'); // 转发次数 $all['share_count'] = count($shared_employee); $all['share_employee_count']=count(array_values(array_unique($shared_employee))); // 获得线索 $clue_where[] = ['employee_id', 'in', $sub_employee_ids]; $clue_where[] = ['pipe_type', '=', $clue_type]; $clue_count = CustomerClue::where($clue_where)->count(); $all['clue_count']=$clue_count; // 浏览次数 $foot_where[] = ['employee_id', 'in', $sub_employee_ids]; $foot_where[] = ['pipe_type', '=', $clue_type]; $foot_user_count = Footprints::where($foot_where)->field('id,uid,visit_due_time')->select()->toArray(); $all['footprints_user_count']=count(array_unique(array_column($foot_user_count,'uid'))); // 浏览时长 $all['visit_long'] = array_sum(array_column($foot_user_count,'visit_due_time')); return $all; } //统计员工列表 public function statistics_emplist() { $request = request(); $param=$request->only(['page'=>1,'limit'=>10,'keyword','org_id','time']); if (!request()->isAjax()) { view::assign('org_id', $param['org_id']); return view::fetch(); } $e_where[]=['org_id', '=', $param['org_id']]; $e_where[]=['state', '=', '在职']; $e_where[]=['uid', '<>', 0]; if(!empty($param['keyword'])){ $e_where[]=['name','like','%'.$param['keyword'].'%']; } $employee_list = Employee::where($e_where)->field('id,name')->page($param['page'],$param['limit'])->select()->toArray(); $clue_type = 'video'; $share_type = 'Video'; $empid=array_column($employee_list,'id'); if(!empty($param['time'])){ $newtime=explode(' - ', $param['time']); $start_time=$newtime[0].' 00:00:00'; $end_time=$newtime[1].' 23:59:59'; $where[] = ['share_time', 'between', [$start_time, $end_time]]; $clue_where[] = ['addtime', 'between', [$start_time, $end_time]]; $foot_where[] = ['addtime', 'between', [$start_time, $end_time]]; } $where[]=['type', '=', $share_type]; $where[]=['employee_id', 'in', $empid]; $clue_where[]=['employee_id', 'in', $empid]; $clue_where[]=['pipe_type', '=', $clue_type]; $foot_where[] = ['employee_id', 'in', $empid]; $foot_where[] = ['pipe_type', '=', $clue_type]; $shared_employee = ShareLog::where($where)->column('employee_id'); $clue_count = CustomerClue::where($clue_where)->column('employee_id'); $foot_data = Footprints::where($foot_where)->field('id,employee_id,uid,visit_due_time')->select()->toArray(); $new=[]; foreach($foot_data as $key=>$val){ $new[$val['employee_id']][]=$val; } foreach($employee_list as $key=>$val){ $empids=[$val['id']]; $employee_list[$key]['share_count']=count(array_intersect($shared_employee,$empids)); $yes_share_count=count(array_unique(array_intersect($shared_employee,$empids))); $employee_list[$key]['share_employee_count']=$yes_share_count; $employee_list[$key]['clue_count']=count(array_intersect($clue_count,$empids)); $cont=$visit_due_time=$uid=0; foreach($new as $k=>$v){ if(in_array($k,$empids)){ $cont+=count($v); $visit_due_time+=array_sum(array_column($v,'visit_due_time')); $uid+=count(array_unique(array_column($v,'uid'))); } } $employee_list[$key]['footprints_count']=$cont; $employee_list[$key]['visit_long']=$visit_due_time; $employee_list[$key]['footprints_user_count']=$uid; $un_share_employee = count($empids) - $yes_share_count; $employee_list[$key]['un_share_employee_count'] = $un_share_employee; } $count=Employee::where($e_where)->count(); return json(['code' => 0, 'msg' => '获取成功', 'data' => $employee_list,'count'=>$count]); } //统计员工转发记录详情列表 public function emp_logdetail_list() { $request = request(); $param=$request->only(['page'=>1,'limit'=>10,'keyword','emp_id','time']); if (!request()->isAjax()) { view::assign('emp_id', $param['emp_id']); return view::fetch(); } $empid=$param['emp_id']; $share_list=$this->sel_emp_videolist($empid); if(!empty($param['keyword'])){ $key_list=VideoModel::where([['root_id','=',request()->employee->root_id],['title','like','%'.$param['keyword'].'%']])->column('id'); if(!empty($key_list)&&!empty($share_list)){ $tm= array_intersect($key_list,$share_list); if(!empty($tm)){ $share_list=$tm; }else{ return json(['code' => 0, 'msg' => '获取成功', 'data' => [],'count'=>0]); } }else{ return json(['code' => 0, 'msg' => '获取成功', 'data' => [],'count'=>0]); } } $list=VideoModel::where([['root_id','=',request()->employee->root_id],['id','in',$share_list]])->field('id,title')->page($param['page'],$param['limit'])->select()->toArray(); foreach($list as $key=>$val){ $clue_type = 'video'; $share_type = 'Video'; //转发人数 if(!empty($param['time'])){ $newtime=explode(' - ', $param['time']); $start_time=$newtime[0].' 00:00:00'; $end_time=$newtime[1].' 23:59:59'; $where[] = ['share_time', 'between', [$start_time, $end_time]]; $clue_where[] = ['addtime', 'between', [$start_time, $end_time]]; $foot_where[] = ['addtime', 'between', [$start_time, $end_time]]; } $where[] = ['type', '=', $share_type]; $where[] = ['employee_id', '=', $empid]; $where[] = ['data_id','=',$val['id']]; $list[$key]['share_count'] = ShareLog::where($where)->count(); // 获得线索 $clue_where[] = ['employee_id', '=', $empid]; $clue_where[] = ['pipe_type', '=', $clue_type]; $clue_where[] = ['pipe_id','=',$val['id']]; $clue_count = CustomerClue::where($clue_where)->count(); $list[$key]['clue_count'] = $clue_count; // 浏览次数 $foot_where[] = ['employee_id', '=', $empid]; $foot_where[] = ['pipe_type', '=', $clue_type]; $foot_where[] = ['reg_info', 'like', '{"id":' . $val['id'] . ',%']; $foot_user_count = Footprints::where($foot_where)->field('id,uid')->group('uid')->select(); $list[$key]['footprints_user_count'] = count($foot_user_count); // 浏览时长 $visit_long = Footprints::where($foot_where)->sum('visit_due_time'); $list[$key]['visit_long'] = $visit_long; $where = []; $clue_where = []; $foot_where = []; } $count=VideoModel::where([['root_id','=',request()->employee->root_id],['id','in',$share_list]])->count(); //$list = array_slice($list, ($param['page'] - 1) * $param['limit'],$param['limit']); return json(['code' => 0, 'msg' => '获取成功', 'data' => $list,'count'=>$count]); } //计算所有关联员工的视频id public function sel_emp_videolist($empid) { $clue_type = 'video'; $share_type = 'Video'; $where[] = ['type', '=', $share_type]; $where[] = ['employee_id', '=', $empid]; $shared_id = ShareLog::where($where)->group('data_id')->column('data_id'); $clue_where[] = ['employee_id', '=', $empid]; $clue_where[] = ['pipe_type', '=', $clue_type]; $clue_id = CustomerClue::where($clue_where)->group('pipe_id')->column('pipe_id'); $foot_where[] = ['employee_id', '=', $empid]; $foot_where[] = ['pipe_type', '=', $clue_type]; $foot_list = Footprints::where($foot_where)->field('id,pipe_type,reg_info')->select(); $foot_id=[]; foreach($foot_list as $key=>$val){ $m=$val->getData('reg_info'); if(!empty($m)){ $info=json_decode($m,true); $foot_id[]=$info['id']; } } $vdid=array_values(array_unique(array_merge($shared_id,$clue_id,$foot_id))); return $vdid; } }