Files
huangjingfen/pro_v3.5.1/app/controller/api/v2/agent/Agent.php
panchengyong c1e74d8e68 chore(php): 统一 ScottPan 文件头与注释域名替换
- 按 docs/renew-code-comment.md 将 PHP 文件头改为带边框的 Author 注释\n- 注释中的 crmeb.com 替换为 uj345.cn(代码字符串中的外链未改)\n- 新增 docs/renew-code-comment.md 说明

Made-with: Cursor
2026-03-29 11:22:58 +08:00

58 lines
2.1 KiB
PHP

<?php
// +----------------------------------------------------------------------
// | Author: ScottPan Team
// +----------------------------------------------------------------------
namespace app\controller\api\v2\agent;
use app\Request;
use app\services\other\AgreementServices;
use app\services\user\UserBrokerageServices;
use app\services\user\UserServices;
class Agent
{
/**
* 获取用户推广用户列表
* @param Request $request
* @param UserServices $userServices
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function agentUserList(Request $request, UserServices $userServices)
{
[$type] = $request->getMore([
['type', 0]
], true);
$uid = $request->uid();
return app('json')->successful($userServices->agentUserList($uid, $type));
}
/**
* 获取用户推广获得收益,佣金轮播,分销规则
* @param Request $request
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function agentInfo(Request $request)
{
/** @var AgreementServices $agreementService */
$agreementService = app()->make(AgreementServices::class);
/** @var UserBrokerageServices $userBrokerageServices */
$userBrokerageServices = app()->make(UserBrokerageServices::class);
$data['agreement'] = $agreementService->getAgreementBytype(2)['content'] ?? '';
$data['price'] = $userBrokerageServices->sum(['uid' => $request->uid(), 'pm' => 1, 'not_type' => ['extract_fail', 'refund']], 'number', true);
$list = $userBrokerageServices->getList(['pm' => 1, 'not_type' => ['extract_fail', 'refund']], '*', 1, 10, [], ['user']);
foreach ($list as $item) {
$data['list'][] = [
'nickname' => $item['user']['nickname'] ?? '',
'price' => $item['number']
];
}
return app('json')->successful($data);
}
}