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

306 lines
9.2 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\user;
use app\Request;
use app\services\product\product\StoreProductLogServices;
use app\services\user\UserServices;
use app\services\wechat\WechatUserServices;
use think\annotation\Inject;
/**
* 用户类
* Class User
* @package app\api\controller\store
*/
class User
{
/**
* @var UserServices
*/
#[Inject]
protected UserServices $services;
/**
* 获取用户信息
* @param Request $request
* @return mixed
*/
public function userInfo(Request $request)
{
$info = $request->user()->toArray();
return app('json')->success($this->services->userInfo($info));
}
/**
* 用户资金统计
* @param Request $request
* @return mixed
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function balance(Request $request)
{
$uid = (int)$request->uid();
return app('json')->successful($this->services->balance($uid));
}
/**
* 个人中心
* @param Request $request
* @return mixed
*/
public function user(Request $request)
{
$user = $request->user()->toArray();
return app('json')->success($this->services->personalHome($user, $request->tokenData()));
}
/**
* 获取活动状态
* @return mixed
*/
public function activity()
{
return app('json')->successful($this->services->activity());
}
/**
* 用户修改信息
* @param Request $request
* @return mixed
*/
public function edit(Request $request)
{
[$avatar, $nickname, $extend_info] = $request->postMore([
['avatar', ''],
['nickname', ''],
['extend_info', []]
], true);
if (!$avatar && $nickname == '') {
return app('json')->fail('请输入昵称或者选择头像');
}
$uid = (int)$request->uid();
$this->services->saveExtendForm($uid, $extend_info, ['avatar' => $avatar, 'nickname' => $nickname], true);
return app('json')->success('修改成功');
}
/**
* 推广人排行
* @param Request $request
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function rank(Request $request)
{
$data = $request->getMore([
['page', ''],
['limit', ''],
['type', '']
]);
$data['uid'] = $request->uid();
$info = $this->services->getRankList($data);
$info['avatar'] = $request->user()['avatar'];
$info['nickname'] = $request->user()['nickname'];
$info['uid'] = $request->uid();
return app('json')->success($info);
}
/**
* 添加访问记录
* @param Request $request
* @return mixed
*/
public function set_visit(Request $request)
{
$data = $request->postMore([
['url', ''],
['stay_time', 0]
]);
if ($data['url'] == '') return app('json')->fail('未获取页面路径');
$data['uid'] = (int)$request->uid();
$data['ip'] = $request->ip();
if ($this->services->setVisit($data)) {
return app('json')->success('添加访问记录成功');
} else {
return app('json')->fail('添加访问记录失败');
}
}
/**
* 静默绑定推广人
* @param Request $request
* @return mixed
*/
public function spread(Request $request)
{
[$spreadUid, $code] = $request->postMore([
['puid', 0],
['code', 0]
], true);
$uid = (int)$request->uid();
$this->services->spread($uid, (int)$spreadUid, $code);
return app('json')->success();
}
/**
* 推荐用户
* @param Request $request
* @return mixed
*
* grade == 0 获取一级推荐人
* grade == 1 获取二级推荐人
*
* keyword 会员名称查询
*
* sort childCount ASC/DESC 团队排序 numberCount ASC/DESC 金额排序 orderCount ASC/DESC 订单排序
*/
public function spread_people(Request $request)
{
$spreadInfo = $request->postMore([
['grade', 0],
['keyword', ''],
['sort', ''],
['start', 0],
['stop', 0],
['type', 0],
]);
if (!in_array($spreadInfo['grade'], [0, 1])) {
return app('json')->fail('等级错误');
}
$spreadInfo['time'] = [$spreadInfo['start'], $spreadInfo['stop']];
$uid = $request->uid();
return app('json')->successful($this->services->getUserSpreadGrade($uid, $spreadInfo['grade'], $spreadInfo['sort'], $spreadInfo['keyword'], $spreadInfo['time'], $spreadInfo['type']));
}
public function peopleHead()
{
}
/**
* 是否关注
* @param Request $request
* @return mixed
*/
public function subscribe(Request $request)
{
if ($request->uid()) {
/** @var WechatUserServices $wechatUserService */
$wechatUserService = app()->make(WechatUserServices::class);
$subscribe = (bool)$wechatUserService->value(['uid' => $request->uid()], 'subscribe');
return app('json')->success(['subscribe' => $subscribe]);
} else {
return app('json')->success(['subscribe' => true]);
}
}
/**
* 用户付款code
* @param Request $request
* @return mixed
*/
public function randCode(Request $request)
{
$uid = (int)$request->uid();
$code = $this->services->getRandCode((int)$uid);
return app('json')->success(['code' => $code]);
}
/**
* 商品浏览记录
* @param Request $request
* @param StoreProductLogServices $services
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function visitList(Request $request, StoreProductLogServices $services)
{
$where['uid'] = (int)$request->uid();
$where['type'] = 'visit';
$result = $services->getList($where, 'product_id', 'id,product_id,max(add_time) as add_time');
$time_data = [];
if ($result['list']) {
foreach ($result['list'] as $key => &$item) {
$add_time = strtotime($item['add_time']);
if (date('Y') == date('Y', $add_time)) {//今年
$item['time_key'] = date('m月d日', $add_time);
} else {
$item['time_key'] = date('Y年m月d日', $add_time);
}
}
$time_data = array_merge(array_unique(array_column($result['list'], 'time_key')));
}
$result['time'] = $time_data;
return app('json')->success($result);
}
/**
* 商品浏览记录删除
* @param Request $request
* @param StoreProductLogServices $services
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function visitDelete(Request $request, StoreProductLogServices $services)
{
$uid = (int)$request->uid();
[$ids] = $request->postMore([
['ids', []],
], true);
if ($ids) {
$where = ['uid' => $uid, 'product_id' => $ids];
$services->update($where, ['delete_time' => date('Y-m-d H:i:s')]);
}
return app('json')->success('删除成功');
}
/**
* 用户注销
* @param Request $request
* @return mixed
*/
public function cancelUser(Request $request)
{
$uid = $request->uid();
if (!$uid) return app('json')->fail('用户不存在');
event('user.cancelUser', [$uid]);
return app('json')->success('注销成功');
}
/**
* 切换身份
* @param Request $request
* @return \think\Response
* User: liusl
* DateTime: 2025/4/8 下午3:17
*/
public function switchIdentity(Request $request)
{
[$identity] = $request->postMore([
['identity', 0],
], true);
$uid = (int)$request->uid();
if (!$uid) return app('json')->fail('用户不存在');
$this->services->switchIdentity($uid, (int)$identity);
return app('json')->success('切换成功');
}
}