feat(dashboard): 从专业财富观角度重构升级后台收益与分成统计仪表盘

这个提交包含在:
chen
2026-09-17 08:22:23 +08:00
父节点 64a9563779
当前提交 b6287bf2e0
共有 40 个文件被更改,包括 5145 次插入 和 1015 次删除

查看文件

@@ -35,22 +35,32 @@ class MadowService
$each = function_exists('bcdiv') ? bcdiv((string) $pool, (string) $count, 8) : number_format($pool / $count, 8, '.', '');
$distributed = 0;
foreach ($userIds as $userId) {
AgentModel::where('user_id', $userId)->setInc('madow', $each);
PartnerRewardService::write([
'order_id' => PartnerRewardService::dailyOrderId($settleDate),
'buyer_id' => 0,
'user_id' => $userId,
'role' => 'taster',
'reward_type' => 'madow_share',
'amount' => 0,
'madow' => $each,
'base_amount' => $pool,
'settle_date' => $settleDate,
'ext' => ['formula' => "GMV {$pool} / {$count} = {$each}", 'share_user_count' => $count, 'gmv' => $pool],
'status' => 1,
]);
$distributed = function_exists('bcadd') ? bcadd((string) $distributed, (string) $each, 8) : ($distributed + $each);
$dailyOrderId = PartnerRewardService::dailyOrderId($settleDate);
$now = time();
$chunks = array_chunk($userIds, 500);
foreach ($chunks as $chunk) {
AgentModel::whereIn('user_id', $chunk)->setInc('madow', $each);
$batchRows = [];
foreach ($chunk as $userId) {
$batchRows[] = [
'order_id' => $dailyOrderId,
'buyer_id' => 0,
'user_id' => $userId,
'role' => 'taster',
'reward_type' => 'madow_share',
'amount' => 0,
'madow' => $each,
'base_amount' => $pool,
'settle_date' => $settleDate,
'ext' => json_encode(['formula' => "GMV {$pool} / {$count} = {$each}", 'share_user_count' => $count, 'gmv' => $pool], JSON_UNESCAPED_UNICODE),
'status' => 1,
'createtime' => $now,
'updatetime' => $now,
];
$distributed = function_exists('bcadd') ? bcadd((string) $distributed, (string) $each, 8) : ($distributed + $each);
}
\think\Db::name('shopro_partner_reward')->insertAll($batchRows);
}
$tail = function_exists('bcsub') ? bcsub((string) $pool, (string) $distributed, 8) : round($pool - $distributed, 8);
if ((float) $tail > 0) {
@@ -80,10 +90,8 @@ class MadowService
->where('user_id', '>', 0)
->select();
foreach ($rows as $row) {
$agent = AgentModel::where('user_id', $row->user_id)->find();
if ($agent && (float) $row->madow > 0) {
$agent->madow = max(0, (float) $agent->madow - (float) $row->madow);
$agent->save();
if ((float) $row->madow > 0) {
AgentModel::where('user_id', $row->user_id)->setDec('madow', $row->madow);
}
}
}