isAjax()){ return json_encode(['code' => 500, 'msg' => '重新登陆', 'data' => []], JSON_UNESCAPED_UNICODE); }else{ $this->redirect(url('home/Index/index')); } } } /** * 获取列表 * * @param Request $request * @return string */ public function getList(Request $request){ $this->check_login(); $limit = $request->param('limit', 30); $user_id = session('hid'); $where=['a.user_id' => $user_id]; $apply_type=input('apply_type','','intval'); $fields=['a.apply_id', 'a.status', 'a.apply_status','b.contract','b.contract_status', 'a.create_time', 'b.hoster_name', 'b.capital_type', 'b.apply_type']; $obj=DB::name('capitalapply a')->join('capitalbaseinfo b', 'a.apply_id = b.apply_id'); if($apply_type){ $user=session('user'); $groupid=isset($user['member_list_groupid'])?$user['member_list_groupid']:''; if($groupid==6){ $where=['a.status'=>40,'a.apply_status'=>0,'p.user_id'=>$user_id]; } $where['b.apply_type']=$apply_type; $where['p.del_flag']=0; array_push($fields,'p.score'); $obj->join('capitalproassign p', 'a.apply_id = p.apply_id'); } $data =$obj->field($fields)->where($where)->order('a.apply_id', 'desc')->paginate($limit)->toArray(); if (!empty($data)) { foreach ($data['data'] as $key => $val) { $data['data'][$key]['capital_name'] =($val['apply_type']!=2)?config('capital_type')[$val['capital_type']]:''; $data['data'][$key]['status_name'] = config('status')[$val['status']] . '中'; $data['data'][$key]['create_date'] =$val['create_time']?date("Y-m-d",$val['create_time']):''; $status=$val['status']; if($val['apply_type']==3)$status=60; $applyid=$val['apply_id']; $where=array('apply_id'=>$applyid,'check_type'=>$status); $checkinfo = Db::name('capitalcheck')->where($where)->select(); $astatus=intval($val['apply_status']); if ($astatus == 1&&$val['apply_type']!=2) { $data['data'][$key]['status_name'] = config('status')[$val['status']] . '(审核通过)'; $data['data'][$key]['advice'] = isset($checkinfo[0])?strip_tags($checkinfo[0]['advice']):''; } else if ($astatus == 2) { $data['data'][$key]['status_name'] = config('status')[$val['status']] . '(审核不通过)'; $advice=db('capitalcheck')->where(['apply_id'=>$applyid,'check_type'=>$val['status']])->order('check_id desc')->find(); $data['data'][$key]['advice'] =strip_tags($advice['advice']); }else if ($val['status'] == 50) { $check_type=($val['apply_type']==1)?20:40; $advice=db('capitalcheck')->where(['apply_id'=>$applyid,'check_type'=>$check_type])->order('check_id desc')->find(); $data['data'][$key]['advice'] =$advice?strip_tags($advice['advice']):''; }else { $msg=config('status')[$val['status']].'中'; if($val['apply_type']==2&&$val['status']==100){ $msg='待签协议,我们的工作人员会尽快与您联系'; } if($val['apply_type']==2&&$val['status']==110){ if($astatus==0)$msg='等待办理入库'; if($astatus==3)$msg='可办理入库'; if($astatus==1)$msg='完成入库'; } $data['data'][$key]['status_name'] =$msg; $data['data'][$key]['advice'] = ''; } $data['data'][$key]['signurl'] = ''; $data['data'][$key]['viewpdf'] = ''; $data['data'][$key]['downpdf'] = ''; //生成合同连接 if(($val['apply_type']==3||$val['apply_type']==1)&&$val['status'] ==90&&$astatus!=2){ $task=Db::name('capitaltask')->where(['apply_id'=>$applyid,'status'=>0,'step'=>8])->find(); if($task){ $params=$task['params']; $signurl=''; try { $params=json_decode($params,true); if(isset($params['signurl'])){ $signurl=$params['signurl']; } } catch (Exception $e) { } $data['data'][$key]['signurl'] =$signurl; } $task=Db::name('capitaltask')->where(['apply_id'=>$applyid,'status'=>0,'step'=>9])->find(); if($task){ $params=$task['params']; $viewpdf=''; $downpdf=''; try { $params=json_decode($params,true); if(isset($params['viewpdf_url'])){ $viewpdf=$params['viewpdf_url']; } if(isset($params['download_url'])){ $downpdf=$params['download_url']; } } catch (Exception $e) { } $data['data'][$key]['viewpdf'] =$viewpdf; $data['data'][$key]['downpdf'] =$downpdf; } } } } return json_encode(['code' => 200, 'msg' => 'success', 'data' => $data], JSON_UNESCAPED_UNICODE); } /** * 托管申请 * * @param Request $request * @return string */ public function apply(Request $request){ $this->check_login(); $params = $request->param(); $jump=isset($params['jump'])?$params['jump']:''; $mobile=isset($params['mobile'])?$params['mobile']:0; $user_id = session('hid'); $tgtype=isset($params['tg_type'])?(is_array($params['tg_type'])?implode(',', $params['tg_type']):$params['tg_type']):''; $assagree=isset($params['assagree'])?$params['assagree']:''; $apply_id =isset($params['apply_id'])&&$params['apply_id']?$params['apply_id']:''; $config=[ 'apply_type' => 'require|integer', 'hoster_type' => 'require|integer', 'hoster_name' => 'require', ]; if($params['apply_type']!=2){ $config['capital_type']='require'; } $validate = new Validate($config); if (!$validate->check($params)) { $msg = $validate->getError(); return json_encode(['code' => 0, 'msg' => $msg, 'data' => []], JSON_UNESCAPED_UNICODE); } $unique_code=$params['unique_code']; $unique_has=isset($params['unique_has'])?$params['unique_has']:1; if(empty($unique_code)&&$unique_has){ return json_encode(['code' => 0, 'msg' => '附件不能为空', 'data' => []], JSON_UNESCAPED_UNICODE); } $products=isset($params['products'])?$params['products']:''; if($products){ $products=html_entity_decode($products); try { $products=json_decode($products,true); } catch (Exception $e) {} } //详情信息 $detail_data1 = [ 'mobile' =>intval($mobile), 'apply_type' => intval($params['apply_type']), 'hoster_name' => $params['hoster_name'], 'hoster_type' => intval($params['hoster_type']), 'tg_type' =>$tgtype, 'hoster_reason' => !isset($params['hoster_reason']) ? '0' : $params['hoster_reason'], 'business_code' => !isset($params['business_code']) ? '' : $params['business_code'], 'company_addr' => !isset($params['company_addr']) ? '' : $params['company_addr'], 'company_name' => !isset($params['company_name']) ? '' : $params['company_name'], 'legal_person' => !isset($params['legal_person']) ? '' : $params['legal_person'], 'legal_code' => !isset($params['legal_code']) ? '' : $params['legal_code'], 'legal_cardno' => !isset($params['legal_cardno']) ? '' : $params['legal_cardno'], 'legal_tel' => !isset($params['legal_tel']) ? '' : $params['legal_tel'], 'reg_capital' => !isset($params['reg_capital']) ? '' : $params['reg_capital'], 'eco_nature' => !isset($params['eco_nature']) ? '' : $params['eco_nature'], 'leader_cardtype' => !isset($params['leader_cardtype']) ? '' : $params['leader_cardtype'], 'leader_cardno' => !isset($params['leader_cardno']) ? '' : $params['leader_cardno'], 'leader_name' => !isset($params['leader_name']) ? '' : $params['leader_name'], 'natural_name' => !isset($params['natural_name']) ? '' : $params['natural_name'], 'natural_addr' => !isset($params['natural_addr']) ? '' : $params['natural_addr'], 'natural_tel' => !isset($params['natural_tel']) ? '' : $params['natural_tel'], 'natural_fax' => !isset($params['natural_fax']) ? '' : $params['natural_fax'], 'natural_email' => !isset($params['natural_email']) ? '' : $params['natural_email'], 'natural_code' => !isset($params['natural_code']) ? '' : $params['natural_code'], 'capital_own' => !isset($params['capital_own']) ? 0: intval($params['capital_own']), 'capital_class' => !isset($params['capital_class']) ? 0: intval($params['capital_class']), 'capital_name' => !isset($params['capital_name']) ? '' : $params['capital_name'], 'capital_cycle' => !isset($params['capital_cycle']) ? '' : $params['capital_cycle'], 'capital_unit' => !isset($params['capital_unit']) ? '' : $params['capital_unit'], 'capital_price' => !isset($params['capital_price']) ? '' : $params['capital_price'], 'assessment' => !isset($params['assessment']) ? '' : $params['assessment'], 'assessment_date' => !isset($params['assessment_date']) ? '' : $params['assessment_date'], 'recom_agency' => !isset($params['recom_agency']) ? '' : $params['recom_agency'] ]; $detail_data2=[ 'capital_num' => !isset($params['capital_num']) ? '' :intval($params['capital_num']), 'capital_type' =>($params['apply_type']==2)?'':$params['capital_type'], 'capital_child' =>!isset($params['capital_child'])?0:intval($params['capital_child']), ]; $status=''; $baseInfo = Db::name('capitalbaseinfo')->where(['apply_id' => $apply_id])->find(); $file_data=$nfile_data=$detail_data=[]; if(!$apply_id){ $detail_data=array_merge($detail_data1,$detail_data2); //基础信息 $base_data = [ 'user_id' => $user_id, 'status' => 10, 'apply_status' => 0, 'create_time' => time(), 'pay_img' => !isset($params['pay_img']) ? '' : $params['pay_img'], ]; Db::name('capitalapply')->insert($base_data); $apply_id = Db::name('capitalapply')->getLastInsID(); if (empty($apply_id)) { return json_encode(['code' => 500, 'msg' => 'Fail', 'data' => []], JSON_UNESCAPED_UNICODE); } $detail_data['create_time']=time(); $detail_data['apply_id']=$apply_id; Db::name('capitalbaseinfo')->insert($detail_data); $fee_data = ['apply_id' => $apply_id,'fee_flag' => 0,'create_time' => time()]; Db::name('capitalfee')->insert($fee_data); if (!empty($params['unique_code'])) { $params['unique_code'] = explode(',', $params['unique_code']); Db::name('capital_upfiles')->whereIn('unique_code',$unique_code)->update(['apply_id' => $apply_id]); } if(count($products)&&$detail_data['apply_type']==2){ $details=[]; foreach ($products as $pro){ $detail=[]; $detail['apply_id']=$apply_id; $detail['capital_type']=$pro['capital_type']; $detail['hoster_reason']=implode(',', $pro['hoster_reason']); $detail['capital_name']=$pro['capital_name']; $detail['capital_price']=$pro['capital_price']; $detail['capital_sprice']=$pro['capital_sprice']; $detail['capital_agency']=$pro['capital_agency']; $detail['capital_desc']=$pro['capital_desc']; $detail['capital_size']=$pro['capital_size']; $detail['capital_date']=$pro['capital_date']?strtotime($pro['capital_date']):''; $detail['capital_files']=urldecode($pro['capital_files']); $detail['create_time']=time(); if(count($detail))array_push($details,$detail); } Db::name('capitaldetail')->insertAll($details); } if(count($products)&&$detail_data['apply_type']==3){ $details=[]; foreach ($products as $pro){ $captype=intval($pro['capital_type']); $capchild=isset($pro['capital_child'])?$pro['capital_child']:''; $detail=[]; $detail['apply_id']=intval($apply_id); $detail['capital_parent']=isset($pro['capital_parent'])?intval($pro['capital_parent']):''; $detail['capital_type']=$captype; $detail['capital_child']=$capchild; $detail['capital_name']=isset($pro['capital_name'])?$pro['capital_name']:''; $detail['capital_elem']=isset($pro['capital_elem[]'])?implode(',',$pro['capital_elem[]']):''; $detail['capital_mortgage']=isset($pro['capital_mortgage'])?$pro['capital_mortgage']:''; $detail['capital_num']=isset($pro['capital_num'])?intval($pro['capital_num']):0; $detail['capital_files']=isset($pro['capital_files'])?urldecode($pro['capital_files']):''; $detail['capital_owner']=isset($pro['capital_owner'])?urldecode($pro['capital_owner']):''; $marimg=''; if($pro['capital_mortgage']==1)$marimg=isset($pro['mortgage_img'])?urldecode($pro['mortgage_img']):''; $detail['mortgage_img']=$marimg; $level=$cla=$cother=$info=$area=$space=$land=$det=$infother=$kind=$size=$mat=$year=$yearother=$device=$major=$loca=$floor=$lother=''; if($captype==5){ $cla=isset($pro['capital_class'])?$pro['capital_class']:''; if($cla==9)$cother=isset($pro['class_other'])?$pro['class_other']:''; $area=isset($pro['capital_area'])?$pro['capital_area']:''; if($capchild=='A12'){ $kind=isset($pro['capital_kind'])?$pro['capital_kind']:''; } } if($captype==15){ $loca=isset($pro['capital_location'])?$pro['capital_location']:''; $area=isset($pro['capital_area'])?$pro['capital_area']:''; $year=isset($pro['capital_year'])?intval($pro['capital_year']):''; if($year==4)$yearother=isset($pro['year_other'])?$pro['year_other']:''; $cla=isset($pro['capital_class'])?$pro['capital_class']:''; if($cla==9)$cother=$pro['class_other']; if($capchild=='B1'){ $land=$pro['capital_land']; if($land==5)$lother=$pro['land_other']; $space=$pro['capital_space']; $info=$pro['capital_info[]']?implode(',',$pro['capital_info[]']):''; if(in_array(4,$pro['capital_info[]']))$infother=$pro['info_other']; $level=$pro['capital_rank']; }else{ $size=$pro['capital_size']; $mat=$pro['capital_material']; } } if($captype==35){ $land=$pro['capital_land']; if($land==5)$lother=$pro['land_other']; $area=$pro['capital_area']; $device=$pro['capital_device']; $major=$pro['capital_major']; $det=$pro['capital_detail']; } if($captype==55){ $loca=$pro['capital_location']; $area=$pro['capital_area']; $cla=$pro['capital_class']; if($cla==9)$cother=$pro['class_other']; } if($captype==45){ $area=$pro['capital_area']; if($capchild=='D11'||$capchild=='D12'){ $loca=$pro['capital_location']; $land=$pro['capital_land']; if($land==5)$lother=$pro['land_other']; $space=$pro['capital_space']; $info=$pro['capital_info[]']?implode(',',$pro['capital_info[]']):''; if(in_array(4,$pro['capital_info[]']))$infother=$pro['info_other']; $level=$pro['capital_rank']; }else{ $size=$pro['capital_size']; $mat=$pro['capital_material']; } $year=intval($pro['capital_year']); if($year==4)$yearother=$pro['year_other']; $cla=$pro['capital_class']; if($cla==9)$cother=$pro['class_other']; } if($captype==5||$captype==55){ $size=$pro['capital_size']; $mat=$pro['capital_material']; $year=intval($pro['capital_year']); if($year==4)$yearother=$pro['year_other']; } $detail['capital_kind']=$kind; $detail['capital_info']=$info; $detail['info_other']=$infother; $detail['capital_area']=$area; $detail['capital_space']=$space; $land=$land?$land:0; $detail['capital_land']=$land; $detail['land_other']=$lother; $detail['capital_detail']=$det; $detail['capital_device']=$device; $detail['capital_major']=$major; $detail['capital_location']=$loca; $floor=$floor?$floor:0; $detail['capital_floor']=$floor; $level=$level?$level:0; $detail['capital_rank']=$level; $detail['capital_class']=$cla; $detail['capital_size']=$size; $detail['capital_material']=$mat; $detail['capital_year']=$year; $detail['year_other']=$yearother; $detail['class_other']=$cother; $detail['capital_price']=$pro['capital_price']; $detail['capital_desc']=$pro['capital_desc']; if(count($detail))array_push($details,$detail); } array_walk($details,function(&$v, $k, $p) { $v = array_merge($v, $p); },['create_time'=>time()]); Db::name('capitaldetail')->insertAll($details); } if(count($products)&&$detail_data['apply_type']==4){ $details=[]; foreach ($products as $pro){ $detail=[]; $captype=5; $detail['apply_id']=intval($apply_id); $detail['capital_name']=isset($pro['capital_name'])?$pro['capital_name']:''; $detail['capital_elem']=isset($pro['capital_elem[]'])?implode(',',$pro['capital_elem[]']):''; $detail['capital_mortgage']=isset($pro['capital_mortgage'])?$pro['capital_mortgage']:''; $detail['capital_num']=isset($pro['capital_num'])?intval($pro['capital_num']):0; $detail['capital_files']=isset($pro['capital_files'])?urldecode($pro['capital_files']):''; $marimg=''; if($pro['capital_mortgage']==1)$marimg=isset($pro['mortgage_img'])?urldecode($pro['mortgage_img']):''; $detail['mortgage_img']=$marimg; $kind=$size=$year=$yearother=''; $year=intval($pro['capital_year']); if($year==4)$yearother=$pro['year_other']; $kind=isset($pro['capital_kind'])?$pro['capital_kind']:''; $detail['capital_kind']=$kind; $detail['capital_area']=$pro['capital_area']; $detail['other_info']=$pro['other_info']; $detail['capital_location']=$pro['capital_location']; $detail['capital_year']=$year; $detail['year_other']=$yearother; if(in_array($pro['capital_child'],['B21','B22','B23','B24']))$captype=15; if(in_array($pro['capital_child'],['B31','B32']))$captype=35; $detail['capital_type']=$captype; $detail['capital_child']=$pro['capital_child']; $detail['capital_price']=$pro['capital_price']; $detail['capital_desc']=$pro['capital_desc']; if(count($detail))array_push($details,$detail); } array_walk($details,function(&$v, $k, $p) { $v = array_merge($v, $p); },['create_time'=>time()]); Db::name('capitaldetail')->insertAll($details); } }else{ $info=[]; if($unique_has){ $unique_code2=[]; if($unique_code)$unique_code2=explode(',', $unique_code); $info = Db::name('capital_upfiles')->where('unique_code', 'in', $unique_code2)->select(); $fileNum = count($info); if ($fileNum == 0 || $fileNum != count($unique_code2)) { // return json_encode(['code' => 0, 'msg' => '没有对应的数据']); } } $checkInfo = Db::name('capitalapply')->where(['apply_id' => $apply_id])->where(['user_id' => $user_id])->find(); $upfiles= Db::name('capital_upfiles')->where(['apply_id' => $apply_id,'status'=>0])->select(); $details= Db::name('capitaldetail')->where(['apply_id' => $apply_id])->select(); if (!$checkInfo) { return json_encode(['code' => 0, 'msg' => '错误的记录']); } $proassign=$baseInfo['proassign']; $status=$checkInfo['status']; $apply_type=$baseInfo['apply_type']; if($apply_type==2&&$status==40&&$proassign==1&&$assagree==0){ Db::name('capitalapply')->where(['apply_id' => $apply_id,'user_id' => $user_id])->update(['apply_status'=>2]); return json_encode(['code' => 200, 'msg' => '提交成功','url'=>$jump,'data' => []], JSON_UNESCAPED_UNICODE); } if($apply_type==2&&$status==40&&$proassign==1&&$assagree==1){ Db::name('capitalbaseinfo')->where(['apply_id' => $apply_id])->update(['ass_agree'=>$assagree]); } if($apply_type==2){ //旧纪录取出个人附件、托管附件 $file_data1=[]; $file_data2=[]; foreach ($upfiles as $row){ if(!in_array($row['ftype_id'],[25,26])){ array_push($file_data2,$row['unique_code']); }else{ array_push($file_data1,$row['unique_code']); } } $file_data=array_merge($file_data1,$file_data2); //新纪录取出个人附件、托管附件 $nfile_data1=[]; $nfile_data2=[]; if(count($info)){ foreach ($info as $row){ if(!in_array($row['ftype_id'],[25,26])){ array_push($nfile_data2,$row['unique_code']); }else{ array_push($nfile_data1,$row['unique_code']); } } } $nfile_data=array_merge($nfile_data1,$nfile_data2); //专委会审核通过前修改 if($status<=40){ $past_data1=[ 'mobile' => intval($baseInfo['mobile']), 'apply_type' => intval($baseInfo['apply_type']), 'hoster_name' => $baseInfo['hoster_name'], 'hoster_type' => intval($baseInfo['hoster_type']), 'tg_type' => $baseInfo['tg_type'], 'hoster_reason' =>$baseInfo['hoster_reason'], 'business_code' =>$baseInfo['business_code'], 'company_addr' => $baseInfo['company_addr'], 'company_name' => $baseInfo['company_name'], 'legal_person' => $baseInfo['legal_person'], 'legal_code' => $baseInfo['legal_code'], 'legal_cardno' => $baseInfo['legal_cardno'], 'legal_tel' => $baseInfo['legal_tel'], 'reg_capital' => $baseInfo['reg_capital'], 'eco_nature' => $baseInfo['eco_nature'], 'leader_cardtype' =>$baseInfo['leader_cardtype'], 'leader_cardno' =>$baseInfo['leader_cardno'], 'leader_name' =>$baseInfo['leader_name'], 'natural_name' =>$baseInfo['natural_name'], 'natural_addr' =>$baseInfo['natural_addr'], 'natural_tel' => $baseInfo['natural_tel'], 'natural_fax' => $baseInfo['natural_fax'], 'natural_email' => $baseInfo['natural_email'], 'natural_code' => $baseInfo['natural_code'], 'capital_own' => intval($baseInfo['capital_own']), 'capital_class' => intval($baseInfo['capital_class']), 'capital_name' => $baseInfo['capital_name'], 'capital_cycle' => $baseInfo['capital_cycle'], 'capital_unit' => $baseInfo['capital_unit'], 'capital_price' => $baseInfo['capital_price'], 'assessment' => $baseInfo['assessment'], 'assessment_date' => $baseInfo['assessment_date'], 'recom_agency' => $baseInfo['recom_agency'] ]; $past_data2=[ 'capital_num' => intval($baseInfo['capital_num']), 'capital_type' => $baseInfo['capital_type'], 'capital_child' =>$baseInfo['capital_child']?$baseInfo['capital_child']:0 ]; $all1=array_merge($past_data1,$file_data1); $all2=array_merge($past_data2,$file_data2); $nall1=array_merge($detail_data1,$nfile_data1); $nall2=array_merge($detail_data2,$nfile_data2); if(count($products)){ $last=Db::name('capitaldetail')->field('apply_id,capital_type,hoster_reason,capital_name,capital_price,capital_sprice,capital_agency,capital_desc,capital_size,capital_files,capital_date')->where(array('apply_id' => $apply_id))->select(); foreach ($last as $k=>$row){ $last[$k]['apply_id']=intval($row['apply_id']); $last[$k]['capital_type']=intval($row['capital_type']); } $details=[]; foreach ($products as $pro){ $detail=[]; $detail['apply_id']=intval($apply_id); $detail['capital_type']=intval($pro['capital_type']); $detail['hoster_reason']=implode(',', $pro['hoster_reason']); $detail['capital_name']=$pro['capital_name']; $detail['capital_price']=$pro['capital_price']; $detail['capital_sprice']=$pro['capital_sprice']; $detail['capital_agency']=$pro['capital_agency']; $detail['capital_desc']=$pro['capital_desc']; $detail['capital_size']=$pro['capital_size']; $detail['capital_files']=urldecode($pro['capital_files']); $detail['capital_date']=$pro['capital_date']?strtotime($pro['capital_date']):'0'; if(count($detail))array_push($details,$detail); } $current=array_diff_key($details,['create_time'=>time()]); $all2=array_merge($all2,$last); $nall2=array_merge($nall2,$current); array_walk($details,function(&$v, $k, $p) { $v = array_merge($v, $p); },['create_time'=>time()]); Db::name('capitaldetail')->where(array('apply_id' => $apply_id))->delete(); Db::name('capitaldetail')->insertAll($details); } //个人信息专委会审核通过前都可以修改 if(in_array($status,[10,30,40])&&md5(json_encode($all1))!=md5(json_encode($nall1))){ $detail_data=$detail_data1; Db::name('capitalbaseinfo')->where(['apply_id' => $apply_id])->update($detail_data); } //托管信息初审通过前可修改 专委会审核前就跳回 if(in_array($status,[10,30,40])&&md5(json_encode($all2))!=md5(json_encode($nall2))){ $detail_data=$detail_data2; Db::name('capitalbaseinfo')->where(['apply_id' => $apply_id])->update($detail_data); if(in_array($status,[10,30,40])){ $upInfo = array( 'status' => 10, 'apply_status' => 0 ); $statusInfo = Db::name('capitalapply')->where(['apply_id' => $apply_id])->where(['user_id' => $user_id])->update($upInfo); Db::name('capitalproassign')->where(['apply_id' => $apply_id])->delete(); $msg='【深圳文化产权交易所】'.date("Y年m月d日 H:i").'系统官网后台收到一条艺术品托管修改消息,请及时查看处理!'; $tel=config('arttgnotice'); if($tel)send_sms($tel,$msg); } } } }else{ $query1=Db::name('capitalbaseinfo')->where(['apply_id' => $apply_id])->update($detail_data1); $query2=Db::name('capitalbaseinfo')->where(['apply_id' => $apply_id])->update($detail_data2); if(count($products)&&$apply_type==3){ $details=[]; foreach ($products as $pro){ $captype=intval($pro['capital_type']); $capchild=$pro['capital_child']; $detail=[]; $detail['apply_id']=intval($apply_id); $detail['capital_parent']=isset($pro['capital_parent'])?intval($pro['capital_parent']):''; $detail['capital_type']=$captype; $detail['capital_child']=$capchild; $detail['capital_name']=$pro['capital_name']; $elem=''; if(isset($pro['capital_elem'])){ $elem=$pro['capital_elem']; } if(isset($pro['capital_elem[]'])&&count($pro['capital_elem[]'])){ $elem=$pro['capital_elem[]']?implode(',',$pro['capital_elem[]']):''; } $detail['capital_elem']=$elem; $detail['capital_mortgage']=$pro['capital_mortgage']; $detail['capital_num']=intval($pro['capital_num']); $detail['capital_files']=urldecode($pro['capital_files']); $detail['capital_owner']=isset($pro['capital_owner'])?urldecode($pro['capital_owner']):''; $marimg=''; if($pro['capital_mortgage']==1)$marimg=isset($pro['mortgage_img'])?urldecode($pro['mortgage_img']):''; $detail['mortgage_img']=$marimg; $level=$cla=$cother=$cinfo=$area=$space=$land=$det=$infother=$kind=$size=$mat=$year=$yearother=$device=$major=$loca=$floor=$lother=''; if($captype==5){ $cla=isset($pro['capital_class'])?$pro['capital_class']:''; if($cla==9)$cother=$pro['class_other']; $area=$pro['capital_area']; if($capchild=='A12'){ $kind=$pro['capital_kind']; } } if($captype==15){ $loca=$pro['capital_location']; $area=$pro['capital_area']; $year=intval($pro['capital_year']); if($year==4)$yearother=$pro['year_other']; $cla=$pro['capital_class']; if($cla==9)$cother=$pro['class_other']; if($capchild=='B1'){ $land=$pro['capital_land']; if($land==5)$lother=$pro['land_other']; $space=$pro['capital_space']; $level=$pro['capital_rank']; $ciarr=[]; if(isset($pro['capital_info'])){ $cinfo=$pro['capital_info']; $ciarr=explode(',', $cinfo); } if(isset($pro['capital_info[]'])&&count($pro['capital_info[]'])){ $cinfo=$pro['capital_info[]']?implode(',',$pro['capital_info[]']):''; $ciarr=$pro['capital_info[]']; } if(in_array(4,$ciarr))$infother=$pro['info_other']; }else{ $size=$pro['capital_size']; $mat=$pro['capital_material']; } } if($captype==35){ $land=$pro['capital_land']; if($land==5)$lother=$pro['land_other']; $area=$pro['capital_area']; $device=$pro['capital_device']; $major=$pro['capital_major']; $det=$pro['capital_detail']; } if($captype==55){ $loca=$pro['capital_location']; $area=$pro['capital_area']; $cla=$pro['capital_class']; if($cla==9)$cother=$pro['class_other']; } if($captype==45){ $area=$pro['capital_area']; if($capchild=='D11'||$capchild=='D12'){ $loca=$pro['capital_location']; $land=$pro['capital_land']; if($land==5)$lother=$pro['land_other']; $space=$pro['capital_space']; $info=$pro['capital_info[]']?implode(',',$pro['capital_info[]']):''; if(in_array(4,$pro['capital_info[]']))$infother=$pro['info_other']; $level=$pro['capital_rank']; }else{ $size=$pro['capital_size']; $mat=$pro['capital_material']; } $year=intval($pro['capital_year']); if($year==4)$yearother=$pro['year_other']; $cla=$pro['capital_class']; if($cla==9)$cother=$pro['class_other']; } if($captype==5||$captype==55){ $size=$pro['capital_size']; $mat=$pro['capital_material']; $year=intval($pro['capital_year']); if($year==4)$yearother=$pro['year_other']; } $detail['capital_kind']=$kind; $detail['capital_info']=$cinfo; $detail['info_other']=$infother; $detail['capital_area']=$area; $detail['capital_space']=$space; $land=$land?$land:0; $detail['capital_land']=$land; $detail['land_other']=$lother; $detail['capital_detail']=$det; $detail['capital_device']=$device; $detail['capital_major']=$major; $detail['capital_location']=$loca; $floor=$floor?$floor:0; $detail['capital_floor']=$floor; $level=$level?$level:0; $detail['capital_rank']=$level; $detail['capital_class']=$cla; $detail['capital_size']=$size; $detail['capital_material']=$mat; $detail['capital_year']=$year; $detail['year_other']=$yearother; $detail['class_other']=$cother; $detail['capital_price']=$pro['capital_price']; $detail['capital_desc']=$pro['capital_desc']; if(count($detail))array_push($details,$detail); } array_walk($details,function(&$v, $k, $p) { $v = array_merge($v, $p); },['create_time'=>time()]); Db::name('capitaldetail')->where(array('apply_id' => $apply_id))->delete(); Db::name('capitaldetail')->insertAll($details); } if(count($products)&&$apply_type==4){ $details=[]; foreach ($products as $pro){ $captype=intval($pro['capital_type']); $capchild=isset($pro['capital_child'])?$pro['capital_child']:''; $detail=[]; $detail['apply_id']=intval($apply_id); $detail['capital_parent']=isset($pro['capital_parent'])?intval($pro['capital_parent']):''; $detail['capital_type']=$captype; $detail['capital_child']=$capchild; $detail['capital_name']=isset($pro['capital_name'])?$pro['capital_name']:''; $elem=''; if(isset($pro['capital_elem'])){ $elem=$pro['capital_elem']; } if(isset($pro['capital_elem[]'])&&count($pro['capital_elem[]'])){ $elem=$pro['capital_elem[]']?implode(',',$pro['capital_elem[]']):''; } $detail['capital_elem']=$elem; $detail['capital_mortgage']=isset($pro['capital_mortgage'])?$pro['capital_mortgage']:''; $detail['capital_num']=isset($pro['capital_num'])?intval($pro['capital_num']):0; $detail['capital_files']=isset($pro['capital_files'])?urldecode($pro['capital_files']):''; $marimg=''; if($pro['capital_mortgage']==1)$marimg=isset($pro['mortgage_img'])?urldecode($pro['mortgage_img']):''; $detail['mortgage_img']=$marimg; $kind=$size=$year=$yearother=''; $year=intval($pro['capital_year']); if($year==4)$yearother=$pro['year_other']; $kind=isset($pro['capital_kind'])?$pro['capital_kind']:''; $detail['capital_kind']=$kind; $detail['capital_area']=$pro['capital_area']; $detail['other_info']=$pro['other_info']; $detail['capital_location']=$pro['capital_location']; $detail['capital_year']=$year; $detail['year_other']=$yearother; $detail['capital_price']=$pro['capital_price']; $detail['capital_desc']=$pro['capital_desc']; if(count($detail))array_push($details,$detail); } array_walk($details,function(&$v, $k, $p) { $v = array_merge($v, $p); },['create_time'=>time()]); Db::name('capitaldetail')->where(array('apply_id' => $apply_id))->delete(); Db::name('capitaldetail')->insertAll($details); } if(in_array($status,[10])){ $upInfo = array( 'status' => 10, 'apply_status' => 0 ); $statusInfo = Db::name('capitalapply')->where(['apply_id' => $apply_id])->where(['user_id' => $user_id])->update($upInfo); } if($unique_has){ $file_data1=[]; $file_data2=[]; foreach ($upfiles as $row){ array_push($file_data1,$row['unique_code']); } $file_data=array_merge($file_data1,$file_data2); //新纪录取出个人附件、托管附件 $nfile_data1=[]; $nfile_data2=[]; foreach ($info as $row){ array_push($nfile_data1,$row['unique_code']); } $nfile_data=array_merge($nfile_data1,$nfile_data2); } } if($unique_has){ if(md5(json_encode($file_data))!=md5(json_encode($nfile_data))){ $upInfo = array('apply_id' => $apply_id); $upRtn = Db::name('capital_upfiles')->where('unique_code', 'in', explode(',', $unique_code))->update($upInfo); foreach ($info as $row) { $ftype_id = $row['ftype_id']; $del = Db::name('capital_upfiles')->where('apply_id', $apply_id)->where('ftype_id', $ftype_id)->where('unique_code', 'not in', explode(',', $unique_code))->where('flag', 0)->delete(); } } } } return json_encode(['code' => 200, 'msg' => '提交成功','url'=>$jump,'data' => []], JSON_UNESCAPED_UNICODE); } /** * 上传图片 * * @param Request $request * @return string */ public function uploads(Request $request) { set_time_limit(0); $params = $request->param(); //表名 $table = isset($params['table']) ? $params['table'] : 'capital_upfiles'; $user_id = session('hid'); //文件在哪个状态下添加 $status = $request->param('status', 0); if (empty($user_id)) { return json_encode(['code' => 500, 'msg' => '重新登陆', 'data' => []], JSON_UNESCAPED_UNICODE); } $files = $request->file(''); if (!$files) { return json_encode(['code' => 500, 'msg' => '什么都没有上传', 'data' => []], JSON_UNESCAPED_UNICODE); } //上传地址 $upload_path = '/data' . DS . 'upload'; $img_url = ''; $unique_code = md5(time() + $user_id); foreach ($files as $key => $file) { // if ($file->getInfo('size') > (20 * 1024 * 1024)) { // session('TOKEN', input('TOKEN')); // $this->error('上传文件不能大于20M!'); // } if (!in_array(strtoupper(substr(strrchr($file->getInfo('name'), '.'), 1)), ['PDF', 'JPG', 'DOC', 'DOCX', 'RAR', 'ZIP'])) { session('TOKEN', input('TOKEN')); $this->error('上传文件类型错误!'); } //处理file_one2,得到ftype_id $ftype_id = intval(substr($key, 8)); $upath = $upload_path . DS . date('Y-m-d'); $validate = config('upload_validate'); $info = $file->rule('md5')->validate($validate)->move(ROOT_PATH . $upath); $ftype = 1; if (count($params) && isset($params[$ftype])) $ftype = ($params[$ftype_id]['apply_id'] == 0) ? 1 : 2; if ($info) { $img_url = $upath . DS . $info->getFilename(); //写入数据表capital_upfiles $data = [ 'user_id' => isset($user_id) ? $user_id : 0, 'user_type' => 1, 'status' => $status, 'upload_time' => time(), 'ftype_id' => $ftype_id, 'ftype' => $ftype, 'filesize' => $info->getSize(), 'path' => $img_url, 'flag' => 0, 'unique_code' => $unique_code ]; Db::name($table)->insert($data); } else { return json_encode(['code' => 500, 'msg' => $file->getError()]); } } $retData = [ 'unique_code' => $unique_code, 'img_url' => 'http://' . $_SERVER['HTTP_HOST'] . DS . $img_url ]; return json_encode(['code' => 200, 'msg' => '上传成功', 'data' => $retData], JSON_UNESCAPED_UNICODE); } public function upload(Request $request){ set_time_limit(0); $params = $request->param(); //表名 $table = isset($params['table']) ? $params['table'] : 'capital_upfiles'; $user_id = session('hid'); //文件在哪个状态下添加 $status = $request->param('status', 0); $ftype_id = $request->param('ftype_id'); $apply_id = $request->param('apply_id',0); $filesize = $request->param('filesize', 0); if (empty($user_id)) { echo json_encode(['code' => 500, 'msg' => '重新登陆', 'data' => []], JSON_UNESCAPED_UNICODE);exit; } $files = $request->file(''); if (!$files) { echo json_encode(['code' => 500, 'msg' => '没有上传文件', 'data' => []], JSON_UNESCAPED_UNICODE);exit; } $filesize = !$filesize ? $_FILES["file"]["size"] : $filesize; //上传地址 $upload_path = 'data' . DS . 'upload'; $unique_code = md5(time() + $user_id); // Settings $targetDir = ROOT_PATH . $upload_path; $uploadDir = ROOT_PATH . $upload_path . DS . date('Y-m-d') . DS . $user_id; // Create target dir if (!file_exists($targetDir)) { @mkdir($targetDir,0755,true); } // Create target dir if (!file_exists($uploadDir)) { @mkdir($uploadDir,0755,true); } // Get a file name $fileName = $_FILES["file"]["name"]; $filePath = $targetDir . DIRECTORY_SEPARATOR . $fileName; $uploadPath = $uploadDir . DIRECTORY_SEPARATOR . $fileName; // Chunking might be enabled $chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0; $chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 1; // Open temp file if (!$out = @fopen("{$filePath}_{$chunk}.parttmp", "wb")) { echo json_encode(['code' => 500, 'msg' => '没有找到文件', 'data' => []], JSON_UNESCAPED_UNICODE);exit; } if (!empty($_FILES)) { if ($_FILES["file"]["error"] || !is_uploaded_file($_FILES["file"]["tmp_name"])) { echo json_encode(['code' => 500, 'msg' => '无法移动上传文件', 'data' => []], JSON_UNESCAPED_UNICODE);exit; } // Read binary input stream and append it to temp file if (!$in = @fopen($_FILES["file"]["tmp_name"], "rb")) { echo json_encode(['code' => 500, 'msg' => '无法打开分输入流', 'data' => []], JSON_UNESCAPED_UNICODE);exit; } } else { if (!$in = @fopen("php://input", "rb")) { echo json_encode(['code' => 500, 'msg' => '无法打开分输入流.', 'data' => []], JSON_UNESCAPED_UNICODE);exit; } } while ($buff = fread($in, 4096)) { fwrite($out, $buff); } @fclose($out); @fclose($in); rename("{$filePath}_{$chunk}.parttmp", "{$filePath}_{$chunk}.part"); $index = 0; $done = true; for ($index = 0; $index < $chunks; $index++) { if (!file_exists("{$filePath}_{$index}.part")) { $done = false; break; } } if ($done) { if (!$out = @fopen($uploadPath, "wb")) { echo json_encode(['code' => 500, 'msg' => '无法打开分输出流!', 'data' => []], JSON_UNESCAPED_UNICODE);exit; } if (flock($out, LOCK_EX)) { for ($index = 0; $index < $chunks; $index++) { if (!$in = @fopen("{$filePath}_{$index}.part", "rb")) { break; } while ($buff = fread($in, 4096)) { fwrite($out, $buff); } @fclose($in); @unlink("{$filePath}_{$index}.part"); } flock($out, LOCK_UN); } @fclose($out); } $img_url = $upload_path . DS . date('Y-m-d') . DS . $user_id . DS . $fileName; $result = Db::name($table)->where(['user_id' => $user_id, 'ftype_id' => $ftype_id,'apply_id'=>$apply_id])->find(); if (empty($result)) { //写入数据表capital_upfiles $data = [ 'user_id' => isset($user_id) ? $user_id : 0, 'user_type' => 1, 'status' => $status, 'upload_time' => time(), 'ftype_id' => $ftype_id, 'ftype' => 1, 'filesize' => $filesize, 'path' => $img_url, 'flag' => 0, 'unique_code' => $unique_code ]; Db::name($table)->insert($data); } else { Db::name($table)->where(['file_id' => $result['file_id']])->update([ 'unique_code' => $unique_code ]); } $retData = [ 'unique_code' => $unique_code, 'img_url' => 'http://' . $_SERVER['HTTP_HOST'] .DS. $img_url ]; echo json_encode(['code' => 200, 'msg' => '上传成功', 'data' => $retData], JSON_UNESCAPED_UNICODE);exit; } public function aliUpload(Request $request){ $params = $request->param(); //表名 $table = isset($params['table']) ? $params['table'] : 'capital_upfiles'; if(!in_array($table,['capital_upfiles'])){ echo json_encode(['code' => 500, 'msg' => 'table不存在', 'data' => []], JSON_UNESCAPED_UNICODE);exit; } $user_id = session('hid'); if(!$user_id){ echo json_encode(['code' => 500, 'msg' => '重新登陆', 'data' => []], JSON_UNESCAPED_UNICODE);exit; } //上传地址 $upload_path='data'.DS.'upload'; // Get a file name $fileName = $request->param('fileName'); $fileName = !$fileName ? $_FILES["file"]["name"] : $fileName; //阿里配置 $filesize =input('filesize','','intval'); $step=input('step',1,'intval'); $ftype_id =input('ftype_id'); $applyid =input('apply_id','','intval'); $unique_code =input('unique_code'); $fileId=input('fileId'); $uploadId=input('uploadId'); $retData=[]; $accessKeyId=config('aliyun_oss.accesskey'); $accessKeySecret=config('aliyun_oss.secretkey'); $endpoint=config('aliyun_oss.endpoint'); $bucket=config('aliyun_oss.bucket'); $ufileName='wjstg/'.$user_id.'/'.$fileName; $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint); /** * 步骤1:初始化一个分片上传事件,获取uploadId。 */ if($step==1){ $unique_code = md5($unique_code.$user_id); $where=['user_id' => $user_id, 'ftype_id' => $ftype_id, 'unique_code' => $unique_code]; $result = Db::name($table)->where($where)->find(); //已上传过 if($result&&$result['etags']){ $fileId=$result['file_id']; $uploadId=$result['upload_id']; $etags=$result['etags']?json_decode($result['etags'],true):[]; $chunks=$result['chunks']; $applyid=trim($applyid,'undefined'); //上传完 if($result['path']&&count($etags)==$chunks){ if($applyid&&$result['apply_id']!=$applyid){ $data = [ 'user_id' =>$user_id, 'user_type' =>1, 'status' => 0, 'upload_time' => time(), 'ftype_id' => $ftype_id, 'ftype' => 1, 'filesize' =>$filesize, 'path' =>$result['path'], 'flag' => 0, 'apply_id' =>$applyid, 'upload_id' => $uploadId, 'unique_code' => $unique_code ]; Db::name($table)->where(['apply_id'=>$applyid,'ftype_id'=>$ftype_id])->delete(); $query=Db::name($table)->insert($data,false,true); if($query)$fileId=$query; } $retData = ['uploadId'=>$uploadId,'fileId'=>$fileId,'unique_code' => $unique_code,'img_url' =>$result['path']]; }else{ //未上传完 $hastags=[]; if(count($etags)){ $hastags=array_column($etags,'PartNumber'); } $retData = ['uploadId'=>$uploadId,'fileId'=>$fileId,'unique_code' => $unique_code,'etags' =>$hastags,'img_url' =>'']; } }else{ try{ //返回uploadId。uploadId是分片上传事件的唯一标识,您可以根据uploadId发起相关的操作,如取消分片上传、查询分片上传等。 $uploadId = $ossClient->initiateMultipartUpload($bucket, $ufileName); if($result){ $fileId=$result['file_id']; Db::name($table)->where(['file_id' =>$fileId])->update(['upload_id' => $uploadId]); }else{ $applyid=trim($applyid,'undefined'); $data = [ 'user_id' =>$user_id, 'user_type' =>1, 'status' => 0, 'upload_time' => time(), 'ftype_id' => $ftype_id, 'ftype' => 1, 'filesize' =>$filesize, 'path' =>$ufileName, 'flag' => 0, 'apply_id' =>$applyid, 'upload_id' => $uploadId, 'unique_code' => $unique_code ]; Db::name($table)->where(['apply_id'=>$applyid,'ftype_id'=>$ftype_id])->delete(); $query=Db::name($table)->insert($data,false,true); if($query)$fileId=$query; } $retData=['uploadId'=>$uploadId,'fileId'=>$fileId,'img_url' =>'']; } catch(OssException $e) { echo json_encode(['code' => 500, 'msg' => '初始化失败', 'data' => []], JSON_UNESCAPED_UNICODE);exit; } } } /** * 步骤2:上传分片。 */ if($step==2){ if(empty($uploadId)){ echo json_encode(['code' => 500, 'msg' => '初始化失败,uploadId不存在', 'data' =>[]], JSON_UNESCAPED_UNICODE);exit; } if (!$_FILES["file"]||$_FILES["file"]["error"]||!is_uploaded_file($_FILES["file"]["tmp_name"])) { echo json_encode(['code' => 500, 'msg' => '没有上传文件', 'data' => []], JSON_UNESCAPED_UNICODE);exit; } $uploadFile=$_FILES["file"]['tmp_name']; $partSize =config('aliyun_oss.piecesize'); $cursize=filesize($uploadFile); // Chunking might be enabled $chunk =input('chunk',0,'intval'); if($chunk==0&&$cursize<$partSize){ $filesize=filesize($uploadFile); } //if($chunk==2)exit; // Read binary input stream and append it to temp file $result = Db::name($table)->where(['file_id' =>$fileId])->find(); if(!$result) { echo json_encode(['code' => 500, 'msg' => '初始化不成功', 'data' => []], JSON_UNESCAPED_UNICODE);exit; } $resUploadPart =$result['etags']?json_decode($result['etags'],true):[]; $hastags=[]; if(count($resUploadPart)){ $hastags=array_column($resUploadPart,'PartNumber'); } //已上传过跳过 if(in_array($chunk+1,$hastags)){ $retData = ['etags' =>$resUploadPart]; }else{ $uploadId=$result['upload_id']; $pieces = $ossClient->generateMultiuploadParts($filesize, $partSize); $uploadPosition = 0; $isCheckMd5 = false; $piece=$pieces[$chunk]; $fromPos =$uploadPosition + (integer)$piece[$ossClient::OSS_SEEK_TO]; $toPos = (integer)$piece[$ossClient::OSS_LENGTH] + $fromPos - 1; $upOptions = array( // 上传文件。 $ossClient::OSS_FILE_UPLOAD => $uploadFile, // 设置分片号。 $ossClient::OSS_PART_NUM =>($chunk+1), // 指定分片上传起始位置。 $ossClient::OSS_SEEK_TO => 0,//$fromPos, // 指定文件长度。 $ossClient::OSS_LENGTH => $toPos - $fromPos + 1, // 是否开启MD5校验,true为开启。 $ossClient::OSS_CHECK_MD5 => $isCheckMd5, ); // 开启MD5校验。 if ($isCheckMd5) { $contentMd5 = OssUtil::getMd5SumForFile($uploadFile, 0, $toPos); $upOptions[$ossClient::OSS_CONTENT_MD5] = $contentMd5; } try { $respart= $ossClient->uploadPart($bucket, $ufileName, $uploadId, $upOptions); // 上传分片。 $respart=trim($respart,'"'); $resUploadPart[$chunk]=array("PartNumber"=>$chunk+1, "ETag"=>$respart); $retData = ['etags' =>$resUploadPart]; } catch(OssException $e) { $retData=['msg'=>$e->getErrorMessage(),'code'=>$e->getErrorCode()]; echo json_encode(['code' => 500, 'msg' =>"分片{$chunk}上传失败", 'data' =>$retData], JSON_UNESCAPED_UNICODE);exit; } Db::name($table)->where(['file_id' =>$fileId])->update(['etags' =>json_encode($resUploadPart),'chunks'=>count($pieces)]); } } if($step==3){ $result = Db::name($table)->where(['file_id' =>$fileId])->find(); if(!$result) { echo json_encode(['code' => 500, 'msg' => '初始化不成功', 'data' => []], JSON_UNESCAPED_UNICODE);exit; } $unique_code=$result['unique_code']; $uploadId=$result['upload_id']; $chunks=$result['chunks']; $resUploadPart =$result['etags']?json_decode($result['etags'],true):[]; if(count($resUploadPart)==$chunks&&$chunks>0){ asort($resUploadPart); /** * 步骤3:完成上传。 */ $bucketurl=config('aliyun_oss.bucketurl'); $path=''; try { // 执行completeMultipartUpload操作时,需要提供所有有效的$uploadParts。OSS收到提交的$uploadParts后,会逐一验证每个分片的有效性。当所有的数据分片验证通过后,OSS将把这些分片组合成一个完整的文件。 $ossClient->completeMultipartUpload($bucket, $ufileName, $uploadId, $resUploadPart); $path=$bucketurl.'/'.$ufileName; Db::name($table)->where(['file_id' =>$fileId])->update(['path'=>$path]); } catch(OssException $e) { $retData=['msg'=>$e->getErrorMessage()]; echo json_encode(['code' => 500, 'msg' =>"completeMultipartUpload FAILED", 'data' =>$retData], JSON_UNESCAPED_UNICODE);exit; } $retData = ['unique_code' => $unique_code,'img_url' =>$path]; }else{ echo json_encode(['code' => 500, 'msg' => '上传失败', 'data' => []], JSON_UNESCAPED_UNICODE);exit; } } echo json_encode(['code' => 200, 'msg' => '上传成功', 'data' => $retData], JSON_UNESCAPED_UNICODE);exit; } /** * 缴费审核提交 * * @param Request $request * @return string * @throws \think\Exception */ public function setPayImg(Request $request){ $this->check_login(); $apply_id = $request->param('apply_id'); $files = $request->file('file'); $user_id = session('hid'); $apply = Db::name('capitalapply')->where(['apply_id'=>$apply_id,'user_id'=>$user_id])->find(); if(!$apply)return json_encode(['code' => 500, 'msg' =>"项目不存在"]); if (empty($apply_id) || empty($files)) { return json_encode(['code' => 500, 'msg' => '参数错误', 'data' => []], JSON_UNESCAPED_UNICODE); } // if ($files->getInfo('size') > (20 * 1024 * 1024)) { // session('TOKEN', input('TOKEN')); // $this->error('上传文件不能大于20M!'); // } if (!in_array(strtoupper(substr(strrchr($files->getInfo('name'), '.'), 1)), ['JPG', 'PNG', 'JPEG'])) { session('TOKEN', input('TOKEN')); $this->error('上传文件类型错误!'); } $upath = '/data' . DS . 'upload' . DS . date('Y-m-d'); $info = $files->rule('md5')->move(ROOT_PATH . $upath); if ($info) { $img_url = $upath . DS . $info->getFilename(); //修改capitalapply $data = [ 'pay_img' => $img_url, 'update_time' => time(), ]; Db::name('capitalapply')->where(['apply_id' => $apply_id])->update($data); $baseinfo=db('capitalbaseinfo')->where(['apply_id'=>$apply_id])->find(); if($baseinfo['apply_type']==1){ $notice_title='文化资产托管项目【'.$baseinfo['capital_name'].'】:已上传缴费凭证'; $sl_data=[ 'notice_title'=>$notice_title, 'notice'=>'', 'user_id'=>$apply['user_id'], 'apply_id'=>$apply_id, 'create_id'=>$apply['update_user_id'], 'create_type'=>0, 'create_time'=>time() ]; Db::name('capitalnotice')->insert($sl_data); } } else { return json_encode(['code' => 500, 'msg' => $files->getError()]); } return json_encode(['code' => 200, 'msg' => '上传成功', 'data' => []], JSON_UNESCAPED_UNICODE); } /** * 上传服务协议 * @param Request $request * @return unknown */ public function setContract(Request $request){ $this->check_login(); $apply_id = $request->param('apply_id'); $user_id = session('hid'); $where=array('apply_id'=>$apply_id); $apply = Db::name('capitalapply')->where(['apply_id'=>$apply_id,'user_id'=>$user_id])->find(); if(!$apply)return json_encode(['code' => 500, 'msg' =>"项目不存在"]); $baseinfo = Db::name('capitalbaseinfo')->where($where)->find(); if($baseinfo['contract_status']>2)return json_encode(['code' => 500, 'msg' =>"上传失败"]); $contract_status=$baseinfo['contract_status']; if($baseinfo['contract_status']==1)$contract_status=2; $key="file"; if(!$key)return json_encode(['code' => 500, 'msg' => '参数错误', 'data' => []], JSON_UNESCAPED_UNICODE); $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){ $data=array(); $data['ext']=$info->getExtension(); $path=$uploadpath.DS.$info->getSaveName();; $data['path']=$path; $data['filename']=$info->getFilename(); $query=Db::name('capitalbaseinfo')->where($where)->update(['contract'=>$path,'contract_status'=>$contract_status]); if($baseinfo['apply_type']==2){ Db::name('capitalapply')->where(['apply_id'=>$apply_id,'user_id'=>$user_id,'status'=>100])->update(['status'=>50]); } return json_encode(['code' => 200, 'msg' => '上传成功', 'data' => []], JSON_UNESCAPED_UNICODE); }else{ return json_encode(['code' => 500, 'msg' => '上传失败', 'data' => []], JSON_UNESCAPED_UNICODE); } } /** * 查询详情 * @param Request $request * @return false|string * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function getInfo(Request $request) { $apply_id = $request->param('apply_id'); $user_id = session('hid'); if (!$apply_id || !$user_id) { return json_encode(['code' => 500, 'msg' => '无效的参数']); } $checkInfo = Db::name('capitalapply')->where(['apply_id' => $apply_id])->where(['user_id' => $user_id])->find(); if (!$checkInfo) { return json_encode(['code' => 500, 'msg' => '错误的记录']); } $info = Db::name('capitalbaseinfo')->where(['apply_id' => $apply_id])->find(); if (!$info) { return json_encode(['code' => 500, 'msg' => '没有对应的数据']); } if ($checkInfo['apply_status'] == 1) { $info['status_name'] = config('status')[$checkInfo['status']] . '(审核通过)'; } else if ($checkInfo['apply_status'] == 2) { $info['status_name'] = config('status')[$checkInfo['status']] . '(审核不通过)'; } else { $info['status_name'] = config('status')[$checkInfo['status']] . '中'; } $info['apply_status'] = $checkInfo['apply_status']; $info['status'] = $checkInfo['status']; $files = Db::name('capital_upfiles f ')->join('capitaluptype t', 'f.ftype_id=t.ftype_id')->where(['f.apply_id' => $apply_id])->field('f.path,f.unique_code,f.ftype_id,t.ftypedescr,f.flag')->select(); $rtn = array_merge($info, array('files' => $files)); return json_encode(['code' => 200, 'msg' => '', 'data' => $rtn], JSON_UNESCAPED_UNICODE); } /** * 补充资料 * @param Request $request * @return false|string * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException */ public function reUpload(Request $request) { $apply_id = $request->param('apply_id'); $unique_code = $request->param('unique_code'); $user_id = session('hid'); if (!$apply_id || !$unique_code || !$user_id) { return json_encode(['code' => 500, 'msg' => '无效的参数']); } $checkInfo = Db::name('capitalapply')->where(['apply_id' => $apply_id])->where(['user_id' => $user_id])->find(); if (!$checkInfo) { return json_encode(['code' => 500, 'msg' => '错误的记录']); } $info = Db::name('capital_upfiles')->where('unique_code', 'in', explode(',', $unique_code))->select(); $fileNum = count($info); if ($fileNum == 0 || $fileNum != count(explode(',', $unique_code))) { return json_encode(['code' => 500, 'msg' => '没有对应的数据']); } $upInfo = array( 'apply_id' => $apply_id, ); $upRtn = Db::name('capital_upfiles')->where('unique_code', 'in', explode(',', $unique_code))->update($upInfo); foreach ($info as $row) { $ftype_id = $row['ftype_id']; $del = Db::name('capital_upfiles')->where('apply_id', $apply_id)->where('ftype_id', $ftype_id)->where('unique_code', 'not in', explode(',', $unique_code))->where('flag', 0)->delete(); } $upInfo = array( 'status' => 10, 'apply_status' => 0 ); $statusInfo = Db::name('capitalapply')->where(['apply_id' => $apply_id])->where(['user_id' => $user_id])->update($upInfo); if ($statusInfo) { return json_encode(['code' => 200, 'msg' => '上传成功',], JSON_UNESCAPED_UNICODE); } else { return json_encode(['code' => 500, 'msg' => '出现错误']); } } }