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

307 lines
11 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\admin\user;
use app\jobs\BatchHandleJob;
use app\Request;
use app\services\activity\coupon\StoreCouponIssueServices;
use app\services\activity\coupon\StoreCouponUserServices;
use app\services\other\queue\QueueServices;
use app\services\user\channel\ChannelMerchantServices;
use app\services\user\group\UserGroupServices;
use app\services\user\label\UserLabelCateServices;
use app\services\user\label\UserLabelRelationServices;
use app\services\user\level\SystemUserLevelServices;
use app\services\user\level\UserLevelServices;
use app\services\user\UserBatchProcessServices;
use app\services\user\UserServices;
use think\annotation\Inject;
use think\Response;
/**
* 用户类
* Class StoreProduct
* @package app\api\controller\store
*/
class User
{
/**
* 用户services
* @var UserServices
*/
#[Inject]
protected UserServices $services;
public function list(Request $request): Response
{
$where = $request->getMore([
['page', 1],
['limit', 20],
['nickname', ''],
['status', ''],
['pay_count', ''],
['is_promoter', ''],
['order', ''],
['data', ''],
['user_type', ''],
['country', ''],
['province', ''],
['city', ''],
['user_time_type', ''],
['user_time', ''],
['sex', ''],
[['level', 0], 0],
[['group_id', 'd'], 0],
[['label_id', 'd'], 0],
['now_money', 'normal'],
['field_key', ''],
['isMember', ''],
['label_ids', '']
]);
if ($where['label_ids']) {
$where['label_id'] = stringToIntArray($where['label_ids']);
unset($where['label_ids']);
}
$where['user_time_type'] = $where['user_time_type'] == 'all' ? '' : $where['user_time_type'];
return app('json')->success($this->services->index($where));
}
/**
* 用户详情
* @param $id
* @return Response
* User: liusl
* DateTime: 2024/1/26 11:38
*/
public function info($id)
{
if (!$id) {
return app('json')->fail('用户id不能为空');
}
return app('json')->success($this->services->manageRead($id));
}
/**
* 获取用户标签
* @param $uid
* @param UserLabelCateServices $services
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* User: liusl
* DateTime: 2024/1/26 11:50
*/
public function userLabel($uid, UserLabelCateServices $services)
{
return app('json')->success($services->getUserLabel((int)$uid));
}
/**
* 分组
* @param UserGroupServices $services
* @return Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* User: liusl
* DateTime: 2024/1/29 10:24
*/
public function userGroup(UserGroupServices $services)
{
return app('json')->success($services->getGroupList('*'));
}
/**
* 等级
* @param SystemUserLevelServices $services
* @return Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* User: liusl
* DateTime: 2024/1/29 11:00
*/
public function userLevel(SystemUserLevelServices $services)
{
return app('json')->success($services->getLevelList(['is_show' => 1, 'is_del' => 0], 'id,name,grade,image,icon'));
}
/**
* 优惠券列表
* @param Request $request
* @param StoreCouponIssueServices $services
* @return Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* User: liusl
* DateTime: 2024/1/29 15:51
*/
public function couponGrant(Request $request, StoreCouponIssueServices $services, StoreCouponUserServices $storeCouponUserServices)
{
[$coupon_title, $uid] = $request->getMore([
['coupon_title', ''],
['uid', 0],
], true);
if ($uid == 0) {
$where['receive'] = 'send';
$where['coupon_title'] = $coupon_title;
$data = $services->getCouponIssueList($where);
} else {
$data = $storeCouponUserServices->getUserCouponList($uid, 0);
}
return app('json')->success($data);
}
/**
* 修改余额积分
* @param Request $request
* @param $uid
* @return Response
* User: liusl
* DateTime: 2024/1/29 15:10
*/
public function updateOther(Request $request, $uid)
{
$data = $request->postMore([
['status', 0],
['number', 0],
['type', 1]//1余额 2积分
]);
if (!$uid) return app('json')->fail('数据不存在');
$data['adminId'] = (int)$request->uid();
$data['is_other'] = true;
$type = $data['type'];
unset($data['type']);
$data['money'] = $data['integration'] = $data['money_status'] = $data['integration_status'] = 0;
if ($type == 1) {
$data['money'] = (string)$data['number'];
$data['money_status'] = $data['status'];
} else {
$data['integration'] = (string)$data['number'];
$data['integration_status'] = $data['status'];
}
return app('json')->success($this->services->updateInfo($uid, $data) ? '修改成功' : '修改失败');
}
/**
* 编辑用户
* @param Request $request
* @param UserBatchProcessServices $batchProcessServices
* @return Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* User: liusl
* DateTime: 2024/1/29 17:34
*/
public function update(Request $request, UserBatchProcessServices $batchProcessServices)
{
[$uid, $type, $level, $days_status, $days, $coupon_id, $group_id, $label_id] = $request->postMore([
['uid', 0],
['type', 1],//类型
['level', 0],//等级
['days_status', 0],//付费会员赠加/减少
['days', 0],//赠送天数
['coupon_id', 0],//优惠券id
['group_id', 0],//分组
['label_id', []],//标签
], true);
if (!$uid) return app('json')->fail('缺少参数');
$res = true;
$updateData = [];
if (!is_array($uid)) {
$info = $this->services->get((int)$uid);
if (!$info) return app('json')->fail('用户不存在');
}
switch ($type) {
case 1://等级
if ($level == 0) return app('json')->fail('请选择等级');
if ($level == $info['level']) return app('json')->fail('当前等级无需修改');
/** @var UserLevelServices $userLevelService */
$userLevelService = app()->make(UserLevelServices::class);
$res = $userLevelService->setUserLevel((int)$uid, (int)$level);
$msg = $res ? '修改成功' : '修改失败';
break;
case 2://付费会员
$res = $this->services->saveGiveLevelTime((int)$uid, (int)$days, (int)$days_status);
$msg = $res ? '赠送成功' : '赠送失败';
break;
case 3://赠送优惠券
/** @var StoreCouponIssueServices $issueService */
$issueService = app()->make(StoreCouponIssueServices::class);
$coupon = $issueService->get($coupon_id);
if (!$coupon) {
return app('json')->fail('数据不存在!');
} else {
$coupon = $coupon->toArray();
}
if (is_array($uid)) {
/** @var QueueServices $queueService */
$queueService = app()->make(QueueServices::class);
$queueService->setQueueData([], 'uid', $uid);
//加入队列
BatchHandleJob::dispatch([$coupon, 1]);
$msg = '赠送成功';
} else {
/** @var StoreCouponIssueServices $storeCouponIssueServices */
$storeCouponIssueServices = app()->make(StoreCouponIssueServices::class);
$res = $storeCouponIssueServices->setCoupon($coupon, [$uid], '', '', true);
$msg = $res ? '赠送成功' : '赠送失败';
}
break;
case 4://分组
if (is_array($uid)) {
$batchProcessServices->batchProcess(1, $uid, ['group_id' => $group_id]);
} else {
if ($group_id == $info['group_id']) return app('json')->fail('当前分组无需修改');
$updateData['group_id'] = $group_id;
}
$msg = '修改成功';
break;
case 5://标签
$label_id = array_filter($label_id);
if (is_array($uid)) {
$batchProcessServices->batchProcess(2, $uid, ['label_id' => $label_id]);
$msg = '修改成功';
} else {
/** @var UserLabelRelationServices $userLabel */
$userLabel = app()->make(UserLabelRelationServices::class);
$res = $userLabel->setUserLable([$uid], $label_id, 0, 0, true);
$msg = $res ? '修改成功' : '修改失败';
}
break;
default:
return app('json')->fail('参数错误');
}
if ($res && count($updateData) > 0) {
$this->services->update((int)$uid, $updateData);
}
return app('json')->success($msg);
}
/**
* 采购商列表
* @return void
* User: liusl
* DateTime: 2025/4/12 上午10:04
*/
public function channelList(Request $request, ChannelMerchantServices $channelMerchantServices)
{
$where = $request->postMore([
['keyword', ''],
]);
return app('json')->success($channelMerchantServices->getChannelList($where));
}
}