why.xingtongworld.com项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

772 lines
34 KiB

<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/3/22
* Time: 14:45
*/
namespace app\tuoguan\controller;
use app\admin\controller\Base;
use app\tuoguan\model\Tuptype as UptypeModel;
use app\tuoguan\model\TApply as ApplyModel;
use app\admin\model\Options;
use think\Db;
use think\Cache;
class Trusteeship extends Base
{
/**
* 托管上传文件类型列表
* @param int $process
* @param int $status 上传文件状态
* @param int $ftype 上传文件类型
* @return fetch
*/
public function uptype_list($process=-1,$status=-1,$ftype=1)
{
$apply_id=input('apply_id');
//添加固定内容
if (!($ftype == 1 and $status ==-1)) {
//权限检查
if (check_cult4UserRight($apply_id, session('admin_auth.aid'), $status) == 0) {
$this->error('无权限',url('admin/Index/index'));
}
}
$whereType=array(
'apply_id'=>$apply_id,
'new_flag'=>1,
);
if($status==-1){
//固定类型input('apply_id')==null
$uptype_list=UptypeModel::getList(-1,$apply_id,$ftype,$status,-1,'status,apply_type,ftype_id',-1);
$page = $uptype_list->render();
$this->assign('uptype_list',$uptype_list);
$this->assign('page',$page);
}else{
//临时类型
$uptype_list=UptypeModel::getList(-1,$apply_id,$ftype,$status,-1);
$this->assign('uptype_list',$uptype_list);
$this->assign('apply_id',$apply_id);
$this->assign('status',$status);
}
return $this->fetch();
}
/**
* 托管文件类型添加
*/
public function uptype_add($process=-1,$status=-1)
{
if ($process > 0 and $status > 0) {
//权限检查
if (check_cult4UserRight(input('apply_id'), session('admin_auth.aid'), $status) == 0) {
$this->error('无权限',url('admin/Index/index'));
}
}
//创建token
creatToken();
$apply_id=input('apply_id');
$this->assign('apply_id',$apply_id);
$this->assign('status',$status);
$where['status'] = array('egt',0);
$statuslist=Db::name('trusteeship_status')->where($where)->select();
$this->assign('statuslist',$statuslist);
return $this->fetch();
}
/**
* 文化四板固定文件类型修改
*/
public function uptype_edit(){
if(!request()->isAjax()) {
//创建token
creatToken();
$ftype_id = input('ftype_id', 0, 'intval');
if (!$ftype_id) $this->error('参数错误', url('tuoguan/Trusteeship/uptype_list'));
$uptype = Db::name('trusteeship_uptype')->where('ftype_id', $ftype_id)->find();
$this->assign('uptype', $uptype);
if(!empty($uptype['ftemp_id'])){
$upfile = Db::name('trusteeship_upfiles')->where('file_id', $uptype['ftemp_id'])->find();
$this->assign('upfile', $upfile);
}
$where['status'] = array('egt',0);
$statuslist=Db::name('trusteeship_status')->where($where)->select();
$this->assign('statuslist',$statuslist);
$list1=array();
if($uptype['upload_role_type']==1){
$map1['member_group_id']=array(array('gt',0),array('neq',2));//>0 and !=2
$list1=Db::name("member_group")->field(array('member_group_id'=>'id','member_group_name'=>'name'))->where($map1)->select();
}elseif($uptype['upload_role_type']==2){
$map2['id']=array('gt',0);
$list1=Db::name("auth_group")->field(array('id'=>'id','title'=>'name'))->where($map2)->select();
}
$this->assign('list1',$list1);
$list2=array();
if($uptype['upload_role_type2']==1){
$map1['member_group_id']=array(array('gt',0),array('neq',2));//>0 and !=2
$list2=Db::name("member_group")->field(array('member_group_id'=>'id','member_group_name'=>'name'))->where($map1)->select();
}elseif($uptype['upload_role_type2']==2){
$map2['id']=array('gt',0);
$list2=Db::name("auth_group")->field(array('id'=>'id','title'=>'name'))->where($map2)->select();
}
$this->assign('list2',$list2);
return $this->fetch();
}else{
$roletype=input('roletype');
$roleid=input('roletitle');
$roletype2=input('roletype2');
$roleid2=input('roletitle2');
if($roletype<=0 or $roleid<=0)
{
$this->error('请选择资料上传类型及对应的角色!');
}
if(empty($roletype2))$roletype2=0;
if(empty($roleid2))$roleid2=0;
if(!(($roletype2==0 and $roleid2==0) or ($roletype2>0 and $roleid2>0) or ($roletype2<=0 and $roleid2<=0)))
{
$this->error('请选择资料辅助上传类型及对应的角色!');
}
//防止重复提交
if (!checkToken(input('TOKEN'))) {
return;
}
//固定
$apply_id = 0;
$apply_type=input('apply_type');
$isgp=input('isgp');
$mustupload=input('mustupload');
//上传模板部分
$file_id=0;
//支持多个字段单文件
$file = request()->file('file_one');
$file_one='';
if(!empty($file)){
$validate = config('upload_validate');
unset($validate['ext']);//不限制后缀
//单图
$info = $file->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$file_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['apply_id'] = 0;//模板文件未使用该字段
$data['user_id'] = session('admin_auth.aid');
$data['user_type'] = 2;
$data['status'] = input('status');
$data['upload_time'] = time();
$data['ftype_id'] = 0;//模板文件为0
$data['ftype'] = 3;//模板类型
$data['filesize'] = $info->getSize();
$data['path'] = $file_url;
$data['addorder'] = 0;//固定文件需要更新
$data['new_flag'] = 1;//固定文件需要更新
$file_id = Db::name('trusteeship_upfiles')->insert($data,false,true);
} else {
$this->error($file->getError());//否则就是上传错误,显示错误原因
}
}else{
$file_id = input('ftemp_id');
$data['file_id'] = $file_id;//模板文件未使用该字段
$data['status'] = input('status');
Db::name('trusteeship_upfiles')->where('file_id',$file_id)->update($data);
}
$sl_data=array(
'ftype_id'=>input('ftype_id'),
'ftypedescr'=>input('ftypedescr'),
'ftemp_id' => $file_id,
'apply_type' => $apply_type,
'isgp' => $isgp,
'mustupload' => $mustupload,
'ftype'=>input('ftype'),
'status'=>input('status'),
'isopen'=>input('isopen',0),
'apply_id'=>$apply_id,
'user_id'=>session('admin_auth.aid'),
'create_time'=>time(),
'upload_role_type'=>$roletype,
'upload_role_id'=>$roleid,
'upload_role_type2'=>$roletype2,
'upload_role_id2'=>$roleid2,
);
$uptype_id=Db::name('trusteeship_uptype')->where('ftype_id',input('ftype_id'))->update($sl_data);
if($uptype_id){
$this->success('文件类型修改成功',url('tuoguan/Trusteeship/uptype_list'));
}else{
$this->error('文件类型修改失败');
}
}
}
/**
* 托管文件类型添加操作
*/
public function uptype_runadd($process=-1,$status=-1)
{
//添加固定内容
if (!($process == -1 or $status ==-1)) {
//权限检查
if (check_cult4UserRight(input('apply_id'), session('admin_auth.aid'), $status) == 0) {
$this->error('无权限',url('admin/Index/index'));
}
}
$roletype=input('roletype');
$roleid=input('roletitle');
$roletype2=input('roletype2');
$roleid2=input('roletitle2');
if($roletype<=0 or $roleid<=0)
{
$this->error('请选择资料上传类型及对应的角色!');
}
if(empty($roletype2))$roletype2=0;
if(empty($roleid2))$roleid2=0;
if(!(($roletype2==0 and $roleid2==0) or ($roletype2>0 and $roleid2>0) or ($roletype2<=0 and $roleid2<=0)))
{
$this->error('请选择资料辅助上传类型及对应的角色!');
}
//防止重复提交
if (!checkToken(input('TOKEN'))) {
//return;
}
//状态为-1时对应固定文件
$apply_id=input('apply_id');
$whereType=array(
'apply_id'=>$apply_id,
'new_flag'=>1,
);
$mustupload=1;
if($process==-1){
$apply_id = 0;
$apply_type=input('apply_type');
$isgp=input('isgp');
$mustupload=input('mustupload');
}
//上传模板部分
$file_id=0;
//支持多个字段单文件
$file = request()->file('file_one');
$file_one='';
if(!empty($file)){
$validate = config('upload_validate');
unset($validate['ext']);//不限制后缀
//单图
$info = $file->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$file_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['apply_id'] = 0;//模板文件未使用该字段
$data['user_id'] = session('admin_auth.aid');
$data['user_type'] = 2;
$data['status'] = $status;
$data['upload_time'] = time();
$data['ftype_id'] = 0;//模板文件为0
$data['ftype'] = 3;//模板类型
$data['filesize'] = $info->getSize();
$data['path'] = $file_url;
$data['addorder'] = 0;//固定文件需要更新
$data['new_flag'] = 1;//固定文件需要更新
$file_id = Db::name('trusteeship_upfiles')->insert($data,false,true);
} else {
$this->error($file->getError());//否则就是上传错误,显示错误原因
}
}
if ($process == -1 or $status ==-1) {
$uptype_id=UptypeModel::add($apply_type,$isgp,input('ftypedescr'),$file_id,input('ftype'),input('status'),input('isopen',0),0,session('admin_auth.aid'),$roletype,$roleid,$roletype2,$roleid2,$mustupload);
if($uptype_id){
$this->success('文件类型添加成功',url('tuoguan/Trusteeship/uptype_list'));
}else{
$this->error('文件类型添加失败');
}
}else{
$uptype_id=UptypeModel::add($apply_type,$isgp,input('ftypedescr'),$file_id,input('ftype'),$status,input('isopen',0),$apply_id,session('admin_auth.aid'),$roletype,$roleid,$roletype2,$roleid2);
if($uptype_id){
$sl_data2['apply_id']=input('apply_id');
$sl_data2['status']=$status;
$this->success('文件类型添加成功',url('tuoguan/Trusteeship/uptype_list'.$process,$sl_data2));
}else{
$this->error('文件类型添加失败');
}
}
}
/**
* 托管文件类型列表开启/禁止
*/
public function uptype_state($process=-1,$status=-1)
{
$id=input('x');
if (empty($id)){
//如果不是固定添加类型
if (!($process == -1 or $status ==-1)) {
$this->error('文件ID不存在', url('tuoguan/trusteeship/uptype_list' . $process));
}else{
$this->error('文件ID不存在', url('tuoguan/trusteeship/uptype_list'));
}
}
//取得apply_id
$tempfile = UptypeModel::getFileTypeInfo($id);
if(empty($tempfile)){
$this->error('无权限',url('admin/Index/index'));
}
$isopen=Db::name('trusteeship_uptype')->where('ftype_id',$id)->value('isopen');//判断当前状态情况
if($isopen==1){
$statedata = array('isopen'=>0);
Db::name('trusteeship_uptype')->where('ftype_id',$id)->setField($statedata);
$this->success('状态禁止');
}else{
$statedata = array('isopen'=>1);
Db::name('trusteeship_uptype')->where('ftype_id',$id)->setField($statedata);
$this->success('状态开启');
}
}
/**
* 审核列表
*
* @param int $applystatus 查询单个状态
* @param int $allstatus 查询全部状态标识
* @return fetch
*
*/
public function apply_list($applystatus=-1,$allstatus=-1){
$admin_id = session('admin_auth.aid');
$search_name=input('search_name');
$apply_list=ApplyModel::getList($search_name,$applystatus,$admin_id,'tg_time desc,tg_id desc',$allstatus);
$page = $apply_list->render();
$this->assign('apply_list',$apply_list);
$this->assign('page',$page);
$this->assign('search_name',$search_name);
$this->assign('applystatus',$applystatus);
$this->assign('allstatus',$allstatus);
$this->assign('loginuser',session('admin_auth.aid'));
return $this->fetch();
}
/**
* 托管列表
*/
public function tg_list(){
$applystatus=11;
$search_name=input('search_name');
$apply_list=ApplyModel::getList($search_name,$applystatus,'','tg_time desc,tg_id desc',-1);
$page = $apply_list->render();
$this->assign('apply_list',$apply_list);
$this->assign('page',$page);
$this->assign('search_name',$search_name);
return $this->fetch();
}
/**
* 受理操作
*/
public function apply_applyed($tg_status)
{
if(session('admin_auth.aid')){
$apply = ApplyModel::applyed(input('tg_id'),session('admin_auth.aid'),$tg_status);
if($apply==0){
$this->error('数据已更新,请重试!');
} else {
$this->success('已受理',url('tuoguan/Trusteeship/apply_check',array('tg_id'=>input('tg_id'),'applystatus'=>$tg_status)));
}
}
else
{
$this->error('用户ID不存在');
}
}
/*
* 审核用户信息界面
*/
public function apply_check(){
//创建token
creatToken();
$apply_id=input('tg_id');
$applystatus=input('applystatus');
$user_id=session('admin_auth.aid');
$this->assign('user_id',$user_id);
//托管申请信息
$tgapply = Db::name('trusteeship_apply')->where('tg_id',$apply_id)->find();
$where['apply_type']=array('in','0,'.$tgapply['tg_type']);
$where['status']=0;
$where['isopen']=1;
if($tgapply['tg_type']==1){
$where['isgp']=array('in',$tgapply['tg_isgp'].',0');
}
//上传文件列表
$apply_uptypelist = Db::name('trusteeship_uptype')->where($where)->select();
for ($x=0; $x<count($apply_uptypelist); $x++) {
$filewhere['apply_id']=$apply_id;
$filewhere['ftype_id']=$apply_uptypelist[$x]['ftype_id'];
$filewhere['new_flag']=1;
$file = Db::name('trusteeship_upfiles')->where($filewhere)->order('upload_time desc')->find();
$apply_uptypelist[$x]['file']=$file;
}
//尽职调查历史
if($tgapply['tg_status']==12){
$curr_step='尽职调查';//当前步骤
}
$apply_jzdc = Db::name('trusteeship_checkdd')->where('apply_id',$apply_id)->order('create_time desc')->select();
$this->assign('apply_jzdc',$apply_jzdc);
$jzdc_files = Db::name('trusteeship_upfiles')->where(['apply_id'=>$tgapply['tg_id'],'status'=>12])->order('upload_time desc')->select();
$this->assign('jzdc_files',$jzdc_files);
//查询尽职调查模板
$temp_files = Db::name('trusteeship_upfiles')->alias("f")->join(config('database.prefix').'trusteeship_uptype t','t.ftemp_id=f.file_id')
->where(['t.isopen'=>'1','t.status'=>12,'ftypedescr'=>'尽职调查表'])->where('t.apply_type','in',['0',$tgapply['tg_type']])->order('upload_time desc')->select();
if(!empty($temp_files)){
$this->assign('temp_files',$temp_files[0]);
}
//初审信息历史
if($tgapply['tg_status']==1){
$curr_step='初审';//当前步骤
}
$apply_cs = Db::name('trusteeship_cs')->where('apply_id',$apply_id)->order('create_time desc')->select();
$this->assign('apply_cs',$apply_cs);
//风控审核信息历史
if($tgapply['tg_status']==2){
$curr_step='风控';//当前步骤
}
$apply_fk = Db::name('trusteeship_fk')->where('apply_id',$apply_id)->order('create_time desc')->select();
$this->assign('apply_fk',$apply_fk);
//客户上传缴费凭证历史
$apply_jfpz = Db::name('trusteeship_upfiles')->where(['apply_id'=>$tgapply['tg_id'],'status'=>3])->order('upload_time desc')->find();
$this->assign('apply_jfpz',$apply_jfpz);
//缴费确认历史
if($tgapply['tg_status']==4){
$curr_step='缴费确认';//当前步骤
}
$apply_cw = Db::name('trusteeship_cw')->where('apply_id',$apply_id)->order('create_time desc')->select();
$this->assign('apply_cw',$apply_cw);
//专家评分历史
if($tgapply['tg_status']==5){
$curr_step='专家评分';//当前步骤
}
$apply_zjpf = Db::name('trusteeship_zjpf')->where('apply_id',$apply_id)->order('create_time desc')->find();
$this->assign('apply_zjpf',$apply_zjpf);
//联席会审核历史
if($tgapply['tg_status']==6){
$curr_step='联席会';//当前步骤
}
$apply_lxh = Db::name('trusteeship_lxh')->where('apply_id',$apply_id)->order('create_time desc')->select();
//查联席会决议模板
$lxhjy_tmep = Db::name('trusteeship_upfiles')->alias("f")->join(config('database.prefix').'trusteeship_uptype t','t.ftemp_id=f.file_id')
->where(['t.isopen'=>'1','t.status'=>6])->where('t.apply_type','in',['0',$tgapply['tg_type']])->order('upload_time desc')->select();
if(!empty($lxhjy_tmep)){
$this->assign('lxhjy_tmep',$lxhjy_tmep[0]);
}
$this->assign('apply_lxh',$apply_lxh);
$this->assign('curr_step',$curr_step);
$this->assign('tgapply',$tgapply);
$this->assign('apply_uptypelist',$apply_uptypelist);
return $this->fetch();
}
/**
* 托管文件核验开启/禁止
*/
public function apply_state()
{
$id=input('x');
if (empty($id)){
$this->error('用户ID不存在');
}
$flag=Db::name('trusteeship_upfiles')->where('file_id',$id)->value('flag');//判断当前状态情况
if($flag==1){
$flagdata = array('flag'=>0);
Db::name('trusteeship_upfiles')->where('file_id',$id)->setField($flagdata);
$this->success('审核未通过');
}else{
$flagdata = array('flag'=>1);
Db::name('trusteeship_upfiles')->where('file_id',$id)->setField($flagdata);
$this->success('审核已通过');
}
}
/**
* 托管审核
*/
public function apply_runcheck()
{
//防止重复提交
if (!checkToken(input('TOKEN'))) {
return;
}
$tg_id=input('tg_id');
$apply = Db::name('trusteeship_apply')->where('tg_id',$tg_id)->find();
//检查是否还有未审核通过的文件
if(input('submitType')==1) {
$file_count = Db::name('trusteeship_upfiles')->where(['apply_id'=>$tg_id,'flag'=>0,'new_flag'=>1])->count();
if($file_count){
session('TOKEN',input('TOKEN'));
$this->error('还有文件未审核通过');
}
}else if($apply['tg_status']!=4){
$file_count = Db::name('trusteeship_upfiles')->where(['apply_id'=>$tg_id,'flag'=>0,'new_flag'=>1])->count();
if($file_count==0){
session('TOKEN',input('TOKEN'));
$this->error('文件已全部审核通过,请将文件审核未不通过再操作!');
}
}
if(empty($apply)){
session('TOKEN',input('TOKEN'));
$this->error('用户ID不存在');
}
if(config('cult4advice.check')==1)
{
if(input('advice')=='')
{
session('TOKEN',input('TOKEN'));
$this->error('请输入审核意见!');
}
}
$data=array(
'apply_id'=>$tg_id,//托管申请ID
'advice'=>input('advice',"未填写"),//审批意见
'create_id'=>session('admin_auth.aid'),//审批人
'create_time'=>time(),//审批时间
);
if($apply['tg_status']==1){
$table_name='trusteeship_cs';//托管初审意见表
if(input('submitType')==1) {
$update_status = 2;//风控审核中(初审已通过)
}else{
$update_status = 7;//托管会员修改中(初审未通过)
}
}else if($apply['tg_status']==2){
$table_name='trusteeship_fk';//风控审核意见表
if(input('submitType')==1) {
if(input('tg_type',1,'intval')==1){//企业股权
$count=Db::name('cult4apply')->where(['user_id'=>session('hid')])->where('status','eq',31)->count();
if($count>0){
$update_status = 4;//已挂牌企业直接财务缴费确认
}else{
$update_status = 3;//缴费中(风控审核已通过)
}
}
}else{
$update_status = 8;//托管会员修改中(风控审核未通过)
}
}else if($apply['tg_status']==4){
$table_name='trusteeship_cw';//缴费确认意见表
if(input('submitType')==1) {
$update_status = 5;//专家评分中(缴费状态已确认)
}else{
$update_status = 9;//托管会员修改中(缴费确认未通过)
}
}else if($apply['tg_status']==5){//专家只是评分,没有审核
$table_name='trusteeship_zjpf';//专家评分意见表
$update_status = 6;//联席会审核中(专家已评分)
$data['score'] = input('score');
}else if($apply['tg_status']==6){
$table_name='trusteeship_lxh';//联席会审核意见表
if(input('submitType')==1) {
$update_status = 11;//托管成功
}else{
$update_status = 10;//托管会员修改中(联席会审核未通过)
}
}else if($apply['tg_status']==12){//尽职调查审核
$file = request()->file('file_one');
$table_name='trusteeship_checkdd';//联席会审核意见表
if(input('submitType')==1) {
$update_status = 1;//初审(尽职调查已通过)
}else{
$update_status = 13;//托管会员修改中(尽职调查未通过)
}
}
//找到当前最大addorder
$check=Db::name($table_name)->where('apply_id',$tg_id)->order('addorder desc') ->find ();
if(!empty($check)){
$data['addorder']=$check['addorder']+1;
}else{
$data['addorder']=0;
}
//开始事务
Db::startTrans();
try{
$sl_data['tg_status']=$update_status;
$sl_data['update_user_id']=session('admin_auth.aid');
$sl_data['update_user_type']=2;//后台
$sl_data['update_time']=time();
$sl_data['apply_admin_id']=0;
$sl_data['tg_org']=input('tg_org');
$sl_data['tg_cycle']=input('tg_cycle');
$sl_data['tg_equity']=input('tg_equity');
$sl_data['tg_assets']=input('tg_assets');
$where=array(
'tg_id'=>$apply['tg_id'],
'tg_status'=>$apply['tg_status'],
);
Db::name('trusteeship_apply')->where($where)->update($sl_data);
//审核不通过发送通知给客户
$defaultFileLink='</br>请点击: <div class="basicname modeub modeac modepc " onclick="to_tgdeit('.$tg_id.')">上传资料</div>';
if(input('submitType')==2){
if($apply['tg_status']==1){
$notice_title='您(或您关联)的托管申请初审不通过,请修改资料!';
$sys=Options::get_options('tgcheck_options',$this->lang);//初审不通过通知书
$notic_content=str_replace('#APPLYCONTENTS#',$data['advice'],$sys['content_tpl']);
$notic_content=str_replace('#COMNAME#',$apply['tg_apply_org'],$notic_content);
$notic_content=str_replace('#DATE#',date('Y年m月d日', time()),$notic_content);
}else if($apply['tg_status']==2){
$notice_title='您(或您关联)的托管申请风控审核不通过,请修改资料!';
$sys=Options::get_options('tgcheckfk_options',$this->lang);//风控审核不通过通知书
$notic_content=str_replace('#APPLYCONTENTS#',input('advice').$defaultFileLink,$sys['content_tpl']);
$notic_content=str_replace('#COMNAME#',$apply['tg_apply_org'],$notic_content);
$notic_content=str_replace('#DATE#',date('Y年m月d日', time()),$notic_content);
}else if($apply['tg_status']==4){
$notice_title='您(或您关联)的托管申请缴费确认审核不通过,请修改资料!';
$notic_content='您(或您关联)的申请托管不通过,需要您重新修改信息或上传缴费凭证后再提交。<br>审批意见:'.input('advice').$defaultFileLink;
}else if($apply['tg_status']==6){
$notice_title='您(或您关联)的托管申请联席会审核不通过,请修改资料!';
$notic_content='您(或您关联)的申请托管不通过,需要您重新修改信息或上传资料后再提交。<br>审批意见:'.input('advice').$defaultFileLink;
}else if($apply['tg_status']==12){
$notice_title='您(或您关联)的托管申请尽职调查审核不通过,请修改资料!';
$notic_content='您(或您关联)的申请托管不通过,需要您重新修改信息或上传资料后再提交。<br>审批意见:'.input('advice').$defaultFileLink;
}
}else if($update_status==3){//缴费中,需要发送缴费通知费可以
$sys=Options::get_options('tgfee_options',$this->lang);//缴费通知
$notic_content=str_replace('#COMNAME#',$apply['tg_apply_org'],$sys['content_tpl']);
$notic_content=str_replace('#DATE#',date('Y年m月d日', time()),$notic_content);
$notice_title='您(或您关联)的托管申请风控审核已通过,请缴费后上传缴费凭证!';
}else if($update_status==11){//托管成功,发送成功通知给客户
$info2 = request()->file('lxhjy')->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
$file_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info2->getFilename();
//写入数据库
$lxhjy['apply_id'] = $tg_id;//模板文件未使用该字段
$lxhjy['user_id'] = session('admin_auth.aid');
$lxhjy['user_type'] = 2;
$lxhjy['status'] = 6;
$lxhjy['upload_time'] = time();
$lxhjy['ftype_id'] = 0;//模板文件为0
$lxhjy['ftype'] = 1;//模板类型
$lxhjy['filesize'] = $info2->getSize();
$lxhjy['path'] = $file_url;
$lxhjy['addorder'] = 0;//固定文件需要更新
$lxhjy['new_flag'] = 1;//固定文件需要更新
$lxhjy['flag'] = 1;
Db::name('trusteeship_upfiles')->insert($lxhjy,false,true);
if($apply['tg_type']==1){
$notice_key='tgnotice_options';//企业股权通知书
$successgg_key = 'tgsuccess_options';//企业股权成功公告
$tg_thing=input('tg_equity');//股权
}else{
$notice_key='zc_successgg';//资产通知书
$successgg_key = 'zc_successgg';//资产成功公告
$tg_thing=input('tg_assets');//托管资产
}
$sys=Options::get_options($notice_key,$this->lang);//缴费通知
$notice_title='托管申请成功通知书';
$notic_content =str_replace('#DATE#',date('Y年m月d日', time()),$sys['content_tpl']);
$notic_content=str_replace('#COMNAME#',$apply['tg_apply_org'],$notic_content);
$notic_content=str_replace('#EQUITY#',$tg_thing,$notic_content);
$notic_content=str_replace('#CYCLE#',input('tg_cycle'),$notic_content);
$sys=Options::get_options($successgg_key,$this->lang);//托管成功公告
$gg_content=$sys['content_tpl'];
$gg_content=str_replace('#EQUITY#',$tg_thing,$gg_content);
$gg_content=str_replace('#CYCLE#',input('tg_cycle'),$gg_content);
$gg_content=str_replace('#COMNAME#',$apply['tg_apply_org'],$gg_content);
$gg_content=str_replace('#DATE#',date('Y年m月d日', time()),$gg_content);
if($apply['tg_isgp']==2){
if($apply['tg_type']==1){
//未挂牌企业,公告标题和通知书标题改为“关于企业”
$notic_content=str_replace('关于文化产业板养成板挂牌企业',"关于企业",$notic_content);
$gg_content=str_replace('关于文化产业板养成板挂牌企业',"关于企业",$gg_content);
$notic_content=str_replace('关于文化产业板挂牌企业',"关于企业",$notic_content);
$gg_content=str_replace('关于文化产业板挂牌企业',"关于企业",$gg_content);
}else{
$notic_content=str_replace('关于文化产业板挂牌企业',"",$notic_content);
$gg_content=str_replace('关于文化产业板挂牌企业',"",$gg_content);
$notic_content=str_replace('##','关于',$notic_content);
$gg_content=str_replace('##','关于',$gg_content);
}
}else{
$notic_content=str_replace('##','',$notic_content);
$gg_content=str_replace('##','',$gg_content);
}
}else if($update_status==1){//尽职调查审核通过
$validate = config('upload_validate');
unset($validate['ext']);//不限制后缀
//单图
$info = $file->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$file_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$filedata['apply_id'] = $tg_id;//模板文件未使用该字段
$filedata['user_id'] = session('admin_auth.aid');
$filedata['user_type'] = 2;
$filedata['status'] = 12;
$filedata['upload_time'] = time();
$filedata['ftype_id'] = 0;//模板文件为0
$filedata['ftype'] = 1;//模板类型
$filedata['filesize'] = $info->getSize();
$filedata['path'] = $file_url;
$filedata['addorder'] = 0;//固定文件需要更新
$filedata['new_flag'] = 1;//固定文件需要更新
$filedata['flag'] = 1;
$file_id = Db::name('trusteeship_upfiles')->insert($filedata,false,true);
$data['file_id']=$file_id;
} else {
session('TOKEN',input('TOKEN'));//审核失败,将token添加回session里
$this->error($file->getError());//否则就是上传错误,显示错误原因
}
}
Db::name($table_name)->insert($data);
if(input('submitType')==2 || $update_status==3 || $update_status==11){
$n_data=[
'notice_title'=>$apply['tg_apply_org'].$notice_title,
'notice'=>$notic_content,
'apply_id'=>$tg_id,
'user_id'=>$apply['tg_uid'],
'is_read'=>'0',
'create_id'=>session('admin_auth.aid'),
'create_type'=>1,
'create_time'=>time()
];
Db::name('cult4notice')->insert($n_data);
}
if($update_status==11){
$gg_data = [
'n_content'=>$gg_content,
'n_title'=>$apply['tg_apply_org'].'托管申请成功公告',
'n_cid'=>3,
'n_time'=>time(),
'n_status'=>1,
'n_hits'=>0,
'n_uid'=>1
];
Db::name('bsgg')->insert($gg_data);
}
// 提交事务
Db::commit();
}catch (\Exception $exception){
Db::rollback();//回滚事务
session('TOKEN',input('TOKEN'));//审核失败,将token添加回session里
$this->error('审核失败');
}
$this->success('审核成功',url('tuoguan/Trusteeship/apply_list',array('applystatus'=>$apply['tg_status'])));
}
}