Files
huangjingfen/pro_v3.5.1/app/controller/api/v1/hjf/HjfAssets.php
panchengyong ec56ae3286 fix(fsgx): 修复 issues-0325-1 前端与后端问题
UniApp:会员码图片兜底、海报下载 Promise、账单移除公排退款、
佣金状态与资产页 NavBar、资产接口 total_points_earned。

后端:推荐人须自报单才得周期佣金;升级前快照等级再发积分;
积分按报单商品数量倍乘;伞下级差按伞下基数传递;直推/伞下任务
统计补充 refund_status;周期佣金在事务内锁推荐人行防竞态;
新增 hjf:verify-agent-config 命令做等级与任务 e2e 验收。

Made-with: Cursor
2026-03-28 10:23:20 +08:00

56 lines
2.1 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
// +----------------------------------------------------------------------
// | 范氏国香 fsgx — 资产总览 API
// +----------------------------------------------------------------------
namespace app\controller\api\v1\hjf;
use app\Request;
use app\services\user\UserServices;
use app\services\agent\AgentLevelServices;
class HjfAssets
{
/**
* GET /api/hjf/assets/overview
* 资产总览聚合接口
* 返回:佣金余额、待释放积分、已释放积分、今日释放、分销等级名称
*/
public function overview(Request $request)
{
$uid = (int)$request->uid();
/** @var UserServices $userServices */
$userServices = app()->make(UserServices::class);
$user = $userServices->get($uid, ['uid', 'brokerage_price', 'frozen_points', 'available_points', 'agent_level', 'now_money']);
if (!$user) {
return app('json')->fail('用户不存在');
}
$agentLevelName = '';
if (!empty($user['agent_level'])) {
/** @var AgentLevelServices $agentLevelServices */
$agentLevelServices = app()->make(AgentLevelServices::class);
$levelInfo = $agentLevelServices->get((int)$user['agent_level'], ['id', 'name']);
$agentLevelName = $levelInfo ? $levelInfo['name'] : '';
}
// 今日释放积分frozen_points * 0.4‰(与定时任务逻辑一致)
$frozenPoints = (int)($user['frozen_points'] ?? 0);
$todayRelease = (int)floor($frozenPoints * 0.0004);
$availablePoints = (int)($user['available_points'] ?? 0);
return app('json')->successful([
'brokerage_price' => (string)($user['brokerage_price'] ?? '0.00'),
'now_money' => (string)($user['now_money'] ?? '0.00'),
'frozen_points' => $frozenPoints,
'available_points' => $availablePoints,
'today_release' => $todayRelease,
'total_points_earned' => $frozenPoints + $availablePoints,
'agent_level' => (int)($user['agent_level'] ?? 0),
'agent_level_name' => $agentLevelName,
]);
}
}