action(); $post = $request->post(); $params=isset($post['data'])?$post['data']:[]; $keys=[ 'import'=>'9417aaa07a16d1fa', 'importartbook'=>'2ce09d0fd2a21809', 'importebook'=>'2fdd1f00234aca81', ]; $agencykey=isset($keys[$action])?$keys[$action]:''; /* if(empty($agencykey)){ $this->error('缺少参数'); } if (!isset($post['time'])) { $this->error('缺少参数'); } $timestamp = $post['time']; if (empty($timestamp)) { $this->error('缺少参数'); } // 判断token $token =$post['token']; if(!$token) { $this->error('缺少参数'); } $curtime = time(); $expire = 60; // 允许延迟秒数 if (!$timestamp || $timestamp > $curtime || ($timestamp + $expire) < $curtime) { $this->error('token验证超时'); } $sign = $this->getSign($agencykey, $post); if ($token != $sign) { $this->error('token验证失败'); } */ } protected function replaceTitle($title=""){ $keys=["唐","唐代","宋","北宋","南宋","宋-元","元","元代","金","金代","清","元-明","明","明代","大明万历年制款","清中期","清同治","清康熙","清嘉庆","清光绪","宋金","元末明初","清中期","大清雍正年制款","大清乾隆年制款","清末","清初", "元-明初","南北朝","明永乐","明宣德","明成化","明崇祯","明晚清初","民国","宋代","金(或元)","雍正年制款","大清","乾隆年制款","中和堂(款)","金元","乾隆御制","明代弘治年制","清代","大清雍正","大清同治年制款", "明早期","宣德","崇祯","新石器时代","春秋-战国","战国-汉","汉","汉代","古汉代","西汉","东汉","清代乾隆款","乾隆","北魏","明末","清末","唐-五代","明以前","康熙款", "商代","洪武","南","商周","年制","大年制","南","万历","康熙","嘉靖","雍正","光绪","(大年制楷书款)","万历",",光绪(康熙款)","北,","内府",",万历",",雍正",",康熙",",嘉靖", "春秋战国","五代","战国","永乐","大弘治","正德","大正德","枢府","老玉","中期","早期","明,","(清)","元·","(元)","东","古玉","宋·","金(或元)·","清乾隆·","明永乐·","明万历·", "南宋·","北宋·","“大清光绪”","(早期)","(清光绪款)","柜台面议"]; arsort($keys); $title=str_replace($keys,"",$title); return $title; } // 获取sign protected function getSign($secret, $data) { if (isset($data['token'])) unset($data['token']); // 对数组的值按key排序 ksort($data); // 生成url的形式 $params = http_build_query($data); // 生成sign $sign = md5($params.$secret); return $sign; } /** * 我的托管 * @param Request $request * @return string */ protected function mytg(Request $request){ $limit = $request->param('limit', 30); $user_id = session('hid'); $where=['a.user_id' => $user_id]; $apply_type=2;//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')->field($fields)->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]; } $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->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']):''; $applyid=$val['apply_id']; $astatus=intval($val['apply_status']); 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'] = ''; } } } return json_encode(['code' => 200, 'msg' => 'success', 'data' => $data], JSON_UNESCAPED_UNICODE); } public function products(){ $products=Db::name('capitalbaseinfo')->alias('b')->field("d.apply_id,d.hoster_reason,d.capital_name,d.capital_size,d.capital_type,d.capital_price,d.capital_desc,d.capital_sprice,d.capital_agency,d.capital_date,d.capital_files")->join(config('database.prefix').'capitaldetail d','d.apply_id = b.apply_id')->where(['d.flag'=>1,'b.apply_type'=>2])->select(); if(count($products)){ foreach ($products as &$item){ $item['capital_date']=$item['capital_date']?date("Y-m-d",$item['capital_date']):''; $item['type_name']=getCapitalType($item['capital_type']); $files=html_entity_decode($item['capital_files']); $files=explode(";",$files); foreach ($files as $k=>$jow){ $files[$k]=str_replace('\\','/',$jow); } $item['capital_files']=implode(";",$files); } } return json(['code' => 200, 'msg' => 'success','products'=>$products]); } /** * 托管项目详情 * @param Request $request * @return string */ protected function detail(Request $request){ $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('hid'); $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']):''; } } return json_encode(['code' => 200, 'msg' => 'success', 'baseinfo' => $baseinfo,'products'=>$products,'files'=>$files], JSON_UNESCAPED_UNICODE); } /** * 托管申请 * * @param Request $request * @return string */ protected 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', ]; $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)){ $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); } }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]); } //旧纪录取出个人附件、托管附件 $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'); send_sms($tel,$msg); } } } 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 */ protected 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 (!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); } /** * 同意协议 * @return string */ protected function agreement(){ $agreesys1=Options::get_options('tgagree_options3',$this->lang); $agreesys2=Options::get_options('tgagree_options4',$this->lang); $agreesys3=Options::get_options('tgagree_options5',$this->lang); return json_encode(['code' => 200, 'msg' => '上传成功', 'data' =>['agree1'=>$agreesys1,'agree2'=>$agreesys2,'agree3'=>$agreesys3]], JSON_UNESCAPED_UNICODE); } /** * 托管公告 * @return string */ protected function notice(){ $uid=session('hid'); $lists=Db::name('capitalnotice')->alias('a')->where(['a.user_id'=>$uid])->order('a.create_time desc')->field('a.*')->paginate(config('paginate.list_rows')); $show=$lists->render(); return json_encode(['code' => 200, 'msg' => '上传成功', 'data' =>['list'=>$lists,'page'=>$show]], JSON_UNESCAPED_UNICODE); } /** * 已查阅 * @return string */ protected function read(){ $notice_id=input('notice_id',0,'intval'); //设置为已读 Db::name('capitalnotice')->update(['notice_id'=>$notice_id,'is_read'=>1]); return json_encode(['code' => 200, 'msg' => '查阅成功'], JSON_UNESCAPED_UNICODE); } /** * 托管产品列表 * @return string */ protected function index(){ $kind=4; $childs=config("tuoguan.childs"); $parents=config('tuoguan.parents'); $state=input('state','','intval'); $states=[1=>['name'=>'预披露'],2=>['name'=>'正式披露'],['name'=>'成交公示'],['name'=>'艺术资产转让']]; $page=input('page',1); $mprice=input('mprice'); $sprice=input('sprice'); if($mprice)$mprice=intval($mprice); if($sprice)$sprice=intval($sprice); $keyword=input('keyword',''); $cid=input('cid','','intval'); $kid=input('kid','','intval'); $showtype=input('showtype',0,'intval'); $yearsort=input('yearsort','asc'); $pricesort=input('pricesort','asc'); $timesort=input('timesort','asc'); if(!in_array($yearsort,['asc','desc']))$yearsort='asc'; if(!in_array($pricesort,['asc','desc']))$pricesort='asc'; if(!in_array($timesort,['asc','desc']))$timesort='asc'; if($cid||$state){ if($state){ $categorys=[]; $where=['c_status'=>1,'c_kind'=>$kind]; $where['c_state']=$state; $stateslist=[1=>'预披露','正式披露','成交公示','艺术资产转让']; $parent=isset($stateslist[$state])?$stateslist[$state]:''; foreach ($states as $k=>$v){ if($k!=$state)unset($states[$k]); } }else{ $categorys=isset($childs[$cid])?$childs[$cid]:[]; $where=['c_status'=>1,'c_kind'=>$kind]; $where['c_parent']=array('like',[$cid.',%','%,'.$cid.'%',$cid],'OR'); foreach ($categorys as $k=>$v){ $where['c_child']=array('like',[$k.',%','%,'.$k.'%',$k],'OR'); $check=Db::name('finance')->where($where)->count(); if($check==0)unset($categorys[$k]); } if(isset($where['c_cid']))unset($where['c_cid']); if(isset($where['c_child']))unset($where['c_child']); $parent=isset($parents[$cid])?$parents[$cid]:''; } if($kid){ $where['c_child']=array('like',[$kid.',%','%,'.$kid.'%',$kid],'OR'); } $db=Db::name('finance')->where($where); if($keyword){ $db->where('c_name|c_code|c_content','like','%'.$keyword.'%'); } if($mprice){ $db->where('c_price','<=',$mprice); } if($sprice){ $db->where('c_price','>=',$sprice); } $order=[]; $order['c_year']=$yearsort; $order['c_price']=$pricesort; $order['c_time']=$timesort; $order['c_order']='desc'; $products=$db->order($order)->paginate(15,false,['query'=>get_query()]); $show = $products->render(); if($products){ $products=$products->toArray(); $products=$products['data']; foreach ($products as $k=>$item){ if($item['c_jump']){ if(strpos(strtolower($item['c_jump']),'http')===false){ $products[$k]['c_jump']='http://'.$item['c_jump']; } } $products[$k]['c_name']=$this->replaceTitle($item['c_name']); $products[$k]['c_content']=$this->replaceTitle($item['c_content']); } } }else{ $list=[]; if(count($states)){ $where=['c_status'=>1,'c_kind'=>$kind]; foreach ($states as $id=>$item){ if($id==1){ unset($states[$id]); continue; } $where['c_state']=$id; $db=Db::name('finance')->where($where); $products=$db->order('c_order desc,c_time desc')->limit(5)->select(); foreach ($products as $k=>$item){ if($item['c_jump']){ if(strpos(strtolower($item['c_jump']),'http')===false){ $products[$k]['c_jump']='http://'.$item['c_jump']; } } $products[$k]['c_name']=$this->replaceTitle($item['c_name']); $products[$k]['c_content']=$this->replaceTitle($item['c_content']); } $states[$id]['products']=$products; } } if($kind==4&&$cid==''){ $row=[]; $id=11; $row['id']=$id; $row['name']=$parents[$id]; $childrow=isset($childs[$id])?$childs[$id]:[]; $row['has']=count($childrow)?1:0; if(count($childrow)){ foreach ($childrow as $k=>$v){ $where['c_child']=array('like',[$k.',%','%,'.$k.'%',$k],'OR'); $check=Db::name('finance')->where($where)->count(); if($check==0)unset($childrow[$k]); } } $row['childs']=$childrow; $where=['c_status'=>1,'c_kind'=>$kind]; $where['c_parent']=array('like',[$id.',%','%,'.$id.'%',$id],'OR'); $db=Db::name('finance')->where($where)->order('c_order desc,c_time desc'); if($keyword){ $db->where('c_name|c_code','like','%'.$keyword.'%'); } $products=$db->limit(10)->select(); foreach ($products as $k=>$item){ if($item['c_jump']){ if(strpos(strtolower($item['c_jump']),'http')===false){ $products[$k]['c_jump']='http://'.$item['c_jump']; } } $products[$k]['c_name']=$this->replaceTitle($item['c_name']); $products[$k]['c_content']=$this->replaceTitle($item['c_content']); } $row['products']=$products; array_push($list, $row); $row=[]; $row['id']='all'; $row['name']="专区"; $childrow=[]; $parentrow=[]; foreach ($parents as $k=>$jow){ if($k>4&&$k<11){ $childrow[$k]=$jow; }else if($k>11){ $parentrow[$k]=$jow; } } if(count($childrow)){ foreach ($childrow as $k=>$v){ $where['c_parent']=array('like',[$k.',%','%,'.$k.'%',$k],'OR'); $check=Db::name('finance')->where($where)->count(); if($check==0)unset($childrow[$k]); } } $row['has']=count($childrow)?1:0; $row['childs']=$childrow; $where=['c_status'=>1,'c_kind'=>$kind]; $where['c_parent']=array('<>',10); $db=Db::name('finance')->where($where)->order('c_order desc,c_time desc'); if($keyword){ $db->where('c_name|c_code','like','%'.$keyword.'%'); } $products=$db->limit(10)->select(); foreach ($products as $k=>$item){ if($item['c_jump']){ if(strpos(strtolower($item['c_jump']),'http')===false){ $products[$k]['c_jump']='http://'.$item['c_jump']; } } $products[$k]['c_name']=$this->replaceTitle($item['c_name']); $products[$k]['c_content']=$this->replaceTitle($item['c_content']); $cparent=$item['c_parent']; $cparent=explode(",",$cparent); $products[$k]['c_parent']=count($cparent)?$cparent[0]:''; } $row['products']=$products; array_push($list, $row); foreach ($parentrow as $k=>$item){ $id=$k; $row=[]; $row['id']=$id; $row['name']=$item; $childrow=isset($childs[$id])?$childs[$id]:[]; $row['has']=count($childrow)?1:0; if(count($childrow)){ foreach ($childrow as $k=>$v){ $where['c_child']=array('like',[$k.',%','%,'.$k.'%',$k],'OR'); $check=Db::name('finance')->where($where)->count(); if($check==0)unset($childrow[$k]); } } $row['childs']=$childrow; $where=['c_status'=>1,'c_kind'=>$kind]; $where['c_parent']=array('like',[$id.',%','%,'.$id.'%',$id],'OR'); $db=Db::name('finance')->where($where)->order('c_order desc,c_time desc'); if($keyword){ $db->where('c_name|c_code','like','%'.$keyword.'%'); } $products=$db->limit(10)->select(); foreach ($products as $k=>$item){ if($item['c_jump']){ if(strpos(strtolower($item['c_jump']),'http')===false){ $products[$k]['c_jump']='http://'.$item['c_jump']; } } $products[$k]['c_name']=$this->replaceTitle($item['c_name']); $products[$k]['c_content']=$this->replaceTitle($item['c_content']); } $row['products']=$products; array_push($list, $row); } }else{ if($kind==4&&$cid==0){ foreach ($parents as $k=>$item){ if($k<5||$k>10){unset($parents[$k]);} } } foreach ($parents as $id=>$item){ $row=[]; $row['id']=$id; $row['name']=$item; $childrow=isset($childs[$id])?$childs[$id]:[]; $row['has']=count($childrow)?1:0; $where=['c_status'=>1,'c_kind'=>$kind]; $where['c_parent']=array('like',[$id.',%','%,'.$id.'%',$id],'OR'); if(count($childrow)){ foreach ($childrow as $k=>$v){ $where['c_child']=array('like',[$k.',%','%,'.$k.'%',$k],'OR'); $check=Db::name('finance')->where($where)->count(); if($check==0)unset($childrow[$k]); } if(isset($where['c_cid']))unset($where['c_cid']); if(isset($where['c_child']))unset($where['c_child']); } $row['childs']=$childrow; $db=Db::name('finance')->where($where)->order('c_order desc,c_time desc'); if($keyword){ $db->where('c_name|c_code','like','%'.$keyword.'%'); } $products=$db->limit(10)->select(); foreach ($products as $k=>$item){ if($item['c_jump']){ if(strpos(strtolower($item['c_jump']),'http')===false){ $products[$k]['c_jump']='http://'.$item['c_jump']; } } $products[$k]['c_name']=$this->replaceTitle($item['c_name']); $products[$k]['c_content']=$this->replaceTitle($item['c_content']); } $row['products']=$products; array_push($list, $row); } } } $banners=Db::name('link')->where(['lk_status'=>1,'lk_cid'=>15])->order('lk_order desc')->select(); return json_encode(['code' => 200, 'msg' => 'success', 'list' =>$list,'banners'=>$banners,'states'=>$states], JSON_UNESCAPED_UNICODE); } /** * 搜索 * @return string */ protected function search(){ $cid=input('cid','','intval'); $this->assign('cid',$cid); $kid=input('kid','','intval'); $this->assign('kid',$kid); $banners=Db::name('link')->where(['lk_status'=>1,'lk_cid'=>15])->order('lk_order desc')->select(); $kind=input('kind','','intval'); $page=input('page',1); $mprice=input('mprice'); $sprice=input('sprice'); if($sprice){ $sprice=str_replace(',', '', $sprice); $sprice=intval($sprice); } if($mprice){ $mprice=str_replace(',', '', $mprice); $mprice=intval($mprice); } $keyword=input('keyword',''); $showtype=input('showtype',0,'intval'); $yearsort=input('yearsort','asc'); $pricesort=input('pricesort','asc'); $timesort=input('timesort','desc'); if(!in_array($yearsort,['asc','desc']))$yearsort='asc'; if(!in_array($pricesort,['asc','desc']))$pricesort='asc'; if(!in_array($timesort,['asc','desc']))$timesort='desc'; if($keyword)$keyword=$this->replaceTitle($keyword); $where=['c_status'=>1,'c_kind'=>$kind]; $db=Db::name('finance')->where($where); if($keyword){ $db->where('c_name|c_code|c_content|c_material|c_class','like','%'.$keyword.'%'); } if($mprice){ $db->where('convert(`c_price`,SIGNED)<='.$mprice); } if($sprice){ $db->where('convert(`c_price`,SIGNED)>='.$sprice); } $order=['c_order'=>'desc','c_time'=>$timesort]; if($kind==4){ $db->order("c_year ".$yearsort); } $query=$db->order("c_price+0 ".$pricesort); if($kind==4){ $order=[]; $order['c_time']=$timesort; $order['c_order']='desc'; } $query=$query->order($order); $products=$query->paginate(20,false,['query'=>get_query(),'type'=>'bootstrap','var_page' =>'page']); $show = $products->render(); if($products){ $products=$products->toArray(); $products=$products['data']; foreach ($products as $k=>$item){ if($item['c_jump']){ if(strpos(strtolower($item['c_jump']),'http')===false){ $products[$k]['c_jump']='http://'.$item['c_jump']; } } $products[$k]['c_name']=$this->replaceTitle($item['c_name']); $products[$k]['c_content']=$this->replaceTitle($item['c_content']); } } return json_encode(['code' => 200, 'msg' => 'success', 'products' =>$products,'banners'=>$banners,'page'=>$show], JSON_UNESCAPED_UNICODE); } /** * 托管详情 * @return string */ protected function prodetail(){ $c_id=input('c_id',0,'intval'); $list=Db::name('finance')->where(['c_status'=>1,'c_id'=>$c_id])->find(); $pic_list = array_filter(explode(",", $list['c_photos'])); $list['photos']=$pic_list; return json_encode(['code' => 200, 'msg' => 'success', 'list' =>$list], JSON_UNESCAPED_UNICODE); } /** * 艺术资产托管申请 */ protected function subscription(){ $params=request()->param(); $query=$this->_checksub($params); if($query)$this->success('提交成功'); else $this->error('提交失败'); } /** * 预约登记 * @param array $params * @return number|string */ protected function _checksub($params=array()){ $username=isset($params['username'])?$params['username']:''; $mobile=isset($params['mobile'])?$params['mobile']:''; $email=isset($params['email'])?$params['email']:''; $kind=isset($params['kind'])?$params['kind']:''; $pid=isset($params['c_id'])?$params['c_id']:''; $type=isset($params['type'])?$params['type']:1; $price=isset($params['price'])?$params['price']:''; $prepay=isset($params['prepay'])?intval($params['prepay']):''; $remark=isset($params['remark'])?$params['remark']:''; $creditcard=isset($params['creditcard'])?$params['creditcard']:''; $num=isset($params['num'])?intval($params['num']):0; $role=isset($params['role'])?intval($params['role']):1; if(in_array($type,[1,2])){ $validate=new Validate([ '__token__' => 'require|token', ]); $post=input("post."); if (!$validate->check($post)) { $this->error('令牌失败,请刷新页面重新提交',url('news/finance',['c_id'=>$pid,'kind'=>$kind])); } } if($type==2){ if(empty($price))$this->error('请输入价格'); } if(isset($params['c_id'])){ if(empty($pid))$this->error('请输入产品id'); } if(isset($params['num'])){ if(empty($num))$this->error('请输入出席人数'); } if(isset($params['prepay'])){ if(empty($prepay))$this->error('请选择是否愿意交纳保证金'); } if(isset($params['creditcard'])){ if(empty($creditcard))$this->error('请输入身份证号码'); } if(empty($username))$this->error('请输入姓名'); if(!preg_match('/^[\x7f-\xff]+$/', $username))$this->error("请输入中文姓名"); if(empty($mobile))$this->error('请输入联系电话'); if(!preg_match("/^1[34578]\d{9}$/", $mobile)){ $this->error('请输入正确手机号码'); } if(isset($params['email'])&&$kind!=4){ if(empty($email))$this->error('请输入邮箱'); $check=filter_var($email,FILTER_VALIDATE_EMAIL); if(!$check)$this->error('请输入正确的邮箱'); } $data=array(); $data['username']=$username; if($type==2){ $data['price']=$price; } $data['type']=$type; $data['kind']=$kind; $data['mobile']=$mobile; $data['email']=$email; $data['created_time']=time(); $data['productid']=$pid; $data['prepay']=$prepay; $data['remark']=$remark; $data['creditcard']=$creditcard; $data['num']=$num; $data['role']=$role; $query=Db::name('subscription')->insert($data); return $query; } }