编辑改版面费
This commit is contained in:
@@ -194,6 +194,56 @@ class Order extends base{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改文章价格
|
||||||
|
*
|
||||||
|
* 该函数用于编辑者修改指定文章的费用信息,包括费用金额和费用备注。
|
||||||
|
* 同时会同步更新相关的订单信息(如果存在未完成的订单)。
|
||||||
|
*
|
||||||
|
* @return \think\response\Json 返回JSON格式的结果,成功时返回成功状态,失败时返回错误信息
|
||||||
|
*/
|
||||||
|
public function changePrice(){
|
||||||
|
// 获取POST请求数据
|
||||||
|
$data = $this->request->post();
|
||||||
|
|
||||||
|
// 验证必要字段
|
||||||
|
$rule = new Validate([
|
||||||
|
"editor_id"=>"require",
|
||||||
|
"article_id"=>"require",
|
||||||
|
"fee"=>"require",
|
||||||
|
"fee_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",$data['editor_id'])->find();
|
||||||
|
|
||||||
|
// 验证编辑者权限
|
||||||
|
if($journal_info['editor_id']!=$editor_info['user_id']){
|
||||||
|
return jsonError("You are not the editor of this journal");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新文章费用信息
|
||||||
|
$article_update['fee']=$data['fee'];
|
||||||
|
$article_update['fee_remark']=$data['fee_remark'];
|
||||||
|
$this->article_obj->where("article_id",$data['article_id'])->update($article_update);
|
||||||
|
|
||||||
|
// 如果存在未完成的订单,则同步更新订单费用
|
||||||
|
$order_info = $this->order_obj->where("article_id",$data['article_id'])->whereIn("state",[0,1])->find();
|
||||||
|
if($order_info){
|
||||||
|
$update1['fee']=$data['fee'];
|
||||||
|
$this->order_obj->where("order_id",$order_info['order_id'])->update($update1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return jsonSuccess();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws DataNotFoundException
|
* @throws DataNotFoundException
|
||||||
|
|||||||
@@ -1122,7 +1122,7 @@ function add_usermsg($userid, $content, $url)
|
|||||||
return $msg_obj->insert($msgdata);
|
return $msg_obj->insert($msgdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
function jsonSuccess($data)
|
function jsonSuccess($data=[])
|
||||||
{
|
{
|
||||||
return json(['code' => 0, 'msg' => 'success', 'data' => $data]);
|
return json(['code' => 0, 'msg' => 'success', 'data' => $data]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user