Files
huangjingfen/pro_v3.5.1_副本/app/services/activity/video/VideoCommentServices.php
apple 434aa8c69d feat(fsgx): 完成全部24项开发任务 Phase1-7
Phase1 后端核心:
- 新增 fsgx_v1.sql 迁移脚本(is_queue_goods/frozen_points/available_points/no_assess)
- SystemConfigServices 返佣设置扩展(周期人数/分档比例/范围/时机)
- StoreOrderCreateServices 周期循环佣金计算
- StoreOrderTakeServices 佣金发放后同步冻结积分
- StoreProductServices/StoreProduct 保存 is_queue_goods

Phase2 后端接口:
- GET /api/hjf/brokerage/progress 佣金周期进度
- GET /api/hjf/assets/overview 资产总览
- HjfPointsServices 每日 frozen_points 0.4‰ 释放定时任务
- PUT /adminapi/hjf/member/{uid}/no_assess 不考核接口
- GET /adminapi/hjf/points/release_log 积分日志接口

Phase3 前端清理:
- hjfCustom.js 路由精简(仅保留 points/log)
- hjfQueue.js/hjfMember.js API 清理/重定向至 CRMEB 原生接口
- pages.json 公排→推荐佣金/佣金记录/佣金规则

Phase4-5 前端改造:
- queue/status.vue 推荐佣金进度页整体重写
- 商品详情/订单确认/支付结果页文案与逻辑改造
- 个人中心/资产页/引导页/规则页文案改造
- HjfQueueProgress/HjfRefundNotice/HjfAssetCard 组件改造
- 推广中心嵌入佣金进度摘要
- hjfMockData.js 全量更新(公排字段→佣金字段)

Phase6 Admin 增强:
- 用户列表新增 frozen_points/available_points 列及不考核操作按钮
- hjfPoints.js USE_MOCK=false 对接真实积分日志接口

Phase7 配置文档:
- docs/fsgx-phase7-config-checklist.md 后台配置与全链路验收清单

Made-with: Cursor
2026-03-23 22:32:19 +08:00

257 lines
9.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\services\activity\video;
use app\dao\activity\video\VideoCommentDao;
use app\services\BaseServices;
use app\services\user\UserRelationServices;
use app\services\user\UserServices;
use crmeb\exceptions\AdminException;
use crmeb\services\FormBuilder as Form;
use think\annotation\Inject;
use think\exception\ValidateException;
use think\facade\Route as Url;
/**
* Class VideoCommentServices
* @package app\services\activity\video
* @mixin VideoCommentDao
*/
class VideoCommentServices extends BaseServices
{
/**
* @var VideoCommentDao
*/
#[Inject]
protected VideoCommentDao $dao;
/**
* 视频评价列表
* @param array $where
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function sysPage(array $where)
{
$where['pid'] = 0;
$where['is_del'] = 0;
[$page, $limit] = $this->getPageValue();
$with = ['video', 'replyContent'];
$list = $this->dao->getList($where, '*', $with, $page, $limit);
$count = $this->dao->count($where);
return compact('list', 'count');
}
/**
* 回复评论
* @param int $id
* @param string $content
*/
public function setReply(int $id, string $content)
{
if ($content == '') throw new AdminException('请输入回复内容');
$comment = $this->dao->get($id);
if (!$comment) {
throw new AdminException('回复的评论不存在');
}
$save = [];
$save['type'] = $comment['type'];
$save['relation_id'] = $comment['relation_id'];
$save['pid'] = $comment['pid'] ? $comment['pid'] : $id;
$save['video_id'] = $comment['video_id'];
$save['content'] = $content;
$save['nickname'] = sys_config('site_name');
$save['avatar'] = sys_config('wap_login_logo');
$where = ['video_id' => $comment['video_id'], 'uid' => 0, 'pid' => $id, 'is_del' => 0];
if ($this->dao->count($where)) {
$res = $this->dao->update($where, ['content' => $content, 'update_time' => time()]);
} else {
$save['add_time'] = time();
$res = $this->dao->save($save);
/** @var VideoServices $videoServices */
$videoServices = app()->make(VideoServices::class);
$videoServices->bcInc($comment['video_id'], 'comment_num', '1');
}
if (!$res) throw new AdminException('回复失败,请稍后再试');
$this->dao->update($id, ['is_reply' => 1]);
return true;
}
/**
* 获取评论回复列表
* @param int $id
* @param array $where
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getCommentReplyList(int $id, array $where)
{
$comment = $this->dao->get($id);
if (!$comment) {
throw new AdminException('回复的评论不存在');
}
$where['pid'] = $id;
$where['is_del'] = 0;
[$page, $limit] = $this->getPageValue();
$list = $this->dao->getList($where, '*', ['video', 'user' => function ($query) {
$query->field('uid,avatar,nickname,is_money_level');
}, 'children' => function ($query) {
$query->with([
'user' => function ($query) {
$query->field('uid,avatar,nickname,is_money_level');
}
]);
}], $page, $limit);
$count = $this->dao->count($where);
return compact('list', 'count');
}
/**
* 创建虚拟评论表单
* @param int $video_id
* @param $store_id
* @return mixed
*/
public function createForm(int $video_id, $store_id = 0)
{
if ($video_id == 0) {
$field[] = Form::frameImage('video', '视频', Url::buildUrl($store_id ? 'store/video.shortVideo/index' : 'admin/video.shortVideo/index', array('fodder' => 'video')))->icon('ios-add')->width('960px')->height('560px')->modal(['footer-hide' => true])->Props(['srcKey' => 'image']);
} else {
$field[] = Form::hidden('video_id', $video_id);
}
$field[] = Form::frameImage('avatar', '用户头像', Url::buildUrl($store_id ? 'store/widget.images/index' : 'admin/widget.images/index', array('fodder' => 'avatar')))->icon('ios-add')->width('960px')->height('505px')->modal(['footer-hide' => true]);
$field[] = Form::input('nickname', '用户名称')->col(24);
$field[] = Form::input('content', '评价文字')->type('textarea');
$field[] = Form::dateTime('add_time', '评论时间', '')->placeholder('请选择评论时间(不选择默认当前添加时间)');
return create_form('添加虚拟评论', $field, Url::buildUrl('/marketing/video/comment/save_fictitious'), 'POST');
}
/**
* 保存评价、回复
* @param int $uid
* @param int $video_id
* @param $id
* @param array $data
* @return \crmeb\basic\BaseModel|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function saveComment(int $uid, int $video_id, $id, array $data)
{
/** @var VideoServices $videoServices */
$videoServices = app()->make(VideoServices::class);
$video = $videoServices->get($video_id);
if (!$video) {
throw new AdminException('评论的视频不存在');
}
$pid = $id;
if ($id) {//回复评价
$comment = $this->dao->get($id);
if (!$comment) {
throw new ValidateException('评论不存在或已删除');
}
if ($comment['pid']) $pid = $comment['pid'];
}
if ($uid && $uid != -1) {
/** @var UserServices $userServices */
$userServices = app()->make(UserServices::class);
$userInfo = $userServices->getUserInfo($uid);
if (!$userInfo) {
throw new ValidateException('用户不存在');
}
$data['nickname'] = $userInfo['nickname'] ?? '';
$data['avatar'] = $userInfo['avatar'] ?? '';
}
//ip转城市信息
if (isset($data['ip']) && $data['ip']) {
$data['city'] = $this->convertIp($data['ip']);
}
$data['uid'] = $uid;
$data['video_id'] = $video_id;
$data['pid'] = $pid;
$data['type'] = $video['type'];
$data['relation_id'] = $video['relation_id'];
$time = time();
if (isset($data['add_time']) && $data['add_time']) {
if ($data['add_time'] > $time) {
throw new AdminException('评论时间应小于当前时间');
}
$data['add_time'] = strtotime($data['add_time']);
} else {
$data['add_time'] = $time;
}
$res = $this->dao->save($data);
/** @var VideoServices $videoServices */
$videoServices = app()->make(VideoServices::class);
$videoServices->bcInc($video_id, 'comment_num', 1);
if (!$res) throw new AdminException('保存评论失败');
return $res;
}
/**
* 获取短视频评价列表
* @param int $uid
* @param int $id
* @param int $pid
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getVideoCommentList(int $uid, int $id, int $pid = 0)
{
$where = ['video_id' => $id, 'is_del' => 0];
[$page, $limit] = $this->getPageValue();
if ($limit > 20) $limit = 20;
if ($pid) {
$comment = $this->dao->get($pid);
if (!$comment) {
throw new ValidateException('评论不存在或已删除');
}
$where['video_id'] = $comment['video_id'];
}
$where['pid'] = $pid;
$list = $this->dao->getList($where, 'id,pid,video_id,uid,nickname,avatar,content,like_num,city,add_time', ['children' => function ($query) {
$query->field("id,pid")->with(['userVip']);
}, 'userVip'], $page, $limit);
if ($list) {
$userLike = [];
if ($uid) {
$ids = array_column($list, 'id');
/** @var UserRelationServices $userRelationServices */
$userRelationServices = app()->make(UserRelationServices::class);
$userLike = $userRelationServices->getColumn([['uid', '=', $uid], ['relation_id', 'in', $ids], ['category', '=', 'video_comment'], ['type', '=', 'like']], 'id,relation_id', 'relation_id');
}
foreach ($list as &$item) {
$item['add_time'] = $item['add_time'] ? date('Y-m-d H:i:s', $item['add_time']) : '';
$item['is_like'] = isset($userLike[$item['id']]);
$item['reply'] = [];
$item['reply_count'] = isset($item['children']) ? (int)count($item['children']) : 0;
$item['city'] = $this->addressHandle($item['city'])['city'] ?? '';
unset($item['children']);
}
}
return $list;
}
}