编辑改版面费

This commit is contained in:
wangjinlei
2025-11-21 14:08:20 +08:00
parent 1b227c101e
commit 4298ec83c6
2 changed files with 51 additions and 1 deletions

View File

@@ -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

View File

@@ -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]);
} }