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
191 lines
6.2 KiB
PHP
191 lines
6.2 KiB
PHP
<?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\kefu;
|
||
|
||
|
||
use app\Request;
|
||
use app\services\system\attachment\SystemAttachmentServices;
|
||
use app\services\user\group\UserGroupServices;
|
||
use crmeb\services\CacheService;
|
||
use crmeb\services\UploadService;
|
||
use Psr\SimpleCache\InvalidArgumentException;
|
||
use think\annotation\Inject;
|
||
use app\services\kefu\UserServices;
|
||
use app\services\user\label\UserLabelCateServices;
|
||
use app\services\user\label\UserLabelRelationServices;
|
||
use app\services\message\service\StoreServiceRecordServices;
|
||
use think\db\exception\DataNotFoundException;
|
||
use think\db\exception\DbException;
|
||
use think\db\exception\ModelNotFoundException;
|
||
use think\facade\Config;
|
||
|
||
|
||
/**
|
||
* Class User
|
||
* @package app\kefuapi\controller
|
||
*/
|
||
class User extends AuthController
|
||
{
|
||
|
||
/**
|
||
* @var StoreServiceRecordServices
|
||
*/
|
||
#[Inject]
|
||
protected StoreServiceRecordServices $services;
|
||
|
||
/**
|
||
* 获取当前客服和用户的聊天记录
|
||
* @return mixed
|
||
* @throws DataNotFoundException
|
||
* @throws DbException
|
||
* @throws ModelNotFoundException
|
||
*/
|
||
public function recordList(string $nickname = '', $is_tourist = 0)
|
||
{
|
||
return $this->success($this->services->getServiceList($this->kefuInfo['uid'], $nickname, (int)$is_tourist));
|
||
}
|
||
|
||
/**
|
||
* 获取用户信息
|
||
* @param UserServices $services
|
||
* @param $uid
|
||
* @return mixed
|
||
* @throws DataNotFoundException
|
||
* @throws DbException
|
||
* @throws ModelNotFoundException
|
||
*/
|
||
public function userInfo(UserServices $services, $uid)
|
||
{
|
||
return $this->success($services->getUserInfo((int)$uid));
|
||
}
|
||
|
||
/**
|
||
* 标签分类
|
||
* @param UserLabelCateServices $services
|
||
* @param $uid
|
||
* @return mixed
|
||
* @throws DataNotFoundException
|
||
* @throws DbException
|
||
* @throws ModelNotFoundException
|
||
*/
|
||
public function getUserLabel(UserLabelCateServices $services, $uid)
|
||
{
|
||
return $this->success($services->getUserLabel((int)$uid));
|
||
}
|
||
|
||
/**
|
||
* 获取用户分组
|
||
* @param UserGroupServices $services
|
||
* @return mixed
|
||
* @throws DataNotFoundException
|
||
* @throws DbException
|
||
* @throws ModelNotFoundException
|
||
*/
|
||
public function getUserGroup(UserGroupServices $services)
|
||
{
|
||
return $this->success($services->getGroupList());
|
||
}
|
||
|
||
/**
|
||
* 设置分组
|
||
* @param UserGroupServices $services
|
||
* @param UserServices $userServices
|
||
* @param $uid
|
||
* @param $id
|
||
* @return mixed
|
||
*/
|
||
public function setUserGroup(UserGroupServices $services, UserServices $userServices, $uid, $id)
|
||
{
|
||
if (!$services->count(['id' => $id])) {
|
||
return $this->fail('添加的会员标签不存在');
|
||
}
|
||
if (!($userInfo = $userServices->get($uid))) {
|
||
return $this->fail('用户不存在');
|
||
}
|
||
if ($userInfo->group_id == $id) {
|
||
return $this->fail('已拥有此分组');
|
||
}
|
||
$userInfo->group_id = $id;
|
||
if ($userInfo->save()) {
|
||
return $this->success('设置成功');
|
||
} else {
|
||
return $this->fail('设置失败');
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 设置用户标签
|
||
* @param UserLabelRelationServices $services
|
||
* @param $uid
|
||
* @return mixed
|
||
*/
|
||
public function setUserLabel(UserLabelRelationServices $services, $uid)
|
||
{
|
||
[$labels, $unLabelIds] = $this->request->postMore([
|
||
['label_ids', []],
|
||
['un_label_ids', []]
|
||
], true);
|
||
if (!count($labels) && !count($unLabelIds)) {
|
||
return $this->fail('请选择标签');
|
||
}
|
||
if ($services->setUserLable($uid, $labels) && $services->unUserLabel($uid, $unLabelIds)) {
|
||
return $this->success('设置成功');
|
||
} else {
|
||
return $this->fail('设置失败');
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 退出登陆
|
||
* @return mixed
|
||
*/
|
||
public function logout()
|
||
{
|
||
$key = trim(ltrim($this->request->header(Config::get('cookie.token_name')), 'Bearer'));
|
||
CacheService::redisHandler()->delete(md5($key));
|
||
return $this->success();
|
||
}
|
||
|
||
/**
|
||
* 图片上传
|
||
* @param Request $request
|
||
* @param SystemAttachmentServices $services
|
||
* @return mixed
|
||
* @throws InvalidArgumentException
|
||
*/
|
||
public function upload(Request $request, SystemAttachmentServices $services)
|
||
{
|
||
$data = $request->postMore([
|
||
['filename', 'file'],
|
||
]);
|
||
if (!$data['filename']) return $this->fail('参数有误');
|
||
if (CacheService::has('start_uploads_' . $request->kefuId()) && CacheService::get('start_uploads_' . $request->kefuId()) >= 100) return $this->fail('非法操作');
|
||
$upload = UploadService::init();
|
||
$info = $upload->to('store/comment')->validate()->move($data['filename']);
|
||
if ($info === false) {
|
||
return $this->fail($upload->getError());
|
||
}
|
||
$res = $upload->getUploadInfo();
|
||
$services->attachmentAdd($res['name'], $res['size'], $res['type'], $res['dir'], $res['thumb_path'], 1, (int)sys_config('upload_type', 1), $res['time'], 2);
|
||
if (CacheService::has('start_uploads_' . $request->kefuId()))
|
||
$start_uploads = (int)CacheService::get('start_uploads_' . $request->kefuId());
|
||
else
|
||
$start_uploads = 0;
|
||
$start_uploads++;
|
||
CacheService::set('start_uploads_' . $request->kefuId(), $start_uploads, 86400);
|
||
$res['dir'] = path_to_url($res['dir']);
|
||
if (strpos($res['dir'], 'http') === false) $res['dir'] = $request->domain() . $res['dir'];
|
||
return $this->success('图片上传成功!', ['name' => $res['name'], 'url' => $res['dir']]);
|
||
}
|
||
|
||
}
|