Files
huangjingfen/pro_v3.5.1_副本/app/services/user/UserBatchProcessServices.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

169 lines
6.6 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\user;
use app\jobs\user\UserBatchJob;
use app\services\BaseServices;
use app\dao\user\UserDao;
use app\services\user\group\UserGroupServices;
use app\services\user\label\UserLabelServices;
use app\services\user\level\SystemUserLevelServices;
use crmeb\exceptions\AdminException;
use think\annotation\Inject;
use think\exception\ValidateException;
/**
* 用户批量操作
* Class UserBatchProcessServices
* @package app\services\user
* @mixin UserDao
*/
class UserBatchProcessServices extends BaseServices
{
/**
* 批量处理参数
* @var array[]
*/
protected array $data = [
'group_id' => [],//分组ID
'label_id' => [],//标签ids
'level_id' => 0,//等级ID
'money_status' => 0,//余额变动状态
'money' => 0,//余额变动金额
'integration_status' => 0,//积分变动状态
'integration' => 0,//积分变动数量
'days_status' => 0,//付费会员条数变动状态
'day' => 0,//变动天数
'spread_uid' => 0,//上级推广人uid
];
/**
* @var UserDao
*/
#[Inject]
protected UserDao $dao;
/**
* 根据搜索条件查询uids
* @param $where
* @return array
*/
public function getUidByWhere($where)
{
if ($where) {
if (is_string($where)) {
$where = json_decode($where, true);
} elseif (is_array($where)) {
$where = $where;
} else {
$where = [];
}
}
/** @var UserWechatuserServices $userWechatUser */
$userWechatUser = app()->make(UserWechatuserServices::class);
$fields = 'u.uid';
[$list, $count] = $userWechatUser->getWhereUserList($where, $fields);
$uids = array_unique(array_column($list, 'uid'));
return $uids;
}
/**
* 用户批量操作
* @param int $type
* @param array $uids
* @param array $input_data
* @param bool $is_all
* @param array $where
* @return bool
*/
public function batchProcess(int $type, array $uids, array $input_data, bool $is_all = false, array $where = [], $label_type = 0)
{
//全选
if ($is_all == 1) {
$uids = $this->getUidByWhere($where);
}
$data = [];
switch ($type) {
case 1://分组
$group_id = $input_data['group_id'] ?? 0;
if (!$group_id) throw new ValidateException('请选择分组');
/** @var UserGroupServices $userGroup */
$userGroup = app()->make(UserGroupServices::class);
if (!$userGroup->getGroup($group_id)) {
throw new ValidateException('该分组不存在');
}
$data['group_id'] = $group_id;
break;
case 2://标签
$label_id = $input_data['label_id'] ?? [];
if (!$label_id) throw new ValidateException ('请选择标签');
/** @var UserLabelServices $userLabelServices */
$userLabelServices = app()->make(UserLabelServices::class);
$count = $userLabelServices->getCount([['id', 'IN', $label_id]]);
if ($count != count($label_id)) {
throw new ValidateException('用户标签不存在或被删除');
}
$data['label_id'] = $label_id;
break;
case 3://等级
$level_id = $input_data['level_id'] ?? 0;
if (!$level_id) throw new ValidateException('请选择用户等级');
/** @var SystemUserLevelServices $systemLevelServices */
$systemLevelServices = app()->make(SystemUserLevelServices::class);
//查询当前选择的会员等级
$systemLevel = $systemLevelServices->getLevel($level_id);
if (!$systemLevel) throw new AdminException('您选择赠送的用户等级不存在!');
$data['level_id'] = $level_id;
break;
case 4://积分余额
$data['money_status'] = $input_data['money_status'] ?? 0;
$data['money'] = $input_data['money'] ?? 0;
$data['integration_status'] = $input_data['integration_status'] ?? 0;
$data['integration'] = $input_data['integration'] ?? 0;
if (!$data['money_status'] && !$data['integration_status']) {
throw new AdminException('请选择操作积分或余额');
}
if ($data['money_status'] && !$data['money']) {
throw new AdminException('请填写变动余额数量');
}
if ($data['integration_status'] && !$data['integration']) {
throw new AdminException('请填写变动积分数量');
}
break;
case 5://赠送会员
$data['days_status'] = $input_data['days_status'] ?? 0;
$data['day'] = $input_data['day'] ?? 0;
if (!$data['days_status']) {
throw new AdminException('请选择增加或者减少会员天数');
}
if (!$data['day']) {
throw new AdminException('请填写变动会员天数');
}
break;
case 6://上级推广人
$spread_uid = $input_data['spread_uid'] ?? 0;
if (!$spread_uid) throw new ValidateException('请选择上级推广人');
if (!$this->dao->count(['uid' => $spread_uid])) {
throw new ValidateException('上级用户不存在');
}
$data['spread_uid'] = $spread_uid;
break;
default:
throw new AdminException('暂不支持该类型批操作');
}
//加入批量队列
UserBatchJob::dispatchDo('userBatch', [$type, $uids, $data, $label_type]);
return true;
}
}