123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <?php
- namespace app\adminall\controller;
- use think\facade\View;
- use think\facade\Request;
- use app\logics\Activity as Logic;
- use app\model\Activity as ModelActivity;
- use app\model\ActivityCustomerExportLog;
- use app\model\Footprints;
- use think\facade\Db;
- use app\model\Employee;
- use app\model\Customer;
- use app\model\Org;
- use app\model\Permission;
- use app\model\Grant;
- use app\model\CustomerVisitLog;
- use app\model\Broadcast;
- use app\model\Lecturer;
- class Boss
- {
- private $root_id = 0;//总后台店面id默认0
- private $employee_id = 0;
- /**
- * 列表
- */
- public function list()
- {
- if (!Request::isAjax()) {
- $eid = ModelActivity::where([['del', '=', 0], ['root_id', '=', $this->root_id], ['employee_id', '>', 0]])->group('employee_id')->column('employee_id');
- $where = [
- ['del', '=', 0],
- ['root_id', '=', $this->root_id]
- ];
- // 运营人员列表
- $employee = Lecturer::where($where)->column('id,name');
- View::assign('employee', $employee);
- return View::fetch();
- }
- $param = Request::only(['page', 'limit', 'keyword', 'date', 'employee_id']);
- $where = [
- ['del', '=', 0],
- ['root_id', '=', $this->root_id]
- ];
- if (!empty($param['date'])) {
- $dates = explode(' - ', $param['date']);
- $where[] = ['start_date', '>=', strtotime($dates[0])];
- $where[] = ['start_date', '<=', strtotime($dates[1])];
- }
- if (!empty($param['keyword'])) {
- $where[] = ['name', 'like', '%' . $param['keyword'] . '%'];
- }
- if (!empty($param['employee_id'])) {
- $where[] = ['lecturer_id', '=', $param['employee_id']];
- }
- $list = Broadcast::with(['lecturer'=>function($query){
- $query->bind(['lecturer_name'=>'name']);
- }])->where($where)->page($param['page'], $param['limit'])->field('*')->order('addtime desc')->select()->toArray();
- $aids = [];
- foreach ($list as &$val) {
- $val['start_date'] = str_replace('-','/',$val['start_date']);
- $val['end_date'] = str_replace('-','/',$val['end_date']);
- $val['time'] = $val['start_date'].'-'.$val['end_date'];
- $val['type'] = $val['broadcast_type']==1 ? '威哥直播' : '直播';
- $val['broadcast_platform'] = $val['broadcast_platform']==1 ? '其他平台' : 'boos直播';
- }
- $count = Broadcast::where($where)->count();
- return json(['code' => 0, 'data' => $list, 'count' => $count, 'msg' => '获取成功']);
- }
- /**
- * 添加视图
- */
- public function add()
- {
- //讲师列表
- $employee = Lecturer::where([['del','=',0],['root_id','=',0]])->column('name,id');
- View::assign('employee', $employee);
- return View::fetch();
- }
- /**
- * 删除直播
- */
- public function del()
- {
- $id = input('id',0);
- Broadcast::where([['id','=',$id],['root_id','=',0]])->update(['del'=>1]);
- return json(['code' => 0, 'msg' => '删除成功']);
- }
- /**
- * 添加直播
- */
- public function addActivity()
- {
- $data = Request::only(['name','lecturer_id','start_date','broadcast_type','broadcast_platform','broadcast_url','broadcast_cover']);
- $date = explode(' - ',$data['start_date']);
- $data['start_date'] = strtotime($date[0]);
- $data['end_date'] = strtotime($date[1]);
- $data['root_id'] = $this->root_id;
- $data['addtime'] = time();
- if ($data['start_date'] > $data['end_date']) return json(['code' => 1, 'msg' => '开始日期需在结束日期之前']);
- Broadcast::insert($data);
- return json(['code' => 0, 'msg' => '添加成功']);
- }
- /**
- * 修改视图
- */
- public function edit($id)
- {
- $where = [
- ['root_id','=',0],
- ['id','=',$id]
- ];
- $data = Broadcast::where($where)->findOrEmpty();
- View::assign('data', $data);
- //讲师列表
- $employee = Lecturer::where([['del','=',0],['root_id','=',0]])->column('name,id');
- View::assign('employee', $employee);
- return View::fetch();
- }
- /**
- * 编辑直播
- */
- public function editActivity()
- {
- $data = Request::only(['name','lecturer_id','start_date','broadcast_type','broadcast_platform','broadcast_url','broadcast_cover']);
- $id = input('id',0);
- $info = Broadcast::where([['root_id','=',0],['id','=',$id]])->findOrEmpty();
- $date = explode(' - ',$data['start_date']);
- $data['start_date'] = strtotime($date[0]);
- $data['end_date'] = strtotime($date[1]);
- foreach ($data as $key => $value) {
- $info->$key = $value;
- }
- $info->save();
- return json(['code' => 0, 'msg' => '添加成功']);
- }
- /**
- * 直播回访
- */
- public function playback()
- {
- $id = input('id',0);
- $data = Broadcast::where([['root_id','=',0],['id','=',$id]])->field('id,playback_cover,playback_url')->findOrEmpty();
- View::assign('data', $data);
- return View::fetch();
- }
- /**
- * 直播回访
- */
- public function savePlayback()
- {
- $data = Request::only(['playback_cover'=>'','playback_url'=>'']);
- $id = input('id',0);
- $info = Broadcast::where([['root_id','=',0],['id','=',$id]])->field('id,playback_cover,playback_url')->findOrEmpty();
- foreach ($data as $key => $value) {
- $info->$key = $value;
- }
- $info->save();
- return json(['code' => 0, 'msg' => '保存成功','data'=>'保存成功']);
- }
- }
|