123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use app\common\model\AcitivityOrder;
- use app\common\model\MeetingOrder;
- use app\common\model\OfficeOrderModel;
- use app\common\model\SheActivityModel;
- use think\Db;
- /**
- * 我的活动
- */
- class MyActivity extends Api
- {
- protected $noNeedLogin = ['acvitityLists', 'Info', 'listInfo', 'qustion', 'qustionInfo', 'buildInfo', 'protable', 'trueTime', 'chooseTime', 'GgInfo'];
- protected $noNeedRight = ['*'];
- /**
- * 我的活动(个人)
- */
- public function gerenFabu()
- {
- $page = $this->request->get('page');
- $limit = $this->request->get('limit');
- if (!$page) {
- $pages = '0,10';
- } else {
- $page = $page - 1;
- if ($page < 0) $page = 0;
- $pages = $page . ',' . $limit;
- }
- $sheActivityModel = new SheActivityModel();
- $user = $this->auth->getUser();
- $where = [];
- if ($user) $where['a.uid'] = $user['id'];
- $data = $sheActivityModel->alias('a')
- ->join('user u','a.uid=u.id',"left")
- ->where($where)
- ->limit($pages)
- ->order('a.create_time desc')
- ->field('a.*')
- ->select()->toArray();
- $time = date('Y-m-d H:i:s', time());
- foreach ($data as $k => $v) {
- if ($time < $v['start_time']) {
- $data[$k]['status'] = '0';
- $data[$k]['status_str'] = '未开始';
- }
- if ($time > $v['start_time'] && $time < $v['end_time']) {
- $data[$k]['status'] = '1';
- $data[$k]['status_str'] = '报名中';
- }
- if ($time > $v['end_time']) {
- $data[$k]['status'] = '3';
- $data[$k]['status_str'] = '报名结束';
- }
- $order = AcitivityOrder::where('a_id', $v['id'])->column('uid');
- $str = implode(',', $order);
- $data[$k]['users'] = Db::name('user')->where('id', 'in', $str)->field('id,avatar')->select();
- unset($order);
- }
- return json(['code' => 1, 'data' => $data]);
- }
- /**
- * 我参与的
- */
- public function join()
- {
- $user = $this->auth->getUser();
- // 后台发布的活动
- $data = Db::name('park_order o')
- ->join('park_activity p','o.a_id=p.id')
- ->where('o.uid',$user['id'])
- ->select();
- $time = date('Y-m-d H:i:s', time());
- if (!empty($data)) {
- foreach ($data as $m=>$n) {
- $data[$m]['type'] = 1;
- $data[$m]['mianfei'] = '';
- $data[$m]['price'] = '';
- $data[$m]['image'] = config('site.httpurl'). $data[$m]['image'];
- $data[$m]['images'] =[];
- $data[$m]['notice'] =$data[$m]['content'];
- if ($time < $data[$m]['start_time']) {
- $data[$m]['status'] = '0';
- $data[$m]['status_str'] = '未开始';
- }
- if ($time > $data[$m]['start_time'] && $time < $data[$m]['end_time']) {
- $data[$m]['status'] = '1';
- $data[$m]['status_str'] = '报名中';
- }
- if ($time > $data[$m]['end_time']) {
- $data[$m]['status'] = '3';
- $data[$m]['status_str'] = '报名结束';
- }
- $data[$m]['num_count'] = Db::name('park_order')->where('a_id',$n['id'])->count();
- $arr = Db::name('park_order')->where('a_id',$n['id'])->column('uid');
- $arrStr = implode(',',$arr);
- unset($arr);
- $data[$m]['user'] = Db::name('user')->where('id','in',$arrStr)->field('id,avatar')->select();
- }
- }
- // 用户发布的活动
- $activcityOrder = new AcitivityOrder();
- $data1 = $activcityOrder->alias('o')
- ->join('avcitity a','o.a_id = a.id','left')
- ->where('o.uid',$user['id'])
- ->select();
- if (!empty($data1)) {
- foreach ($data1 as $k=>$v) {
- $data1[$k]['type'] = 2;
- if ($time < $data1[$k]['start_time']) {
- $data1[$k]['status'] = '0';
- $data1[$k]['status_str'] = '未开始';
- }
- if ($time > $data1[$k]['start_time'] && $time < $data1[$k]['end_time']) {
- $data1[$k]['status'] = '1';
- $data1[$k]['status_str'] = '报名中';
- }
- if ($time > $data1[$k]['end_time']) {
- $data1[$k]['status'] = '3';
- $data1[$k]['status_str'] = '报名结束';
- }
- $arr = $activcityOrder->where('a_id',$v['a_id'])->group('uid')->column('uid');
- $arrStr = implode(',',$arr);
- unset($arr);
- $data1[$k]['user'] = Db::name('user')->where('id','in',$arrStr)->field('id,avatar')->select();
- }
- }
- $data2 = array_merge($data1,$data);
- return json(['code' =>1,'data'=>$data2]);
- }
- /**
- * 我分享的
- */
- public function fenxiang()
- {
- $user = $this->auth->getUser();
- // 后台发布的活动
- $data = Db::name('activity_fenxiang o')
- ->join('park_activity p','o.a_id=p.id')
- ->where('o.uid',$user['id'])
- ->where('type',1)
- ->select();
- $time = date('Y-m-d H:i:s', time());
- if (!empty($data)) {
- foreach ($data as $m=>$n) {
- $data[$m]['type'] = 1;
- $data[$m]['mianfei'] = '';
- $data[$m]['price'] = '';
- $data[$m]['image'] = config('site.httpurl'). $data[$m]['image'];
- $data[$m]['images'] =[];
- $data[$m]['notice'] =$data[$m]['content'];
- if ($time < $data[$m]['start_time']) {
- $data[$m]['status'] = '0';
- $data[$m]['status_str'] = '未开始';
- }
- if ($time > $data[$m]['start_time'] && $time < $data[$m]['end_time']) {
- $data[$m]['status'] = '1';
- $data[$m]['status_str'] = '报名中';
- }
- if ($time > $data[$m]['end_time']) {
- $data[$m]['status'] = '3';
- $data[$m]['status_str'] = '报名结束';
- }
- $data[$m]['num_count'] = Db::name('activity_fenxiang')->where('type',1)->where('a_id',$n['id'])->count();
- $arr = Db::name('activity_fenxiang')->where('type',1)->where('a_id',$n['id'])->column('uid');
- $arrStr = implode(',',$arr);
- unset($arr);
- $data[$m]['user'] = Db::name('user')->where('id','in',$arrStr)->field('id,avatar')->select();
- }
- }
- // 用户发布的活动
- $activcityOrder = new AcitivityOrder();
- $data1 = Db::name('activity_fenxiang o')
- ->join('avcitity a','o.a_id = a.id','left')
- ->where('o.uid',$user['id'])
- ->where('type',2)
- ->select();
- if (!empty($data1)) {
- foreach ($data1 as $k=>$v) {
- $data1[$k]['type'] = 2;
- if ($time < $data1[$k]['start_time']) {
- $data1[$k]['status'] = '0';
- $data1[$k]['status_str'] = '未开始';
- }
- if ($time > $data1[$k]['start_time'] && $time < $data1[$k]['end_time']) {
- $data1[$k]['status'] = '1';
- $data1[$k]['status_str'] = '报名中';
- }
- if ($time > $data1[$k]['end_time']) {
- $data1[$k]['status'] = '3';
- $data1[$k]['status_str'] = '报名结束';
- }
- $arr = Db::name('activity_fenxiang')->where('type',2)->where('a_id',$v['a_id'])->group('uid')->column('uid');
- $arrStr = implode(',',$arr);
- unset($arr);
- $data1[$k]['user'] = Db::name('user')->where('id','in',$arrStr)->field('id,avatar')->select();
- }
- }
- $data2 = array_merge($data1,$data);
- return json(['code' =>1,'data'=>$data2]);
- }
- /**
- * 我收藏的
- */
- public function collection()
- {
- $user = $this->auth->getUser();
- // 后台发布的活动
- $data = Db::name('activity_collection o')
- ->join('park_activity p','o.a_id=p.id')
- ->where('o.uid',$user['id'])
- ->select();
- $time = date('Y-m-d H:i:s', time());
- if (!empty($data)) {
- foreach ($data as $m=>$n) {
- $data[$m]['type'] = 1;
- $data[$m]['mianfei'] = '';
- $data[$m]['price'] = '';
- $data[$m]['image'] = config('site.httpurl'). $data[$m]['image'];
- $data[$m]['images'] =[];
- $data[$m]['notice'] =$data[$m]['content'];
- if ($time < $data[$m]['start_time']) {
- $data[$m]['status'] = '0';
- $data[$m]['status_str'] = '未开始';
- }
- if ($time > $data[$m]['start_time'] && $time < $data[$m]['end_time']) {
- $data[$m]['status'] = '1';
- $data[$m]['status_str'] = '报名中';
- }
- if ($time > $data[$m]['end_time']) {
- $data[$m]['status'] = '3';
- $data[$m]['status_str'] = '报名结束';
- }
- $data[$m]['num_count'] = Db::name('activity_collection')->where('a_id',$n['id'])->count();
- $arr = Db::name('activity_collection')->where('a_id',$n['id'])->column('uid');
- $arrStr = implode(',',$arr);
- unset($arr);
- $data[$m]['user'] = Db::name('user')->where('id','in',$arrStr)->field('id,avatar')->select();
- }
- }
- // 用户发布的活动
- $activcityOrder = new AcitivityOrder();
- $data1 = Db::name('user_collection o')
- ->join('avcitity a','o.a_id = a.id','left')
- ->where('o.uid',$user['id'])
- ->select();
- if (!empty($data1)) {
- foreach ($data1 as $k=>$v) {
- $data1[$k]['type'] = 2;
- if ($time < $data1[$k]['start_time']) {
- $data1[$k]['status'] = '0';
- $data1[$k]['status_str'] = '未开始';
- }
- if ($time > $data1[$k]['start_time'] && $time < $data1[$k]['end_time']) {
- $data1[$k]['status'] = '1';
- $data1[$k]['status_str'] = '报名中';
- }
- if ($time > $data1[$k]['end_time']) {
- $data1[$k]['status'] = '3';
- $data1[$k]['status_str'] = '报名结束';
- }
- $arr = Db::name('user_collection')->where('a_id',$v['a_id'])->group('uid')->column('uid');
- $arrStr = implode(',',$arr);
- unset($arr);
- $data1[$k]['user'] = Db::name('user')->where('id','in',$arrStr)->field('id,avatar')->select();
- }
- }
- $data2 = array_merge($data1,$data);
- return json(['code' =>1,'data'=>$data2]);
- }
- /**
- * 我的活动(商家/企业)
- * @param string $type 0全部1待审核2已结束3已取消
- */
- public function qiye()
- {
- $type = $this->request->get('type');
- $page = $this->request->get('page');
- $limit = $this->request->get('limit');
- if (!$page) {
- $pages = '0,10';
- } else {
- $page = $page - 1;
- if ($page < 0) $page = 0;
- $pages = $page . ',' . $limit;
- }
- if ($type==0) {
- $sheActivityModel = new SheActivityModel();
- $user = $this->auth->getUser();
- $where = [];
- if ($user) $where['a.uid'] = $user['id'];
- $data = $sheActivityModel->alias('a')
- ->join('user u','a.uid=u.id',"left")
- ->where($where)
- ->limit($pages)
- ->order('create_time desc')
- ->field('a.*')
- ->select()->toArray();
- if (empty($data)) return json(['code'=>1,'data'=>$data]);
- $time = date('Y-m-d H:i:s', time());
- foreach ($data as $k => $v) {
- $startTime = strtotime($v['start_time']);
- $endTime = strtotime($v['end_time']);
- if ($v['is_quxiao'] == 1) {
- $data[$k]['status'] = '3';
- $data[$k]['status_str'] = '已取消';
- } else if($v['is_quxiao']==0&&$v['switch']==0) {
- $data[$k]['status'] = '1';
- $data[$k]['status_str'] = '待审核';
- } else if ($v['is_quxiao']==0&&$v['switch']==1) {
- if ($startTime <= $time && $endTime >= $time) {
- $data[$k]['status'] = 4;
- $data[$k]['status_name'] = '进行中';
- Db::name('park_activity')->where('id',$v['id'])->update(['status' => 1]);
- } elseif ( $startTime > $time && $endTime > $time) {
- $data[$k]['status'] = 0;
- $data[$k]['status_name'] = '未开始';
- Db::name('park_activity')->where('id',$v['id'])->update(['status' => 0]);
- } elseif ($startTime <= $time && $endTime <= $time) {
- $data[$k]['status'] = 2;
- $data[$k]['status_name'] = '已结束';
- Db::name('park_activity')->where('id',$v['id'])->update(['status' => 2]);
- }
- }
- $order = AcitivityOrder::where('a_id',$v['id'])->column('uid');
- $str = implode(',',$order);
- $data[$k]['users'] = Db::name('user')->where('id','in',$str)->field('id,avatar')->select();
- unset($order);
- }
- return json(['code'=>1,'data'=>$data]);
- } else if($type==1) {
- $sheActivityModel = new SheActivityModel();
- $user = $this->auth->getUser();
- $where = [];
- if ($user) $where['a.uid'] = $user['id'];
- $data = $sheActivityModel->alias('a')
- ->join('user u','a.uid=u.id',"left")
- ->where($where)
- ->limit($pages)
- ->where('switch',0)
- ->where('is_quxiao',0)
- ->order('create_time desc')
- ->field('a.*')
- ->select()->toArray();
- if (empty($data)) return json(['code'=>1,'data'=>$data]);
- $time = date('Y-m-d H:i:s', time());
- foreach ($data as $k => $v) {
- // if ($v['is_quxiao'] == 1) {
- // $data[$k]['status'] = '3';
- // $data[$k]['status_str'] = '已取消';
- // } else if($v['is_quxiao']==0&&$v['switch']==0) {
- $data[$k]['status'] = '1';
- $data[$k]['status_str'] = '待审核';
- // }
- //
- // if ($time > $v['end_time']) {
- // $data[$k]['status'] = '2';
- // $data[$k]['status_str'] = '已结束';
- // }
- $order = AcitivityOrder::where('a_id',$v['id'])->column('uid');
- $str = implode(',',$order);
- $data[$k]['users'] = Db::name('user')->where('id','in',$str)->field('id,avatar')->select();
- unset($order);
- }
- return json(['code'=>1,'data'=>$data]);
- } else if($type==2) {
- $sheActivityModel = new SheActivityModel();
- $user = $this->auth->getUser();
- $where = [];
- if ($user) $where['a.uid'] = $user['id'];
- $data = $sheActivityModel->alias('a')
- ->join('user u','a.uid=u.id',"left")
- ->where($where)
- ->limit($pages)
- ->order('create_time desc')
- ->field('a.*')
- ->select()->toArray();
- if (empty($data)) return json(['code'=>1,'data'=>$data]);
- $time = date('Y-m-d H:i:s', time());
- $res = [];
- foreach ($data as $k => $v) {
- if ($time > $v['end_time']) {
- $res[$k] = $v;
- $res[$k]['status'] = '2';
- $res[$k]['status_str'] = '已结束';
- $order = AcitivityOrder::where('a_id',$v['id'])->column('uid');
- $str = implode(',',$order);
- unset($order);
- $res[$k]['users'] = Db::name('user')->where('id','in',$str)->field('id,avatar')->select();
- }
- }
- return json(['code'=>1,'data'=>$res]);
- } else if($type==3) {
- $sheActivityModel = new SheActivityModel();
- $user = $this->auth->getUser();
- $where = [];
- if ($user) $where['a.uid'] = $user['id'];
- $data = $sheActivityModel->alias('a')
- ->join('user u','a.uid=u.id',"left")
- ->where($where)
- ->limit($pages)
- // ->where('switch',0)
- ->where('is_quxiao',1)
- ->order('create_time desc')
- ->field('a.*')
- ->select()->toArray();
- if (empty($data)) return json(['code'=>1,'data'=>$data]);
- $time = date('Y-m-d H:i:s', time());
- foreach ($data as $k => $v) {
- $data[$k]['status'] = '3';
- $data[$k]['status_str'] = '已取消';
- $order = AcitivityOrder::where('a_id',$v['id'])->column('uid');
- $str = implode(',',$order);
- $data[$k]['users'] = Db::name('user')->where('id','in',$str)->field('id,avatar')->select();
- unset($order);
- }
- return json(['code'=>1,'data'=>$data]);
- }
- }
- /**
- * 报名人员
- *
- * @param string $id 活动id
- */
- public function baoming()
- {
- $id = $this->request->get('id');
- $orderModel = new AcitivityOrder();
- $page = $this->request->get('page');
- $limit = $this->request->get('limit');
- if (!$page) {
- $pages = '0,10';
- } else {
- $page = $page - 1;
- if ($page < 0) $page = 0;
- $pages = $page . ',' . $limit;
- }
- $data = $orderModel->alias('a')
- ->where('a_id',$id)
- ->group('uid')
- ->limit($pages)
- ->column('uid');
- if (empty($data)) return $this->success('',[]);
- $dataArr = implode(',',$data);
- $users = Db::name('user')
- ->where('id','in',$dataArr)
- ->where('status',1)
- ->field('id,username,position,company')
- ->select();
- foreach ($users as $k=>$v) {
- if (!empty($v['company'])) {
- $isqiye = Db::name('user')->where('group_id',2)->where('shenhe_status',0)->find();
- if ($isqiye) {
- $users[$k]['company_str'] =$isqiye['notice'];
- } else {
- $users[$k]['company_str'] = '';
- }
- } else {
- $users[$k]['company_str'] = '';
- }
- }
- return $this->success('',$users);
- }
- /**
- * 我的办公室订单
- */
- public function officeOrder()
- {
- $page = $this->request->get('page');
- $limit = $this->request->get('limit');
- if (!$page) {
- $pages = '0,10';
- } else {
- $page = $page - 1;
- if ($page < 0) $page = 0;
- $pages = $page . ',' . $limit;
- }
- $user = $this->auth->getUser();
- $orderModel = new OfficeOrderModel();
- $data = $orderModel
- ->with(['office'])
- ->where('uid',$user['id'])
- ->limit($pages)
- ->order('create_time desc')
- ->select();
- return $this->success('',$data);
- }
- /**
- * 我的会议室订单
- */
- public function meetingOrder()
- {
- $page = $this->request->get('page');
- $limit = $this->request->get('limit');
- if (!$page) {
- $pages = '0,10';
- } else {
- $page = $page - 1;
- if ($page < 0) $page = 0;
- $pages = $page . ',' . $limit;
- }
- $user = $this->auth->getUser();
- $orderModel = new MeetingOrder();
- $data = $orderModel
- ->with(['meeting'])
- ->where('u_id',$user['id'])
- ->limit($pages)
- ->order('create_time desc')
- ->select();
- return $this->success('',$data);
- }
- /**
- *
- * 邀请记录
- * @param string $a_id $活动id
- */
- public function yaoqing()
- {
- $a_id = $this->request->get('a_id');
- $user = $this->auth->getUser();
- $beUid = Db::name('fenxiang')
- ->where('a_id',$a_id)
- ->where('u_id',$user['id'])
- ->column('be_uid');
- $str = implode(',',$beUid);
- $users = Db::name('user')->where('id','in',$str)->where('status',1)->field('id,username,avatar')->select();
- return json(['code' => 1, 'data'=>$users]);
- }
- }
|