1.结算记录中新增结算信息

2.优化渠道页面样式
This commit is contained in:
2026-05-30 14:58:17 +08:00
parent 1cdd597879
commit 7ab3db121c
13 changed files with 297 additions and 61 deletions

View File

@@ -32,5 +32,59 @@ class CommissionRecord extends Backend
$this->model = new \app\common\model\AgentCommissionRecord();
return null;
}
protected function _index(): Response
{
if ($this->request && $this->request->get('select')) {
return $this->select($this->request);
}
list($where, $alias, $limit, $order) = $this->queryBuilder();
$res = $this->model
->field($this->indexField)
->withJoin($this->withJoinTable, $this->withJoinType)
->with($this->withJoinTable)
->alias($alias)
->where($where)
->order($order)
->paginate($limit);
$list = $this->enrichCommissionRecordList($res->items());
return $this->success('', [
'list' => $list,
'total' => $res->total(),
'remark' => get_route_remark(),
]);
}
/**
* @param array<int, mixed> $items
* @return array<int, mixed>
*/
private function enrichCommissionRecordList(array $items): array
{
if ($items === []) {
return $items;
}
$out = [];
foreach ($items as $item) {
$row = is_array($item) ? $item : (method_exists($item, 'toArray') ? $item->toArray() : []);
$gross = strval($row['commission_amount'] ?? '0.00');
$fee = strval($row['handling_fee'] ?? '0.00');
$net = strval($row['net_commission_amount'] ?? '0.00');
if (bccomp($net, '0', 2) <= 0 && (bccomp($gross, '0', 2) > 0 || bccomp($fee, '0', 2) > 0)) {
$net = bcsub($gross, $fee, 2);
if (bccomp($net, '0', 2) < 0) {
$net = '0.00';
}
$row['net_commission_amount'] = $net;
}
$out[] = $row;
}
return $out;
}
}

View File

@@ -121,6 +121,7 @@ return [
'periodSettings' => 'Period settings',
'manualSettle' => 'Manual settle',
'batchSettlePending' => 'Batch settle pending channels',
'viewCommissionRecords' => 'View commission records',
'viewDividendRecords' => 'View paid dividend records',
'viewDirectBetRecords' => 'View direct bet records',
'viewSettlementBetRecords' => 'View settlement-scope bets',

View File

@@ -53,6 +53,7 @@ return [
'periodSettings' => '期号设置',
'manualSettle' => '手动结算',
'batchSettlePending' => '批量结算待结算渠道',
'viewCommissionRecords' => '查看代理佣金记录',
'viewDividendRecords' => '查看已分红记录',
'viewDirectBetRecords' => '查看直属投注记录',
'viewSettlementBetRecords' => '查看总投注金额',

View File

@@ -15,8 +15,13 @@ class AgentCommissionRecord extends Model
'update_time' => 'integer',
'settled_at' => 'integer',
'commission_rate' => 'string',
'share_rate' => 'string',
'calc_base_amount' => 'string',
'commission_amount' => 'string',
'commission_share_percent' => 'string',
'handling_fee' => 'string',
'handling_fee_rate' => 'string',
'net_commission_amount' => 'string',
'status' => 'integer',
];

View File

@@ -194,6 +194,14 @@ class AdminCommissionDistributionService
if ($nodes === []) {
return [];
}
$shareRateByAdmin = [];
foreach ($nodes as $node) {
$nodeAdminId = intval($node['admin_id'] ?? 0);
if ($nodeAdminId <= 0) {
continue;
}
$shareRateByAdmin[$nodeAdminId] = strval($node['share_rate'] ?? '0.00');
}
$defaultRate = self::normalizeHandlingFeeRatePercent($defaultHandlingFeeRate);
$merged = [];
foreach ($nodes as $node) {
@@ -223,6 +231,7 @@ class AdminCommissionDistributionService
'commission_amount' => $gross,
'commission_rate' => $effectiveRate,
'calc_base_amount' => $settlementBase,
'share_rate' => $shareRateByAdmin[$adminId] ?? '0.00',
'commission_share_percent' => self::calcCommissionSharePercent($gross, $totalCommission),
'handling_fee_rate' => $feeRate,
'handling_fee' => $feeAmount,

View File

@@ -73,7 +73,6 @@ class ChannelSettlementService
if ($adminId <= 0) {
continue;
}
unset($row['net_commission_amount']);
$row['status'] = 1;
$row['settled_at'] = $now;
$row['remark'] = strval($row['remark'] ?? '') . ' | 超管结算直接发放';
@@ -370,9 +369,12 @@ class ChannelSettlementService
'channel_id' => $channelId,
'admin_id' => $adminId,
'commission_rate' => strval($dist['commission_rate'] ?? '0.0000'),
'share_rate' => strval($dist['share_rate'] ?? '0.00'),
'calc_base_amount' => strval($dist['calc_base_amount'] ?? '0.00'),
'commission_amount' => $amount,
'commission_share_percent' => strval($dist['commission_share_percent'] ?? '0.00'),
'handling_fee' => strval($dist['handling_fee'] ?? '0.00'),
'handling_fee_rate' => strval($dist['handling_fee_rate'] ?? '0.00'),
'net_commission_amount' => strval($dist['net_commission_amount'] ?? '0.00'),
'status' => 0,
'settled_at' => null,