This commit is contained in:
wangjinlei
2021-07-20 15:26:23 +08:00
parent 0fd546dfbb
commit 55d2b78440
2 changed files with 80 additions and 7 deletions

View File

@@ -1197,9 +1197,9 @@ class Journal extends Controller {
public function addJournalCfp(){ public function addJournalCfp(){
$data = $this->request->post(); $data = $this->request->post();
$insert['journal_id'] = $data['journal_id']; $insert['journal_id'] = $data['journal_id'];
$insert['title'] = $data['title']; $insert['title'] = trim($data['title']);
$insert['icon'] = $data['icon']; $insert['icon'] = $data['icon'];
$insert['sort'] = $data['sort']; $insert['sort'] = isset($data['sort'])?$data['sort']:0;
$insert['showtime'] = $data['showtime']; $insert['showtime'] = $data['showtime'];
$insert['content'] = $data['content']; $insert['content'] = $data['content'];
$insert['ctime'] = time(); $insert['ctime'] = time();

View File

@@ -37,6 +37,7 @@ class Publish extends Controller{
protected $super_danger_obj = ''; protected $super_danger_obj = '';
protected $board_obj = ''; protected $board_obj = '';
protected $board_group_obj = ''; protected $board_group_obj = '';
protected $visit_log_obj = '';
public function __construct(\think\Request $request = null) { public function __construct(\think\Request $request = null) {
parent::__construct($request); parent::__construct($request);
@@ -60,6 +61,7 @@ class Publish extends Controller{
$this->super_danger_obj = Db::name('super_danger'); $this->super_danger_obj = Db::name('super_danger');
$this->board_obj = Db::name('board'); $this->board_obj = Db::name('board');
$this->board_group_obj = Db::name('board_group'); $this->board_group_obj = Db::name('board_group');
$this->visit_log_obj = Db::name('visit_log');
} }
/** /**
@@ -243,6 +245,82 @@ class Publish extends Controller{
return jsonSuccess($journals); return jsonSuccess($journals);
} }
/**
* @title 增加访问次数
* @description 增加访问次数
* @author wangjinlei
* @url /super/Publish/addVisitNum
* @method POST
*
* @param name:type type:string require:1 desc:类型1.de2.journal_id
*/
public function addVisitNum(){
$data = $this->request->post();
$up_id = 0;
if($data['type']=='de'){//数据库访问
$res = $this->visit_log_obj->where('type','de')->where('stime',date('Ym'))->find();
if($res==null){
$insert['type'] = 'de';
$insert['stime'] = date('Ym');
$up_id = $this->visit_log_obj->insertGetId($insert);
}else{
$up_id = $res['vlid'];
}
}else{//期刊访问
$res = $this->visit_log_obj->where('type',$data['type'])->where('stime',date('Ym'))->find();
if($res==null){
$insert['type']= $data['type'];
$insert['stime'] = date('Ym');
$up_id = $this->visit_log_obj->insertGetId($insert);
}else{
$up_id = $res['vlid'];
}
}
$this->visit_log_obj->where('vlid',$up_id)->setInc('num');
return jsonSuccess([]);
}
/**
* @title 获取访问次数
* @description 获取访问次数
* @author wangjinlei
* @url /super/Publish/getVisit
* @method POST
*
*/
public function getVisit(){
$t = strtotime("-4 month");
$stime = date('Ym',$t);
$visits = $this->visit_log_obj->where('stime','>=',$stime)->where('state',0)->select();
$frag = [];
for($i=4;$i>=0;$i--){
$ntime = date('Ym', strtotime("-$i month"));
$frag[$ntime] = [];
foreach ($visits as $v){
if($v['stime']==$ntime){
$frag[$ntime][$v['type']]=$v['num'];
}
}
}
$journals = $this->journal_obj->where('state',0)->select();
$frag1 = [];
foreach ($frag as $k => $v){
$frag1['de'][$k] = isset($frag[$k]['de'])?$frag[$k]['de']:0;
foreach ($journals as $val){
$frag1[$val['title']][$k] = isset($frag[$k][$val['journal_id']])?$frag[$k][$val['journal_id']]:0;
}
}
foreach ($frag1 as $k => $v){
$num = 0;
foreach ($v as $vv){
$num += $vv;
}
$frag1[$k]['all'] = $num;
$frag1[$k]['title'] = $k;
}
return jsonSuccess(array_values($frag1));
}
/** /**
* 获取创刊时间 * 获取创刊时间
*/ */
@@ -388,16 +466,12 @@ class Publish extends Controller{
$cday = intval((time()-strtotime($stage_now['issue_date']))/(3600*24));//过去了多少天 $cday = intval((time()-strtotime($stage_now['issue_date']))/(3600*24));//过去了多少天
$cycle = $journal_info['cycle']==0?2:$journal_info['cycle'];//出刊期限 $cycle = $journal_info['cycle']==0?2:$journal_info['cycle'];//出刊期限
$art_num = $journal_info['art_num']==0?5:$journal_info['art_num'];//期刊文章数量 $art_num = $journal_info['art_num']==0?5:$journal_info['art_num'];//期刊文章数量
$next_time = strtotime("+$cycle month",strtotime($stage_now['issue_date']));//下次出刊时间 $next_time = strtotime("+$cycle month",strtotime($stage_now['issue_date']));//下次出刊时间
$all_days = intval(($next_time-strtotime($stage_now['issue_date']))/(3600*24));//这两次出刊时间差,天数 $all_days = intval(($next_time-strtotime($stage_now['issue_date']))/(3600*24));//这两次出刊时间差,天数
$frag = []; $frag = [];
$frag['count'] = $count; $frag['count'] = $count;
$frag['sy'] = intval(($next_time- time())/(3600*24));//$cycle*30 - $cday; $frag['sy'] = intval(($next_time- time())/(3600*24));//$cycle*30 - $cday;
$frag['ntime'] = $next_time;//strtotime($stage_now['issue_date'])+($cycle*30*3600*24); $frag['ntime'] = $next_time;//strtotime($stage_now['issue_date'])+($cycle*30*3600*24);
if(time()>$next_time){ if(time()>$next_time){
$frag['mk'] = 100; $frag['mk'] = 100;
return $frag; return $frag;
@@ -408,7 +482,6 @@ class Publish extends Controller{
}else{ }else{
$frag['mk'] = intval(($lart - $count)*100/$art_num); $frag['mk'] = intval(($lart - $count)*100/$art_num);
} }
return $frag; return $frag;
} }