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() { $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; } $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']) ->limit($pages) ->column('be_uid'); $str = implode(',',$beUid); $users = Db::name('user') ->where('id','in',$str) ->where('status',1) ->field('id,username,avatar,mobile') ->select(); return json(['code' => 1, 'data'=>$users]); } }