dao = $dao; } public function getList(array $where, $page, $limit) { $query = $this->dao->search($where)->with(['type' => function($query){ $query->field('feedback_category_id,cate_name'); }]); $count = $query->count(); $list = $query->page($page, $limit)->order("feedback_id desc")->withAttr('images',function($val){ return $val ? json_decode($val, true) : []; })->select(); return compact('count', 'list'); } public function getReplyList($userId, $page, $limit) { $feedbackIds = FeedbackReply::where(['uid' => $userId, 'user_read' => 0]) ->limit($page, $limit) ->order('reply_id desc') ->field('feedback_id') ->select() ->toArray(); $feedbackIds = array_column($feedbackIds,'feedback_id'); return $this->getList(['feedback_id'=>$feedbackIds], $page, $limit); } public function get( $id) { // 获取反馈信息 $data = $this->dao->getWhere([$this->dao->getPk() => $id],'*',['getReply']); $type = app()->make(FeedBackCategoryRepository::class)->getWhere(['feedback_category_id' => $data['type']]); $parent = app()->make(FeedBackCategoryRepository::class)->getWhere(['feedback_category_id' => $type['pid']]); $data['type'] = $type['cate_name']; $data['category'] = $parent['cate_name']; // 更改已读状态 $this->read($id, 'user_read'); return $data; } /** * @param $feedbackId * @param $userId * @param $content * @return int|string * @author 史晨 * @date 2026/3/17 14:15 * 回复反馈 */ public function reply($feedbackId, $userId, $content) { $insert = [ 'feedback_id' => $feedbackId, 'uid' => $userId, 'content' => $content, ]; return FeedbackReply::insert($insert); } /** * @param $feedbackId * @param $type * @return void * @author 史晨 * @date 2026/3/17 14:37 * 更改已读状态 */ public function read($feedbackId, $type) { FeedbackReply::update([$type => 1], ['feedback_id' => $feedbackId]); } }