1
This commit is contained in:
@@ -42,6 +42,9 @@ class User extends Controller
|
||||
protected $user_score_log_obj = '';
|
||||
protected $user_index_log_obj = '';
|
||||
protected $article_reviewer_obj = '';
|
||||
protected $user_ash_obj = '';
|
||||
protected $major_obj = '';
|
||||
protected $user_to_yboard_obj = '';
|
||||
|
||||
public function __construct(\think\Request $request = null)
|
||||
{
|
||||
@@ -70,6 +73,9 @@ class User extends Controller
|
||||
$this->user_score_log_obj = Db::name('user_score_log');
|
||||
$this->user_index_log_obj = Db::name('user_index_log');
|
||||
$this->article_reviewer_obj = Db::name('article_reviewer');
|
||||
$this->user_ash_obj = Db::name('user_ash');
|
||||
$this->major_obj = Db::name('major');
|
||||
$this->user_to_yboard_obj = Db::name('user_to_yboard');
|
||||
}
|
||||
|
||||
public function pstest(){
|
||||
@@ -137,6 +143,172 @@ class User extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加青年科学家
|
||||
*/
|
||||
public function addYboard(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
'user_id'=>'require',
|
||||
'journal_id'=>'require',
|
||||
'year'=>'require'
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$check = $this->user_to_yboard_obj
|
||||
->where('user_id',$data['user_id'])
|
||||
->where('journal_id',$data['journal_id'])
|
||||
->where('end_date','>',time())
|
||||
->find();
|
||||
if($check){
|
||||
return jsonError('Already exists');
|
||||
}
|
||||
$user_info = $this->user_obj->where('user_id',$data['user_id'])->find();
|
||||
$journal_info = $this->journal_obj->where('journal_id',$data['journal_id'])->find();
|
||||
$start_time = time();
|
||||
//生成证书
|
||||
$icon = self::createYboardCert($user_info,$journal_info,$start_time,$data['year']);
|
||||
|
||||
//添加数据
|
||||
$insert['user_id'] = $data['user_id'];
|
||||
$insert['journal_id'] = $data['journal_id'];
|
||||
$insert['start_date'] = $start_time;
|
||||
$insert['end_date'] = strtotime("+ ".$data['year']." year",$start_time);
|
||||
$insert['icon'] = $icon;
|
||||
$insert['ctime'] = time();
|
||||
$this->user_to_yboard_obj->insert($insert);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 续约青年科学家
|
||||
*/
|
||||
public function addYboardContinue(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
'user_id'=>'require',
|
||||
'journal_id'=>'require',
|
||||
'year'=>'require'
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$check = $this->user_to_yboard_obj
|
||||
->where('user_id',$data['user_id'])
|
||||
->where('journal_id',$data['journal_id'])
|
||||
->where('end_date','>',time())
|
||||
->find();
|
||||
$start_time = 0;
|
||||
if($check){
|
||||
$start_time = $check['end_date'];
|
||||
}else{
|
||||
$start_time = time();
|
||||
}
|
||||
$user_info = $this->user_obj->where('user_id',$data['user_id'])->find();
|
||||
$journal_info = $this->journal_obj->where('journal_id',$data['journal_id'])->find();
|
||||
//生成证书
|
||||
$icon = self::createYboardCert($user_info,$journal_info,$start_time,$data['year']);
|
||||
|
||||
//添加数据
|
||||
$insert['user_id'] = $data['user_id'];
|
||||
$insert['journal_id'] = $data['journal_id'];
|
||||
$insert['start_date'] = $start_time;
|
||||
$insert['end_date'] = strtotime("+ ".$data['year']." year",$start_time);
|
||||
$insert['icon'] = $icon;
|
||||
$insert['ctime'] = time();
|
||||
$this->user_to_yboard_obj->insert($insert);
|
||||
return jsonSuccess([]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除青年编委
|
||||
*/
|
||||
public function delYboard(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
'utyb_id'=>'require'
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$this->user_to_yboard_obj->where('utyb_id',$data['utyb_id'])->update(['state'=>1]);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取青年科学家列表
|
||||
*/
|
||||
public function getYboardlist(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
'journal_id'=>'require',
|
||||
"type"=>'require',
|
||||
'pageIndex'=>'require',
|
||||
'pageSize'=>'require'
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$time = time();
|
||||
$where['t_user_to_yboard.journal_id'] = $data['journal_id'];
|
||||
$where['t_user_to_yboard.state'] = 0;
|
||||
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
|
||||
if($data['type']==1){//当职
|
||||
$where['t_user_to_yboard.start_date'] = ['<=',$time];
|
||||
$where['t_user_to_yboard.end_date'] = [">=",$time];
|
||||
}elseif($data['type']==2){//过期
|
||||
$where['t_user_to_yboard.end_date'] = ["<",$time];
|
||||
}else{//按年份
|
||||
// $where["_string"] = "t_user_to_yboard.start_date >= 1";
|
||||
$where['t_user_to_yboard.start_date'] = ['<= time',$data['year']."-12-31 23:59:59"];
|
||||
$where['t_user_to_yboard.end_date'] = [">= time",$data['year']."-1-1 00:00:00"];
|
||||
}
|
||||
if(isset($data['keywords'])&&$data['keywords']!=''){
|
||||
$where['t_user.account|t_user.email|t_user.realname'] = ['like',"%".trim($data['keywords'])."%"];
|
||||
}
|
||||
if(isset($data['fieldkey'])&&$data['fieldkey']!=''){
|
||||
$fk = str_replace(";",";",trim($data['fieldkey']));
|
||||
$farr = explode(";",$fk);
|
||||
$ws = [];
|
||||
foreach($farr as $val){
|
||||
$ws[] = ['like',"%".$val."%"];
|
||||
}
|
||||
$where['t_user_reviewer_info.field'] = count($ws)>1?$ws:$ws[0];
|
||||
}
|
||||
$order = '';
|
||||
if(isset($data['order_remark'])&&$data['order_remark']==1){
|
||||
$order = "t_user.remark desc,t_user.score desc";
|
||||
}else{
|
||||
$order = "t_user.score desc";
|
||||
}
|
||||
$list = $this->user_to_yboard_obj
|
||||
->field("t_user.account,t_user.realname,t_user.email,t_user.score,t_user.remark,t_user.wos_index,t_user.wos_time,t_user.google_index,t_user.google_time,t_user_reviewer_info.field,t_user_reviewer_info.company,t_user_to_yboard.*")
|
||||
->join("t_user",'t_user.user_id = t_user_to_yboard.user_id','left')
|
||||
->join("t_user_reviewer_info",'t_user_reviewer_info.reviewer_id = t_user.user_id','left')
|
||||
->where($where)
|
||||
->group("t_user_to_yboard.user_id")
|
||||
->order($order)
|
||||
->limit($limit_start,$data['pageSize'])
|
||||
->select();
|
||||
//总结时间段
|
||||
foreach($list as $k=>$v){
|
||||
$ca_list = $this->user_to_yboard_obj->where("journal_id",$data['journal_id'])->where('user_id',$v['user_id'])->where('state',0)->select();
|
||||
$ca_arr = [];
|
||||
foreach($ca_list as $val){
|
||||
$c['start_date'] = $val['start_date'];
|
||||
$c['end_date'] = $val['end_date'];
|
||||
$ca_arr[] = $c;
|
||||
}
|
||||
$list[$k]['sd'] = $ca_arr;
|
||||
}
|
||||
$count = $this->user_to_yboard_obj->join("t_user",'t_user.user_id = t_user_to_yboard.user_id','left')->join("t_user_reviewer_info",'t_user_reviewer_info.reviewer_id = t_user.user_id','left')->where($where)->count();
|
||||
$re['yboards'] = $list;
|
||||
$re['count'] = $count;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户评价
|
||||
*/
|
||||
@@ -338,6 +510,289 @@ class User extends Controller
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑灰库人员信息
|
||||
*/
|
||||
public function editAshUser(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
'ash_id'=>'require'
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$updata = [];
|
||||
if(isset($data['name'])){
|
||||
$updata['name'] = trim($data['name']);
|
||||
}
|
||||
if(isset($data['email'])){
|
||||
$updata['email'] = trim($data['email']);
|
||||
}
|
||||
if(isset($data['field'])){
|
||||
$updata['field'] = trim($data['field']);
|
||||
}
|
||||
if(isset($data['intro'])){
|
||||
$updata['intro'] = trim($data['intro']);
|
||||
}
|
||||
if(isset($data['remark'])){
|
||||
$updata['remark'] = trim($data['remark']);
|
||||
}
|
||||
if(isset($data['company'])){
|
||||
$updata['company'] = trim($data['company']);
|
||||
}
|
||||
if(isset($data['country'])){
|
||||
$updata['country'] = $data['country'];
|
||||
}
|
||||
if(isset($data['major'])){
|
||||
$updata['major'] = $data['major'];
|
||||
}
|
||||
if(isset($data['title'])){
|
||||
$updata['title'] = $data['title'];
|
||||
}
|
||||
$this->user_ash_obj->where('ash_id',$data['ash_id'])->update($updata);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
public function researchAshUser(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
'pageIndex'=>'require',
|
||||
'pageSize'=>'require'
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$where['state']=0;
|
||||
if(isset($data['major'])&&$data['major']!=0){
|
||||
$where_mids = self::majorids($data['major']);
|
||||
$where['major'] = ['in',$where_mids];
|
||||
}
|
||||
if(isset($data['keywords'])&&$data['keywords']!=''){
|
||||
$where['name|email|intro|company'] = ['like',"%".trim($data['keywords'])."%"];
|
||||
}
|
||||
if(isset($data['title'])&&$data['title']!="all"){
|
||||
$where['title'] = $data['title'];
|
||||
}
|
||||
if(isset($data['fieldkey'])&&$data['fieldkey']!=''){
|
||||
$fk = str_replace(";",";",$data['fieldkey']);
|
||||
$farr = explode(";",$fk);
|
||||
$ws = [];
|
||||
foreach($farr as $val){
|
||||
$ws[] = ['like',"%".$val."%"];
|
||||
}
|
||||
$where['field'] = count($ws)>1?$ws:$ws[0];
|
||||
}
|
||||
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
|
||||
$list = $this->user_ash_obj->where($where)->limit($limit_start,$data['pageSize'])->select();
|
||||
$count = $this->user_ash_obj->where($where)->count();
|
||||
|
||||
foreach($list as $k=>$v){
|
||||
if($v['major']==0){
|
||||
$list[$k]['major_str'] = '';
|
||||
$list[$k]['major_shu'] = 0;
|
||||
continue;
|
||||
}
|
||||
$list[$k]['major_str'] = trim(self::getMajorStr($v['major']),'>');
|
||||
$list[$k]['major_shu'] = self::getMajorShu($v['major']);
|
||||
}
|
||||
|
||||
$re['data']=$list;
|
||||
$re['count'] = $count;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
private function majorids($major_id){
|
||||
$frag[]=$major_id;
|
||||
$list = $this->major_obj->where('pid',$major_id)->select();
|
||||
foreach($list as $v){
|
||||
$cache = self::majorids($v['major_id']);
|
||||
$frag = array_merge($frag,$cache);
|
||||
}
|
||||
return $frag;
|
||||
}
|
||||
private function getMajorShu($major){
|
||||
if($major==0){
|
||||
return '';
|
||||
}
|
||||
$res = $this->major_obj->where('major_id',$major)->find();
|
||||
if($res['pid']==1){
|
||||
return $res['major_id'];
|
||||
}
|
||||
|
||||
$p = self::getMajorShu($res['pid']);
|
||||
return $p.','.$res['major_id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加灰库用户单个
|
||||
*/
|
||||
public function addAshUser(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
'name'=>'require',
|
||||
'email'=>'require',
|
||||
'major'=>'require',
|
||||
'company'=>'require',
|
||||
'field'=>'require',
|
||||
'title'=>'require'
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$check1 = $this->user_obj->where('email',$data['email'])->find();
|
||||
if($check1){
|
||||
return jsonError("用户存在于正式库");
|
||||
}
|
||||
$check2 = $this->user_ash_obj->where('email',$data['email'])->find();
|
||||
if($check2){
|
||||
return jsonError("用户存在于灰库");
|
||||
}
|
||||
|
||||
$insert['name']=trim($data['name']);
|
||||
$insert['email']=trim($data['email']);
|
||||
$insert['major']=$data['major'];
|
||||
$insert['company']=trim($data['company']);
|
||||
$insert['field'] = trim($data['field']);
|
||||
$insert['intro'] = isset($data['intro'])?trim($data['intro']):'';
|
||||
$insert['country'] = isset($data['country'])?trim($data['country']):'';
|
||||
$insert['title'] = trim($data['title']);
|
||||
$insert['ctime'] = time();
|
||||
$this->user_ash_obj->insert($insert);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
|
||||
private function getMajorStr($major_id)
|
||||
{
|
||||
$frag = '';
|
||||
$major_info = $this->major_obj->where('major_id', $major_id)->find();
|
||||
if ($major_info == null) {
|
||||
return '';
|
||||
}
|
||||
if ($major_info['major_level'] == 1) {
|
||||
return 'Medicine';
|
||||
} else {
|
||||
$frag = $this->getMajorStr($major_info['pid']) . ' > ' . $major_info['major_title'];
|
||||
}
|
||||
return $frag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 灰库导入excel用户
|
||||
*/
|
||||
public function importExcelUser(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
// 'users'=>'require|array'
|
||||
'file'=>'require'
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$ds = self::readExcel($data['file']);
|
||||
$frag_suc = [];
|
||||
$frag_err = [];
|
||||
$title_arr = ['Prof','Associate Prof.','Assistant Prof.','Ph.D.','Researcher','Researcher','Associate research fellow','Assistant research fellow','Engineer','Senior engineer'];
|
||||
foreach($ds as $v){
|
||||
if(!$v['email']||!isset($v['field'])||!isset($v['company'])){
|
||||
$v['msg'] = '信息不全或错误';
|
||||
$frag_err[] = $v;
|
||||
continue;
|
||||
}
|
||||
if($v['title']!=''&&!in_array($v['title'],$title_arr)){
|
||||
$v['msg'] = 'title信息错误';
|
||||
$frag_err[] = $v;
|
||||
continue;
|
||||
}
|
||||
$check1 = $this->user_obj->where('email',trim($v['email']))->find();
|
||||
if($check1){
|
||||
$v['msg'] = '用户存在正式库';
|
||||
$frag_err[] = $v;
|
||||
continue;
|
||||
}
|
||||
$check2 = $this->user_ash_obj->where('email',trim($v['email']))->find();
|
||||
if($check2){
|
||||
$v['msg'] = "用户存在于灰库";
|
||||
$frag_err[] = $v;
|
||||
continue;
|
||||
}
|
||||
$insert['name'] = $v['name'];
|
||||
$insert['email'] = trim($v['email']);
|
||||
$major_res=$this->major_obj->where('major_title',trim($v['major']))->find();
|
||||
$major_id = 0;
|
||||
if($major_res){
|
||||
$major_id = $major_res['major_id'];
|
||||
}
|
||||
$insert['major'] = $major_id;
|
||||
$insert['field'] = trim($v['field']);
|
||||
$insert['company'] = trim($v['company']);
|
||||
$insert['intro'] = isset($v['intro'])?trim($v['intro']):'';
|
||||
$insert['title'] = trim($v['title']);
|
||||
$insert['remark'] = isset($v['remark'])?trim($v['remark']):'';
|
||||
$insert['ctime'] = time();
|
||||
$this->user_ash_obj->insert($insert);
|
||||
$frag_suc[] = $v;
|
||||
}
|
||||
|
||||
$re['suc'] = $frag_suc;
|
||||
$re['err'] = $frag_err;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
|
||||
public function upImportFile(){
|
||||
$file = request()->file('userFile');
|
||||
if ($file) {
|
||||
$info = $file->move(ROOT_PATH . 'public' . DS . "userFile");
|
||||
if ($info) {
|
||||
$r = self::readExcel($info->getSaveName());
|
||||
$re['data'] = $r;
|
||||
$re['file'] = str_replace("\\", "/", $info->getSaveName());
|
||||
return jsonSuccess($re);
|
||||
} else {
|
||||
return json(['code' => 1, 'msg' => $file->getError()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function readExcel($file){
|
||||
$afile = ROOT_PATH . 'public' . DS . "userFile".DS.$file;
|
||||
$extension = substr($afile, strrpos($afile, '.') + 1);
|
||||
vendor("PHPExcel.PHPExcel");
|
||||
if ($extension == 'xlsx') {
|
||||
$objReader = new \PHPExcel_Reader_Excel2007();
|
||||
$objPHPExcel = $objReader->load($afile);
|
||||
} else if ($extension == 'xls') {
|
||||
$objReader = new \PHPExcel_Reader_Excel5();
|
||||
$objPHPExcel = $objReader->load($afile);
|
||||
}
|
||||
$sheet = $objPHPExcel->getSheet(0);
|
||||
$highestRow = $sheet->getHighestRow();
|
||||
$frag = [];
|
||||
for ($i = 2; $i <= $highestRow; $i++) {
|
||||
if($objPHPExcel->getActiveSheet()->getCell("A" . $i)->getValue()==''){
|
||||
continue ;
|
||||
}
|
||||
$aa['name'] = $objPHPExcel->getActiveSheet()->getCell("A" . $i)->getValue();
|
||||
$aa['email'] = $objPHPExcel->getActiveSheet()->getCell("B" . $i)->getValue();
|
||||
$aa['major'] = $objPHPExcel->getActiveSheet()->getCell("C" . $i)->getValue();
|
||||
$aa['field'] = $objPHPExcel->getActiveSheet()->getCell("D" . $i)->getValue();
|
||||
$aa['intro'] = $objPHPExcel->getActiveSheet()->getCell("E" . $i)->getValue();
|
||||
$aa['company'] = $objPHPExcel->getActiveSheet()->getCell("F" . $i)->getValue();
|
||||
$aa['title'] = $objPHPExcel->getActiveSheet()->getCell("G" . $i)->getValue();
|
||||
$aa['remark'] = $objPHPExcel->getActiveSheet()->getCell("H" . $i)->getValue();
|
||||
// $aa['username'] = $objPHPExcel->getActiveSheet()->getCell("A" . $i)->getValue();
|
||||
// $aa['has'] = '未出证';
|
||||
// if($aa['username']==''){
|
||||
// continue;
|
||||
// }
|
||||
$frag[] = $aa;
|
||||
|
||||
}
|
||||
return $frag;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @title 获取所有用户
|
||||
* @description 获取所有用户
|
||||
@@ -504,7 +959,54 @@ class User extends Controller
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
public function delYboardApply(){
|
||||
// public function delYboardApply(){
|
||||
// $data = $this->request->post();
|
||||
// $rules = new Validate([
|
||||
// 'ap_yboard_id' => 'require'
|
||||
// ]);
|
||||
// if (!$rules->check($data)) {
|
||||
// return jsonError($rules->getError());
|
||||
// }
|
||||
// $this->apply_yboard_obj->where('ap_yboard_id',$data['ap_yboard_id'])->update(['state'=>1]);
|
||||
// return jsonSuccess([]);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 同意青年科学家申请
|
||||
*/
|
||||
public function agreeYboardApply(){
|
||||
$data = $this->request->post();
|
||||
$rules = new Validate([
|
||||
'ap_yboard_id' => 'require',
|
||||
'year'=>'require'
|
||||
]);
|
||||
if (!$rules->check($data)) {
|
||||
return jsonError($rules->getError());
|
||||
}
|
||||
$start_time = time();
|
||||
$app_info = $this->apply_yboard_obj->where('ap_yboard_id',$data['ap_yboard_id'])->find();
|
||||
$user_info = $this->user_obj->where('user_id',$app_info['user_id'])->find();
|
||||
$journal_info = $this->journal_obj->where('journal_id',$app_info['journal_id'])->find();
|
||||
$check = $this->user_to_yboard_obj->where('user_id',$app_info['user_id'])->where('journal_id',$app_info['journal_id'])->where('start_date',"<=",$start_time)->where('end_date',"<=",$start_time)->find();
|
||||
if($check){
|
||||
return jsonError("Already exists");
|
||||
}
|
||||
$icon = self::createYboardCert($user_info,$journal_info,$start_time,$data['year']);
|
||||
$insert['user_id'] = $app_info['user_id'];
|
||||
$insert['journal_id'] = $app_info['journal_id'];
|
||||
$insert['start_date'] = $start_time;
|
||||
$insert['end_date'] = strtotime("+ ".$data['year']." year",$start_time);
|
||||
$insert['icon'] = $icon;
|
||||
$insert['ctime'] = $start_time;
|
||||
$this->user_to_yboard_obj->insert($insert);
|
||||
$this->apply_yboard_obj->where('ap_yboard_id',$data['ap_yboard_id'])->update(['state'=>1]);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拒绝青年科学家申请
|
||||
*/
|
||||
public function refuseYboardApply(){
|
||||
$data = $this->request->post();
|
||||
$rules = new Validate([
|
||||
'ap_yboard_id' => 'require'
|
||||
@@ -1068,6 +1570,22 @@ class User extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找用户信息byaccountemail
|
||||
*/
|
||||
public function searchUserByAccountEmail(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
'account'=>'require'
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$user_info = $this->user_obj->join('t_user_reviewer_info','t_user_reviewer_info.reviewer_id=t_user.user_id','left')->where('t_user.account|t_user.email',$data['account'])->find();
|
||||
$re['user'] = $user_info;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册功能
|
||||
*/
|
||||
@@ -1887,11 +2405,11 @@ class User extends Controller
|
||||
* 添加用户证书
|
||||
*/
|
||||
public function addUserCert(){
|
||||
die("service stop");
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
'user_id'=>'require',
|
||||
'journal_id'=>'require',
|
||||
'type'=>'require',
|
||||
'year'=>'require'
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
@@ -1899,24 +2417,45 @@ class User extends Controller
|
||||
}
|
||||
$user_info = $this->user_obj->where('user_id',$data['user_id'])->find();
|
||||
$journal_info = $this->journal_obj->where('journal_id',$data['journal_id'])->find();
|
||||
$check = $this->user_cert_obj->where('user_id',$data['user_id'])->where('type',$data['type'])->where('journal_id',$data['journal_id'])->where('year',$data['year'])->where('state',0)->find();
|
||||
if($check){
|
||||
return jsonError("Certificate cannot be issued repeatedly");
|
||||
}
|
||||
$this->createCert($user_info,$journal_info,$data['year'],$data['type']);
|
||||
// $check = $this->user_cert_obj->where('user_id',$data['user_id'])->where('type',$data['type'])->where('journal_id',$data['journal_id'])->where('year',$data['year'])->where('state',0)->find();
|
||||
// if($check){
|
||||
// return jsonError("Certificate cannot be issued repeatedly");
|
||||
// }
|
||||
$start_time = time();
|
||||
// $this->createCert($user_info,$journal_info,$data['year'],$data['type']);
|
||||
self::createYboardCert($user_info,$journal_info,$start_time,$data['year']);
|
||||
|
||||
$insert['user_id']=$data['user_id'];
|
||||
$insert['journal_id'] = $data['journal_id'];
|
||||
$insert['type'] = $data['type'];
|
||||
$insert['year'] = $data['year'];
|
||||
$insert['url'] = "/cert/".$data['user_id'].'_'.$data['type'].'_'.$data['year'] . '.png';
|
||||
$insert['ctime'] = time();
|
||||
$this->user_cert_obj->insert($insert);
|
||||
// $insert['type'] = $data['type'];
|
||||
$insert['start_date'] = $start_time;
|
||||
$insert['end_date'] = strtotime("+ ".$data['year'].' year',$start_time);//date("+ ".$data['year']." year",$start_time);
|
||||
$insert['url'] = "/cert/".$data['user_id'].'_yboard_'.$data['year'] . '.png';
|
||||
$insert['ctime'] = $start_time;
|
||||
// $this->user_cert_obj->insert($insert);
|
||||
|
||||
return jsonSuccess([]);
|
||||
return jsonSuccess($insert);
|
||||
}
|
||||
private function createYboardCert($user_info,$journal_info,$start_time,$year){
|
||||
if(!is_dir(ROOT_PATH . 'public' . DS . 'cert' . DS .$journal_info['journal_id'])){
|
||||
mkdir(ROOT_PATH . 'public' . DS . 'cert' . DS .$journal_info['journal_id']);
|
||||
}
|
||||
$sj_num = rand(1000,9999);
|
||||
$template = ROOT_PATH . 'public' . DS . 'cert' . DS . 'yboard_template.png';
|
||||
$ziti = ROOT_PATH . 'public' . DS . 'zhengshu' . DS . 'siyuan.ttf';
|
||||
$ziti1 = ROOT_PATH . 'public' . DS . 'zhengshu' . DS . 'Georgia0.ttf';
|
||||
$image = \think\Image::open($template);
|
||||
$ys = date("F Y",$start_time)." to ".date("F Y",strtotime("+ ".$year." year",$start_time));
|
||||
$image->text($user_info['realname'], $ziti, 45, '#000000', [1060, 750])
|
||||
->text($ys, $ziti1, 32, '#C49A6C', [1370, 1015])
|
||||
->text(date("Y.m.d",$start_time), $ziti, 25, '#000000', [500, 1280])
|
||||
->text($journal_info['title'], $ziti1, 36, '#C49A6C', [860, 930])
|
||||
->save(ROOT_PATH . 'public' . DS . 'cert' . DS .$journal_info['journal_id'].DS. $user_info['user_id'].'_yboard_'.date('Y',$start_time).$sj_num . '.png');
|
||||
return $journal_info['journal_id'].DS.$user_info['user_id'].'_yboard_'.date('Y',$start_time).$sj_num . '.png';
|
||||
}
|
||||
|
||||
private function createCert($user_info,$journal_info,$year,$type){
|
||||
//type:1编委,2青年科学家
|
||||
$template = ROOT_PATH . 'public' . DS . 'cert' . DS . 'cert_template.png';
|
||||
$ziti = ROOT_PATH . 'public' . DS . 'zhengshu' . DS . 'siyuan.ttf';
|
||||
$image = \think\Image::open($template);
|
||||
@@ -1926,7 +2465,7 @@ class User extends Controller
|
||||
->text($year, $ziti, 36, '#C49A6C', [1665, 1052])
|
||||
->text($journal_info['title'], $ziti, 36, '#C49A6C', [920, 980])
|
||||
->save(ROOT_PATH . 'public' . DS . 'cert' . DS . $user_info['user_id'].'_'.$type.'_'.$year . '.png');
|
||||
// return ROOT_PATH . 'public' . DS . 'cert' . DS . $user_info['user_id'] . '.png';
|
||||
return $user_info['user_id'].'_'.$type.'_'.$year . '.png';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user