渠道新增用户权限

This commit is contained in:
wong
2025-12-29 15:12:57 +08:00
parent 2c90f6f33c
commit 203e8c8eaf
2 changed files with 66 additions and 9 deletions

View File

@@ -43,6 +43,11 @@ class WithdrawalController extends BaseController
$where = [];
$where[] = ['w.companyId', '=', $companyId];
// 如果不是管理员,只能查看自己创建的提现申请
if (!$this->getUserInfo('isAdmin')) {
$where[] = ['w.userId', '=', $this->getUserInfo('id')];
}
// 状态筛选
if ($status !== 'all') {
$where[] = ['w.status', '=', $status];
@@ -89,6 +94,7 @@ class WithdrawalController extends BaseController
$list = $query->field([
'w.id',
'w.channelId',
'w.userId',
'w.amount',
'w.status',
'w.payType',
@@ -123,6 +129,7 @@ class WithdrawalController extends BaseController
'channelId' => (string)$item['channelId'],
'channelName' => $item['channelName'] ?? '',
'channelCode' => $item['channelCode'] ?? '',
'userId' => (int)($item['userId'] ?? 0),
'amount' => round($item['amount'] / 100, 2), // 分转元保留2位小数
'status' => $item['status'] ?? DistributionWithdrawal::STATUS_PENDING,
'payType' => !empty($item['payType']) ? $item['payType'] : null, // 支付类型
@@ -168,6 +175,7 @@ class WithdrawalController extends BaseController
$amount = $this->request->param('amount', 0); // 金额单位:元
$companyId = $this->getUserInfo('companyId');
$userId = $this->getUserInfo('id');
// 参数验证
if (empty($channelCode)) {
@@ -271,6 +279,7 @@ class WithdrawalController extends BaseController
$withdrawalData = [
'companyId' => $companyId,
'channelId' => $channelId,
'userId' => $userId,
'amount' => $amountInFen, // 存储为分
'status' => DistributionWithdrawal::STATUS_PENDING,
'applyTime' => time(),
@@ -315,6 +324,7 @@ class WithdrawalController extends BaseController
'channelId' => (string)$withdrawal['channelId'],
'channelName' => $withdrawal['channelName'] ?? '',
'channelCode' => $withdrawal['channelCode'] ?? '',
'userId' => (int)($withdrawal['userId'] ?? 0),
'amount' => round($withdrawal['amount'] / 100, 2), // 分转元保留2位小数
'status' => $withdrawal['status'],
'payType' => !empty($withdrawal['payType']) ? $withdrawal['payType'] : null, // 支付类型wechat、alipay、bankcard创建时为null
@@ -603,17 +613,26 @@ class WithdrawalController extends BaseController
]);
}
// 构建查询条件
$where = [
['w.id', '=', $id],
['w.companyId', '=', $companyId]
];
// 如果不是管理员,只能查看自己创建的提现申请
if (!$this->getUserInfo('isAdmin')) {
$where[] = ['w.userId', '=', $this->getUserInfo('id')];
}
// 查询申请详情(关联渠道表)
$withdrawal = Db::name('distribution_withdrawal')
->alias('w')
->join('distribution_channel c', 'w.channelId = c.id AND c.deleteTime = 0', 'left')
->where([
['w.id', '=', $id],
['w.companyId', '=', $companyId]
])
->where($where)
->field([
'w.id',
'w.channelId',
'w.userId',
'w.amount',
'w.status',
'w.payType',
@@ -641,6 +660,7 @@ class WithdrawalController extends BaseController
'channelId' => (string)$withdrawal['channelId'],
'channelName' => $withdrawal['channelName'] ?? '',
'channelCode' => $withdrawal['channelCode'] ?? '',
'userId' => (int)($withdrawal['userId'] ?? 0),
'amount' => round($withdrawal['amount'] / 100, 2), // 分转元保留2位小数
'status' => $withdrawal['status'],
'payType' => !empty($withdrawal['payType']) ? $withdrawal['payType'] : null, // 支付类型wechat、alipay、bankcard