20201112
This commit is contained in:
@@ -37,6 +37,7 @@ class Publish extends Controller{
|
||||
protected $super_danger_obj = '';
|
||||
protected $board_obj = '';
|
||||
protected $board_group_obj = '';
|
||||
protected $visit_log_obj = '';
|
||||
|
||||
public function __construct(\think\Request $request = null) {
|
||||
parent::__construct($request);
|
||||
@@ -60,6 +61,7 @@ class Publish extends Controller{
|
||||
$this->super_danger_obj = Db::name('super_danger');
|
||||
$this->board_obj = Db::name('board');
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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));//过去了多少天
|
||||
$cycle = $journal_info['cycle']==0?2:$journal_info['cycle'];//出刊期限
|
||||
$art_num = $journal_info['art_num']==0?5:$journal_info['art_num'];//期刊文章数量
|
||||
|
||||
$next_time = strtotime("+$cycle month",strtotime($stage_now['issue_date']));//下次出刊时间
|
||||
|
||||
$all_days = intval(($next_time-strtotime($stage_now['issue_date']))/(3600*24));//这两次出刊时间差,天数
|
||||
|
||||
$frag = [];
|
||||
$frag['count'] = $count;
|
||||
$frag['sy'] = intval(($next_time- time())/(3600*24));//$cycle*30 - $cday;
|
||||
$frag['ntime'] = $next_time;//strtotime($stage_now['issue_date'])+($cycle*30*3600*24);
|
||||
|
||||
if(time()>$next_time){
|
||||
$frag['mk'] = 100;
|
||||
return $frag;
|
||||
@@ -408,7 +482,6 @@ class Publish extends Controller{
|
||||
}else{
|
||||
$frag['mk'] = intval(($lart - $count)*100/$art_num);
|
||||
}
|
||||
|
||||
return $frag;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user