Files
huangjingfen/pro_v3.5.1_副本/app/controller/out/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

280 lines
9.3 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\out;
use app\Request;
use app\services\user\UserServices;
use app\services\user\level\UserLevelServices;
use think\annotation\Inject;
/**
* 用户类
* Class StoreProductController
* @package app\api\controller\store
*/
class User
{
/**
* 用户services
* @var UserServices
*/
#[Inject]
protected UserServices $services;
/**
* 用户等级列表
* @param Request $request
* @return mixed
*/
public function levelList(Request $request)
{
$where = $request->getMore([
['page', 0],
['limit', 10],
['title', ''],
['is_show', ''],
]);
/** @var UserLevelServices $levelServices */
$levelServices = app()->make(UserLevelServices::class);
return app('json')->success($levelServices->getSytemList($where));
}
/**
* 用户列表
* @return mixed
*/
public function userList(Request $request)
{
$where = $request->postMore([
['uid', 0],
]);
if ($where['uid']) {
$where['uid'] = is_string($where['uid']) ? stringToIntArray($where['uid']) : $where['uid'];
} else {
$where['uid'] = [];
}
return app('json')->success($this->services->index($where));
}
/**
* 添加用户
* @param Request $request
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function userSave(Request $request)
{
$data = $request->postMore([
['is_promoter', 0],
['real_name', ''],
['card_id', ''],
['birthday', ''],
['mark', ''],
['status', 0],
['level', 0],
['phone', 0],
['addres', ''],
['label_id', []],
['group_id', 0],
['pwd', ''],
['true_pwd', ''],
['spread_open', 1],
['sex', 0],
['provincials', ''],
['province', 0],
['city', 0],
['area', 0],
['street', 0],
['extend_info', []],
['adminId', 0],
]);
if ($data['phone']) {
if (!check_phone($data['phone'])) {
return app('json')->fail('手机号码格式不正确');
}
if ($this->services->count(['phone' => $data['phone']])) {
return app('json')->fail('手机号已经存在不能添加相同的手机号用户');
}
$data['nickname'] = substr_replace($data['phone'], '****', 3, 4);
}
if ($data['card_id']) {
try {
if (!check_card($data['card_id'])) return $this->fail('请输入正确的身份证');
} catch (\Throwable $e) {
// return $this->fail('请输入正确的身份证');
}
}
if ($data['birthday']) {
if (strtotime($data['birthday']) > time()) return app('json')->fail('生日请选择今天之前日期');
}
if ($data['pwd']) {
if (strlen($data['pwd']) < 6) {
return app('json')->fail('密码长度最小6位');
}
if ($data['pwd'] == '123456') {
return app('json')->fail('您设置的密码太过简单');
}
$data['pwd'] = md5($data['pwd']);
} else {
unset($data['pwd']);
}
unset($data['true_pwd']);
$data['avatar'] = sys_config('h5_avatar');
$data['user_type'] = 'h5';
$labels = $data['label_id'];
unset($data['label_id']);
foreach ($labels as $k => $v) {
if (!$v) {
unset($labels[$k]);
}
}
$data['add_time'] = time();
$data['extend_info'] = $this->services->handelExtendInfo($data['extend_info']);
$this->services->transaction(function () use ($data, $labels) {
$res = true;
$userInfo = $this->services->save($data);
if ($labels) {
$res = $this->services->saveSetLabel([$userInfo->uid], $labels);
}
if ($data['level']) {
$res = $this->services->saveGiveLevel((int)$userInfo->uid, (int)$data['level']);
}
if (!$res) {
return app('json')->fail('保存添加用户失败');
}
event('user.register', [$this->services->get((int)$userInfo->uid), true, 0]);
});
event('user.create', $data);
return app('json')->success('添加成功');
}
/**
* 更新用户信息
* @param Request $request
* @param $uid
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function userUpdate(Request $request, $uid)
{
$data = $request->postMore([
['money_status', 0],
['is_promoter', 0],
['real_name', ''],
['card_id', ''],
['birthday', ''],
['mark', ''],
['money', 0],
['integration_status', 0],
['integration', 0],
['status', 0],
['level', 0],
['phone', 0],
['addres', ''],
['label_id', []],
['group_id', 0],
['pwd', ''],
['true_pwd'],
['spread_open', 1],
['sex', 0],
['provincials', ''],
['province', 0],
['city', 0],
['area', 0],
['street', 0],
['spread_uid', -1],
['extend_info', []],
['adminId', 0],
]);
if ($data['phone']) {
if (!check_phone($data['phone'])) return app('json')->fail('手机号码格式不正确');
}
if ($data['card_id']) {
try {
if (!check_card($data['card_id'])) return app('json')->fail('请输入正确的身份证');
} catch (\Throwable $e) {
// return app('json')->fail('请输入正确的身份证');
}
}
if ($data['birthday']) {
if (strtotime($data['birthday']) > time()) return app('json')->fail('生日请选择今天之前日期');
}
if ($data['pwd']) {
$data['pwd'] = md5($data['pwd']);
} else {
unset($data['pwd']);
}
$userInfo = $this->services->get($uid);
if (!$userInfo) {
return app('json')->fail('用户不存在');
}
if (!in_array($data['spread_uid'], [0, -1])) {
$spreadUid = $data['spread_uid'];
if ($uid == $spreadUid) {
return app('json')->fail('上级推广人不能为自己');
}
if (!$this->services->count(['uid' => $spreadUid])) {
return app('json')->fail('上级用户不存在');
}
$spreadInfo = $this->services->get($spreadUid);
if ($spreadInfo->spread_uid == $uid) {
return app('json')->fail('上级推广人不能为自己下级');
}
}
unset($data['true_pwd']);
if (!$uid) return app('json')->fail('数据不存在');
$data['money'] = (string)$data['money'];
$data['integration'] = (string)$data['integration'];
$data['extend_info'] = $this->services->handelExtendInfo($data['extend_info']);
return app('json')->success($this->services->updateInfo((int)$uid, $data) ? '修改成功' : '修改失败');
}
/**
* 修改用户余额和积分
* @param Request $request
* @param $uid
* @return mixed
*/
public function userGive(Request $request, $uid)
{
$data = $request->postMore([
['money_status', 0],
['money', 0],
['integration_status', 0],
['integration', 0],
]);
if (!$uid) return app('json')->fail('数据不存在');
$data['money'] = (string)$data['money'];
$data['integration'] = (string)$data['integration'];
$data['is_other'] = true;
return app('json')->success($this->services->updateInfo($uid, $data) ? '修改成功' : '修改失败');
}
/**
* 获取用户详情
* @param $uid
* @return \think\Response
* @author 吴汐
* @email 442384644@qq.com
* @date 2023/06/20
*/
public function info($uid)
{
if (!$uid) return app('json')->fail('参数错误');
$data = $this->services->userInfo($uid);
return app('json')->success(compact('data'));
}
}