Files
huangjingfen/pro_v3.5.1_副本/app/controller/api/v1/activity/Video.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

245 lines
8.7 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>
// +----------------------------------------------------------------------
namespace app\controller\api\v1\activity;
use app\Request;
use app\services\activity\video\VideoCommentServices;
use app\services\activity\video\VideoServices;
use app\services\product\product\StoreProductServices;
use app\services\user\UserRelationServices;
use think\annotation\Inject;
/**
* 短视频类
* Class Video
* @package app\api\controller\activity
*/
class Video
{
/**
* @var VideoServices
*/
#[Inject]
protected VideoServices $services;
/**
* 获取短视频列表
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function list(Request $request)
{
[$order_type, $id] = $request->getMore([
['order_type', ''],
['id', 0]
], true);
return app('json')->success($this->services->getVideoList((int)$request->uid(), '*', (int)$order_type, (int)$id));
}
/**
* 短视频详情
* @param $id
* @return \think\Response
*/
public function info($id)
{
if (!(int)$id) return app('json')->fail('缺少参数');
$data = [];
// $data['videoInfo'] = $this->services->get((int)$id);
$data['recommend'] = $this->services->getRecommend((int)$id);
return app('json')->success($data);
}
/**
* 获取短视频评价列表
* @param Request $request
* @param VideoCommentServices $commentServices
* @param $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function commentList(Request $request, VideoCommentServices $commentServices, $id)
{
if (!(int)$id) return app('json')->fail('缺少参数');
return app('json')->success($commentServices->getVideoCommentList((int)$request->uid(), (int)$id));
}
/**
* 获取短视频评价回复列表
* @param Request $request
* @param VideoCommentServices $commentServices
* @param $pid
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function commentReplyList(Request $request, VideoCommentServices $commentServices, $pid)
{
if (!(int)$pid) return app('json')->fail('缺少参数');
return app('json')->success($commentServices->getVideoCommentList((int)$request->uid(), 0, (int)$pid));
}
/**
* 短视频关联商品
* @param Request $request
* @param StoreProductServices $productServices
* @param $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function productList(Request $request, StoreProductServices $productServices, $id)
{
if (!$id) return app('json')->fail('缺少参数');
$video = $this->services->getVideoInfo((int)$id);
$list = [];
$count = 0;
if ($video['product_id']) {
$ids = is_string($video['product_id']) ? explode(',', $video['product_id']) : $video['product_id'];
$where = ['ids' => $ids];
$list = $productServices->getGoodsList($where, (int)$request->uid());
$newList = [];
foreach ($list as $key => $item) {
$item['promotions'] = !isset($item['promotions']) || !$item['promotions'] ? (object)[] : $item['promotions'];
if ($item['relation_id'] && $item['type'] == 1) {
$item['store_id'] = $item['relation_id'];
} else {
$item['store_id'] = 0;
}
$newList[$key] = $item;
}
$where['is_verify'] = 1;
$where['is_show'] = 1;
$where['is_del'] = 0;
$count = $productServices->getCount($where);
$list = get_thumb_water($newList, 'small');
}
return app('json')->success(compact('list', 'count'));
}
/**
* 短视频点赞、收藏、分享(再次点击取消)
* @param Request $request
* @param $id
* @param $type
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function relation(Request $request, $id, $type = 'like')
{
if (!$id) return app('json')->fail('缺少参数');
if (!in_array($type, ['like', 'collect', 'share'])) {
return app('json')->fail('类型错误');
}
$uid = (int)$request->uid();
$this->services->userRelationVideo($uid, $id, $type);
return app('json')->success();
}
/**
* 保存评价
* @param Request $request
* @param VideoCommentServices $commentServices
* @param $video_id
* @param $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function saveComment(Request $request, VideoCommentServices $commentServices, $id, $pid = 0)
{
if (!$id) return app('json')->fail('缺少参数');
[$content] = $request->getMore([
['content', '']
], true);
if (!$content) {
return app('json')->fail('请输入评论内容');
}
$uid = (int)$request->uid();
$comment = $commentServices->saveComment($uid, (int)$id, (int)$pid, ['content' => $content, 'ip' => $request->ip()]);
return app('json')->success('评价成功', $comment->toArray());
}
/**
* 评论点赞(再次点击取消)
* @param Request $request
* @param UserRelationServices $userRelationServices
* @param $id
* @param $type
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function commentRelation(Request $request, UserRelationServices $userRelationServices, VideoCommentServices $commentServices, $id, $type = 'like')
{
if (!$id) return app('json')->fail('缺少参数');
if (!in_array($type, ['like', 'collect', 'share'])) {
return app('json')->fail('类型错误');
}
$comment = $commentServices->get($id);
if (!$comment) {
return app('json')->fail('评论不存在或已删除');
}
$uid = (int)$request->uid();
$data = ['uid' => $uid, 'relation_id' => $id, 'category' => UserRelationServices::CATEGORY_VIDEO_COMMENT, 'type' => $type];
$relation = $userRelationServices->get($data);
if ($relation) {//取消
$userRelationServices->delete($relation['id']);
$commentServices->bcDec($id, $type . '_num', 1);
$status = 0;
} else {
$data['add_time'] = time();
$userRelationServices->save($data);
$commentServices->bcInc($id, $type . '_num', 1);
$status = 1;
}
return app('json')->success(($status == 1 ? '取消' : '') . (UserRelationServices::TYPE_NAME[$type] ?? '收藏') . '成功');
}
/**
* 撤销评价
* @param Request $request
* @param VideoCommentServices $commentServices
* @param $id
* @return mixed
*/
public function commentDelete(Request $request, VideoCommentServices $commentServices, $id)
{
if (!$id) return app('json')->fail('缺少参数');
$comment = $commentServices->get($id);
if (!$comment) {
return app('json')->fail('评论不存在或已删除');
}
$uid = (int)$request->uid();
if ($comment['uid'] != $uid) {
return app('json')->fail('只能撤销自己的评价');
}
$commentServices->update($id, ['is_del' => 1]);
$this->services->bcDec($comment['video_id'], 'comment_num', 1);
return app('json')->success('撤销成功');
}
}