文件
fenleixinxi/application/admin/model/FcReport.php
MiAn 7e22a66de0 feat: 新增举报功能及我的举报页面
本次更新主要内容:
1. 新增举报功能,支持举报信息和评价,包含防重复提交和频控保护
2. 新增我的举报页面,展示用户提交的举报记录
3. 新增平台客服弹窗,支持微信在线客服和电话客服
4. 优化消息通知,支持跳转业务页面
5. 新增举报原因字典配置,支持自定义举报原因
6. 修复服务电话默认值问题,移除硬编码兜底
7. 新增相关图标和页面组件,完善用户体验
2026-11-18 10:38:18 +08:00

90 行
2.0 KiB
PHP

<?php
namespace app\admin\model;
use think\Model;
use app\common\library\FcRelation;
/**
* 同城-举报数据模型
*/
class FcReport extends Model
{
// 表名
protected $name = 'fc_report';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = false;
// 追加属性
protected $append = [
'status_text',
'reporter_name',
'target_title',
];
/**
* 获取举报人昵称获取器
*
* @param mixed $value 原值
* @param array $data 行数据
* @return string
*/
public function getReporterNameAttr($value, $data)
{
return FcRelation::userName(isset($data['reporter_id']) ? $data['reporter_id'] : 0);
}
/**
* 获取被举报对象标题/摘要获取器
*
* @param mixed $value 原值
* @param array $data 行数据
* @return string
*/
public function getTargetTitleAttr($value, $data)
{
$type = isset($data['target_type']) ? $data['target_type'] : '';
$id = isset($data['target_id']) ? $data['target_id'] : 0;
if ($type === 'post') {
return FcRelation::postTitle($id);
}
if ($type === 'comment') {
return FcRelation::commentSnippet($id);
}
return '';
}
/**
* 获取状态字典
*
* @return array
*/
public function getStatusList()
{
return [
'pending' => __('待处理'),
'handled' => __('已处理'),
];
}
/**
* 获取状态文本获取器
*
* @param mixed $value 原值
* @param array $data 行数据
* @return string
*/
public function getStatusTextAttr($value, $data)
{
$value = $value ?: ($data['status'] ?? '');
$list = $this->getStatusList();
return $list[$value] ?? '';
}
}