| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- /**
- * @package merchant
- *
- * @author xaboy
- * @day 2020/5/28
- *
- *
- */
- namespace app\common\repositories\user;
- use app\common\dao\user\FeedbackDao;
- use app\common\dao\user\FeedbackReplyDao;
- use app\common\model\user\FeedbackReply;
- use app\common\repositories\BaseRepository;
- /**
- * Class FeedbackRepository
- * @package app\common\repositories\user
- * @author xaboy
- * @day 2020/5/28
- * @mixin FeedbackDao
- */
- class FeedbackRepository extends BaseRepository
- {
- /**
- * FeedbackRepository constructor.
- * @param FeedbackDao $dao
- */
- public function __construct(FeedbackDao $dao)
- {
- $this->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 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]);
- }
- }
|