feat: 新增举报详情功能及相关接口、页面

新增举报详情页面路由与配置
新增举报详情接口及路由规则
新增举报列表状态筛选功能
新增错误信息标准化处理方法
优化举报列表页面UI交互
完善微信登录异常提示处理
这个提交包含在:
2026-11-19 09:16:58 +08:00
父节点 7e22a66de0
当前提交 134267fcd9
共有 31 个文件被更改,包括 2849 次插入 和 572 次删除

查看文件

@@ -19,6 +19,12 @@ class Area extends Backend
*/
protected $model = null;
/**
* 快速搜索字段
* @var string
*/
protected $searchFields = 'id,province,city,district';
public function _initialize()
{
parent::_initialize();
@@ -101,5 +107,9 @@ class Area extends Backend
$this->error($field === 'lat' ? '纬度格式不正确' : '经度格式不正确');
}
}
if (isset($params['sort']) && $params['sort'] !== '' && (int)$params['sort'] < 0) {
$this->error('排序权重不能为负数');
}
}
}

查看文件

@@ -18,11 +18,56 @@ class Banner extends Backend
*/
protected $model = null;
/**
* 快速搜索字段
* @var string
*/
protected $searchFields = 'id,title';
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\FcBanner;
}
/**
* 新增轮播图前校验排序权重等边界值
*
* @return string
*/
public function add()
{
if ($this->request->isPost()) {
$this->validateBannerParams($this->request->post('row/a', []));
}
return parent::add();
}
/**
* 编辑轮播图前校验排序权重等边界值
*
* @param mixed $ids
* @return string
*/
public function edit($ids = null)
{
if ($this->request->isPost()) {
$this->validateBannerParams($this->request->post('row/a', []));
}
return parent::edit($ids);
}
/**
* 校验轮播图表单边界参数
*
* @param array $params
* @return void
*/
protected function validateBannerParams(array $params)
{
if (isset($params['sort']) && $params['sort'] !== '' && (int)$params['sort'] < 0) {
$this->error('排序权重不能为负数');
}
}

查看文件

@@ -19,6 +19,12 @@ class Category extends Backend
*/
protected $model = null;
/**
* 快速搜索字段
* @var string
*/
protected $searchFields = 'id,name,icon_key';
protected $noNeedRight = ['selectpage'];
/**
@@ -225,6 +231,9 @@ class Category extends Backend
*/
protected function normalizeCategoryParams(array $params, $currentId = 0)
{
if (isset($params['sort']) && $params['sort'] !== '' && (int)$params['sort'] < 0) {
$this->error('排序权重不能为负数');
}
$pid = isset($params['pid']) ? max(0, (int)$params['pid']) : 0;
if ($currentId > 0 && $pid === $currentId) {
$pid = 0;

查看文件

@@ -93,6 +93,58 @@ class Comment extends Backend
$this->success($top === 1 ? '置顶成功' : '取消置顶成功');
}
/**
* 切换评价显示/隐藏状态(支持单条与批量)
*
* @return void
*/
public function status()
{
$ids = $this->request->post('ids');
$status = (int)$this->request->post('status', -1);
$reason = trim((string)$this->request->post('reason', ''));
if (!in_array($status, [0, 1], true)) {
$this->error('状态参数错误');
}
$ids = is_array($ids) ? $ids : explode(',', (string)$ids);
$ids = array_filter(array_map('intval', $ids));
if (!$ids) {
$this->error('请选择要操作的评价');
}
$now = time();
$comments = $status === 0
? Db::name('fc_comment')->where('id', 'in', $ids)->field('id,user_id,post_id,content,status')->select()
: [];
Db::name('fc_comment')->where('id', 'in', $ids)->update([
'status' => $status,
'updatetime' => $now,
]);
// 隐藏评价时,向对应评价发布者发送系统站内信通知
if ($status === 0 && $comments) {
foreach ($comments as $cmt) {
if ((int)$cmt['status'] === 0 || (int)$cmt['user_id'] <= 0) {
continue;
}
$snippet = mb_substr((string)$cmt['content'], 0, 20) . (mb_strlen((string)$cmt['content']) > 20 ? '...' : '');
$reasonText = $reason !== '' ? ",原因:{$reason}" : '';
Db::name('fc_message')->insert([
'user_id' => (int)$cmt['user_id'],
'type' => 'system',
'title' => '评价隐藏通知',
'content' => "您发布的评价「{$snippet}」已被管理员隐藏{$reasonText}。您仍可在原信息详情页查看或删除该评价。",
'extra' => json_encode(['path' => '/pages/detail/detail', 'id' => (int)$cmt['post_id']], JSON_UNESCAPED_UNICODE),
'isread' => 0,
'createtime' => $now,
'updatetime' => $now,
]);
}
}
$this->success($status === 1 ? '已恢复显示' : '已隐藏评价');
}
}

查看文件

@@ -9,123 +9,463 @@ use think\Db;
* 同城分类信息 - 数据总览与运营看板
*
* 后台核心运营仪表盘:
* 1. 今日核心指标与昨日对比(发布量 / 订单额 / 新增用户 / 浏览曝光量)
* 1. 核心 KPI 双维展示(累计总计 + 今日新增 + 较昨日对比 + 选中日期区间统计)
* 2. 待办督办中心(帖子待审 / 商家待审 / 提现待审 / 举报待处理)
* 3. 多时段多维趋势分析(近 7 天 / 14 天 / 30 天,支持发布量、订单额、新增用户、浏览量平滑折线图)
* 4. 营收来源构成分析(会员购买 / 发帖付费 / 置顶推广 / 付费查看等占比环形图)
* 5. 热门分类发帖分布与同城区域活跃排行
* 6. 用户、会员、商户与分销生态资产全景
* 3. 全局日期统计切换(全部累计 / 今日 / 昨日 / 近7天 / 近14天 / 近30天 / 本月 / 自定义区间)
* 4. 营收来源构成、热门分类发帖分布、同城区域排行(支持按所选日期动态联动)
* 5. 多维趋势分析图与每日数据明细表
* 6. 会员、商户与分销生态资产(累计总计 + 今日新增)
*
* @icon fa fa-dashboard
*/
class Dashboard extends Backend
{
/**
* 数据总览首页入口与数据下发
* 数据总览首页入口与 AJAX 筛选接口
*
* @return string|\think\response\Json
*/
public function index()
{
$todayStart = strtotime('today');
$todayEnd = $todayStart + 86400 - 1;
$todayStart = strtotime('today');
$todayEnd = $todayStart + 86400 - 1;
$yesterdayStart = $todayStart - 86400;
$yesterdayEnd = $todayStart - 1;
/* =========================================================
* 1. 核心 KPI(今日、较昨日对比、累计总量)
* ========================================================= */
// 发布量
$todayPost = (int)Db::name('fc_post')->where('createtime', 'between', [$todayStart, $todayEnd])->count();
$yesterdayPost = (int)Db::name('fc_post')->where('createtime', 'between', [$yesterdayStart, $yesterdayEnd])->count();
$totalPost = (int)Db::name('fc_post')->count();
// 解析日期筛选参数(默认全部累计,支持按日期切换)
$rangeKey = $this->request->get('range', 'all');
$startDate = $this->request->get('start_date', '');
$endDate = $this->request->get('end_date', '');
$period = $this->resolveDateRange($rangeKey, $startDate, $endDate, $todayStart, $todayEnd);
// 订单额与笔数(仅统计已支付订单)
$todayOrderAmount = round((float)Db::name('fc_order')->where('status', 'paid')
->whereTime('paytime|createtime', 'between', [$todayStart, $todayEnd])->sum('amount'), 2);
$yesterdayOrderAmount = round((float)Db::name('fc_order')->where('status', 'paid')
->whereTime('paytime|createtime', 'between', [$yesterdayStart, $yesterdayEnd])->sum('amount'), 2);
$totalOrderAmount = round((float)Db::name('fc_order')->where('status', 'paid')->sum('amount'), 2);
$todayOrderCount = (int)Db::name('fc_order')->where('status', 'paid')
->whereTime('paytime|createtime', 'between', [$todayStart, $todayEnd])->count();
$totalOrderCount = (int)Db::name('fc_order')->where('status', 'paid')->count();
// 如果是 AJAX 局部筛选请求,直接返回对应日期区间的完整数据包
if ($this->request->isAjax() && $this->request->get('action') === 'filter') {
$filterData = $this->buildPeriodPayload(
$period,
$todayStart,
$todayEnd,
$yesterdayStart,
$yesterdayEnd
);
return json(['code' => 1, 'msg' => 'ok', 'data' => $filterData]);
}
// 用户与会员
$todayUser = (int)Db::name('user')->where('createtime', 'between', [$todayStart, $todayEnd])->count();
$yesterdayUser = (int)Db::name('user')->where('createtime', 'between', [$yesterdayStart, $yesterdayEnd])->count();
// 首屏全量数据组装
$metrics = $this->getCoreMetrics($todayStart, $todayEnd, $yesterdayStart, $yesterdayEnd, $period);
$pending = $this->getPendingSummary();
$ecosystem = $this->getEcosystemStats($todayStart, $todayEnd, $period, $metrics['rangeUser']);
// 区间联动模块(营收构成、分类分布、区域排行、趋势图)
$rangeStart = $period['is_all'] ? null : $period['start'];
$rangeEnd = $period['is_all'] ? null : $period['end'];
$revenueData = $this->getRevenueBreakdown($rangeStart, $rangeEnd);
$categoryData = $this->getCategoryRanks($rangeStart, $rangeEnd);
$areaRanks = $this->getAreaRanks($rangeStart, $rangeEnd);
$trendData = $this->getTrendSeries($period['trend_start'], $period['trend_end']);
$this->view->assign('metrics', $metrics);
$this->view->assign('pending', $pending);
$this->view->assign('ecosystem', $ecosystem);
$this->view->assign('period', $period);
$this->view->assign('revenueTypes', $revenueData['items']);
$this->view->assign('revenueTotal', $revenueData['total']);
$this->view->assign('categoryRanks', $categoryData['items']);
$this->view->assign('categoryTotal', $categoryData['total']);
$this->view->assign('areaRanks', $areaRanks);
$this->view->assign('trendRows', $trendData['rows']);
$this->view->assign('updatedAt', date('Y-m-d H:i'));
// 向前端 RequireJS 传入初始配置
$this->assignconfig('initialTrend', $trendData);
$this->assignconfig('revenueTypes', $revenueData['items']);
$this->assignconfig('initialPeriod', $period);
return $this->view->fetch();
}
/**
* 组装 AJAX 日期切换时的响应数据包
*
* @param array $period 解析后的日期区间信息
* @param int $todayStart 今日开始时间戳
* @param int $todayEnd 今日结束时间戳
* @param int $yesterdayStart 昨日开始时间戳
* @param int $yesterdayEnd 昨日结束时间戳
* @return array
*/
protected function buildPeriodPayload(array $period, $todayStart, $todayEnd, $yesterdayStart, $yesterdayEnd)
{
$metrics = $this->getCoreMetrics($todayStart, $todayEnd, $yesterdayStart, $yesterdayEnd, $period);
$ecosystem = $this->getEcosystemStats($todayStart, $todayEnd, $period, $metrics['rangeUser']);
$rangeStart = $period['is_all'] ? null : $period['start'];
$rangeEnd = $period['is_all'] ? null : $period['end'];
$revenueData = $this->getRevenueBreakdown($rangeStart, $rangeEnd);
$categoryData = $this->getCategoryRanks($rangeStart, $rangeEnd);
$areaRanks = $this->getAreaRanks($rangeStart, $rangeEnd);
$trendData = $this->getTrendSeries($period['trend_start'], $period['trend_end']);
return [
'period' => $period,
'metrics' => $metrics,
'ecosystem' => $ecosystem,
'revenueTypes' => $revenueData['items'],
'revenueTotal' => $revenueData['total'],
'categoryRanks' => $categoryData['items'],
'categoryTotal' => $categoryData['total'],
'areaRanks' => $areaRanks,
'trend' => $trendData,
'updatedAt' => date('Y-m-d H:i'),
];
}
/**
* 解析日期统计切换参数,统一返回区间起止时间戳与展示标签
*
* @param string $rangeKey 预设标识 (today/yesterday/7d/14d/30d/month/all/custom)
* @param string $startDate 自定义开始日期 Y-m-d
* @param string $endDate 自定义结束日期 Y-m-d
* @param int $todayStart 今日零点时间戳
* @param int $todayEnd 今日末点时间戳
* @return array
*/
protected function resolveDateRange($rangeKey, $startDate, $endDate, $todayStart, $todayEnd)
{
$isAll = false;
$label = '近 14 天';
$start = $todayStart - 13 * 86400;
$end = $todayEnd;
switch ($rangeKey) {
case 'today':
$start = $todayStart;
$end = $todayEnd;
$label = '今日';
break;
case 'yesterday':
$start = $todayStart - 86400;
$end = $todayStart - 1;
$label = '昨日';
break;
case '7d':
$start = $todayStart - 6 * 86400;
$end = $todayEnd;
$label = '近 7 天';
break;
case '30d':
$start = $todayStart - 29 * 86400;
$end = $todayEnd;
$label = '近 30 天';
break;
case 'month':
$start = strtotime(date('Y-m-01 00:00:00'));
$end = $todayEnd;
$label = '本月';
break;
case 'all':
$isAll = true;
$start = 0;
$end = $todayEnd;
$label = '全部累计';
break;
case 'custom':
$sTs = $startDate ? strtotime($startDate . ' 00:00:00') : false;
$eTs = $endDate ? strtotime($endDate . ' 23:59:59') : false;
if ($sTs !== false && $eTs !== false) {
if ($sTs > $eTs) {
$tmp = $sTs;
$sTs = strtotime(date('Y-m-d 00:00:00', $eTs));
$eTs = strtotime(date('Y-m-d 23:59:59', $tmp));
}
// 自定义跨度最大限制 90 天,防止图表过密
if (($eTs - $sTs) > 90 * 86400) {
$sTs = strtotime(date('Y-m-d 00:00:00', $eTs - 89 * 86400));
}
$start = $sTs;
$end = $eTs;
$label = date('Y-m-d', $start) . ' ~ ' . date('Y-m-d', $end);
} else {
$rangeKey = '14d';
}
break;
case '14d':
default:
$rangeKey = '14d';
$start = $todayStart - 13 * 86400;
$end = $todayEnd;
$label = '近 14 天';
break;
}
// 趋势图时间范围:全部累计时展示近 30 天趋势,其余展示所选区间
$trendStart = $isAll ? ($todayStart - 29 * 86400) : $start;
$trendEnd = $end;
$days = (int)floor(($trendEnd - $trendStart) / 86400) + 1;
return [
'key' => $rangeKey,
'label' => $label,
'is_all' => $isAll,
'start' => $start,
'end' => $end,
'start_date' => $isAll ? '' : date('Y-m-d', $start),
'end_date' => date('Y-m-d', $end),
'trend_start' => $trendStart,
'trend_end' => $trendEnd,
'days' => max(1, $days),
];
}
/**
* 获取订单实际支付归属时间 SQL 表达式(优先取非 0 的 paytime,否则取 createtime)
*
* @param string $alias 表别名(可选)
* @return string
*/
protected function getOrderTimeExpr($alias = '')
{
$prefix = $alias ? $alias . '.' : '';
return "COALESCE(NULLIF({$prefix}paytime, 0), {$prefix}createtime)";
}
/**
* 获取用户注册归属时间 SQL 表达式(优先取非 0 的 createtime,否则取 jointime)
*
* @param string $alias 表别名(可选)
* @return string
*/
protected function getUserTimeExpr($alias = '')
{
$prefix = $alias ? $alias . '.' : '';
return "COALESCE(NULLIF({$prefix}createtime, 0), {$prefix}jointime)";
}
/**
* 计算指定时间区间内的已支付订单净实收金额(已扣除退款)
*
* @param int|null $startTs 开始时间戳(null 表示不限)
* @param int|null $endTs 结束时间戳(null 表示不限)
* @return float
*/
protected function sumNetOrderAmount($startTs = null, $endTs = null)
{
$orderTimeExpr = $this->getOrderTimeExpr();
$netAmountExpr = "GREATEST(amount - IFNULL(refund_amount, 0), 0)";
$query = Db::name('fc_order')->where('status', 'paid');
if ($startTs !== null && $endTs !== null) {
$s = (int)$startTs;
$e = (int)$endTs;
$query->whereRaw("{$orderTimeExpr} BETWEEN {$s} AND {$e}");
}
return round((float)$query->value("SUM({$netAmountExpr})"), 2);
}
/**
* 统计核心 KPI 指标(累计总计 + 今日新增 + 较昨日对比 + 所选日期区间)
*
* @param int $todayStart 今日开始时间戳
* @param int $todayEnd 今日结束时间戳
* @param int $yesterdayStart 昨日开始时间戳
* @param int $yesterdayEnd 昨日结束时间戳
* @param array $period 当前选中的日期区间
* @return array
*/
protected function getCoreMetrics($todayStart, $todayEnd, $yesterdayStart, $yesterdayEnd, array $period)
{
$orderTimeExpr = $this->getOrderTimeExpr();
$userTimeExpr = $this->getUserTimeExpr();
// 1. 发布量(过滤软删除)
$totalPost = (int)Db::name('fc_post')->whereNull('deletetime')->count();
$todayPost = (int)Db::name('fc_post')->whereNull('deletetime')->where('createtime', 'between', [$todayStart, $todayEnd])->count();
$yesterdayPost = (int)Db::name('fc_post')->whereNull('deletetime')->where('createtime', 'between', [$yesterdayStart, $yesterdayEnd])->count();
$rangePost = $period['is_all']
? $totalPost
: (int)Db::name('fc_post')->whereNull('deletetime')->where('createtime', 'between', [$period['start'], $period['end']])->count();
// 2. 订单实收与笔数(仅统计已支付,扣除退款金额,按实际支付时间归属)
$totalOrderAmount = $this->sumNetOrderAmount();
$todayOrderAmount = $this->sumNetOrderAmount($todayStart, $todayEnd);
$yesterdayOrderAmount = $this->sumNetOrderAmount($yesterdayStart, $yesterdayEnd);
$rangeOrderAmount = $period['is_all']
? $totalOrderAmount
: $this->sumNetOrderAmount($period['start'], $period['end']);
$totalOrderCount = (int)Db::name('fc_order')->where('status', 'paid')->count();
$todayOrderCount = (int)Db::name('fc_order')->where('status', 'paid')
->whereRaw("{$orderTimeExpr} BETWEEN " . (int)$todayStart . " AND " . (int)$todayEnd)->count();
$rangeOrderCount = $period['is_all']
? $totalOrderCount
: (int)Db::name('fc_order')->where('status', 'paid')
->whereRaw("{$orderTimeExpr} BETWEEN " . (int)$period['start'] . " AND " . (int)$period['end'])->count();
// 3. 注册用户
$totalUser = (int)Db::name('user')->count();
$memberCount = (int)Db::name('fc_user_ext')->where('is_member', 1)->count();
$merchantCount = (int)Db::name('fc_merchant')->count();
$recommendMerchantCount = (int)Db::name('fc_merchant')->where('recommend', 1)->count();
$todayUser = (int)Db::name('user')->whereRaw("{$userTimeExpr} BETWEEN " . (int)$todayStart . " AND " . (int)$todayEnd)->count();
$yesterdayUser = (int)Db::name('user')->whereRaw("{$userTimeExpr} BETWEEN " . (int)$yesterdayStart . " AND " . (int)$yesterdayEnd)->count();
$rangeUser = $period['is_all']
? $totalUser
: (int)Db::name('user')->whereRaw("{$userTimeExpr} BETWEEN " . (int)$period['start'] . " AND " . (int)$period['end'])->count();
// 浏览量 PV
// 4. 浏览曝光量(全部累计取帖子总 views,按时间筛选时取 fc_view_log 浏览记录)
$totalViews = (int)Db::name('fc_post')->whereNull('deletetime')->sum('views');
$todayViews = (int)Db::name('fc_view_log')->where('createtime', 'between', [$todayStart, $todayEnd])->count();
$yesterdayViews = (int)Db::name('fc_view_log')->where('createtime', 'between', [$yesterdayStart, $yesterdayEnd])->count();
$totalViews = (int)Db::name('fc_post')->sum('views');
$rangeViews = $period['is_all']
? $totalViews
: (int)Db::name('fc_view_log')->where('createtime', 'between', [$period['start'], $period['end']])->count();
$metrics = [
return [
'todayPost' => $todayPost,
'yesterdayPost' => $yesterdayPost,
'postDelta' => $todayPost - $yesterdayPost,
'totalPost' => $totalPost,
'rangePost' => $rangePost,
'todayOrderAmount' => $todayOrderAmount,
'yesterdayOrderAmount' => $yesterdayOrderAmount,
'orderDelta' => round($todayOrderAmount - $yesterdayOrderAmount, 2),
'totalOrderAmount' => $totalOrderAmount,
'rangeOrderAmount' => $rangeOrderAmount,
'todayOrderCount' => $todayOrderCount,
'totalOrderCount' => $totalOrderCount,
'rangeOrderCount' => $rangeOrderCount,
'todayUser' => $todayUser,
'yesterdayUser' => $yesterdayUser,
'userDelta' => $todayUser - $yesterdayUser,
'totalUser' => $totalUser,
'memberCount' => $memberCount,
'merchantCount' => $merchantCount,
'recommendMerchant' => $recommendMerchantCount,
'rangeUser' => $rangeUser,
'todayViews' => $todayViews,
'yesterdayViews' => $yesterdayViews,
'viewsDelta' => $todayViews - $yesterdayViews,
'totalViews' => $totalViews,
'rangeViews' => $rangeViews,
];
}
/* =========================================================
* 2. 待办督办中心(待审核事项与预警)
* ========================================================= */
$pendingPost = (int)Db::name('fc_post')->where('audit_status', 0)->count();
$pendingMerchant = (int)Db::name('fc_merchant')->where('audit_status', 0)->count();
$pendingWithdraw = (int)Db::name('fc_withdraw')->where('status', 'auditing')->count();
/**
* 获取待办督办统计数据
*
* @return array
*/
protected function getPendingSummary()
{
$pendingPost = (int)Db::name('fc_post')->whereNull('deletetime')->where('audit_status', 0)->count();
$pendingMerchant = (int)Db::name('fc_merchant')->where('audit_status', 0)->count();
$pendingWithdraw = (int)Db::name('fc_withdraw')->where('status', 'auditing')->count();
$pendingWithdrawAmount = round((float)Db::name('fc_withdraw')->where('status', 'auditing')->sum('amount'), 2);
$pendingReport = (int)Db::name('fc_report')->where('status', 'pending')->count();
$pendingTotal = $pendingPost + $pendingMerchant + $pendingWithdraw + $pendingReport;
$pendingReport = (int)Db::name('fc_report')->where('status', 'pending')->count();
$pending = [
'total' => $pendingTotal,
'post' => $pendingPost,
'merchant' => $pendingMerchant,
'withdraw' => $pendingWithdraw,
'withdrawAmount' => $pendingWithdrawAmount,
'report' => $pendingReport,
return [
'total' => $pendingPost + $pendingMerchant + $pendingWithdraw + $pendingReport,
'post' => $pendingPost,
'merchant' => $pendingMerchant,
'withdraw' => $pendingWithdraw,
'withdrawAmount' => $pendingWithdrawAmount,
'report' => $pendingReport,
];
}
/* =========================================================
* 3. 平台生态与分销资产
* ========================================================= */
$commissionPending = round((float)Db::name('fc_commission')->where('status', 0)->sum('amount'), 2);
$commissionSettled = round((float)Db::name('fc_commission')->where('status', 1)->sum('amount'), 2);
$distributorCount = (int)Db::name('fc_dist_relation')->distinct(true)->field('parent_id')->count();
/**
* 获取平台生态资产统计(主指标随筛选时间区间变化,同时保留今日新增)
*
* @param int $todayStart 今日开始时间戳
* @param int $todayEnd 今日结束时间戳
* @param array $period 当前选中的日期区间
* @param int $rangeUser 当前选定区间的新增/总用户数
* @return array
*/
protected function getEcosystemStats($todayStart, $todayEnd, array $period, $rangeUser)
{
$now = time();
$orderTimeExpr = $this->getOrderTimeExpr();
$isAll = !empty($period['is_all']);
$s = (int)$period['start'];
$e = (int)$period['end'];
$ecosystem = [
'commissionPending' => $commissionPending,
'commissionSettled' => $commissionSettled,
'distributorCount' => $distributorCount,
'memberRate' => $totalUser > 0 ? round(($memberCount / $totalUser) * 100, 1) : 0,
// VIP 会员:全部累计时取当前有效 VIP 会员总数;按时间筛选时取区间内支付开通/续费的去重会员数
if ($isAll) {
$memberCount = (int)Db::name('fc_user_ext')
->where('is_member', 1)
->where(function ($query) use ($now) {
$query->where('member_expiretime', '>', $now)
->whereOr('member_expiretime', 0)
->whereOr('member_expiretime', 'null');
})
->count();
} else {
$memberCount = (int)Db::name('fc_order')
->where('status', 'paid')
->where('type', 'member')
->whereRaw("{$orderTimeExpr} BETWEEN {$s} AND {$e}")
->count('DISTINCT user_id');
}
// 今日新开通/续费会员人数(按今日已支付 member 订单去重统计)
$todayMemberCount = (int)Db::name('fc_order')
->where('status', 'paid')
->where('type', 'member')
->whereRaw("{$orderTimeExpr} BETWEEN " . (int)$todayStart . " AND " . (int)$todayEnd)
->count('DISTINCT user_id');
// 已审核通过的入驻商户(按筛选时间)
$merchantQuery = Db::name('fc_merchant')->where('audit_status', 1);
$recommendQuery = Db::name('fc_merchant')->where('audit_status', 1)->where('recommend', 1);
if (!$isAll) {
$merchantQuery->where('createtime', 'between', [$s, $e]);
$recommendQuery->where('createtime', 'between', [$s, $e]);
}
$merchantCount = (int)$merchantQuery->count();
$recommendMerchantCount = (int)$recommendQuery->count();
$todayMerchantCount = (int)Db::name('fc_merchant')->where('audit_status', 1)->where('createtime', 'between', [$todayStart, $todayEnd])->count();
// 推广分销员人数(按筛选时间,按 parent_id 去重)
$distQuery = Db::name('fc_dist_relation')->where('parent_id', '>', 0);
if (!$isAll) {
$distQuery->where('createtime', 'between', [$s, $e]);
}
$distributorCount = (int)$distQuery->count('DISTINCT parent_id');
$todayDistributorCount = (int)Db::name('fc_dist_relation')->where('parent_id', '>', 0)->where('createtime', 'between', [$todayStart, $todayEnd])->count('DISTINCT parent_id');
// 佣金统计(按筛选时间 + 今日新增)
$settledQuery = Db::name('fc_commission')->where('status', 1);
$pendingQuery = Db::name('fc_commission')->where('status', 0);
if (!$isAll) {
$settledQuery->where('createtime', 'between', [$s, $e]);
$pendingQuery->where('createtime', 'between', [$s, $e]);
}
$commissionSettled = round((float)$settledQuery->sum('amount'), 2);
$commissionPending = round((float)$pendingQuery->sum('amount'), 2);
$todayCommissionPending = round((float)Db::name('fc_commission')->where('status', 0)->where('createtime', 'between', [$todayStart, $todayEnd])->sum('amount'), 2);
$todayCommissionSettled = round((float)Db::name('fc_commission')->where('status', 1)->where('createtime', 'between', [$todayStart, $todayEnd])->sum('amount'), 2);
return [
'memberCount' => $memberCount,
'todayMemberCount' => $todayMemberCount,
'memberRate' => $rangeUser > 0 ? min(100, round(($memberCount / $rangeUser) * 100, 1)) : 0,
'merchantCount' => $merchantCount,
'todayMerchantCount' => $todayMerchantCount,
'recommendMerchant' => $recommendMerchantCount,
'distributorCount' => $distributorCount,
'todayDistributorCount' => $todayDistributorCount,
'commissionPending' => $commissionPending,
'commissionSettled' => $commissionSettled,
'todayCommissionPending' => $todayCommissionPending,
'todayCommissionSettled' => $todayCommissionSettled,
];
}
/* =========================================================
* 4. 营收构成分析(按订单类型统计已支付实收)
* ========================================================= */
/**
* 获取营收来源构成(支持按日期范围筛选,null 表示全部累计)
*
* @param int|null $startTs 开始时间戳
* @param int|null $endTs 结束时间戳
* @return array
*/
protected function getRevenueBreakdown($startTs = null, $endTs = null)
{
$orderTypeLabels = [
'member' => 'VIP会员购买',
'post' => '发布信息付费',
@@ -135,21 +475,26 @@ class Dashboard extends Backend
'refresh' => '信息刷新',
];
$rawRevenue = Db::name('fc_order')
->where('status', 'paid')
->fieldRaw("type, count(*) as count, sum(amount) as amount")
$query = Db::name('fc_order')->where('status', 'paid');
if ($startTs !== null && $endTs !== null) {
$orderTimeExpr = $this->getOrderTimeExpr();
$query->whereRaw("{$orderTimeExpr} BETWEEN " . (int)$startTs . " AND " . (int)$endTs);
}
$rawRevenue = $query
->fieldRaw("type, count(*) as count, sum(GREATEST(amount - IFNULL(refund_amount, 0), 0)) as amount")
->group('type')
->order('amount', 'desc')
->select();
$revenueTotalSum = 0;
$revenueTypes = [];
$totalSum = 0;
$items = [];
foreach ($rawRevenue as $r) {
$amt = round((float)$r['amount'], 2);
$cnt = (int)$r['count'];
$label = isset($orderTypeLabels[$r['type']]) ? $orderTypeLabels[$r['type']] : ($r['type'] ? $r['type'] : '其他服务');
$revenueTotalSum += $amt;
$revenueTypes[] = [
$amt = round((float)$r['amount'], 2);
$cnt = (int)$r['count'];
$label = isset($orderTypeLabels[$r['type']]) ? $orderTypeLabels[$r['type']] : ($r['type'] ?: '其他服务');
$totalSum += $amt;
$items[] = [
'type' => $r['type'],
'label' => $label,
'count' => $cnt,
@@ -157,75 +502,122 @@ class Dashboard extends Backend
];
}
foreach ($revenueTypes as &$item) {
$item['percent'] = $revenueTotalSum > 0 ? round(($item['amount'] / $revenueTotalSum) * 100, 1) : 0;
$totalSum = round($totalSum, 2);
foreach ($items as &$item) {
$item['percent'] = $totalSum > 0 ? round(($item['amount'] / $totalSum) * 100, 1) : 0;
}
unset($item);
/* =========================================================
* 5. 热门分类发帖分布与同城区域排行
* ========================================================= */
// 一级分类发帖分布
return ['total' => $totalSum, 'items' => $items];
}
/**
* 获取一级分类发帖分布(过滤软删除帖子,支持日期范围筛选)
*
* @param int|null $startTs 开始时间戳
* @param int|null $endTs 结束时间戳
* @return array
*/
protected function getCategoryRanks($startTs = null, $endTs = null)
{
$prefix = config('database.prefix');
$joinCond = "(p.category_id = c.id OR p.category_id IN (SELECT sub.id FROM {$prefix}fc_category sub WHERE sub.pid = c.id)) AND p.deletetime IS NULL";
if ($startTs !== null && $endTs !== null) {
$joinCond .= " AND p.createtime BETWEEN " . (int)$startTs . " AND " . (int)$endTs;
}
$rawCategories = Db::name('fc_category')
->alias('c')
->join('__FC_POST__ p', '(p.category_id = c.id OR p.category_id IN (SELECT sub.id FROM ' . config('database.prefix') . 'fc_category sub WHERE sub.pid = c.id))', 'LEFT')
->join('__FC_POST__ p', $joinCond, 'LEFT')
->where('c.pid', 0)
->field('c.id, c.name, count(p.id) as post_count')
->group('c.id')
->order('post_count', 'desc')
->select();
$categoryTotal = 0;
$categoryRanks = [];
$total = 0;
$items = [];
foreach ($rawCategories as $c) {
$cnt = (int)$c['post_count'];
$categoryTotal += $cnt;
$categoryRanks[] = [
$cnt = (int)$c['post_count'];
$total += $cnt;
$items[] = [
'id' => $c['id'],
'name' => $c['name'],
'count' => $cnt,
];
}
foreach ($categoryRanks as &$cItem) {
$cItem['percent'] = $categoryTotal > 0 ? round(($cItem['count'] / $categoryTotal) * 100, 1) : 0;
foreach ($items as &$cItem) {
$cItem['percent'] = $total > 0 ? round(($cItem['count'] / $total) * 100, 1) : 0;
}
unset($cItem);
// 同城热门地区 Top 5
$rawAreas = Db::name('fc_post')
return ['total' => $total, 'items' => $items];
}
/**
* 获取同城热门活跃区域 Top 5(过滤软删除帖子,支持日期范围筛选)
*
* @param int|null $startTs 开始时间戳
* @param int|null $endTs 结束时间戳
* @return array
*/
protected function getAreaRanks($startTs = null, $endTs = null)
{
$query = Db::name('fc_post')
->whereNull('deletetime')
->where("area != '' OR city != ''");
if ($startTs !== null && $endTs !== null) {
$query->where('createtime', 'between', [$startTs, $endTs]);
}
$rawAreas = $query
->fieldRaw("IF(area != '', area, city) as region_name, count(*) as count")
->where("area != '' OR city != ''")
->group('region_name')
->order('count', 'desc')
->limit(5)
->select();
$areaRanks = [];
$areaMaxCount = 1;
$items = [];
$maxCount = 1;
foreach ($rawAreas as $ar) {
$cnt = (int)$ar['count'];
if ($cnt > $areaMaxCount) {
$areaMaxCount = $cnt;
if ($cnt > $maxCount) {
$maxCount = $cnt;
}
$areaRanks[] = [
'region_name' => $ar['region_name'] ? $ar['region_name'] : '未知区域',
$items[] = [
'region_name' => $ar['region_name'] ?: '未知区域',
'count' => $cnt,
];
}
foreach ($areaRanks as &$arItem) {
$arItem['percent'] = round(($arItem['count'] / $areaMaxCount) * 100, 1);
foreach ($items as &$arItem) {
$arItem['percent'] = round(($arItem['count'] / $maxCount) * 100, 1);
}
unset($arItem);
/* =========================================================
* 6. 多时段趋势数据计算(近 7 天 / 14 天 / 30 天)
* ========================================================= */
$maxTrendDays = 30;
$trendStart = $todayStart - ($maxTrendDays - 1) * 86400;
return $items;
}
/**
* 按起止时间戳生成多维度分日趋势序列与明细表行
*
* @param int $startTs 开始时间戳
* @param int $endTs 结束时间戳
* @return array
*/
protected function getTrendSeries($startTs, $endTs)
{
$orderTimeExpr = $this->getOrderTimeExpr();
$userTimeExpr = $this->getUserTimeExpr();
$netAmountExpr = "GREATEST(amount - IFNULL(refund_amount, 0), 0)";
// 发帖趋势
$postsMap = [];
$postsMap = [];
$postsQuery = Db::name('fc_post')
->where('createtime', 'between', [$trendStart, $todayEnd])
->whereNull('deletetime')
->where('createtime', 'between', [$startTs, $endTs])
->fieldRaw("FROM_UNIXTIME(`createtime`,'%Y-%m-%d') AS day, COUNT(*) AS num")
->group('day')
->select();
@@ -233,12 +625,12 @@ class Dashboard extends Backend
$postsMap[$row['day']] = (int)$row['num'];
}
// 订单额趋势
$ordersMap = [];
// 订单实收趋势
$ordersMap = [];
$ordersQuery = Db::name('fc_order')
->where('status', 'paid')
->whereTime('paytime|createtime', 'between', [$trendStart, $todayEnd])
->fieldRaw("FROM_UNIXTIME(IFNULL(`paytime`,`createtime`),'%Y-%m-%d') AS day, SUM(`amount`) AS num")
->whereRaw("{$orderTimeExpr} BETWEEN " . (int)$startTs . " AND " . (int)$endTs)
->fieldRaw("FROM_UNIXTIME({$orderTimeExpr},'%Y-%m-%d') AS day, SUM({$netAmountExpr}) AS num")
->group('day')
->select();
foreach ($ordersQuery as $row) {
@@ -246,10 +638,10 @@ class Dashboard extends Backend
}
// 新增用户趋势
$usersMap = [];
$usersMap = [];
$usersQuery = Db::name('user')
->where('createtime', 'between', [$trendStart, $todayEnd])
->fieldRaw("FROM_UNIXTIME(`createtime`,'%Y-%m-%d') AS day, COUNT(*) AS num")
->whereRaw("{$userTimeExpr} BETWEEN " . (int)$startTs . " AND " . (int)$endTs)
->fieldRaw("FROM_UNIXTIME({$userTimeExpr},'%Y-%m-%d') AS day, COUNT(*) AS num")
->group('day')
->select();
foreach ($usersQuery as $row) {
@@ -257,9 +649,9 @@ class Dashboard extends Backend
}
// 浏览量趋势
$viewsMap = [];
$viewsMap = [];
$viewsQuery = Db::name('fc_view_log')
->where('createtime', 'between', [$trendStart, $todayEnd])
->where('createtime', 'between', [$startTs, $endTs])
->fieldRaw("FROM_UNIXTIME(`createtime`,'%Y-%m-%d') AS day, COUNT(*) AS num")
->group('day')
->select();
@@ -267,74 +659,44 @@ class Dashboard extends Backend
$viewsMap[$row['day']] = (int)$row['num'];
}
// 计算 7/14/30 天数据包
$ranges = [7, 14, 30];
$allTrends = [];
foreach ($ranges as $span) {
$startTs = $todayStart - ($span - 1) * 86400;
$dates = [];
$posts = [];
$orders = [];
$users = [];
$views = [];
$rows = [];
for ($i = 0; $i < $span; $i++) {
$day = date('Y-m-d', $startTs + $i * 86400);
$p = isset($postsMap[$day]) ? $postsMap[$day] : 0;
$o = isset($ordersMap[$day]) ? $ordersMap[$day] : 0;
$u = isset($usersMap[$day]) ? $usersMap[$day] : 0;
$v = isset($viewsMap[$day]) ? $viewsMap[$day] : 0;
$dates = [];
$posts = [];
$orders = [];
$users = [];
$views = [];
$rows = [];
$dates[] = $day;
$posts[] = $p;
$orders[] = $o;
$users[] = $u;
$views[] = $v;
$rows[] = [
'date' => $day,
'posts' => $p,
'orders' => $o,
'users' => $u,
'views' => $v,
];
}
$allTrends[$span] = [
'dates' => $dates,
'posts' => $posts,
'orders' => $orders,
'users' => $users,
'views' => $views,
'rows' => array_reverse($rows),
$cursor = strtotime(date('Y-m-d 00:00:00', $startTs));
$limit = strtotime(date('Y-m-d 00:00:00', $endTs));
while ($cursor <= $limit) {
$day = date('Y-m-d', $cursor);
$p = isset($postsMap[$day]) ? $postsMap[$day] : 0;
$o = isset($ordersMap[$day]) ? $ordersMap[$day] : 0;
$u = isset($usersMap[$day]) ? $usersMap[$day] : 0;
$v = isset($viewsMap[$day]) ? $viewsMap[$day] : 0;
$dates[] = $day;
$posts[] = $p;
$orders[] = $o;
$users[] = $u;
$views[] = $v;
$rows[] = [
'date' => $day,
'posts' => $p,
'orders' => $o,
'users' => $u,
'views' => $v,
];
$cursor += 86400;
}
// 如果是 AJAX 请求局部刷新趋势,可直接返回对应时段数据
if ($this->request->isAjax() && $this->request->get('action') === 'trend') {
$days = (int)$this->request->get('days', 14);
$trendData = isset($allTrends[$days]) ? $allTrends[$days] : $allTrends[14];
return json(['code' => 1, 'msg' => 'ok', 'data' => $trendData]);
}
// 默认 14 天用于模板首屏初始化
$defaultTrend = $allTrends[14];
/* =========================================================
* 7. 视图变量绑定与前端配置传递
* ========================================================= */
$this->view->assign('metrics', $metrics);
$this->view->assign('pending', $pending);
$this->view->assign('ecosystem', $ecosystem);
$this->view->assign('revenueTypes', $revenueTypes);
$this->view->assign('categoryRanks', $categoryRanks);
$this->view->assign('areaRanks', $areaRanks);
$this->view->assign('trendRows', $defaultTrend['rows']);
$this->view->assign('updatedAt', date('Y-m-d H:i'));
// 向前端 RequireJS 传入完整时段数据包及分类分布,供平滑渲染交互
$this->assignconfig('allTrends', $allTrends);
$this->assignconfig('revenueTypes', $revenueTypes);
$this->assignconfig('categoryRanks', $categoryRanks);
return $this->view->fetch();
return [
'dates' => $dates,
'posts' => $posts,
'orders' => $orders,
'users' => $users,
'views' => $views,
'rows' => array_reverse($rows),
];
}
}

查看文件

@@ -20,6 +20,12 @@ class Post extends Backend
*/
protected $model = null;
/**
* 快速搜索字段
* @var string
*/
protected $searchFields = 'id,title,content,contact,phone';
/**
* 无需鉴权的方法(只读辅助接口;审核/置顶/下架/上架必须走权限节点)
* @var array
@@ -32,6 +38,46 @@ class Post extends Backend
$this->model = new \app\admin\model\FcPost;
}
/**
* 新增信息前校验价格等边界参数
*
* @return string
*/
public function add()
{
if ($this->request->isPost()) {
$this->validatePostParams($this->request->post('row/a', []));
}
return parent::add();
}
/**
* 编辑信息前校验价格等边界参数
*
* @param mixed $ids
* @return string
*/
public function edit($ids = null)
{
if ($this->request->isPost()) {
$this->validatePostParams($this->request->post('row/a', []));
}
return parent::edit($ids);
}
/**
* 校验信息表单边界参数(如价格不可为负数)
*
* @param array $params
* @return void
*/
protected function validatePostParams(array $params)
{
if (isset($params['price']) && $params['price'] !== '' && (float)$params['price'] < 0) {
$this->error('价格不能为负数');
}
}
/**
* 查看信息列表
*

查看文件

@@ -19,6 +19,12 @@ class Postaudit extends Backend
*/
protected $model = null;
/**
* 快速搜索字段
* @var string
*/
protected $searchFields = 'id,title,content,contact,phone';
/**
* 无需鉴权的方法(只读辅助接口)
* @var array

查看文件

@@ -405,6 +405,22 @@ class Report extends Backend
'status' => 0,
'updatetime' => $now,
]);
// 通知被隐藏评价的发布者
if ($cmt && (int)$cmt['user_id'] > 0 && (int)$cmt['status'] !== 0) {
$cmtSnippet = mb_substr((string)$cmt['content'], 0, 20) . (mb_strlen((string)$cmt['content']) > 20 ? '...' : '');
$reasonNote = $remark !== '' ? $remark : $report['reason'];
Db::name('fc_message')->insert([
'user_id' => (int)$cmt['user_id'],
'type' => 'system',
'title' => '评价违规隐藏通知',
'content' => "您发布的评价「{$cmtSnippet}」因被举报核实违规({$reasonNote})已被平台隐藏。您仍可在原信息详情页查看或删除该评价。",
'extra' => json_encode(['path' => '/pages/detail/detail', 'id' => (int)$cmt['post_id']], JSON_UNESCAPED_UNICODE),
'isread' => 0,
'createtime' => $now,
'updatetime' => $now,
]);
}
}
} else {
if ($report['target_type'] === 'post') {

查看文件

@@ -90,4 +90,39 @@ return [
'信息曝光量 (次)' => '信息曝光量 (次)',
'暂无明细数据' => '暂无明细数据',
'元' => '元',
'订单额仅统计已支付实收净额(已扣退款)' => '订单额仅统计已支付实收净额(已扣退款)',
'日期统计切换' => '日期统计切换',
'统计周期' => '统计周期',
'选择统计周期' => '选择统计周期',
'全部累计' => '全部累计',
'今日' => '今日',
'昨日' => '昨日',
'本月' => '本月',
'开始日期' => '开始日期',
'至' => '至',
'结束日期' => '结束日期',
'筛选' => '筛选',
'当前:' => '当前:',
'核心运营指标' => '核心运营指标',
'信息发布量' => '信息发布量',
'累计总计' => '累计总计',
'今日新增' => '今日新增',
'订单实收' => '订单实收',
'注册用户' => '注册用户',
'信息曝光量' => '信息曝光量',
'今日浏览' => '今日浏览',
'该时段暂无已支付订单数据' => '该时段暂无已支付订单数据',
'该时段暂无分类发帖数据' => '该时段暂无分类发帖数据',
'该时段暂无地区发布数据' => '该时段暂无地区发布数据',
'会员沉淀、商户入驻及分销裂变体系(累计总计 / 今日新增)'
=> '会员沉淀、商户入驻及分销裂变体系(累计总计 / 今日新增)',
'已审入驻商户' => '已审入驻商户',
'每日数据明细' => '每日数据明细',
'暂无数据' => '暂无数据',
'数据加载失败' => '数据加载失败',
'网络异常,请稍后重试' => '网络异常,请稍后重试',
'请选择完整的开始和结束日期' => '请选择完整的开始和结束日期',
'全站累计' => '全站累计',
'会员沉淀、商户入驻及分销裂变体系(所选周期统计 / 今日新增)'
=> '会员沉淀、商户入驻及分销裂变体系(所选周期统计 / 今日新增)',
];

查看文件

@@ -7,6 +7,8 @@
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}">刷新</a>
<a href="javascript:;" class="btn btn-success btn-show btn-disabled disabled" title="批量显示"><i class="fa fa-eye"></i> 显示</a>
<a href="javascript:;" class="btn btn-warning btn-hide btn-disabled disabled" title="批量隐藏"><i class="fa fa-eye-slash"></i> 隐藏</a>
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('fc/comment/edit')}"

查看文件

@@ -4,29 +4,29 @@
<div class="fc-dash__head-info">
<h1 class="fc-dash__title">{:__('业务总览与运营看板')}</h1>
<p class="fc-dash__desc">
{:__('同城便民生活服务平台')} · {:__('数据更新于')} {$updatedAt} · {:__('订单额仅统计已支付实收口径')}
{:__('同城便民生活服务平台')} · {:__('数据更新于')} <span id="fc-updated-at">{$updatedAt}</span> · {:__('订单额仅统计已支付实收净额(已扣退款)')}
</p>
</div>
<div class="fc-dash__actions">
<a href="fc/post" title="{:__('内容管理')}" class="fc-btn addtabsit {:$auth->check('fc/post')?'':'hide'}">
<a href="{:url('fc/post/index')}" title="{:__('内容管理')}" class="fc-btn addtabsit {:$auth->check('fc/post')?'':'hide'}">
<i class="fa fa-file-text-o" aria-hidden="true"></i> {:__('内容管理')}
{if $pending.post > 0}
<span class="fc-btn__badge">{$pending.post}</span>
{/if}
</a>
<a href="fc/merchant" title="{:__('商家管理')}" class="fc-btn addtabsit {:$auth->check('fc/merchant')?'':'hide'}">
<a href="{:url('fc/merchant/index')}" title="{:__('商家管理')}" class="fc-btn addtabsit {:$auth->check('fc/merchant')?'':'hide'}">
<i class="fa fa-shopping-bag" aria-hidden="true"></i> {:__('商家管理')}
{if $pending.merchant > 0}
<span class="fc-btn__badge">{$pending.merchant}</span>
{/if}
</a>
<a href="fc/withdraw" title="{:__('提现审核')}" class="fc-btn addtabsit {:$auth->check('fc/withdraw')?'':'hide'}">
<a href="{:url('fc/withdraw/index')}" title="{:__('提现审核')}" class="fc-btn addtabsit {:$auth->check('fc/withdraw')?'':'hide'}">
<i class="fa fa-credit-card" aria-hidden="true"></i> {:__('提现审核')}
{if $pending.withdraw > 0}
<span class="fc-btn__badge">{$pending.withdraw}</span>
{/if}
</a>
<a href="fc/report" title="{:__('举报投诉')}" class="fc-btn addtabsit {:$auth->check('fc/report')?'':'hide'}">
<a href="{:url('fc/report/index')}" title="{:__('举报投诉')}" class="fc-btn addtabsit {:$auth->check('fc/report')?'':'hide'}">
<i class="fa fa-shield" aria-hidden="true"></i> {:__('举报投诉')}
{if $pending.report > 0}
<span class="fc-btn__badge">{$pending.report}</span>
@@ -47,25 +47,25 @@
</div>
<div class="fc-alert-banner__items">
{if $pending.post > 0}
<a href="fc/post" class="fc-alert-pill addtabsit" title="{:__('待审核信息')}">
<a href="{:url('fc/post/index')}" class="fc-alert-pill addtabsit" title="{:__('待审核信息')}">
<i class="fa fa-clock-o text-warning" aria-hidden="true"></i>
<span>{:__('信息待审核')} <b>{$pending.post}</b></span>
</a>
{/if}
{if $pending.merchant > 0}
<a href="fc/merchant" class="fc-alert-pill addtabsit" title="{:__('商家入驻待审')}">
<a href="{:url('fc/merchant/index')}" class="fc-alert-pill addtabsit" title="{:__('商家入驻待审')}">
<i class="fa fa-user-circle-o text-info" aria-hidden="true"></i>
<span>{:__('商家入驻待审')} <b>{$pending.merchant}</b></span>
</a>
{/if}
{if $pending.withdraw > 0}
<a href="fc/withdraw" class="fc-alert-pill addtabsit" title="{:__('提现申请待审')}">
<a href="{:url('fc/withdraw/index')}" class="fc-alert-pill addtabsit" title="{:__('提现申请待审')}">
<i class="fa fa-money text-danger" aria-hidden="true"></i>
<span>{:__('提现待审核')} <b>{$pending.withdraw}</b> ({:__('共')} ¥{$pending.withdrawAmount|number_format=2})</span>
</a>
{/if}
{if $pending.report > 0}
<a href="fc/report" class="fc-alert-pill addtabsit" title="{:__('违规举报待处理')}">
<a href="{:url('fc/report/index')}" class="fc-alert-pill addtabsit" title="{:__('违规举报待处理')}">
<i class="fa fa-exclamation-triangle text-warning" aria-hidden="true"></i>
<span>{:__('举报待处理')} <b>{$pending.report}</b></span>
</a>
@@ -79,108 +79,161 @@
</div>
{/if}
<!-- 4 大核心 KPI 指标卡 -->
<section class="fc-kpi-grid" aria-label="{:__('今日核心指标')}">
<!-- 1. 今日发布量 -->
<!-- 全局日期统计切换栏 -->
<section class="fc-filter-bar" aria-label="{:__('日期统计切换')}">
<div class="fc-filter-bar__left">
<span class="fc-filter-bar__label"><i class="fa fa-calendar" aria-hidden="true"></i> {:__('统计周期')}</span>
<div class="fc-seg fc-seg--date" role="group" aria-label="{:__('选择统计周期')}">
<button type="button" class="fc-seg__btn fc-date-btn {if $period.key == 'all'}is-active{/if}" data-range="all">{:__('全部累计')}</button>
<button type="button" class="fc-seg__btn fc-date-btn {if $period.key == 'today'}is-active{/if}" data-range="today">{:__('今日')}</button>
<button type="button" class="fc-seg__btn fc-date-btn {if $period.key == 'yesterday'}is-active{/if}" data-range="yesterday">{:__('昨日')}</button>
<button type="button" class="fc-seg__btn fc-date-btn {if $period.key == '7d'}is-active{/if}" data-range="7d">{:__('近 7 天')}</button>
<button type="button" class="fc-seg__btn fc-date-btn {if $period.key == '14d'}is-active{/if}" data-range="14d">{:__('近 14 天')}</button>
<button type="button" class="fc-seg__btn fc-date-btn {if $period.key == '30d'}is-active{/if}" data-range="30d">{:__('近 30 天')}</button>
<button type="button" class="fc-seg__btn fc-date-btn {if $period.key == 'month'}is-active{/if}" data-range="month">{:__('本月')}</button>
</div>
</div>
<div class="fc-filter-bar__right">
<div class="fc-date-custom">
<input type="date" id="fc-start-date" class="fc-date-input" value="{$period.start_date}" aria-label="{:__('开始日期')}">
<span class="fc-date-sep">{:__('至')}</span>
<input type="date" id="fc-end-date" class="fc-date-input" value="{$period.end_date}" aria-label="{:__('结束日期')}">
<button type="button" id="fc-custom-apply" class="fc-btn fc-btn--sm fc-btn--primary">{:__('筛选')}</button>
</div>
<span class="fc-filter-bar__current" id="fc-current-period-badge">{:__('当前:')}{$period.label}</span>
</div>
</section>
<!-- 4 大核心 KPI 指标卡(所选周期总数 + 今日新增 + 全站累计) -->
<section class="fc-kpi-grid" aria-label="{:__('核心运营指标')}">
<!-- 1. 信息发布量 -->
<article class="fc-kpi">
<div class="fc-kpi__head">
<span class="fc-kpi__label">{:__('今日发布量')}</span>
<span class="fc-kpi__label">{:__('信息发布量')}</span>
<span class="fc-kpi__icon fc-kpi__icon--green"><i class="fa fa-paper-plane-o" aria-hidden="true"></i></span>
</div>
<p class="fc-kpi__value">{$metrics.todayPost} <small class="fc-kpi__unit">{:__('篇')}</small></p>
<div class="fc-kpi__dual">
<div class="fc-kpi__main">
<span class="fc-kpi__subtag"><span class="fc-period-name">{$period.label}</span></span>
<p class="fc-kpi__value"><span id="fc-kpi-post">{$metrics.rangePost}</span> <small class="fc-kpi__unit">{:__('篇')}</small></p>
</div>
<div class="fc-kpi__today">
<span class="fc-kpi__subtag">{:__('今日新增')}</span>
<p class="fc-kpi__today-val is-green">+{$metrics.todayPost} <small>{:__('篇')}</small></p>
</div>
</div>
<div class="fc-kpi__foot">
<div class="fc-kpi__range">
{:__('全站累计')}:<strong>{$metrics.totalPost}</strong> {:__('篇')}
</div>
<div class="fc-kpi__compare">
{if $metrics.postDelta > 0}
<span class="fc-trend fc-trend--up"><i class="fa fa-long-arrow-up" aria-hidden="true"></i>{$metrics.postDelta}</span>
<span class="fc-kpi__subtext">{:__('较昨日')}</span>
{elseif $metrics.postDelta < 0}
<span class="fc-trend fc-trend--down"><i class="fa fa-long-arrow-down" aria-hidden="true"></i>{:abs($metrics['postDelta'])}</span>
<span class="fc-kpi__subtext">{:__('较昨日')}</span>
{else}
<span class="fc-trend fc-trend--flat">{:__('持平')}</span>
<span class="fc-kpi__subtext">{:__('较昨日')}</span>
{/if}
</div>
<div class="fc-kpi__total">
{:__('累计')} <span>{$metrics.totalPost}</span> {:__('篇')}
<span class="fc-kpi__subtext">{:__('较昨日')}</span>
</div>
</div>
</article>
<!-- 2. 今日订单额 -->
<!-- 2. 订单实收 -->
<article class="fc-kpi">
<div class="fc-kpi__head">
<span class="fc-kpi__label">{:__('今日订单实收')}</span>
<span class="fc-kpi__label">{:__('订单实收')}</span>
<span class="fc-kpi__icon fc-kpi__icon--gold"><i class="fa fa-jpy" aria-hidden="true"></i></span>
</div>
<p class="fc-kpi__value fc-kpi__value--money">¥{$metrics.todayOrderAmount|number_format=2}</p>
<div class="fc-kpi__dual">
<div class="fc-kpi__main">
<span class="fc-kpi__subtag"><span class="fc-period-name">{$period.label}</span> (<span id="fc-kpi-order-cnt">{$metrics.rangeOrderCount}</span>{:__('笔')})</span>
<p class="fc-kpi__value fc-kpi__value--money" id="fc-kpi-order">¥{$metrics.rangeOrderAmount|number_format=2}</p>
</div>
<div class="fc-kpi__today">
<span class="fc-kpi__subtag">{:__('今日')} ({$metrics.todayOrderCount}{:__('笔')})</span>
<p class="fc-kpi__today-val is-gold">¥{$metrics.todayOrderAmount|number_format=2}</p>
</div>
</div>
<div class="fc-kpi__foot">
<div class="fc-kpi__range">
{:__('全站累计')}:<strong>¥{$metrics.totalOrderAmount|number_format=2}</strong> ({$metrics.totalOrderCount}{:__('笔')})
</div>
<div class="fc-kpi__compare">
{if $metrics.orderDelta > 0}
<span class="fc-trend fc-trend--up"><i class="fa fa-long-arrow-up" aria-hidden="true"></i>¥{$metrics.orderDelta|number_format=2}</span>
<span class="fc-kpi__subtext">{:__('较昨日')}</span>
{elseif $metrics.orderDelta < 0}
<span class="fc-trend fc-trend--down"><i class="fa fa-long-arrow-down" aria-hidden="true"></i>¥{:number_format(abs($metrics['orderDelta']), 2)}</span>
<span class="fc-kpi__subtext">{:__('较昨日')}</span>
{else}
<span class="fc-trend fc-trend--flat">{:__('持平')}</span>
<span class="fc-kpi__subtext">{:__('较昨日')}</span>
{/if}
</div>
<div class="fc-kpi__total">
{:__('累计')} <span>¥{$metrics.totalOrderAmount|number_format=2}</span>
<span class="fc-kpi__subtext">{:__('较昨日')}</span>
</div>
</div>
</article>
<!-- 3. 今日新增用户 -->
<!-- 3. 注册用户 -->
<article class="fc-kpi">
<div class="fc-kpi__head">
<span class="fc-kpi__label">{:__('今日新增用户')}</span>
<span class="fc-kpi__label">{:__('注册用户')}</span>
<span class="fc-kpi__icon fc-kpi__icon--blue"><i class="fa fa-user-plus" aria-hidden="true"></i></span>
</div>
<p class="fc-kpi__value">{$metrics.todayUser} <small class="fc-kpi__unit">{:__('人')}</small></p>
<div class="fc-kpi__dual">
<div class="fc-kpi__main">
<span class="fc-kpi__subtag"><span class="fc-period-name">{$period.label}</span></span>
<p class="fc-kpi__value"><span id="fc-kpi-user">{$metrics.rangeUser}</span> <small class="fc-kpi__unit">{:__('人')}</small></p>
</div>
<div class="fc-kpi__today">
<span class="fc-kpi__subtag">{:__('今日新增')}</span>
<p class="fc-kpi__today-val is-blue">+{$metrics.todayUser} <small>{:__('人')}</small></p>
</div>
</div>
<div class="fc-kpi__foot">
<div class="fc-kpi__range">
{:__('全站累计')}:<strong>{$metrics.totalUser}</strong> {:__('人')}
</div>
<div class="fc-kpi__compare">
{if $metrics.userDelta > 0}
<span class="fc-trend fc-trend--up"><i class="fa fa-long-arrow-up" aria-hidden="true"></i>{$metrics.userDelta}</span>
<span class="fc-kpi__subtext">{:__('较昨日')}</span>
{elseif $metrics.userDelta < 0}
<span class="fc-trend fc-trend--down"><i class="fa fa-long-arrow-down" aria-hidden="true"></i>{:abs($metrics['userDelta'])}</span>
<span class="fc-kpi__subtext">{:__('较昨日')}</span>
{else}
<span class="fc-trend fc-trend--flat">{:__('持平')}</span>
<span class="fc-kpi__subtext">{:__('较昨日')}</span>
{/if}
</div>
<div class="fc-kpi__total">
{:__('累计注册')} <span>{$metrics.totalUser}</span> {:__('人')}
<span class="fc-kpi__subtext">{:__('较昨日')}</span>
</div>
</div>
</article>
<!-- 4. 今日信息浏览曝光 -->
<!-- 4. 信息曝光量 -->
<article class="fc-kpi">
<div class="fc-kpi__head">
<span class="fc-kpi__label">{:__('今日信息曝光量')}</span>
<span class="fc-kpi__label">{:__('信息曝光量')}</span>
<span class="fc-kpi__icon fc-kpi__icon--purple"><i class="fa fa-eye" aria-hidden="true"></i></span>
</div>
<p class="fc-kpi__value">{$metrics.todayViews} <small class="fc-kpi__unit">{:__('次')}</small></p>
<div class="fc-kpi__dual">
<div class="fc-kpi__main">
<span class="fc-kpi__subtag"><span class="fc-period-name">{$period.label}</span></span>
<p class="fc-kpi__value"><span id="fc-kpi-views">{$metrics.rangeViews}</span> <small class="fc-kpi__unit">{:__('次')}</small></p>
</div>
<div class="fc-kpi__today">
<span class="fc-kpi__subtag">{:__('今日浏览')}</span>
<p class="fc-kpi__today-val is-purple">+{$metrics.todayViews} <small>{:__('次')}</small></p>
</div>
</div>
<div class="fc-kpi__foot">
<div class="fc-kpi__range">
{:__('全站累计')}:<strong>{$metrics.totalViews}</strong> {:__('次')}
</div>
<div class="fc-kpi__compare">
{if $metrics.viewsDelta > 0}
<span class="fc-trend fc-trend--up"><i class="fa fa-long-arrow-up" aria-hidden="true"></i>{$metrics.viewsDelta}</span>
<span class="fc-kpi__subtext">{:__('较昨日')}</span>
{elseif $metrics.viewsDelta < 0}
<span class="fc-trend fc-trend--down"><i class="fa fa-long-arrow-down" aria-hidden="true"></i>{:abs($metrics['viewsDelta'])}</span>
<span class="fc-kpi__subtext">{:__('较昨日')}</span>
{else}
<span class="fc-trend fc-trend--flat">{:__('持平')}</span>
<span class="fc-kpi__subtext">{:__('较昨日')}</span>
{/if}
</div>
<div class="fc-kpi__total">
{:__('累计曝光')} <span>{$metrics.totalViews}</span> {:__('次')}
<span class="fc-kpi__subtext">{:__('较昨日')}</span>
</div>
</div>
</article>
@@ -192,16 +245,10 @@
<section class="fc-card fc-card--trend">
<header class="fc-card__head">
<div>
<h2 class="fc-card__title">{:__('业务多维趋势透视')}</h2>
<h2 class="fc-card__title">{:__('业务多维趋势透视')} <span class="fc-card__tag" id="fc-trend-period-tag">{$period.label}</span></h2>
<p class="fc-card__desc">{:__('发布量按发布时间归属,订单额按实际支付时间归属')}</p>
</div>
<div class="fc-card__controls">
<!-- 时段切换 -->
<div class="fc-seg fc-seg--range" role="group" aria-label="{:__('选择时段')}">
<button type="button" class="fc-seg__btn fc-range-btn" data-days="7">{:__('近 7 天')}</button>
<button type="button" class="fc-seg__btn fc-range-btn is-active" data-days="14">{:__('近 14 天')}</button>
<button type="button" class="fc-seg__btn fc-range-btn" data-days="30">{:__('近 30 天')}</button>
</div>
<!-- 指标切换 -->
<div class="fc-seg fc-seg--metric" role="group" aria-label="{:__('切换趋势指标')}">
<button type="button" class="fc-seg__btn fc-metric-btn is-active" data-metric="posts">{:__('发布量')}</button>
@@ -238,13 +285,13 @@
<section class="fc-card fc-card--compact">
<header class="fc-card__head">
<h2 class="fc-card__title">{:__('营收来源构成')}</h2>
<span class="fc-card__tag">{:__('实收合计')} ¥{$metrics.totalOrderAmount|number_format=2}</span>
<span class="fc-card__tag" id="fc-revenue-tag">{$period.label} · ¥{$revenueTotal|number_format=2}</span>
</header>
<div class="fc-card__body">
<div class="fc-pie-wrap">
<div id="fc-revenue-chart" class="fc-pie-chart" role="img" aria-label="{:__('营收构成环形图')}"></div>
</div>
<div class="fc-revenue-list">
<div class="fc-revenue-list" id="fc-revenue-list">
{if count($revenueTypes) > 0}
{foreach $revenueTypes as $rev}
<div class="fc-rev-item">
@@ -259,7 +306,7 @@
</div>
{/foreach}
{else}
<div class="fc-empty-hint">{:__('暂无已支付订单数据')}</div>
<div class="fc-empty-hint">{:__('该时段暂无已支付订单数据')}</div>
{/if}
</div>
</div>
@@ -269,9 +316,9 @@
<section class="fc-card fc-card--compact">
<header class="fc-card__head">
<h2 class="fc-card__title">{:__('热门分类发帖分布')}</h2>
<span class="fc-card__tag">{:__('累计发帖')} {$metrics.totalPost} {:__('篇')}</span>
<span class="fc-card__tag" id="fc-category-tag">{$period.label} · {$categoryTotal} {:__('篇')}</span>
</header>
<div class="fc-card__body fc-cat-ranks">
<div class="fc-card__body fc-cat-ranks" id="fc-category-list">
{if count($categoryRanks) > 0}
{foreach $categoryRanks as $cat}
<div class="fc-rank-row">
@@ -285,7 +332,7 @@
</div>
{/foreach}
{else}
<div class="fc-empty-hint">{:__('暂无分类数据')}</div>
<div class="fc-empty-hint">{:__('该时段暂无分类发帖数据')}</div>
{/if}
</div>
</section>
@@ -298,12 +345,12 @@
<section class="fc-card">
<header class="fc-card__head">
<div>
<h2 class="fc-card__title">{:__('同城活跃区域 Top 5')}</h2>
<h2 class="fc-card__title">{:__('同城活跃区域 Top 5')} <span class="fc-card__tag" id="fc-area-tag">{$period.label}</span></h2>
<p class="fc-card__desc">{:__('基于信息发布所处行政区/县的热度分布')}</p>
</div>
<a href="fc/post" title="{:__('查看帖子列表')}" class="fc-card__more addtabsit">{:__('全部帖子')} <i class="fa fa-angle-right" aria-hidden="true"></i></a>
<a href="{:url('fc/post/index')}" title="{:__('查看帖子列表')}" class="fc-card__more addtabsit">{:__('全部帖子')} <i class="fa fa-angle-right" aria-hidden="true"></i></a>
</header>
<div class="fc-card__body">
<div class="fc-card__body" id="fc-area-list">
{if count($areaRanks) > 0}
<div class="fc-area-list">
{foreach $areaRanks as $idx => $area}
@@ -318,17 +365,17 @@
{/foreach}
</div>
{else}
<div class="fc-empty-hint">{:__('暂无地区发布数据')}</div>
<div class="fc-empty-hint">{:__('该时段暂无地区发布数据')}</div>
{/if}
</div>
</section>
<!-- 2. 会员、商家与分销裂变生态 -->
<!-- 2. 会员、商家与分销裂变生态(随筛选时间联动 + 今日) -->
<section class="fc-card">
<header class="fc-card__head">
<div>
<h2 class="fc-card__title">{:__('平台商业与生态资产')}</h2>
<p class="fc-card__desc">{:__('会员沉淀、商户入驻及分销裂变体系')}</p>
<h2 class="fc-card__title">{:__('平台商业与生态资产')} <span class="fc-card__tag" id="fc-eco-tag">{$period.label}</span></h2>
<p class="fc-card__desc">{:__('会员沉淀、商户入驻及分销裂变体系(所选周期统计 / 今日新增)')}</p>
</div>
</header>
<div class="fc-card__body">
@@ -338,11 +385,11 @@
<div class="fc-eco-block__title"><i class="fa fa-diamond text-warning" aria-hidden="true"></i> {:__('VIP会员体系')}</div>
<div class="fc-eco-block__stat">
<div>
<span class="fc-eco-block__val">{$metrics.memberCount}</span>
<span class="fc-eco-block__val"><span id="fc-eco-member">{$ecosystem.memberCount}</span> <small class="fc-eco-today">+{:$ecosystem['todayMemberCount']} {:__('今日')}</small></span>
<span class="fc-eco-block__desc">{:__('有效VIP会员')}</span>
</div>
<div>
<span class="fc-eco-block__val">{$ecosystem.memberRate}%</span>
<span class="fc-eco-block__val" id="fc-eco-member-rate">{$ecosystem.memberRate}%</span>
<span class="fc-eco-block__desc">{:__('会员转化率')}</span>
</div>
</div>
@@ -353,11 +400,11 @@
<div class="fc-eco-block__title"><i class="fa fa-shopping-bag text-success" aria-hidden="true"></i> {:__('商户入驻生态')}</div>
<div class="fc-eco-block__stat">
<div>
<span class="fc-eco-block__val">{$metrics.merchantCount}</span>
<span class="fc-eco-block__desc">{:__('入驻商户数')}</span>
<span class="fc-eco-block__val"><span id="fc-eco-merchant">{$ecosystem.merchantCount}</span> <small class="fc-eco-today">+{:$ecosystem['todayMerchantCount']} {:__('今日')}</small></span>
<span class="fc-eco-block__desc">{:__('已审入驻商户')}</span>
</div>
<div>
<span class="fc-eco-block__val">{$metrics.recommendMerchant}</span>
<span class="fc-eco-block__val" id="fc-eco-recommend">{$ecosystem.recommendMerchant}</span>
<span class="fc-eco-block__desc">{:__('推荐商家数')}</span>
</div>
</div>
@@ -368,15 +415,15 @@
<div class="fc-eco-block__title"><i class="fa fa-sitemap text-primary" aria-hidden="true"></i> {:__('二级分销裂变')}</div>
<div class="fc-eco-block__stat">
<div>
<span class="fc-eco-block__val">{$ecosystem.distributorCount}</span>
<span class="fc-eco-block__val"><span id="fc-eco-dist">{$ecosystem.distributorCount}</span> <small class="fc-eco-today">+{:$ecosystem['todayDistributorCount']} {:__('今日')}</small></span>
<span class="fc-eco-block__desc">{:__('推广分销员')}</span>
</div>
<div>
<span class="fc-eco-block__val is-gold">¥{$ecosystem.commissionSettled|number_format=2}</span>
<span class="fc-eco-block__val is-gold"><span id="fc-eco-settled">¥{$ecosystem.commissionSettled|number_format=2}</span> <small class="fc-eco-today">+{:__('今日')} ¥{$ecosystem.todayCommissionSettled|number_format=2}</small></span>
<span class="fc-eco-block__desc">{:__('已结佣金')}</span>
</div>
<div>
<span class="fc-eco-block__val is-muted">¥{$ecosystem.commissionPending|number_format=2}</span>
<span class="fc-eco-block__val is-muted"><span id="fc-eco-pending">¥{$ecosystem.commissionPending|number_format=2}</span> <small class="fc-eco-today">+{:__('今日')} ¥{$ecosystem.todayCommissionPending|number_format=2}</small></span>
<span class="fc-eco-block__desc">{:__('待结佣金')}</span>
</div>
</div>
@@ -386,12 +433,12 @@
</section>
</div>
<!-- 底区:详细数据明细表(支持折叠和多时段联动) -->
<!-- 底区:详细数据明细表(支持折叠和日期区间联动) -->
<details class="fc-card fc-detail" open>
<summary class="fc-detail__summary">
<div class="fc-detail__title-wrap">
<i class="fa fa-table" aria-hidden="true"></i>
<span class="fc-card__title" id="fc-table-title">{:__('每日数据明细 (近 14 天)')}</span>
<span class="fc-card__title" id="fc-table-title">{:__('每日数据明细')} ({$period.label})</span>
</div>
<span class="fc-detail__hint">
<span class="fc-detail__hint-open">{:__('展开明细')}</span>

查看文件

@@ -10,7 +10,7 @@
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('fc/message/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> 添加</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('fc/message/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('fc/message/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a class="btn btn-info btn-recyclebin btn-dialog {:$auth->check('fc/message/recyclebin')?'':'hide'}" href="fc/message/recyclebin" title="{:__('Recycle bin')}"><i class="fa fa-recycle"></i> 回收站</a>
<a class="btn btn-info btn-recyclebin btn-dialog {:$auth->check('fc/message/recyclebin')?'':'hide'}" href="{:url('fc/message/recyclebin')}" title="{:__('Recycle bin')}"><i class="fa fa-recycle"></i> 回收站</a>
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('fc/message/edit')}"

查看文件

@@ -9,7 +9,7 @@
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}">{:__('Refresh')}</a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('fc/post/add')?'':'hide'}" title="{:__('Add')}">{:__('Add')}</a>
<a class="btn btn-default btn-recyclebin btn-dialog {:$auth->check('fc/post/recyclebin')?'':'hide'}" href="fc/post/recyclebin" title="{:__('Recycle bin')}">回收站</a>
<a class="btn btn-default btn-recyclebin btn-dialog {:$auth->check('fc/post/recyclebin')?'':'hide'}" href="{:url('fc/post/recyclebin')}" title="{:__('Recycle bin')}">回收站</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('fc/post/del')?'':'hide'}" title="{:__('Delete')}">删除所选</a>
</div>

查看文件

@@ -29,7 +29,7 @@ class Auth extends V1
{
$code = trim((string)$this->input('code', ''));
if (!$code) {
$this->fail('缺少微信授权 code');
$this->fail('缺少微信授权凭证,请重试');
}
// 频率限制:同一 IP 每分钟最多 30 次授权登录
@@ -159,7 +159,7 @@ class Auth extends V1
} catch (\Throwable $e) {
Db::rollback();
Db::query('SELECT RELEASE_LOCK(?)', [$lockName]);
$this->fail($e->getMessage() ?: '微信登录失败,请重试');
$this->fail($this->friendlyAuthError($e, '微信登录失败,请重试'));
}
Db::query('SELECT RELEASE_LOCK(?)', [$lockName]);
@@ -208,14 +208,14 @@ class Auth extends V1
$code = trim((string)$this->input('code', ''));
if ($code === '') {
$this->fail('缺少手机号授权 code');
$this->fail('缺少手机号授权凭证,请重试');
}
try {
$phone = WxMini::phoneNumber($code);
} catch (\Throwable $e) {
// 常见原因:手机号快捷验证未开通/额度用尽、code 已失效、用户拒绝授权
$this->fail($e->getMessage() ?: '微信手机号获取失败,请改用手动输入');
$this->fail($this->friendlyAuthError($e, '微信手机号获取失败,请改用手动输入'));
}
$conflict = Db::name('user')->where('mobile', $phone)->where('id', '<>', $user['id'])->find();
@@ -372,10 +372,22 @@ class Auth extends V1
if (!WxMini::isConfigured() && config('app_debug')) {
return strpos($code, 'openid_') === 0 ? $code : 'openid_' . md5($code);
}
$this->fail($e->getMessage() ?: '微信登录失败,请重试');
$this->fail($this->friendlyAuthError($e, '微信登录失败,请重试'));
}
}
/**
* 将登录与认证过程中的异常信息转换为用户可理解的中文提示
*
* @param \Throwable $e 捕获到的异常对象
* @param string $fallback 默认中文兜底文案
* @return string 中文错误提示
*/
protected function friendlyAuthError(\Throwable $e, $fallback = '登录失败,请稍后重试')
{
return WxMini::translateException($e, $fallback);
}
/**
* A7 获取当前用户商家认证与商铺资料
* GET /api/v1/auth/merchant
@@ -552,12 +564,12 @@ class Auth extends V1
{
$refresh = trim((string)$this->input('refreshToken', $this->input('refresh_token', '')));
if ($refresh === '') {
$this->fail('缺少 refreshToken');
$this->fail('登录凭证缺失,请重新登录');
}
$this->rateLimit('refresh:' . $this->request->ip(), 20, 60);
if (strpos($refresh, 'rf_') !== 0) {
$this->fail('refreshToken 无效');
$this->fail('登录凭证无效,请重新登录');
}
$row = Db::name('user_token')->where('token', $refresh)->find();
@@ -603,28 +615,34 @@ class Auth extends V1
// 频率限制:同一手机号 + IP,1 分钟最多 5 次
$this->rateLimit('pwdlogin:' . $phone . ':' . $this->request->ip(), 5, 60);
// 查用户:不存在直接失败,不再自动注册(防止批量造号)
$user = Db::name('user')->where('mobile', $phone)->find();
if (!$user) {
$this->fail('手机号未注册,请先使用微信登录');
}
try {
// 查用户:不存在直接失败,不再自动注册(防止批量造号)
$user = Db::name('user')->where('mobile', $phone)->find();
if (!$user) {
$this->fail('手机号未注册,请先使用微信登录');
}
// 校验密码:只认加盐哈希(已移除历史遗留的 123456 万能密码)
$salt = isset($user['salt']) ? (string)$user['salt'] : '';
$checkHash = md5(md5($password) . $salt);
if ((string)$user['password'] !== $checkHash) {
$this->fail('密码错误,请重新输入');
}
// 校验密码:只认加盐哈希(已移除历史遗留的 123456 万能密码)
$salt = isset($user['salt']) ? (string)$user['salt'] : '';
$checkHash = md5(md5($password) . $salt);
if ((string)$user['password'] !== $checkHash) {
$this->fail('密码错误,请重新输入');
}
if ($user['status'] !== 'normal') {
$this->fail('账号已被禁用,请联系客服');
}
if ($user['status'] !== 'normal') {
$this->fail('账号已被禁用,请联系客服');
}
$token = $this->issueToken($user['id']);
$this->ok([
'token' => $token,
'refreshToken' => $this->issueRefreshToken($user['id']),
'userInfo' => $this->userInfo($user),
]);
$token = $this->issueToken($user['id']);
$this->ok([
'token' => $token,
'refreshToken' => $this->issueRefreshToken($user['id']),
'userInfo' => $this->userInfo($user),
]);
} catch (\think\exception\HttpResponseException $e) {
throw $e;
} catch (\Throwable $e) {
$this->fail($this->friendlyAuthError($e, '登录失败,请稍后重试'));
}
}
}

查看文件

@@ -158,12 +158,18 @@ class Post extends V1
}
// 若传入的 categoryId 是二级分类(pid > 0),自动归属其一级大类与二级分类
$catRow = Db::name('fc_category')->where('id', $categoryId)->find();
if ($catRow && !empty($catRow['pid']) && (int)$catRow['pid'] > 0) {
if (!$catRow || (isset($catRow['enabled']) && (int)$catRow['enabled'] === 0)) {
$this->fail('所选分类不存在或已停用');
}
if (!empty($catRow['pid']) && (int)$catRow['pid'] > 0) {
$subCategoryId = (int)$catRow['id'];
$categoryId = (int)$catRow['pid'];
} elseif ($subCategoryId > 0) {
$subRow = Db::name('fc_category')->where('id', $subCategoryId)->find();
if ($subRow && !empty($subRow['pid']) && (int)$subRow['pid'] > 0) {
if (!$subRow || (isset($subRow['enabled']) && (int)$subRow['enabled'] === 0)) {
$this->fail('所选子分类不存在或已停用');
}
if (!empty($subRow['pid']) && (int)$subRow['pid'] > 0) {
$categoryId = (int)$subRow['pid'];
}
}
@@ -290,7 +296,11 @@ class Post extends V1
$identityType = 1;
}
}
$price = max(0, round((float)$this->input('price', 0), 2));
$rawPrice = $this->input('price', 0);
if ($rawPrice !== '' && $rawPrice !== null && (float)$rawPrice < 0) {
$this->fail('价格不能为负数');
}
$price = max(0, round((float)$rawPrice, 2));
$priceUnit = mb_substr(trim((string)$this->input('priceUnit', '')), 0, 16);
if ($price > 0 && $priceUnit === '') {
$priceUnit = '元/斤';
@@ -1375,10 +1385,13 @@ class Post extends V1
$user = $this->auth();
$id = $this->routeId();
$content = trim((string)$this->input('content', ''));
$content = trim(strip_tags((string)$this->input('content', '')));
if ($content === '') {
$this->fail('评价内容不能为空');
}
if (mb_strlen($content) > 500) {
$this->fail('评价内容不能超过 500 字');
}
$score = (int)$this->input('score', 5);
if ($score < 1 || $score > 5) {
@@ -1485,9 +1498,9 @@ class Post extends V1
/**
* P10 评价列表(详情页「用户评价」)
* GET /api/v1/post/:id/comments → [{id,user,score,content,reply,createdAt}]
* 规则:仅 status=1(正常/审核通过)的评价;置顶优先,其余按时间倒序。
* 替代前端详情页原先写死的两条假评价。
* GET /api/v1/post/:id/comments → [{id,user,score,content,reply,status,isMine,createdAt}]
* 规则:正常评价(status=1)对所有人可见;被隐藏评价(status=0)仅评价发布者本人可见;
* 置顶优先,其余按时间倒序。
*/
public function comments()
{
@@ -1496,11 +1509,23 @@ class Post extends V1
$this->fail('信息不存在', 404);
}
$rows = Db::name('fc_comment')->alias('co')
$currentUser = $this->user();
$currentUserId = $currentUser ? (int)$currentUser->id : 0;
$query = Db::name('fc_comment')->alias('co')
->join('user u', 'u.id = co.user_id', 'LEFT')
->where('co.post_id', $id)
->where('co.status', 1)
->field('co.id, co.user_id, co.score, co.content, co.reply, co.replytime, co.top, co.createtime, u.nickname AS nickname')
->where('co.post_id', $id);
if ($currentUserId > 0) {
$query->where(function ($q) use ($currentUserId) {
$q->where('co.status', 1)->whereOr('co.user_id', $currentUserId);
});
} else {
$query->where('co.status', 1);
}
$rows = $query
->field('co.id, co.user_id, co.score, co.content, co.reply, co.replytime, co.top, co.status, co.createtime, u.nickname AS nickname')
->order('co.top desc, co.id desc')
->select();
@@ -1514,6 +1539,8 @@ class Post extends V1
'content' => (string)$row['content'],
'reply' => (string)$row['reply'],
'replytime' => !empty($row['replytime']) ? $this->iso($row['replytime']) : '',
'status' => (int)$row['status'],
'isMine' => ($currentUserId > 0 && (int)$row['user_id'] === $currentUserId),
'createdAt' => $this->iso($row['createtime']),
];
}
@@ -1521,6 +1548,43 @@ class Post extends V1
$this->ok($list);
}
/**
* P12 删除自己的评价
* POST /api/v1/post/comment/:id/delete
*
* @return void
*/
public function deleteComment()
{
$user = $this->auth();
$commentId = $this->routeId();
if ($commentId <= 0) {
$this->fail('评价不存在', 404);
}
$comment = Db::name('fc_comment')->where('id', $commentId)->find();
if (!$comment) {
$this->fail('评价不存在', 404);
}
if ((int)$comment['user_id'] !== (int)$user['id']) {
$this->fail('无权删除他人的评价', 403);
}
Db::name('fc_comment')->where('id', $commentId)->delete();
// 同步刷新对应信息的有效评价数
$validCount = (int)Db::name('fc_comment')
->where('post_id', (int)$comment['post_id'])
->where('status', 1)
->count();
Db::name('fc_post')->where('id', (int)$comment['post_id'])->update([
'comment_count' => $validCount,
'updatetime' => time(),
]);
$this->ok(['commentId' => $commentId]);
}
/**
* 读取路由 :id 参数(兼容 POST 体/查询串传入)
* @return int

查看文件

@@ -7,8 +7,9 @@ use think\Db;
/**
* 用户端 · 举报(Module-REPORT)
* 路由:
* POST /api/v1/report 举报信息/评价
* GET /api/v1/report/my 我的举报记录
* POST /api/v1/report 举报信息/评价
* GET /api/v1/report/my 我的举报记录
* GET /api/v1/report/:id 我的举报记录详情
*
* 说明:举报原因字典由后台配置 fc_config 的 report.reasons(JSON 数组)维护,
* 小程序端从站点配置读取;本接口做「必填 + 类型合法 + 对象存在 + 防重复提交」校验,
@@ -127,9 +128,13 @@ class Report extends V1
public function my()
{
$user = $this->auth();
$status = trim((string)$this->input('status', ''));
list($rows, $total, $page, $size) = $this->pageQuery(function ($forCount) use ($user) {
list($rows, $total, $page, $size) = $this->pageQuery(function ($forCount) use ($user, $status) {
$q = Db::name('fc_report')->where('reporter_id', (int)$user['id']);
if (in_array($status, ['pending', 'handled'], true)) {
$q->where('status', $status);
}
if ($forCount) {
return $q;
}
@@ -138,40 +143,105 @@ class Report extends V1
$list = [];
foreach ($rows as $row) {
$targetTitle = '';
if ($row['target_type'] === 'post') {
$postTitle = Db::name('fc_post')->where('id', $row['target_id'])->value('title');
$targetTitle = $postTitle ? (string)$postTitle : '信息已下架或删除';
} elseif ($row['target_type'] === 'comment') {
$commentContent = Db::name('fc_comment')->where('id', $row['target_id'])->value('content');
$targetTitle = $commentContent ? (mb_substr($commentContent, 0, 30) . (mb_strlen($commentContent) > 30 ? '...' : '')) : '评价已删除';
}
$rawImages = !empty($row['images']) ? explode(',', (string)$row['images']) : [];
$imgUrls = [];
foreach ($rawImages as $img) {
$img = trim((string)$img);
if ($img !== '') {
$imgUrls[] = cdnurl($img, true);
}
}
$list[] = [
'id' => (int)$row['id'],
'targetType' => (string)$row['target_type'],
'targetId' => (int)$row['target_id'],
'targetTitle' => $targetTitle,
'reason' => (string)$row['reason'],
'images' => $imgUrls,
'detail' => (string)$row['remark'],
'status' => (string)$row['status'],
'statusText' => $row['status'] === 'handled' ? '已处理' : '核实中',
'handleRemark' => (string)($row['handle_remark'] ?? ''),
'createdAt' => $this->iso($row['createtime']),
'updatedAt' => $this->iso($row['updatetime']),
];
$list[] = $this->formatReportRow($row, false);
}
$this->ok($this->paginate($list, $total, $page, $size));
}
/**
* 获取当前用户的单条举报记录详情
* GET /api/v1/report/:id
*
* @param int $id 举报记录 ID
* @return void
*/
public function detail($id = 0)
{
$user = $this->auth();
$reportId = (int)$id ?: (int)$this->input('id', 0);
if ($reportId <= 0) {
$this->fail('举报记录不存在', 404);
}
$row = Db::name('fc_report')
->where('id', $reportId)
->where('reporter_id', (int)$user['id'])
->find();
if (!$row) {
$this->fail('举报记录不存在', 404);
}
$this->ok($this->formatReportRow($row, true));
}
/**
* 格式化单条举报记录输出结构(列表与详情共用)
*
* @param array $row fc_report 数据行
* @param bool $includeFullTarget 是否附带完整被举报对象内容与存在状态
* @return array
*/
private function formatReportRow(array $row, $includeFullTarget = false)
{
$targetTitle = '';
$targetContent = '';
$targetExists = false;
if ($row['target_type'] === 'post') {
$post = Db::name('fc_post')
->where('id', $row['target_id'])
->field('id,title,content,deletetime,status')
->find();
$targetExists = !empty($post) && empty($post['deletetime']);
$targetTitle = !empty($post['title']) ? (string)$post['title'] : '信息已下架或删除';
if ($includeFullTarget && !empty($post['content'])) {
$targetContent = (string)$post['content'];
}
} elseif ($row['target_type'] === 'comment') {
$comment = Db::name('fc_comment')
->where('id', $row['target_id'])
->field('id,content')
->find();
$targetExists = !empty($comment);
$commentContent = !empty($comment['content']) ? (string)$comment['content'] : '';
$targetTitle = $commentContent !== ''
? (mb_substr($commentContent, 0, 30) . (mb_strlen($commentContent) > 30 ? '...' : ''))
: '评价已删除';
if ($includeFullTarget) {
$targetContent = $commentContent;
}
}
$rawImages = !empty($row['images']) ? explode(',', (string)$row['images']) : [];
$imgUrls = [];
foreach ($rawImages as $img) {
$img = trim((string)$img);
if ($img !== '') {
$imgUrls[] = cdnurl($img, true);
}
}
$item = [
'id' => (int)$row['id'],
'targetType' => (string)$row['target_type'],
'targetId' => (int)$row['target_id'],
'targetTitle' => $targetTitle,
'targetExists' => $targetExists,
'reason' => (string)$row['reason'],
'images' => $imgUrls,
'detail' => (string)$row['remark'],
'status' => (string)$row['status'],
'statusText' => $row['status'] === 'handled' ? '已处理' : '核实中',
'handleRemark' => (string)($row['handle_remark'] ?? ''),
'createdAt' => $this->iso($row['createtime']),
'updatedAt' => $this->iso($row['updatetime']),
];
if ($includeFullTarget) {
$item['targetContent'] = $targetContent;
}
return $item;
}
}

查看文件

@@ -134,10 +134,15 @@ class WxMini
{
$code = trim((string)$code);
if ($code === '') {
throw new \RuntimeException('缺少微信授权 code');
throw new \RuntimeException('缺少微信授权凭证,请重试');
}
try {
$res = self::toArray(self::app()->auth->session($code));
} catch (\Throwable $e) {
throw new \RuntimeException(self::translateException($e, '微信登录失败,请重试'));
}
$res = self::toArray(self::app()->auth->session($code));
if (empty($res['openid'])) {
throw new \RuntimeException(self::errorMessage($res, '微信登录失败,请重试'));
}
@@ -171,13 +176,17 @@ class WxMini
{
$code = trim((string)$code);
if ($code === '') {
throw new \RuntimeException('缺少手机号授权 code');
throw new \RuntimeException('缺少手机号授权凭证,请重试');
}
// SDK 的 BaseClient 会自动带上 access_token(含缓存与 401 重试)
$res = self::toArray(
self::app()->getClient()->httpPostJson('wxa/business/getuserphonenumber', ['code' => $code])
);
try {
$res = self::toArray(
self::app()->getClient()->httpPostJson('wxa/business/getuserphonenumber', ['code' => $code])
);
} catch (\Throwable $e) {
throw new \RuntimeException(self::translateException($e, '微信手机号获取失败,请改用手动输入'));
}
$info = (isset($res['phone_info']) && is_array($res['phone_info'])) ? $res['phone_info'] : [];
$phone = '';
@@ -284,7 +293,7 @@ class WxMini
*
* @param array $res 微信应答
* @param string $fallback 兜底文案
* @return string
* @return string 用户可理解的中文提示
*/
protected static function errorMessage(array $res, $fallback)
{
@@ -292,16 +301,98 @@ class WxMini
$msg = isset($res['errmsg']) ? (string)$res['errmsg'] : '';
$known = [
40029 => '微信登录凭证已失效,请重新授权',
40163 => '微信登录凭证已被使用,请重新授权',
41004 => '小程序 AppSecret 不正确,请在后台检查微信登录配置',
45011 => '微信接口调用过于频繁,请稍后再试',
-1 => '微信服务繁忙,请稍后再试',
40001 => '微信授权凭证无效,请联系管理员检查小程序配置',
40002 => '微信授权参数异常,请重新尝试',
40013 => '小程序 AppID 配置无效,请联系管理员检查',
40029 => '微信登录凭证已失效,请重新授权',
40125 => '小程序 AppSecret 配置无效,请联系管理员检查',
40163 => '微信登录凭证已被使用,请重新授权',
40164 => '服务器 IP 未加入微信白名单,请联系管理员处理',
40226 => '当前微信账号存在安全风险,暂无法登录',
41002 => '缺少小程序 AppID 配置,请联系管理员检查',
41004 => '小程序 AppSecret 不正确,请在后台检查微信登录配置',
43002 => '微信接口请求方式异常,请重试',
45009 => '今日微信接口调用次数已达上限,请稍后再试',
45011 => '微信接口调用过于频繁,请稍后再试',
48001 => '当前小程序暂未开通该接口权限,请联系管理员',
50002 => '当前微信账号状态受限,无法完成操作',
89503 => '微信接口调用受限,请稍后再试',
89506 => '微信接口调用受限,请稍后再试',
89507 => '微信接口调用受限,请稍后再试',
];
if (isset($known[$code])) {
return $known[$code];
}
return $msg !== '' ? $fallback . '(' . $code . ': ' . $msg . ')' : $fallback;
if ($msg !== '') {
$lower = strtolower($msg);
if (strpos($lower, 'invalid appid') !== false) {
return '小程序 AppID 配置无效,请联系管理员检查';
}
if (strpos($lower, 'invalid appsecret') !== false) {
return '小程序 AppSecret 配置无效,请联系管理员检查';
}
if (strpos($lower, 'invalid code') !== false) {
return '微信登录凭证已失效,请重新授权';
}
if (strpos($lower, 'code been used') !== false) {
return '微信登录凭证已被使用,请重新授权';
}
if (strpos($lower, 'freq') !== false || strpos($lower, 'limit') !== false) {
return '微信接口调用过于频繁,请稍后再试';
}
if (strpos($lower, 'system error') !== false || strpos($lower, 'busy') !== false) {
return '微信服务繁忙,请稍后再试';
}
\think\Log::error('[WxMini] 微信接口返回未映射错误: errcode=' . $code . ', errmsg=' . $msg);
}
return $code !== 0 ? $fallback . '(错误码:' . $code . ')' : $fallback;
}
/**
* 将微信 SDK / 网络 / 系统异常转换为用户可理解的中文提示
*
* @param \Throwable $e 捕获的异常
* @param string $fallback 默认中文兜底文案
* @return string 中文错误提示
*/
public static function translateException(\Throwable $e, $fallback = '微信服务异常,请稍后再试')
{
$raw = trim((string)$e->getMessage());
if ($raw === '') {
return $fallback;
}
// 若消息本身已包含中文且不含底层英文错误特征(如 SQLSTATE / cURL / JSON 报错),直接透传
if (preg_match('/[\x{4e00}-\x{9fa5}]/u', $raw)
&& stripos($raw, 'SQLSTATE') === false
&& stripos($raw, 'cURL error') === false
&& stripos($raw, 'Request access_token fail') === false
) {
return $raw;
}
// 尝试从 EasyWeChat 异常消息中解析微信 JSON 错误(如 Request access_token fail: {"errcode":40013,"errmsg":"invalid appid"})
if (preg_match('/\{.*"errcode"\s*:\s*-?\d+.*\}/s', $raw, $matches)) {
$decoded = json_decode($matches[0], true);
if (is_array($decoded) && isset($decoded['errcode'])) {
return self::errorMessage($decoded, $fallback);
}
}
$lower = strtolower($raw);
if (strpos($lower, 'timed out') !== false || strpos($lower, 'timeout') !== false || strpos($lower, 'curl error 28') !== false) {
\think\Log::error('[WxMini] 请求微信超时: ' . $raw);
return '连接微信服务器超时,请稍后重试';
}
if (strpos($lower, 'curl error') !== false || strpos($lower, 'could not resolve') !== false || strpos($lower, 'failed to connect') !== false || strpos($lower, 'ssl') !== false) {
\think\Log::error('[WxMini] 请求微信网络异常: ' . $raw);
return '网络连接微信服务器失败,请稍后重试';
}
\think\Log::error('[WxMini] 微信调用异常: ' . $raw);
return $fallback;
}
}

查看文件

@@ -55,6 +55,7 @@ return [
'api/v1/post/:id/dial' => 'api/Post/dial',
'api/v1/post/:id/pay-view' => 'api/Post/payView',
'api/v1/post/comment/:id/reply' => 'api/Post/replyComment',
'api/v1/post/comment/:id/delete' => 'api/Post/deleteComment',
'api/v1/post/:id/comment' => 'api/Post/comment',
'api/v1/post/:id/comments' => 'api/Post/comments',
'api/v1/post/create' => 'api/Post/create',
@@ -77,8 +78,10 @@ return [
* favorite/status、follow/toggle、follow/list),彼此不构成前缀包含关系,注册顺序互不吞并;
* 且本表未登记 favorite/:id、follow/:id、report/:id 之类通配规则,不存在被吞风险。
*/
'api/v1/report' => 'api/Report/create',
'api/v1/report/my' => 'api/Report/my',
'api/v1/report/detail' => 'api/Report/detail',
'api/v1/report/:id' => 'api/Report/detail',
'api/v1/report' => 'api/Report/create',
'api/v1/favorite/list' => 'api/Favorite/list',
'api/v1/favorite/toggle' => 'api/Favorite/toggle',
'api/v1/favorite/status' => 'api/Favorite/status',