更新若干功能
This commit is contained in:
56
app/Service/business/FeedbackService.php
Normal file
56
app/Service/business/FeedbackService.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?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]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user