// +---------------------------------------------------------------------- namespace app\member\controller; use think\Db; use think\Validate; use Flc\Alidayu\Client; use Flc\Alidayu\App; use Flc\Alidayu\Requests\AlibabaAliqinFcSmsNumSend; use app\capital\model\Capitaluptype as CapUptypeModel; use think\captcha\Captcha; use think\Image; class Center extends Base{ protected $menus=[ 1=>['title'=>'基本信息','jump'=>'mobile/Center/index'], ['title'=>'我的登记托管','jump'=>'mobile/Center/my'], ['title'=>'我的托管','jump'=>'mobile/Center/mytg'], ['title'=>'合作机构申请','jump'=>'mobile/Center/myorg'], ['title'=>'修改资料','jump'=>'mobile/Center/edit'], ['title'=>'系统通知','jump'=>'mobile/Center/notice'], ['title'=>'托管系统通知','jump'=>'mobile/Center/capnotice'], ['title'=>'我的申报','jump'=>'home/Center/cuapply'], ['title'=>'活动报名','jump'=>'home/Center/myact'] ]; protected $prefix=''; protected $upload_path=''; protected $user; protected function _initialize(){ parent::_initialize(); $this->prefix=config('database.prefix'); $this->upload_path=config('upload_path'); $user=session('muser'); $this->user=$user; $this->assign('menus',$this->menus); $this->check_login(); } public function jointg(){ return $this->view->fetch('user:tgform1'); } public function jointg3(){ $tgid=input('apply_id',''); $this->assign('apply_id',$tgid); $tg_type=input('tg_type',2); $this->assign('tg_type',$tg_type); return $this->view->fetch('user:tgform3'); } public function jointg2(){ $tg_type=input('tg_type',2); $tg_read1=input('tg_read1',''); $tg_read2=input('tg_read2',''); $tg_read3=input('tg_read3',''); $tgid=input('id'); if(empty($tgid)){ if(!$tg_read1||!$tg_read2||!$tg_read3){ $this->error("请勾选已阅读并同意"); } } $uid=session('mhid'); $baseinfo=['apply_id'=>'','hoster_name'=>'','hoster_type'=>'','apply_type'=>'','tg_type'=>'','hoster_reason'=>'','company_addr'=>'','legal_person'=>'', 'reg_capital'=>'','eco_nature'=>'','leader_cardtype'=>'','leader_cardno'=>'','natural_name'=>'', 'natural_addr'=>'','natural_tel'=>'','natural_fax'=>'','natural_email'=>'','natural_code'=>'','business_code'=>'', 'capital_num'=>'','capital_type'=>'','proassign'=>'', ]; if($tgid){ $baseinfo=Db::name('capitalbaseinfo')->where(['apply_id'=>$tgid])->find(); $tg_type=$baseinfo['apply_type']; $baseinfo['tg_type']=isset($baseinfo['tg_type'])?explode(',',$baseinfo['tg_type']):''; } $status=''; $applystatus=''; if($tgid){ $apply=Db::name('capitalapply')->where(['apply_id'=>$tgid,'user_id'=>$uid])->find(); if(!$apply){ $this->error("没权限查阅此项目"); } $status=isset($apply['status'])?$apply['status']:''; $applystatus=isset($apply['apply_status'])?$apply['apply_status']:''; } //挂牌需要上传的附件 $where=array(); $where['apply_id']=0; $where['status']=0; $where['isopen']=1; $where['apply_type']=$tg_type; if($tg_type==2)$where['mobile']=1; $files=Db::name('capitaluptype')->where($where)->order('forder asc')->select(); $where=['new_flag'=>1,'apply_id'=>$tgid]; if($tg_type!=2||($tg_type==2&&!in_array($status,[10,30,40]))){ $where['flag']=1; } $upfiles=Db::name('capital_upfiles')->where($where)->select(); if(count($files)){ foreach ($files as $k=>$row){ $files[$k]['flag']=0; $files[$k]['path']=''; $files[$k]['unique_code']=''; $files[$k]['fname']=''; $files[$k]['reload']=($tg_type==2&&in_array($status,[10,30,40]))?1:0; foreach ($upfiles as $jow){ if($row['ftype_id']==$jow['ftype_id']){ $files[$k]['flag']=($tg_type==2&&in_array($status,[10,30,40]))?$jow['flag']:1; $files[$k]['unique_code']=$jow['unique_code']; $files[$k]['fname']=basename($jow['path']); $files[$k]['path']=SITE_PATH.str_replace('\\','/',$jow['path']); } } } } $products=Db::name('capitaldetail')->where(['apply_id'=>$tgid])->select(); if(count($products)){ foreach ($products as &$item){ $item['capital_date']=$item['capital_date']?date("Y-m-d",$item['capital_date']):''; } } $this->assign('products', $products); $showinfo=1; if($tg_type==2&&in_array($status,[10,30,40])){ if($applystatus==2&&in_array($status,[30,40])){ $showinfo=1; }else{ $showinfo=0; } } if(empty($tgid))$showinfo=0; $this->assign('showinfo',$showinfo); $this->assign('files', $files); $this->assign('tg_type',$tg_type); $this->assign('info',$baseinfo); $this->assign('apply_id',$tgid); $this->assign('status',$status); return $this->view->fetch('user:tgform2'); } public function pwd_reset(){ $this->assign('code',''); $this->assign('type',''); $this->assign($this->user); return $this->view->fetch('user:pwd_reset'); } public function forget(){ $this->assign('current',['title'=>'忘记密码']); return $this->view->fetch('user:forgot_pwd'); } public function index(){ $this->assign($this->user); return $this->view->fetch('user:center'); } public function info(){ $current=$this->menus[1]; $this->assign('current',$current); $this->assign($this->user); return $this->view->fetch('user:info'); } //编辑用户资料 public function edit(){ $pid=$this->user['member_list_province']; $cid=$this->user['member_list_city']; $regions=Db::name('Region')->where('pid','in','1,'.$pid.','.$cid)->select (); $province=[]; $city=[]; $town=[]; if(count($regions)){ foreach ($regions as $item){ switch ($item['pid']){ case 1: array_push($province, $item); break; case $pid: array_push($city, $item); break; case $cid: array_push($town, $item); break; } } } $this->assign('province',$province); $this->assign('city',$city); $this->assign('town',$town); $this->assign($this->user); $current=$this->menus[5]; $this->assign('current',$current); return $this->view->fetch('user:edit'); } /** * 留言簿 */ public function feedback(){ if (request()->isPost()){ $uid=session('mhid'); $verify =new Captcha (); if (!$verify->check(input('verify'), 'fbmsg')) { $this->error("验证码错误"); } $data=array( 'plug_sug_name'=>input('plug_sug_name'), 'plug_sug_tel'=>input('plug_sug_tel'), 'plug_sug_email'=>input('plug_sug_email'), 'plug_sug_content'=>input('plug_sug_content'), 'plug_sug_addtime'=>time(), 'plug_sug_open'=>0, 'plug_user_id'=>$uid, 'plug_sug_ip'=>request()->ip(), ); $rst=Db::name('plug_sug')->insert($data); if($rst!==false){ $this->success("提交成功",url("center/index")); }else{ $this->error("提交失败"); } } return $this->view->fetch('user:feedback'); } public function runedit(){ if(request()->isPost()){ $post=input('post.'); $file = request()->file('member_list_headpic'); if($file->getInfo('size')>(10*1024*1024)){ $this->error('上传文件不能大于10M!'); } if(!in_array(strtoupper(substr(strrchr($file->getInfo('name'), '.'), 1)),['PNG','JPG','GIF'])){ $this->error('上传文件类型错误!'); } $validate = config('upload_validate'); if ($file) { $info = $file->validate($validate)->rule('md5')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d')); if ($info) { $img_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename(); $post['member_list_headpic']=$img_url; } } $rst=Db::name('member_list')->where(array('member_list_id'=>$this->user['member_list_id']))->update($post); if ($rst!==false) { $this->user=Db::name('member_list')->find($this->user['member_list_id']); session('user',$this->user); $this->success(lang('save success'),url("Center/edit")); } else { $this->error(lang('save failed')); } } } //修改密码 public function runchangepwd(){ if (request()->isPost()) { $old_password=input('old_password'); $password=input('password'); $repassword=input('repassword'); if(empty($old_password)){ $this->error(lang('old pwd empty')); } if(empty($password)){ $this->error(lang('new pwd empty')); } if($password!==$repassword){ $this->error(lang('pwd not same')); } $member=Db::name('member_list'); $user=$member->where(array('member_list_id'=>$this->user['member_list_id']))->find(); $member_list_salt=$user['member_list_salt']; if(encrypt_password($old_password,$member_list_salt)===$user['member_list_pwd']){ if(encrypt_password($password,$member_list_salt)==$user['member_list_pwd']){ $this->error(lang('new pwd the same as old pwd')); }else{ $data['member_list_pwd']=encrypt_password($password,$member_list_salt); $data['member_list_id']=$this->user['member_list_id']; $rst=$member->update($data); if ($rst!==false) { $this->success(lang('revise success'),url('Center/index')); } else { $this->error(lang('revise failed')); } } }else{ $this->error(lang('old pwd not correct')); } } } //发送短信验证码 public function sendsms(){ $account=input('account',''); $where['sms_type']='edittel'; $where['sms_tel']=$account; $rst=Db::name('smslog')->where($where)->find(); if($rst){ if($rst['sms_time']>(time()-120)){ return json(['code'=>0,'msg'=>'已获取过,'.(time()-$rst['sms_time']).'后稍后再试']); } } $rst_sms=false; $error='未设置短信平台配置'; $code=random(6,'number'); if(config('alisms.on')){ $client = new Client(new App(config('alisms'))); $req = new AlibabaAliqinFcSmsNumSend; $req->setRecNum($account) ->setSmsParam([ 'number' => $code ]) ->setSmsFreeSignName(config('alisms.signName')) ->setSmsTemplateCode(config('alisms.TemplateCode')); $resp = $client->execute($req); if($resp->result->success){ $rst_sms=true; }else{ $error=$resp->sub_msg; } }elseif(config('ymsms.on')){ //$arr=send_sms($account,'【'.config('ymsms.signname').'】您好,您修改新手机号的验证码为'.$code.',验证码2分钟内有效!'); $arr=send_sms($account,'您好,您修改新手机号的验证码为'.$code.',验证码2分钟内有效!'); if($arr['code']==1){ $rst_sms=true; }else{ $error=$arr['msg']; } } if($rst_sms){ if($rst){ //更新 $rst['sms_time']=time(); $rst['sms_code']=$code; $rst=Db::name('smslog')->update($rst); if($rst!==false){ return json(['code'=>1]); }else{ return json(['code'=>0,'msg'=>'获取失败,请重试']); } }else{ //插入数据库 $data=[ 'sms_type'=>'edittel', 'sms_tel'=>$account, 'sms_time'=>time(), 'sms_code'=>$code ]; $rst=Db::name('smslog')->insert($data); if($rst){ return json(['code'=>1]); }else{ return json(['code'=>0,'msg'=>'获取失败,请重试']); } } }else{ return json(['code'=>0,'msg'=>$error]); } } public function notice(){ //判断是否激活 if(!$this->user['user_status']){ $current_user=$this->user; $email = $current_user['member_list_email']; $this->assign("email",$email); return $this->view->fetch('user:active'); } $lists=Db::name('capitalnotice')->alias('a') ->where(['a.user_id'=>session('mhid')]) ->order('a.create_time desc') ->field('a.*') ->paginate(config('paginate.list_rows')); $show=$lists->render(); $this->assign('page',$show); $this->assign("lists",$lists); $current=$this->menus[6]; $this->assign('current',$current); return $this->view->fetch('user:notice'); } public function notice_r(){ $notice_id=input('notice_id',0,'intval'); if(!$notice_id) $this->error('通知不存在',url('Center/notice')); $list=Db::name('capitalnotice')->find($notice_id); if(!$list) $this->error('通知不存在',url('Center/notice')); //设置为已读 Db::name('capitalnotice')->update(['notice_id'=>$notice_id,'is_read'=>1]); return $this->view->fetch('user:notice_r'); } public function capnotice_r(){ $notice_id=input('notice_id',0,'intval'); if(!$notice_id) $this->error('通知不存在',url('Center/capnotice')); $list=Db::name('capitalnotice')->find($notice_id); if(!$list) $this->error('通知不存在',url('Center/capnotice')); if($list['create_type']==0){ $user_notice=Db::name('member_list')->field('member_list_nickname,member_list_username,member_list_headpic')->find($list['create_id']); }else{ $user_notice=Db::name('admin')->field('admin_realname,admin_username,admin_avatar')->find($list['create_id']); } $this->assign("list",$list); $this->assign("user_notice",$user_notice); //设置为已读 Db::name('capitalnotice')->update(['notice_id'=>$notice_id,'is_read'=>1]); return $this->view->fetch('user:capnotice_r'); } public function mytg(){ $current=$this->menus[3]; $this->assign('current',$current); return $this->view->fetch('user:mytg'); } public function myscore(){ $current=$this->menus[8]; $this->assign('current',$current); return $this->view->fetch('user:myscore'); } public function tg_pro(){ $prefix=$this->prefix; if(!session('mhid')) $this->redirect(url('Login/index')); $role_id=Db::name('member_list')->where('member_list_id',session('mhid'))->value('member_list_groupid'); if($role_id !=6) $this->error('您无权专家评审!',url('Center/notice')); $apply_id=input('apply_id',0,'intval'); if(!$apply_id) $this->error('参数错误',url('Center/notice')); //原数据 $list=Db::name('capitalapply')->alias('a') ->join($prefix.'capitalbaseinfo b','b.apply_id=a.apply_id') ->join($prefix.'capitalproassign c','c.apply_id=a.apply_id') ->where(['a.apply_id'=>$apply_id,'c.user_id'=>session('mhid'),'c.assign_type'=>0,'c.del_flag'=>0,'status'=>40]) ->order('b.base_id desc') ->find(); if($list){ if(request()->isAjax()){ $pro_id=input('pro_id'); $advice=htmlspecialchars_decode(input('advice','')); if($advice==''){ $this->error('请输入专家评分意见!',url('center/tg_pro',array('apply_id'=>$apply_id,'snd'=>rand(10000,99999)))); } $score=input('score'.$pro_id); if($score<=0){ $this->error('请录入评分!',url('center/tg_pro',array('apply_id'=>$apply_id,'snd'=>rand(10000,99999)))); } $dids=input('dids'); $cnames=input('cnames'); $cprices=input('cprices'); $check=false; if($dids&&$cnames){ try { $dids=explode(";",$dids); $cnames=explode(";",$cnames); $cprices=explode(";",$cprices); $set=[]; foreach ($dids as $k=>$jo){ $name=isset($cnames[$k])?$cnames[$k]:''; $price=isset($cprices[$k])?$cprices[$k]:''; $ret=Db::name('capitaldetail')->where(['id'=>$jo,'apply_id'=>$apply_id])->update(['capital_name'=>$name,'capital_gprice'=>$price]); if($ret&&!$check)$check=true; } } catch (Exception $e) { } } //更新评分表cult4apply $sl_data['score']=$score; $sl_data['advice']=$advice; $sl_data['update_id']=session('mhid'); $sl_data['update_type']=1;//前台 $sl_data['update_time']=time(); $where=array('pro_id'=>$pro_id); $query=Db::name('capitalproassign')->where($where)->update($sl_data); if($query&&$check){ Db::name('capitalbaseinfo')->where(['apply_id'=>$apply_id])->update(['proassign'=>1]); } $this->success('评分成功',url('Center/notice'));//专家评分确认后返回到通知列表 }else{ $list['tg_type']=$list['tg_type']?explode(',', $list['tg_type']):[]; $this->assign('baseinfo',$list); //证件类型表 $cardtype=Db::name('cult4cardtype')->order('id')->select(); $this->assign('cardtype',$cardtype); $apply_type=$list['apply_type']; $products = Db::name('capitaldetail')->where(['apply_id'=>$apply_id])->select(); if(!empty($products)){ if(count($products)){ foreach ($products as $key=>$row){ $reason=explode(",", $row['hoster_reason']); $str=''; if(in_array(1,$reason))$str.='资产背书'; if(in_array(2,$reason))$str.='、协议转让'; if(in_array(3,$reason))$str.='、资产拍卖'; if(in_array(4,$reason))$str.='、资产管理计划(产品设计)'; $products[$key]['hoster_reason']=$str; $products[$key]['capital_files']=explode(";", $row['capital_files']); } } } $this->assign('products',$products); $mobile=''; if($list['apply_type']==2)$mobile=1; $apply_uptypelist=CapUptypeModel::getList($apply_type,$apply_id,1,0,1,'ftype_id,status,apply_id,isopen',-1,$mobile); foreach ($apply_uptypelist as $k=>$row){ $ftype_id=$row['ftype_id']; $where['ftype_id']=array('eq', $ftype_id); $where['new_flag']=array('eq', 1); $where['apply_id']=array('eq', $apply_id); $fileInfo = db('capital_upfiles')->where($where)->order('addorder desc')->find(); $row['flag']=''; $row['path']=''; $row['file_id']=''; $row['upload_time']=''; $row['filesize']=''; if($fileInfo){ $row['flag']=$fileInfo['flag']; $row['filesize']=$fileInfo['filesize']; $row['path']=$fileInfo['path']; $row['file_id']=$fileInfo['file_id']; $row['upload_time']=$fileInfo['upload_time']; } $apply_uptypelist[$k]=$row; } $this->assign('apply_uptypelist',$apply_uptypelist); $this->assign('status',2); $this->assign('apply_id',$apply_id); //缴费状态 $where=array( 'apply_id'=>$apply_id ); $fee_flag=Db::name('capitalfee')->where($where)->value('fee_flag'); $this->assign('fee_flag',$fee_flag); //已分配专家及分配专家评分 $pro=Db::name('capitalproassign')->where(['del_flag'=>0,'apply_id'=>$apply_id,'user_id'=>session('mhid')])->find(); $this->assign('pro',$pro); $checkinfo = Db::name('capitalcheck')->where(['apply_id'=>$apply_id])->select(); $config=require_once APP_PATH.'capital/config.php'; $status=$config['status']; if($checkinfo){ foreach ($checkinfo as $k=>$row){ $check_type=$row['check_type']; $checkinfo[$k]['infor']=$status[$check_type]; } } $this->assign('checkinfo',$checkinfo); return $this->view->fetch('user/tg_pro'); } }else{ $this->error('该托管资料不在专家评审中或您无权专家评审',url('Center/notice')); } } /** *活动报名 */ public function delcom(){ $mid=session("mhid"); $id=input('id'); if(!$id){$this->error("缺少参数");} $find=Db::name('bbslog')->where(['mid'=>$mid,'id'=>$id])->delete(); if(!$find){ $this->error('删除失败'); }else{ $this->success('删除成功'); } } public function savecom(){ $mid=session("mhid"); $id=input('id'); $content=input("content"); if(!$id||!$content){$this->error("缺少参数");} $find=Db::name('bbslog')->where(['mid'=>$mid,'id'=>$id])->update(['content'=>$content]); if(!$find){ $this->error('更新失败'); }else{ $this->success('更新成功'); } } public function myact(){ $lists=Db::name('activityapply')->alias('a') ->join($this->prefix.'activity c','c.id =a.aid') ->where(['a.uid'=>session('mhid')]) ->order('a.create_time desc') ->field('c.title,c.id,a.create_time') ->group("a.aid") ->paginate(config('paginate.list_rows')); $show=$lists->render(); $this->assign('page',$show); $this->assign("lists",$lists); $current=$this->menus[9]; $this->assign('current',$current); return $this->view->fetch('user/myact'); } public function avatar(){ if(request()->isPost()){ $mid=session('mhid'); // 获取表单上传文件 $key=input('key'); if(!$key)return $this->error('參數錯誤'); $file = request()->file($key); // 移动到框架应用根目录/uploads/ 目录下 $uploadpath=config('upload_path'); $path=ROOT_PATH . config('upload_path'); $validate = config('upload_validate'); $info = $file->validate($validate)->move($path); if($info){ $path=$uploadpath.'/'.$info->getSaveName(); $data=array(); $data['ext']=$info->getExtension(); $data['path']=$path; $data['filename']=$info->getFilename(); Db::name("member_list")->where(array('member_list_id'=>$mid))->update(['member_list_headpic'=>$path]); $img=Image::open('.'.$path); $size=$img->size(); $hei=isset($size[1])?$size[1]:0; $wid=isset($size[0])?$size[0]:0; if($wid>240){ $hei=(240/$wid)*$hei; $wid=240; } if($wid>0&&$hei>0){ $img->thumb($wid,$hei,$img::THUMB_CENTER); $img->save('.'.$path); } $member=$this->user; $member['member_list_headpic']=$path; session('muser',$member); return $this->success('上傳成功','',$data); }else{ return $this->error($file->getError()); } } $this->assign($this->user); return $this->fetch('user/avatar'); } public function mybbs(){ $this->assign($this->user); return $this->view->fetch('user/mybbs'); } public function ajaxlist(){ $mid=session('mhid'); $page=input('page'); $order='a.id desc'; $where=['a.mid'=>$mid]; $list= Db::name('bbslist')->alias("a")->field("a.viewnum,a.create_time,a.id,a.child_id,a.name,a.comment,m.member_list_nickname as uname,m.member_list_headpic as poster")->join(config('database.prefix').'member_list m','a.mid =m.member_list_id','left')->where($where)->order($order)->paginate(5); if(count($list)){ $list=$list->toArray(); $data=$list['data']; foreach ($data as $j=>$jow){ $data[$j]['name']=RemoveXSS($jow['name']); $data[$j]['create_time']=date("Y-m-d H:i",$jow['create_time']); } $list['data']=$data; } return $this->success("查询成功","",$list); } public function ajaxlog(){ $mid=session('mhid'); $list= Db::name('bbslog')->alias("a")->field("a.*,m.member_list_nickname as uname,m.member_list_headpic as poster")->join(config('database.prefix').'member_list m','a.mid =m.member_list_id','left')->where(['a.mid'=>$mid])->order('top desc,create_time desc')->paginate(10); if(count($list)){ $list=$list->toArray(); $data=$list['data']; foreach ($data as $k=>$jow){ $pid=$jow['pid']; $parent=[]; if($pid){ $parent=Db::name('bbslog')->alias("a")->field("a.content,m.member_list_nickname as uname,m.member_list_headpic as poster")->join(config('database.prefix').'member_list m','a.mid =m.member_list_id','left')->where(['a.id'=>$pid])->find(); if($parent){ $parent['content']=RemoveXSS(htmlspecialchars_decode($parent['content'])); } } $data[$k]['content']=RemoveXSS(htmlspecialchars_decode($jow['content'])); $data[$k]['create_time']=date("Y-m-d H:i",$jow['create_time']); $data[$k]['parent']=$parent; } $list['data']=$data; } return $this->success("查询成功","",$list); } protected function showtime($time){ $endtime=time(); $showtime=''; if($time){ $date=floor(($endtime-$time)/86400); if($date>=30)return ceil($date%30).'月前'; if($date>0)return $date.'天前'; $hour=floor(($endtime-$time)%86400/3600); if($hour>0)return $hour.'小时前'; $minute=floor(($endtime-$time)%86400/60); if($minute>0)return $minute.'分钟前'; } return $showtime; } }