coachId; if($pageType==1){ $res = json_decode(http('api/feedback/coach/demand-new/list/'.$uid, 'post', $this->authUsername,$param,'armor'),true); $views='index'; }elseif($pageType==2){ $res = json_decode(http('api/feedback/coach/demand-running/list/'.$uid, 'post', $this->authUsername,$param,'armor'),true); $views='runnin'; }elseif($pageType==3){ $res = json_decode(http('api/feedback/coach/demand-queued/list/'.$uid, 'post', $this->authUsername,$param,'armor'),true); $views='queued'; }elseif($pageType==4){ $res = json_decode(http('api/feedback/coach/demand-rejected/list/'.$uid, 'post', $this->authUsername,$param,'armor'),true); $views='rejected'; }elseif($pageType==5){ $res = json_decode(http('api/feedback/coach/demand-completed/list/', 'post', $this->authUsername,$param,'armor'),true); $views='completed'; }else{ $res = json_decode(http('api/feedback/coach/demand-new/list/'.$uid, 'post', $this->authUsername,$param,'armor'),true); } //debug($res); $data=array(); if(isset($res['errCode']) && $res['errCode']=='00' && isset($res['data']) && $res['data']){ $data['list']=$res['data']['list']; $data['pageTotal']=$res['data']['totalPage']; $data['page']=$res['data']['current']; } $param['pagetype']=$pageType; $data['param']=$param; $pageQuery=$param; unset($pageQuery['page']); $data['query_page']=http_build_query($pageQuery); $navQuery=$param; unset($navQuery['pagetype']); $data['query_nav']=http_build_query($navQuery); $data['pageType']=$pageType; if(isset($data['list'] )){ foreach ($data['list'] as $key=>$val){ $data['list'][$key]['id']=number_format($val['id'],0,'',''); $data['list'][$key]['projectId']=number_format($val['projectId'],0,'',''); } } $url = Yii::app()->params['armor']['url'].'api/upload/file'; $data['uploadUrl'] = $url; $data['basic'] = $this->setToken(); $this->render($views, $data); } public function actionReply(){ $id=Req::get('id'); //优先级 $status=Req::get('status'); if(!$id){ Yii::app()->jump->error('需求Id不正确!'); } $uid=$this->coachId; if(isset(Yii::app()->session['coachInfo']['real_name']) && Yii::app()->session['coachInfo']['real_name']){ $authUsername=Yii::app()->session['coachInfo']['real_name']; }else{ $authUsername=Yii::app()->session['coachInfo']['coach_name']; } $param['demandId']=$id; $param['status']=$status; $param['coachId']=$uid; $param['readPeople']=$authUsername; //读取基本信息 $res = json_decode(http('api/feedback/coach/demand/detail', 'post', $this->authUsername,$param,'armor'),true); // debug($res); if(isset($res['errCode']) && $res['errCode']=='00' && isset($res['data']) && $res['data']){ $data['data']=$res['data']; $data['data']['id']=number_format($data['data']['id'],0,'',''); }else{ Yii::app()->jump->error('接口错误!'); } //是否点过赞 $data['is_like']=0; $uid=$this->coachId; $res_like = json_decode(http('api/feedback/coach/demand/is-like/'.$id.'/'.$uid, 'get', $this->authUsername,array(),'armor'),true); if(isset($res_like['errCode']) && $res_like['errCode']=='00' && isset($res_like['data']) && $res_like['data']){ if($res_like['data']['count']>0){ $data['is_like']=1; } } $res_r = json_decode(http('api/feedback/coach/demand/reply/'.$id, 'get', $this->authUsername,array(),'armor'),true); if(isset($res_r['errCode']) && $res_r['errCode']=='00' && isset($res_r['data']) && $res_r['data']){ $data['reply']=$res_r['data']; } $this->render('reply', $data); } //发送回复 public function actionSendReply(){ $id=Req::post('id'); $msg=Req::post('msg'); $result['status']=0; if(!$id || !$msg){ exit(json_encode($result)); } $uid=$this->coachId; if(isset(Yii::app()->session['coachInfo']['real_name']) && Yii::app()->session['coachInfo']['real_name']){ $authUsername=Yii::app()->session['coachInfo']['real_name']; }else{ $authUsername=Yii::app()->session['coachInfo']['coach_name']; } $param['demandId']=$id; $param['content']=$msg; $param['replyPeople']=$authUsername; $res = json_decode(http('api/feedback/coach/demand/reply/'.$uid, 'post', $this->authUsername,$param,'armor'),true); if(isset($res['errCode']) && $res['errCode']=='00'){ $result['status']=1; $result['data']=array( 'msg'=>$msg, 'username'=>$authUsername, 'time'=>date('Y-m-d',time()) ); } exit(json_encode($result)); } //点赞 public function actionPraise(){ $id=Req::post('id'); $result['status']=0; if(!$id ){ exit(json_encode($result)); } $uid=$this->coachId; $param=array(); $param['coachId']=$uid; if(isset(Yii::app()->session['coachInfo']['real_name']) && Yii::app()->session['coachInfo']['real_name']){ $param['likePeople']=Yii::app()->session['coachInfo']['real_name']; }else{ $param['likePeople']=Yii::app()->session['coachInfo']['coach_name']; } $res = json_decode(http('api/feedback/coach/demand/like/'.$id, 'post', $this->authUsername,$param,'armor'),true); if(isset($res['errCode']) && $res['errCode']=='00'){ $result['status']=1; $result['likePeople']=$param['likePeople']; } exit(json_encode($result)); } //取消点赞 public function actionCancelPraise(){ $id=Req::post('id'); $result['status']=0; if(!$id ){ exit(json_encode($result)); } $uid=$this->coachId; $param=array(); $param['coachId']=$uid; if(isset(Yii::app()->session['coachInfo']['real_name']) && Yii::app()->session['coachInfo']['real_name']){ $param['likePeople']=Yii::app()->session['coachInfo']['real_name']; }else{ $param['likePeople']=Yii::app()->session['coachInfo']['coach_name']; } $res = json_decode(http('api/feedback/coach/demand/dislike/'.$id.'/'.$uid, 'post', $this->authUsername,$param,'armor'),true); if(isset($res['errCode']) && $res['errCode']=='00'){ $result['status']=1; } exit(json_encode($result)); } //下载附件 public function actionDownload(){ $id=Req::post('id'); $result['status']=0; if(!$id ){ exit(json_encode($result)); } $param=array(); $res = json_decode(http('api/feedback/coach/demand/accessory/'.$id, 'get', $this->authUsername,$param,'armor'),true); if(isset($res['errCode']) && $res['errCode']=='00'){ $result['status']=1; } exit(json_encode($result)); } public function actionAdd(){ $param['title']=Req::post('title'); $param['type']=Req::post('type'); $param['priority']=Req::post('priority'); $param['question']=Req::post('question'); $param['target']=Req::post('target'); $param['releaseTime']=date('Y-m-d H:i:s',strtotime(Req::post('releaseTime'))); $param['urlList'][]=Req::post('urlList'); $uid=$this->coachId; $result['status']=0; if(isset(Yii::app()->session['coachInfo']['real_name']) && Yii::app()->session['coachInfo']['real_name']){ $param['origin']=Yii::app()->session['coachInfo']['real_name']; }else{ $param['origin']=Yii::app()->session['coachInfo']['coach_name']; } if(!$param['title'] || !$param['question'] || !$param['target'] || !$param['releaseTime']){ exit(json_encode($result)); } $res = json_decode(http('api/feedback/coach/demand/add/'.$uid, 'post', $this->authUsername,$param,'armor'),true); if(isset($res['errCode']) && $res['errCode']=='00'){ $result['status']=1; }else{ $result['msg']=$res['errMsg']; } exit(json_encode($result)); } public function setToken(){ $sign = $this->authUsername.Yii::app()->params['armor']['sign_url'].Yii::app()->params['armor']['sign']; $authPassword = md5($sign); $basic = "Basic ". base64_encode($this->authUsername.":".$authPassword); return $basic; } public function actionPlan(){ $Year=Req::get('year'); $Week=Req::get('week'); $Stage=Req::get('stage'); $Sort=Req::get('sort'); $Origin=Req::get('origin'); $Month=Req::get('month'); $param=array(); $urlArr=array(); if($Year && $Week){ $urlArr['year']=$Year; $urlArr['week']=$Week; $urlArr['month']=$Month; $times=$this->weekday($Year,$Week); $param['startTime']=date('Y-m-d H:i:s',$times['start']); $param['endTime']=date('Y-m-d H:i:s',$times['end']); }else{ $urlArr['year']=date('Y'); $urlArr['month']=date('m'); $urlArr['week']=date('W'); $times=$this->weekday($urlArr['year'],$urlArr['week']); $param['startTime']=date('Y-m-d H:i:s',$times['start']); $param['endTime']=date('Y-m-d H:i:s',$times['end']); } if($Stage){ $urlArr['stage']=$Stage; if($Stage==7){ $param['status']=0; }else{ $param['stage']=(string)$Stage; } } if($Sort){ $urlArr['sort']=$Sort; $param['sort']=$Sort; } if($Origin){ $urlArr['origin']=$Origin; $param['origin']=$Origin; } $res = json_decode(http('api/feedback/coach/demand-plan/list', 'post', $this->authUsername,$param,'armor'),true); // debug($res); $data=array(); if(isset($res['errCode']) && $res['errCode']=='00' && isset($res['data']) && $res['data']){ $data['data']=$res['data']; }else{ // Yii::app()->jump->error('接口错误!'); } $data['urlArr']=$urlArr; $data['Year']=$urlArr['year']; $data['Month']=$urlArr['month']; $data['Week']=$urlArr['week']; if(isset($urlArr['origin'])) $data['origin']=$urlArr['origin']; $this->render('plan', $data); } public function actionGetWeek(){ $Y=Req::post('year'); $M=Req::post('month'); $today = date("Y-m-d",strtotime("$Y-$M")); $firstday = date('Y-m-01', strtotime($today));//本月第一天 $lastday = date('Y-m-d', strtotime("$firstday +1 month -1 day"));//本月最后一天 $firstWeek=intval(date('W',strtotime($firstday))); $lastWeek=intval(date('W',strtotime($lastday))); $result['status']=1; $week=array(); if($lastWeek>$firstWeek){ for($i=$firstWeek;$i<=$lastWeek;$i++){ $week[]=$i; } }else{ if($lastWeek==1 && $M==12){ $lastWeek=date('W',strtotime($lastday)-86400*7); for($i=$firstWeek;$i<=$lastWeek;$i++){ $week[]=$i; } }else{ $week[]=$firstWeek; for($i=1;$i<=$lastWeek;$i++){ $week[]=$i; } } } $result['week']=$week; exit(json_encode($result)); } private function weekday($year,$week=1){ $year_start = mktime(0,0,0,1,1,$year); $year_end = mktime(0,0,0,12,31,$year); // 判断第一天是否为第一周的开始 if (intval(date('W',$year_start))===1){ $start = $year_start;//把第一天做为第一周的开始 }else{ $week++; $start = strtotime('+1 monday',$year_start);//把第一个周一作为开始 } // 第几周的开始时间 if ($week===1){ $weekday['start'] = $start; }else{ $weekday['start'] = strtotime('+'.($week-0).' monday',$start); } // 第几周的结束时间 $weekday['end'] = strtotime('+1 sunday',$weekday['start']); if (date('Y',$weekday['end'])!=$year){ $weekday['end'] = $year_end; } return $weekday; } }