- 新增地址选择插件,支持地图位置选择并返回地址和经纬度 - 新增微信订阅消息发送功能,支持审核结果、提现通知等场景 - 新增订单支付状态查询、提现收款人姓名保存等接口 - 新增服务区域管理,支持按省市区划分并同步到信息发布 - 新增资金流水和营收报表导出功能 - 新增可用优惠券查询、订单退款拆分处理等功能 - 优化后台角标显示、首页数据统计、UI配置下发等 - 修复订单支付并发问题、地区管理逻辑等
117 行
3.8 KiB
PHP
117 行
3.8 KiB
PHP
<?php
|
||
|
||
namespace app\api\controller;
|
||
|
||
use think\Db;
|
||
|
||
/**
|
||
* 后台管理端 · 评价管理(Module-ADM-COMMENT)
|
||
* 路由:
|
||
* GET /api/v1/admin/comments AC1 评价列表
|
||
* POST /api/v1/admin/comment/:id/reply AC2 评价回复
|
||
* GET /api/v1/admin/reports AC3 举报列表
|
||
*/
|
||
class AdminComment extends V1
|
||
{
|
||
/** 管理端接口必须校验管理员身份(V1 默认关闭了 URI 权限校验) */
|
||
public function _initialize()
|
||
{
|
||
parent::_initialize();
|
||
$this->adminOnly();
|
||
}
|
||
|
||
/**
|
||
* AC1 评价列表
|
||
* GET /api/v1/admin/comments 入参 {page,size}
|
||
* → 分页 {list:[{id,postId,postTitle,user,score,content,images,reply,top,createdAt}],page,size,total,hasMore}
|
||
*/
|
||
public function index()
|
||
{
|
||
// 闭包重建查询:TP5.0 的 count() 会清空 Query::options,不能复用同一对象
|
||
list($rows, $total, $page, $size) = $this->pageQuery(function ($forCount) {
|
||
$q = Db::name('fc_comment')->alias('co')
|
||
->join('fc_post p', 'p.id = co.post_id', 'LEFT')
|
||
->join('user u', 'u.id = co.user_id', 'LEFT');
|
||
if ($forCount) {
|
||
return $q;
|
||
}
|
||
return $q->field('co.*, p.title AS post_title, u.nickname AS nickname')
|
||
->order('co.id desc');
|
||
});
|
||
|
||
$list = [];
|
||
foreach ($rows as $row) {
|
||
$list[] = [
|
||
'id' => (int)$row['id'],
|
||
'postId' => (int)$row['post_id'],
|
||
'postTitle' => (string)$row['post_title'],
|
||
'user' => (string)$row['nickname'],
|
||
'score' => (int)$row['score'],
|
||
'content' => (string)$row['content'],
|
||
'images' => $this->jsonArr($row['images']),
|
||
'reply' => (string)$row['reply'],
|
||
'top' => (bool)$row['top'],
|
||
'createdAt' => $this->iso($row['createtime']),
|
||
];
|
||
}
|
||
|
||
$this->ok($this->paginate($list, $total, $page, $size));
|
||
}
|
||
|
||
/**
|
||
* AC2 评价回复
|
||
* POST /api/v1/admin/comment/:id/reply 入参 {id?,reply} → {id,reply}
|
||
*/
|
||
public function reply()
|
||
{
|
||
$id = (int)$this->request->param('id', 0);
|
||
if (!$id) {
|
||
$id = (int)$this->input('id', 0);
|
||
}
|
||
$reply = trim((string)$this->input('reply', ''));
|
||
|
||
if ($reply === '') {
|
||
$this->fail('回复内容不能为空');
|
||
}
|
||
|
||
$comment = Db::name('fc_comment')->where('id', $id)->find();
|
||
if (!$comment) {
|
||
$this->fail('评价不存在', 404);
|
||
}
|
||
|
||
Db::name('fc_comment')->where('id', $id)->update([
|
||
'reply' => $reply,
|
||
'replytime' => time(),
|
||
]);
|
||
|
||
$this->notify($comment['user_id'], 'interact', '评价已回复', '您的评价收到商家回复:' . $reply);
|
||
$this->adminLog('回复评价 #' . $id);
|
||
|
||
$this->ok(['id' => (int)$id, 'reply' => $reply]);
|
||
}
|
||
|
||
/**
|
||
* AC3 举报列表
|
||
* GET /api/v1/admin/reports → 数组 [{id,targetType,targetId,reason,reporter,status,createdAt}]
|
||
*/
|
||
public function reports()
|
||
{
|
||
$rows = Db::name('fc_report')->order('createtime desc')->select();
|
||
|
||
$list = [];
|
||
foreach ($rows as $row) {
|
||
$list[] = [
|
||
'id' => (int)$row['id'],
|
||
'targetType' => (string)$row['target_type'],
|
||
'targetId' => (int)$row['target_id'],
|
||
'reason' => (string)$row['reason'],
|
||
'reporter' => (string)$row['reporter_id'],
|
||
'status' => (string)$row['status'],
|
||
'createdAt' => $this->iso($row['createtime']),
|
||
];
|
||
}
|
||
|
||
$this->ok($list);
|
||
}
|
||
}
|