This commit is contained in:
wangjinlei
2023-06-16 16:48:11 +08:00
parent 39dee4062d
commit 3bd136071d
4 changed files with 34 additions and 21 deletions

View File

@@ -78,16 +78,28 @@ class Preaccept extends Base
}
$p_info = $this->production_article_obj->where('article_id',$data['article_id'])->where('state',0)->find();
$pre_refer = $this->production_article_refer_obj->where('p_refer_id',$data['pre_p_refer_id'])->find();
$this->production_article_refer_obj->where('p_article_id',$p_info['p_article_id'])->where("index",">",$pre_refer['index'])->where('state',0)->setInc('index');
$insert['p_article_id'] = $p_info['p_article_id'];
$insert['refer_doi'] = $data['doi'];
$insert['index'] = $pre_refer['index']+1;
$insert['ctime'] = time();
$adId = $this->production_article_refer_obj->insertGetId($insert);
my_doiToFrag2($this->production_article_refer_obj->where('p_refer_id',$adId)->find());
return jsonSuccess([]);
//判断是否合法
$check = $this->production_article_refer_obj->where('p_refer_id',$adId)->find();
if($check['author']){//合法
$this->production_article_refer_obj->where('p_article_id',$p_info['p_article_id'])->where("p_refer_id","<>",$adId)->where("index",">",$pre_refer['index'])->where('state',0)->setInc('index');
return jsonSuccess([]);
}else{//非法
$this->production_article_refer_obj->where('p_refer_id',$adId)->update(['state'=>1]);
return jsonError("Doi error");
}
}
// public function aaa(){
// $list = $this->production_article_refer_obj->where('p_article_id',423)->where('state',0)->where('index',">",0)->setInc('index');
// dump($list);
// }
/**删除refer
* @return \think\response\Json
* @throws \think\Exception
@@ -105,7 +117,7 @@ class Preaccept extends Base
return jsonError($rule->getError());
}
$refer_info = $this->production_article_refer_obj->where('p_refer_id',$data['p_refer_id'])->find();
$this->production_article_refer_obj->where('p_refer_id',$data['p_refer_id'])->where('index',">",$refer_info['index'])->setDec('index');
$this->production_article_refer_obj->where('p_article_id',$refer_info['p_article_id'])->where('index',">",$refer_info['index'])->where('state',0)->setDec('index');
$this->production_article_refer_obj->where('p_refer_id',$data['p_refer_id'])->update(['state'=>1]);
return jsonSuccess([]);
}
@@ -150,14 +162,14 @@ class Preaccept extends Base
}
$refer_info = $this->production_article_refer_obj->where('p_refer_id',$data['p_refer_id'])->find();
if($data['act']=="up"){
$up_info = $this->production_article_refer_obj->where('p_article_id',$refer_info['p_article_id'])->where('index',$refer_info['index']-1)->find();
$up_info = $this->production_article_refer_obj->where('p_article_id',$refer_info['p_article_id'])->where('index',$refer_info['index']-1)->where('state',0)->find();
if(!$up_info){
return jsonError("system error");
}
$this->production_article_refer_obj->where('p_refer_id',$up_info['p_refer_id'])->setInc("index");
$this->production_article_refer_obj->where('p_refer_id',$refer_info['p_refer_id'])->setDec("index");
}else{
$down_info = $this->production_article_refer_obj->where('p_article_id',$refer_info['p_article_id'])->where('index',$refer_info['index']+1)->find();
$down_info = $this->production_article_refer_obj->where('p_article_id',$refer_info['p_article_id'])->where('index',$refer_info['index']+1)->where('state',0)->find();
if(!$down_info){
return jsonError("system error");
}