大更新,1投稿系统参考文献的类型增加功能,,,2官网数据库功能
This commit is contained in:
@@ -172,6 +172,125 @@ class Order extends base{
|
||||
}
|
||||
}
|
||||
|
||||
/**提交改价申请
|
||||
* @return void
|
||||
*/
|
||||
public function applyPrice(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"article_id"=>"require",
|
||||
"fee"=>"require",
|
||||
"remark"=>"require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
|
||||
// 查询文章、期刊和编辑者信息
|
||||
$article_info = $this->article_obj->where("article_id",$data['article_id'])->find();
|
||||
$journal_info = $this->journal_obj->where("journal_id",$article_info['journal_id'])->find();
|
||||
$editor_info = $this->user_obj->where("user_id",$journal_info['editor_id'])->find();
|
||||
|
||||
// 验证编辑者权限
|
||||
if($journal_info['editor_id']!=$editor_info['user_id']){
|
||||
return jsonError("You are not the editor of this journal");
|
||||
}
|
||||
|
||||
$check = Db::name("article_price_apply")->where("article_id",$data['article_id'])->where("state",0)->find();
|
||||
if($check){
|
||||
return jsonError("There is an unfinished price change application for this article");
|
||||
}
|
||||
|
||||
$insert['article_id'] = $data['article_id'];
|
||||
$insert['old_fee'] = $article_info['fee'];
|
||||
$insert['fee'] = $data['fee'];
|
||||
$insert['remark'] = $data['remark'];
|
||||
$insert['ctime'] = time();
|
||||
Db::name("article_price_apply")->insert($insert);
|
||||
|
||||
return jsonSuccess();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getApplyList(){
|
||||
$list = Db::name("article_price_apply")->where("state",0)->select();
|
||||
foreach ($list as $k=>$v){
|
||||
$list[$k]['article_info'] = $this->article_obj->field("article_id,journal_id,accept_sn,title")->where("article_id",$v['article_id'])->find();
|
||||
$list[$k]['journal_info'] = $this->journal_obj->field("journal_id,title")->where("journal_id",$list[$k]['article_info']['journal_id'])->find();
|
||||
$list[$k]['history'] = Db::name("article_price_apply")->where("article_id",$list[$k]['article_info']['article_id'])->select();
|
||||
}
|
||||
|
||||
$re['list'] = $list;
|
||||
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function acceptPriceApply(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"id"=>"require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
|
||||
$apply_info = Db::name("article_price_apply")->where("id",$data['id'])->find();
|
||||
$article_update['fee']=$apply_info['fee'];
|
||||
$article_update['fee_remark']=$apply_info['remark'];
|
||||
|
||||
if(intval($apply_info['fee'])==0) {
|
||||
$article_update['is_buy']=1;
|
||||
}
|
||||
$this->article_obj->where("article_id",$apply_info['article_id'])->update($article_update);
|
||||
|
||||
Db::name("article_price_apply")->where("id",$data['id'])->update(['state'=>1]);
|
||||
|
||||
$order_info = $this->order_obj->where("article_id",$apply_info['article_id'])->whereIn("state",[0,1])->find();
|
||||
if($order_info){
|
||||
if(intval($apply_info['fee'])==0){
|
||||
$this->order_obj->where("order_id",$order_info['order_id'])->update(['state'=>2]);
|
||||
}else{
|
||||
$update1['order_fee']=$apply_info['fee'];
|
||||
$this->order_obj->where("order_id",$order_info['order_id'])->update($update1);
|
||||
}
|
||||
}
|
||||
|
||||
return jsonSuccess();
|
||||
}
|
||||
|
||||
public function getArticlePriceApplyList(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"article_id"=>"require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
|
||||
$list = Db::name("article_price_apply")->where("article_id",$data['article_id'])->select();
|
||||
|
||||
return jsonSuccess($list);
|
||||
}
|
||||
|
||||
|
||||
public function rejectPriceApply(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"id"=>"require",
|
||||
"remark"=>"require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
// $apply_info = Db::name("article_price_apply")->where("id",$data['id'])->find();
|
||||
Db::name("article_price_apply")->where("id",$data['id'])->update(['state'=>2,"remark"=>trim($data['remark'])]);
|
||||
return jsonSuccess();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改文章价格
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user