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

42 lines
1.1 KiB
PHP

<?php
namespace App\Service\wx;
use App\BaseApp\BaseWxService;
use App\Models\business\FeedbackModel;
/**
* 小程序用户反馈
*/
class WxFeedbackService extends BaseWxService
{
public function list(): array
{
return FeedbackModel::where('user_id', $this->userId)
->where('deleted_at', 0)
->orderByDesc('id')
->get()
->toArray();
}
public function create(array $params): array
{
$content = trim((string) ($params['content'] ?? ''));
if ($content === '') {
$this->utils->errorThrow('请填写反馈内容');
}
$now = time();
$id = (int) FeedbackModel::insertGetId([
'user_id' => $this->userId,
'content' => mb_substr($content, 0, 500),
'images' => is_array($params['images'] ?? null)
? implode(',', $params['images'])
: (string) ($params['images'] ?? ''),
'status' => FeedbackModel::STATUS_PENDING,
'created_at' => $now,
'updated_at' => $now,
]);
return FeedbackModel::where('id', $id)->first()->toArray();
}
}