123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426 |
- <?php
- /**
- * Created by 上海互教教育科技有限公司.
- * User: li
- * Date: 2018/11/6
- * Time: 下午 15:29
- */
- class FeedbackController extends Controller
- {
- public function actionIndex(){
- //$alikeName=Req::post('keyword');
- $priority=Req::get('priority'); //优先级
- $type=Req::get('type'); //类型
- $readStatus=Req::get('readStatus'); //读状态
- $origin=Req::get('origin');
- $pageNum=Req::get('page');
- $pageType=Req::get('pagetype');
- $chargeMan=Req::get('chargeMan');
- if(!$pageType) $pageType=1;
- $param=array();
- if(in_array($priority,array(-1,0,1,2))){
- $param['priority']=$priority;
- }
- if(in_array($readStatus,array(-0,1))){
- $param['readStatus']=$readStatus;
- }
- if(in_array($type,array(-1,0,1,2))){
- $param['type']=$type;
- }
- if($origin){
- $param['origin']=$origin;
- }
- if($chargeMan){
- $param['chargeMan']=$chargeMan;
- }
- $param['pageNum']=1;
- if($pageNum){
- $param['pageNum']=$pageNum;
- }
- $views='index';
- $uid=$this->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;
- }
- }
|