This commit is contained in:
wangjinlei
2023-02-09 17:56:12 +08:00
parent b1b4704964
commit 689581f685
5 changed files with 280 additions and 133 deletions

View File

@@ -35,6 +35,7 @@ class User extends Controller
protected $user_black_obj = '';
protected $user_to_special_obj = '';
protected $user_register_check_obj = '';
protected $user_cert_obj = '';
public function __construct(\think\Request $request = null)
{
@@ -56,6 +57,7 @@ class User extends Controller
$this->user_black_obj = Db::name('user_black');
$this->user_to_special_obj = Db::name('user_to_special');
$this->user_register_check_obj = Db::name('user_register_check');
$this->user_cert_obj = Db::name('user_cert');
}
public function pstest(){
@@ -327,7 +329,9 @@ class User extends Controller
$inser_data['phone'] = isset($data['phone']) ? $data['phone'] : '';
$inser_data['realname'] = isset($data['realname']) ? $data['realname'] : '';
$inser_data['ctime'] = time();
$this->user_obj->insertGetId($inser_data);
$id = $this->user_obj->insertGetId($inser_data);
$insert_reviewer['reviewer_id'] = $id;
$this->user_reviewer_info_obj->insert($insert_reviewer);
return jsonSuccess([]);
}
@@ -390,11 +394,6 @@ class User extends Controller
echo 'Unsubscribe successfully!';
}
public function mytestemail(){
sendEmail('751475802@qq.com', "test", "test", "hello", "tmr@tmrjournals.com", "849192806Pnx");
}
/**
* @title 申请期刊审稿人对于审稿人
* @description 申请期刊审稿人对于审稿人
@@ -881,6 +880,10 @@ class User extends Controller
$inser_data['ctime'] = time();
$id = $this->user_obj->insertGetId($inser_data);
//存入个人额外信息
$insert_reviewer['reviewer_id'] = $id;
$r_res = $this->user_reviewer_info_obj->insert($insert_reviewer);
//存储注册验证信息
$insert_check['user_id'] = $id;
$insert_check['code'] = $code;
@@ -894,7 +897,7 @@ class User extends Controller
$tt .= "<a href='https://submission.tmrjournals.com/login?code=".$code."'>https://submission.tmrjournals.com/login?code=".$code."</a><br><br>";
$tt .= "Thank you.<br>TMR Publishing Group<br>https://www.tmrjournals.com";
if($id&&$i_res){
if($id&&$i_res&&$r_res){
Db::commit();
sendEmail($email, 'Dear ' . $data['name'], 'TMR', $tt);
return jsonSuccess([]);
@@ -1662,6 +1665,52 @@ class User extends Controller
return jsonSuccess($re);
}
/**
* 添加用户证书
*/
public function addUserCert(){
$data = $this->request->post();
$rule = new Validate([
'user_id'=>'require',
'journal_id'=>'require',
'type'=>'require',
'year'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$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']);
$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);
return jsonSuccess([]);
}
private function createCert($user_info,$journal_info,$year,$type){
$template = ROOT_PATH . 'public' . DS . 'cert' . DS . 'cert_template.png';
$ziti = ROOT_PATH . 'public' . DS . 'zhengshu' . DS . 'siyuan.ttf';
$image = \think\Image::open($template);
$image->text($user_info['realname'], $ziti, 50, '#000000', [1060, 760])
->text($year, $ziti, 50, '#C49A6C', [1850, 505])
->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';
}
/**
* 注册绑定orcid至我们的账户
*/