优化渠道

This commit is contained in:
wong
2025-12-20 16:45:25 +08:00
parent 20f567da37
commit f208bbdb9a
5 changed files with 230 additions and 154 deletions

View File

@@ -62,7 +62,7 @@ class ChannelUserController extends Controller
// 获取参数
$phone = $this->request->param('phone', '');
$password = $this->request->param('password', '');
$companyId = $this->request->param('companyId', 0);
// 参数验证
if (empty($phone)) {
return $this->setCorsHeaders(json([
@@ -86,10 +86,12 @@ class ChannelUserController extends Controller
$channel = Db::name('distribution_channel')
->where([
['phone', '=', $phone],
['companyId', '=', $companyId],
['deleteTime', '=', 0]
])
->find();
if (!$channel) {
return $this->setCorsHeaders(json([
'code' => 404,
@@ -224,11 +226,16 @@ class ChannelUserController extends Controller
$channelInfo = [
'channelName' => $channel['name'] ?? '',
'channelCode' => $channel['code'] ?? '',
'phone' => $channel['phone'] ?? '',
'wechatId' => $channel['wechatId'] ?? '',
'remark' => $channel['remark'] ?? '',
'createTime' => !empty($channel['createTime']) ? date('Y-m-d H:i:s', $channel['createTime']) : '',
'createType' => $channel['createType'] ?? '',
];
// 2. 财务统计
// 当前可提现金额
$withdrawableAmount = intval($channel['withdrawableAmount'] ?? 0);
$withdrawableAmount = $channel['withdrawableAmount'] ?? 0;
// 已提现金额(已打款的提现申请)
$withdrawnAmount = Db::name('distribution_withdrawal')
@@ -238,7 +245,7 @@ class ChannelUserController extends Controller
['status', '=', DistributionWithdrawal::STATUS_PAID]
])
->sum('amount');
$withdrawnAmount = intval($withdrawnAmount ?? 0);
$withdrawnAmount = $withdrawnAmount ?? 0;
// 待审核金额(待审核的提现申请)
$pendingReviewAmount = Db::name('distribution_withdrawal')
@@ -248,7 +255,7 @@ class ChannelUserController extends Controller
['status', '=', DistributionWithdrawal::STATUS_PENDING]
])
->sum('amount');
$pendingReviewAmount = intval($pendingReviewAmount ?? 0);
$pendingReviewAmount = $pendingReviewAmount ?? 0;
// 总收益(所有收益记录的总和)
$totalRevenue = Db::name('distribution_revenue_record')
@@ -257,13 +264,13 @@ class ChannelUserController extends Controller
['channelId', '=', $channelId]
])
->sum('amount');
$totalRevenue = intval($totalRevenue ?? 0);
$totalRevenue = $totalRevenue ?? 0;
$financialStats = [
'withdrawableAmount' => round($withdrawableAmount / 100, 2), // 当前可提现金额(元)
'totalRevenue' => round($totalRevenue / 100, 2), // 总收益(元)
'pendingReview' => round($pendingReviewAmount / 100, 2), // 待审核(元)
'withdrawn' => round($withdrawnAmount / 100, 2), // 已提现(元)
'withdrawableAmount' => $withdrawableAmount, // 当前可提现金额
'totalRevenue' => $totalRevenue, // 总收益
'pendingReview' => $pendingReviewAmount, // 待审核
'withdrawn' => $withdrawnAmount, // 已提现
];
// 3. 客户和好友统计