Files
lgp-admin-plus-api/app/Service/business/FeedbackService.php
2026-08-20 19:16:49 +08:00

57 lines
1.4 KiB
PHP

<?php
namespace App\Service\business;
use App\BaseApp\BaseService;
use App\Models\business\FeedbackModel;
/**
* 后台用户反馈
*/
class FeedbackService extends BaseService
{
public function __construct()
{
parent::__construct();
$this->model = FeedbackModel::class;
$this->selectField = ['id', 'user_id', 'content', 'images', 'reply', 'status', 'created_at', 'updated_at'];
$this->queryField = ['user_id' => '=', 'status' => '=', 'content' => 'like'];
$this->with = ['user'];
}
public function list(): array
{
$result = $this->getPageList();
foreach ($result['items'] as &$item) {
$item['user_name'] = $item['user']['nick_name'] ?? '';
$item['user_phone'] = $item['user']['phone'] ?? '';
unset($item['user']);
}
unset($item);
return $result;
}
/**
* 回复反馈
*/
public function reply(int $id, string $reply): mixed
{
if ($id <= 0) {
$this->utils->errorThrow('参数错误');
}
$reply = trim($reply);
if ($reply === '') {
$this->utils->errorThrow('请填写回复');
}
return $this->save($id, [
'reply' => mb_substr($reply, 0, 500),
'status' => FeedbackModel::STATUS_REPLIED,
]);
}
public function delete($ids): mixed
{
return $this->del(is_array($ids) ? $ids : [$ids]);
}
}