<?php
/**
* Created by PhpStorm.
* User: chen
* Date: 2017/7/24
* Time: 上午11:04
*/
use Handler\Handler as Y;
use Respect\Validation\Validator as V;
class NeedsController extends _BaseController {
/**
* 企业表单组建元素
* @return null
*/
public function elementsAction(){
// 0企业需求,1,科技成果
$type = isset($_POST['type'])?$_POST['type']:0;
if($type==0){
//获取企业需求表单信息
$show = $this->field;
}
if($type==1){
//获科技成果v表单信息
$show = $this->fields;
}
return $this->success($show);
}
/**
* 企业需求添加
* @return null
*/
public function needsAddAction(){
//验证登陆
$login = $this->BuserInfo();
// Y::disableView();
$this->rule['title'] = V::stringVal();
$this->rule['domain'] = V::intVal()->min(0);
$this->rule['keyword'] = V::stringVal();
$this->rule['datailescribe'] = V::stringVal();
$this->rule['company'] =V::stringVal();
$this->rule['mobile'] = V::stringVal();
$this->rule['image'] = V::stringVal();
$title= $this->post('title');
$domain= $this->post('domain');
$keyword= $this->post('keyword');
$datailescribe= $this->post('datailescribe');
$company= $this->post('company');
$mobile= $this->post('mobile');
if (isset($this->errorMsg['title'])) {
return $this->error(100000004,['title'=>"企业需求标题错误"]);
}
if (isset($this->errorMsg['domain'])) {
return $this->error(100000004,['domain'=>"企业领域错误"]);
}
if (isset($this->errorMsg['keyword'])) {
return $this->error(100000004,['keyword'=>"关键词错误"]);
}
if (isset($this->errorMsg['datailescribe'])) {
return $this->error(100000004,['datailescribe'=>"详细描述需求有误"]);
}
if (isset($this->errorMsg['company'])) {
return $this->error(100000004,['company'=>"企业名称有误"]);
}
if (isset($this->errorMsg['mobile'])) {
return $this->error(100000004,['mobile'=>"联系电话有误"]);
}
if (isset($this->errorMsg['image'])){
return $this->error(100000004, ['image'=>"图片有误"]);
}
if(empty($title)) {
return $this->error(100000004, ['title' => "企业需求标题不能为空"]);
}
if(empty($domain)){
return $this->error(100000004,['domain'=>"企业需求领域不能为空"]);
}
if(empty($keyword)){
return $this->error(100000004,['keyword'=>"企业需求关键字不能为空"]);
}
if(empty($datailescribe)){
return $this->error(100000004,['datailescribe'=>"详细描述不能为空"]);
}
if(empty($company)){
return $this->error(100000004,['company'=>"企业名称不能为空"]);
}
if(empty($mobile)){
return $this->error(100000004,['mobile'=>"联系号码不能为空"]);
}
$image= $this->post('image','');
if($image!=''){
$image=json_decode($image,true);
}
$data = $this->kClient("microblog", "Needs")->addNeeds($login['id'],$title,$domain,$datailescribe,$company,$mobile,$image,$keyword) ;
if ( $data['code'] == 0 ) {
return $this->success($data['data']);
} else {
return $this->error($data['code'],$data['msg']);
}
}
/**
* 企业需求列表
* @param int $id 企业需求id
* @param int $page 当前页
* @param int $field 领域
*
*/
public function needsListAction(){
// num 每夜都显示几条
$page = isset($_POST['page'])?$_POST['page']:1;
$field = isset($_POST['field'])?$_POST['field']:1;
$type = isset($_POST['type'])?$_POST['type']:1;
$login = $this->BuserInfo();
$num = 10;
$domain= [
1=>'节能环保',3=>'生物医药',5=>'机械制造',7=>'电子信息',
9=>'化学化工',11 =>'新能源',13=>'材料科学',15=>'公共管理',17=>'其他'
];
//uid 领域 当前页面 每页获取多少条
if($type==1){
$data = $this->kClient("microblog", "Needs")->getNeedsAll('',$field,$page,$num);
}
elseif ($type==2){
$data = $this->kClient("microblog", "Needs")->getNeedsAll($login['id'],'',$page,$num);
}
// var_export($data);die;
if(empty($data['data']['list'])){
return $this->success(['']);
}
$arr=$data['data']['list'];
$log=$data['data']['log'];
foreach ($arr as $k=>$v){
$list[$k]['id']=$v['id'];
$list[$k]['uid']=$v['uid'];
$list[$k]['title']=$v['title'];
$list[$k]['needs_detailed']=$v['needs_detailed'];//简介
$list[$k]['business_name']=$v['business_name'];//公司名称
$list[$k]['field']=$v['field'];//领域
}
foreach ($log as $ke=>$va){
foreach ($list as $key=>$val){
//遍历企业需求的最新进展/进展时间
if($log[$ke]['n_id']==$list[$key]['id']){
$list[$key]['handle_type']=$log[$ke]['handle_type'];
$list[$key]['handle_time']= $log[$ke]['handle_time'];
}
}
}
foreach ($list as $ke=>$va ){
//遍历企业需求对应的领域
$list[$ke]['field']=$domain[$list[$ke]['field']];
}
if ( $data['code'] == 0 ) {
return $this->success($list);
} else {
return $this->error($data['code']);
}
}
/**
* 获取企业需求详情
* @param int $id 企业需求id
*
*/
public function needsDescAction(){
$this->rule['id'] = V::intVal()->setTemplate('企业需求id有误');
if($this->errorMsg){
return $this->error(100000004, $this->errorMsg);
}
$id= $this->post('id');
//获取图片存储路径 截取正确需要字段
$config = \Yaf\Application::app()->getConfig();
$a=substr($config['imageUrl'],0,-1);
$h5=$config['h5Url'];
$login = $this->BuserInfo();
$data = $this->kClient("microblog", "Needs")->getNeedsInfo($login['id'],$id);
$domain= [
1=>'节能环保',3=>'生物医药',5=>'机械制造',7=>'电子信息',
9=>'化学化工',11 =>'新能源',13=>'材料科学',15=>'公共管理',17=>'其他'
];
//遍历企业需求对应的领域
foreach ($data['data'] as $ke=>$va ){
$data['data'][$ke]['field']=$domain[$data['data'][$ke]['field']];
$data['data'][$ke]['keywords']= $data['data'][$ke]['keywords'];
$data['data'][$ke]['create_time']= date("Y-m-d H:i:s",$data['data'][$ke]['create_time']) ;
$data['data'][$ke]['is_like']= $data['data'][$ke]['status'];
if(!empty($data['data'][$ke]['file'])){
$arr= json_decode($data['data'][$ke]['file'],true);
foreach ($arr as $k=>$v){
$arr[$k]=$a.$v;
}
$data['data'][$ke]['file']=$arr;
}
}
//整理详情展示
$list=[
['title'=>'关键词','content'=> $data['data'][0]['keywords']==''?'':$data['data'][0]['keywords'],'type'=>3],
['title'=>'客户类型','content'=> $data['data'][0]['customer_type']==''?'':$data['data'][0]['customer_type'],'type'=>2],
['title'=>'解决期限','content'=> $data['data'][0]['solve_term']==''?'':$data['data'][0]['solve_term'],'type'=>2],
['title'=>'最佳预算','content'=> $data['data'][0]['best_budget']==''?'':$data['data'][0]['best_budget'],'type'=>2],
['title'=>'预算上线','content'=> $data['data'][0]['budget_online']==''?'':$data['data'][0]['budget_online'],'type'=>2],
['title'=>'最佳预算','content'=> $data['data'][0]['customer_type']==''?'':$data['data'][0]['customer_type'],'type'=>2],
['title'=>'详细描述','content'=> $data['data'][0]['needs_detailed']==''?'':$data['data'][0]['needs_detailed'],'type'=>2],
['title'=>'技术指标','content'=> $data['data'][0]['technique_target']==''?'':$data['data'][0]['technique_target'],'type'=>2],
['title'=>'不感兴趣的技术','content'=> $data['data'][0]['uninterested']==''?'':$data['data'][0]['uninterested'],'type'=>2],
];
//遍历企业需求的最新进展,有展示,没有就控制展示
$img_url=$arr;
$progress=[
0=>[
'status'=>1,'title'=>'提交需求','content'=> '2017-06-27 10:44'],
1=>['status'=>0,'title'=>'需求确认','content'=> '2017-06-30 12:30'],
2=>['status'=>0,'title'=>'需求签约','content'=> '2017-07-6 15:00'],
3=>['status'=>0,'title'=>'需求服务','content'=> '2017-07-10 10:00'],
4=>['status'=>0,'title'=>'需求关闭','content'=> '2017-07-10 14:20'],
];
if(empty($data['data'][0]['log'])){
$data['data']['progress']=$progress;
}
if(!empty($data['data'][0]['log'])){
foreach ($data['data'][0]['log'] as $k=>$v){
if($v['handle_type']=='提交需求'){
$progress['0']= ['status'=>1,'title'=>'提交需求','content'=> date("Y-m-d H:i:s",$v['handle_time'])];
}
if($v['handle_type']=='已通过'){
$progress['0']['status']=$progress['1']['status']=$progress['2']['status']=$progress['3']['status']=1;
$progress['4']= ['status'=>1,'title'=>'需求关闭','content'=> date("Y-m-d H:i:s",$v['handle_time'])];
}
}
}
$data['data']=$data['data'][0];
$data['data']['img_url']=$img_url;
$data['data']['progress']=$progress;
$data['data']['list']=$list;
$id=$data['data']['id'];
$data['data']['h5url']=$h5.'needs/list?id='.$id;
// 'http://h5.cy.scimall.vip/needs/list?id=2'
unset($data['data'][0]);
if ( $data['code'] == 0 ) {
return $this->success($data['data']);
} else {
return $this->error($data['code']);
}
}
/**
* 科技成果添加
* @return null
*/
public function scienceAddAction(){
//验证登陆
$login = $this->BuserInfo();
// Y::disableView();
$this->rule['title'] = V::stringVal()->setTemplate('科技成果标题错误');
$this->rule['domain'] = V::intVal()->setTemplate('科技成果领域错误');
$this->rule['profile'] = V::stringVal()->setTemplate('科技成果简介错误');
$this->rule['datailescribe'] = V::stringVal()->setTemplate('科技成果技术信息错误');
$this->rule['market'] = V::stringVal()->setTemplate('市场应用错误');
$this->rule['patent'] = V::stringVal()->setTemplate('专利信息错误');
$this->rule['advantage'] = V::stringVal()->setTemplate('技术优势错误');
$this->rule['keyword'] = V::stringVal()->setTemplate('关键词错误');
$this->rule['stage'] = V::intVal()->setTemplate('技术所处阶段错误');
$this->rule['method'] = V::stringVal()->setTemplate('合作方式错误');
$this->rule['input_output'] = V::stringVal()->setTemplate('投入产出有误');
$this->rule['real_name'] =V::stringVal()->setTemplate('联系人姓名有误');
$this->rule['addresss'] =V::stringVal()->setTemplate('现居住地有误');
$this->rule['mobile'] = V::stringVal()->setTemplate('联系电话有误');
$this->rule['email'] = V::stringVal()->setTemplate('联系邮箱有误');
$this->rule['image'] = V::stringVal()->setTemplate('技术成果文件有误');
$this->rule['cooper'] = V::stringVal()->setTemplate('其他合作方式有误');
$title= $this->post('title');//标题
$domain= $this->post('domain');//领域
$profile= $this->post('profile');//简介
$datailescribe= $this->post('datailescribe','');//科技成果技术信息
$market= $this->post('market','');//市场应用
$patent= $this->post('patent','');//专利
$advantage= $this->post('advantage','');//市场优势
$keyword= $this->post('keyword','');//关键词
$stage= $this->post('stage','');//技术阶段
$method= $this->post('method');//合作方式
$input_output= $this->post('input_output','');//投入产出
$real_name= $this->post('real_name');//联系人姓名
$mobile= $this->post('mobile'); //联系电话
$addresss= $this->post('addresss',''); //联系地址
$email= $this->post('email',''); //联系邮箱
$image= $this->post('image','');//文件
$cooper= $this->post('cooper','');//其他合作方式
if($image!=''){
$image=json_decode($image,true);
}
if($cooper=='' && $method==''){
return $this->error(100000004,['method'=>"合作方式不能为空"]);
}
if($cooper!=''&&$method!=''){
$method.=','.'5';
}
if($cooper!=''&&$method==''){
$method.=5;
}
if (isset($this->errorMsg['title'])) {
return $this->error(100000004,['title'=>"标题错误"]);
}
if (isset($this->errorMsg['domain'])) {
return $this->error(100000004,['domain'=>"领域错误"]);
}
if (isset($this->errorMsg['profile'])) {
return $this->error(100000004,['profile'=>"简介错误"]);
}
if (isset($this->errorMsg['datailescribe'])) {
return $this->error(100000004,['datailescribe'=>"技术信息错误"]);
}
if (isset($this->errorMsg['market'])) {
return $this->error(100000004,['market'=>"市场应用错误"]);
}
if (isset($this->errorMsg['patent'])) {
return $this->error(100000004,['patent'=>"专利信息错误"]);
}
if (isset($this->errorMsg['advantage'])) {
return $this->error(100000004,['advantage'=>"市场优势错误"]);
}
if (isset($this->errorMsg['keyword'])) {
return $this->error(100000004,['keyword'=>"关键词错误"]);
}
if (isset($this->errorMsg['stage'])) {
return $this->error(100000004,['stage'=>"技术阶段错误"]);
}
if (isset($this->errorMsg['method'])) {
return $this->error(100000004,['method'=>"合作方式错误"]);
}
if (isset($this->errorMsg['input_output'])) {
return $this->error(100000004,['input_output'=>"投入产出错误"]);
}
if (isset($this->errorMsg['real_name'])) {
return $this->error(100000004,['real_name'=>"联系人姓名错误"]);
}
if (isset($this->errorMsg['mobile'])) {
return $this->error(100000004,['mobile'=>"联系人电话错误"]);
}
if (isset($this->errorMsg['addresss'])) {
return $this->error(100000004,['addresss'=>"联系地址错误"]);
}
if (isset($this->errorMsg['email'])) {
return $this->error(100000004,['email'=>"邮箱地址错误"]);
}
if (isset($this->errorMsg['image'])) {
return $this->error(100000004,['image'=>"上传文件错误"]);
}
if (isset($this->errorMsg['cooper'])) {
return $this->error(100000004,['cooper'=>"其他合作方式错误"]);
}
if(empty($title)){
return $this->error(100000004,['title'=>"标题不能为空"]);
}
if(empty($domain)){
return $this->error(100000004,['domain'=>"领域不能为空"]);
}
if(empty($profile)){
return $this->error(100000004,['profile'=>"简介不能为空"]);
}
if(empty($real_name)){
return $this->error(100000004,['real_name'=>"联系人姓名不能为空"]);
}
if(empty($mobile)){
return $this->error(100000004,['mobile'=>"联系电话不能为空"]);
}
$data = $this->kClient("microblog", "Needs")->addTechnology($login['id'],$title,$domain,$profile,$datailescribe,$market,$patent,$advantage,$keyword,$stage,$method,$input_output,$real_name,$mobile,$addresss,$email,$image,$cooper);
// 1uid 2标题 3领域 4简介 5技术信息 6市场应用 7专利信息 8 技术优势 9技术关键词 10技术所出阶段 11合作方式 12投入产出 13 联系人姓名 14 用户电话 15联系人地址 16联系人邮箱 17文件 18 其他合作方式
if ( $data['code'] == 0 ) {
return $this->success($data['data']);
} else {
return $this->error($data['code']);
}
}
/**
* 科技成果列表
* @param int $field 领域
* @param int $page 当前页
*
*/
public function scienceListAction(){
// num 每夜都显示几条
$page = isset($_POST['page'])?$_POST['page']:1;
$field = isset($_POST['field'])?$_POST['field']:1;
$type = isset($_POST['type'])?$_POST['type']:1;
$login = $this->BuserInfo();
$num = 10;
$domain= [
1=>'节能环保',3=>'生物医药',5=>'机械制造',7=>'电子信息',
9=>'化学化工',11 =>'新能源',13=>'材料科学',15=>'公共管理',17=>'其他'
];
$stage=[1=>'实验室试验',2=>'小试',3=>'中试',4=>'量化生产'];
$method= [1=>'技术转让',2=>'技术授权',3=>'技术入股',4=>'合作开发'];
//uid 领域 当前页面 每页获取多少条
if($type==1){
$data = $this->kClient("microblog", "Needs")->getTechnologyAll('',$field,$page,$num);
}
elseif ($type==2){
$data = $this->kClient("microblog", "Needs")->getTechnologyAll($login['id'],'',$page,$num);
}
if(empty($data['data']['list'])) {
return $this->success(['']);
}
$arr=$data['data']['list'];
$log=$data['data']['log'];
//遍历成果转换的对应领域 合作方式 所处阶段
foreach ($arr as $k=>$v){
$list[$k]['id']=$v['id'];
$list[$k]['uid']=$v['uid'];
$list[$k]['title']=$v['title'];
$list[$k]['introduction']=$v['introduction'];//简介
$list[$k]['cooperation_mode']=$v['cooperation_mode'];
$list[$k]['cooperation_mode']=explode(',',$list[$k]['cooperation_mode']);//合作方式
$list[$k]['field']=$v['field'];//领域
$list[$k]['skill_stage']=$v['skill_stage'];//实验室
$list[$k]['other']=$v['other'];//实验室
}
// var_export($list);exit;
//
foreach ($log as $ke=>$va){
foreach ($list as $key=>$val){
if($log[$ke]['n_id']==$list[$key]['id']){
$list[$key]['handle_type']=$log[$ke]['handle_type'];
$list[$key]['handle_time']= date("Y-m-d H:i",$log[$ke]['handle_time']);
}
}
}
//合作方式遍历获取领域 拼接其他合作方式
foreach ($list as $key=>&$val){
$tmp = [];
$val['field'] = $domain[$list[$key]['field']];
$val['skill_stage'] = $stage[$list[$key]['skill_stage']];
foreach ($val['cooperation_mode'] as $val_mode){
$tmp[] = $val_mode==5?$val['other']:$method[$val_mode];
}
$val['cooperation_mode'] = implode(',',$tmp);
}
if ( $data['code'] == 0 ) {
return $this->success($list);
} else {
return $this->error($data['code']);
}
}
/**
* 获取科技成果详情
* @param int $id 成果转化id
*
*/
public function scienceDescAction(){
$login = $this->BuserInfo();
$this->rule['id'] = V::intVal()->setTemplate('科技成果id错误');
if($this->errorMsg){
return $this->error(100000004, $this->errorMsg);
}
$id= $this->post('id'); //科技成果
//获取图片展示前缀
$config = \Yaf\Application::app()->getConfig();
$a=substr($config['imageUrl'],0,-1);
$h5=$config['h5Url'];
$data = $this->kClient("microblog", "Needs")->getTechnologyInfo($login['id'],$id);
$domain= [
1=>'节能环保',3=>'生物医药',5=>'机械制造',7=>'电子信息',
9=>'化学化工',11 =>'新能源',13=>'材料科学',15=>'公共管理',17=>'其他'
];
$stage=[1=>'实验室试验',2=>'小试',3=>'中试',4=>'量化生产'];
$method= [1=>'技术转让',2=>'技术授权',3=>'技术入股',4=>'合作开发'];
//遍历对应的领域
foreach ($data['data'] as $ke=>$va ){
$data['data'][$ke]['field']=$domain[$data['data'][$ke]['field']];
$data['data'][$ke]['create_time']=date("Y-m-d H:i:s", $data['data'][$ke]['create_time']);
$data['data'][$ke]['skill_stage']='目前所属阶段 :'.$stage[$data['data'][$ke]['skill_stage']];
$data['data'][$ke]['skill_keywords']=$data['data'][$ke]['skill_keywords'];
if(!empty($data['data'][$ke]['file'])){
$arr= json_decode($data['data'][$ke]['file'],true);
foreach ($arr as $k=>$v){
$arr[$k]=$a.$v;
}
$data['data'][$ke]['file']=$arr;
}
}
//遍历合作方式 拼接其他合作方式
// foreach ($data['data'] as $key=>&$val){
$arr=explode(',',$data['data'][0]['cooperation_mode']);
$tmp = [];
foreach ($arr as $val_mode){
$tmp[] = $val_mode==5?$data['data'][0]['other']:$method[$val_mode];
//
}
$val = implode(',',$tmp);
// }
$data['data'][0]['cooperation_mode']=$val;
//整理详情展示
$list=[
['title'=>'技术关键词','content'=> $data['data'][0]['skill_keywords']==''?'':$data['data'][0]['skill_keywords'],'type'=>3],
['title'=>'融资金额','content'=> $data['data'][0]['financing_amount']==''?'':$data['data'][0]['financing_amount'],'type'=>2],
['title'=>'融资占比','content'=> $data['data'][0]['financing_ratio']==''?'':$data['data'][0]['financing_ratio'],'type'=>2],
['title'=>'合作方式','content'=> $val==''?'':$val,'type'=>2],
['title'=>'投入产出','content'=> $data['data'][0]['input_output']==''?'':$data['data'][0]['input_output'],'type'=>2],
['title'=>'专利信息','content'=> $data['data'][0]['patent_info']==''?'':$data['data'][0]['patent_info'],'type'=>2],
['title'=>'项目简介','content'=> $data['data'][0]['introduction']==''?'':$data['data'][0]['introduction'],'type'=>2],
['title'=>'技术信息','content'=> $data['data'][0]['skill_info']==''?'':$data['data'][0]['skill_info'],'type'=>2],
['title'=>'市场应用','content'=> $data['data'][0]['market_application']==''?'':$data['data'][0]['market_application'],'type'=>2],
['title'=>'技术优势','content'=> $data['data'][0]['skill_advantage']==''?'':$data['data'][0]['skill_advantage'],'type'=>2],
];
// var_export($list);exit;
//遍历最新进展
$progress=[
0=>[
'status'=>1,'title'=>'提交需求','content'=> '2017-06-27 10:44'],
1=>['status'=>0,'title'=>'需求确认','content'=> '2017-06-30 12:30'],
2=>['status'=>0,'title'=>'需求签约','content'=> '2017-07-6 15:00'],
3=>['status'=>0,'title'=>'需求服务','content'=> '2017-07-10 10:00'],
4=>['status'=>0,'title'=>'需求关闭','content'=> '2017-07-10 14:20'],
];
// progress
if(empty($data['data'][0]['log'])){
$data['data']['progress']=$progress;
}
if(!empty($data['data'][0]['log'])){
// var_export($data['data'][0]['log']);die;
foreach ($data['data'][0]['log'] as $k=>$v){
if($v['handle_type']=='提交需求'){
$progress['0']= ['status'=>1,'title'=>'提交需求','content'=> date("Y-m-d H:i:s",$v['handle_time'])];
}
if($v['handle_type']=='已通过'){
$progress['0']['status']=$progress['1']['status']=$progress['2']['status']=$progress['3']['status']=1;
$progress['4']= ['status'=>1,'title'=>'需求关闭','content'=> date("Y-m-d H:i:s",$v['handle_time'])];
}
}
}
//图片独立
$img_url=$data['data'][$ke]['file'];
$data['data']=$data['data']['0'];
$data['data']['progress']=$progress;
$data['data']['list']=$list;
$data['data']['img_url']=$img_url;
$id=$data['data']['id'];
$data['data']['h5url']=$h5.'needs/show?id='.$id;
unset($data['data']['0']);
if ( $data['code'] == 0 ) {
return $this->success($data['data']);
} else {
return $this->error($data['code']);
}
}
/**
* 添加收藏
* @param int $id 当前页
* @param int $type 类别 1 企业需求 2 成果转换
*
*/
public function addKeepAction(){
$login = $this->BuserInfo();
$this->rule['id'] = V::intVal()->setTemplate('id错误');
$this->rule['type'] = V::intVal()->setTemplate('收藏类别错误');
if($this->errorMsg){
return $this->error(100000004, $this->errorMsg);
}
$id= $this->post('id');
$type= $this->post('type');
$data = $this->kClient("microblog", "Needs")->addKeep($login['id'],$id,$type);
if ( $data['code'] == 0 ) {
return $this->success($data['data']);
} else {
return $this->error($data['code']);
}
}
/**
* 收藏列表
* @param int $page 当前页
* @param int $type 类别 1 企业需求 2 成果转换
*
*/
public function keepListAction(){
$login = $this->BuserInfo();
$this->rule['type'] = V::intVal()->setTemplate('收藏类别错误');
$page = isset($_POST['page'])?$_POST['page']:1;
if($this->errorMsg){
return $this->error(100000004, $this->errorMsg);
}
$type= $this->post('type');
$data = $this->kClient("microblog", "Needs")->getKeep($login['id'],$type,$page,$num=10);
if(!isset($data['data']['list'])){
return $this->error([]);
}
$domain= [
1=>'节能环保',3=>'生物医药',5=>'机械制造',7=>'电子信息',
9=>'化学化工',11 =>'新能源',13=>'材料科学',15=>'公共管理',17=>'其他'
];
$stage=[1=>'实验室试验',2=>'小试',3=>'中试',4=>'量化生产'];
$method= [1=>'技术转让',2=>'技术授权',3=>'技术入股',4=>'合作开发'];
foreach ($data['data']['list'] as $ke=>$va ){
// 遍历对应的领域 合作方式 所处阶段
$data['data']['list'][$ke]['field']=$domain[$data['data']['list'][$ke]['field']];
$data['data']['list'][$ke]['create_time']=date("Y-m-d H:i:s",$data['data']['list'][$ke]['create_time']);
if($type==2){
$data['data']['list'][$ke]['skill_stage']=$stage[$data['data']['list'][$ke]['skill_stage']];
$arr=explode(',',$data['data']['list'][$ke]['cooperation_mode']);
$tmp = [];
foreach ($arr as $val_mode){
$tmp[] = $val_mode==5?$data['data']['list'][$ke]['other']:$method[$val_mode];
}
$va['cooperation_mode'] = implode(',',$tmp);
$data['data']['list'][$ke]['cooperation_mode']=$va['cooperation_mode'];
}
}
$list=$data['data']['list'];
$log=$data['data']['log'];
//判断进展是否为空
if(!empty($log)){
foreach ($list as $k=>$v){
if($log[$k]['n_id']==$list[$k]['id']){
$list[$k]['handle_type']=$log[$k]['handle_type'];
$list[$k]['handle_time']= date("Y-m-d H:i:s",$log[$k]['handle_time']);
}
}
}
if ( $data['code'] == 0 ) {
return $this->success($list);
} else {
return $this->error($data['code']);
}
}
/**
* 取消收藏
* @param int $id 待取消收藏id(企业需求,成果转化)
* @param int $type 类别 1 企业需求 2 成果转换
*
*/
public function updateKeepAction(){
$login = $this->BuserInfo();
$this->rule['type'] = V::intVal()->setTemplate('收藏类别错误');
$this->rule['id'] = V::intVal()->setTemplate('取消收藏id错误');
if($this->errorMsg){
return $this->error(100000004, $this->errorMsg);
}
$type= $this->post('type');
$id= $this->post('id');
$data = $this->kClient("microblog", "Needs")->updateKeep($login['id'],$id,$type,$state=2);
return $this->success(['修改成功']);
}
//返回领域
public function paramAction(){
$field = isset($_POST['field'])?$_POST['field']:1; //1领域 2 所处阶段 3合作方式
$domain=[
['id'=>1,'title'=>'节能环保'],['id'=>3,'title'=>'生物医药'],['id'=>5,'title'=>'机械制造'],['id'=>7,'title'=>'电子信息'],
['id'=>9,'title'=>'化学化工'],['id'=>11,'title'=>'新能源'],['id'=>13,'title'=>'材料科学'],['id'=>15,'title'=>'公共管理'],['id'=>17,'title'=>'其他']
];
$stage=[['id'=>1,'title'=>'实验室试验'],['id'=>2,'title'=>'小试'],['id'=>3,'title'=>'中试'],['id'=>4,'title'=>'量化生产']];
$method= [['id'=>1,'title'=>'技术转让'],['id'=>2,'title'=>'技术授权'],['id'=>3,'title'=>'技术入股'],['id'=>4,'title'=>'合作开发']];
if($field==1){
return $this->success($domain);
}elseif($field==2){
return $this->success($stage);
}elseif ($field==3){
return $this->success($method);
}
}
}