<?php

namespace App\Support\Settlement;

/**
 * 设计文档 §12.1～§12.4 验收常量（平台视角：玩家输为正）。
 *
 * @see docs/信用占成盘代理系统设计说明文档.md
 */
final class DesignDocExample12
{
    public const GAME_WIN_LOSS = 1000;

    public const BASIC_REBATE = 50;

    public const EXTRA_REBATE_BY_C = 20;

    /** 玩家净结算 P→C：1000 - 50 - 20 */
    public const PLAYER_NET_SETTLEMENT = 930;

    /** 共享净输赢：1000 - 50 */
    public const SHARED_NET_WIN_LOSS = 950;

    /** 总占成：A=60%, B=40%, C=25% */
    public const TOTAL_SHARE_A = 60;

    public const TOTAL_SHARE_B = 40;

    public const TOTAL_SHARE_C = 25;

    /** 实际占成收益（共享池） */
    public const SHARE_PROFIT_C = 237.5;

    public const SHARE_PROFIT_B = 142.5;

    public const SHARE_PROFIT_A = 190.0;

    public const SHARE_PROFIT_PLATFORM = 380.0;

    /** C 最终收益：237.5 - 20 */
    public const FINAL_PROFIT_C = 217.5;

    /** 逐级结算应付 */
    public const TIER_P_TO_C = 930.0;

    public const TIER_C_TO_B = 712.5;

    public const TIER_B_TO_A = 570.0;

    public const TIER_A_TO_PLATFORM = 380.0;

    /**
     * @return array{actual: array<string, float>, total: float}
     */
    public static function actualShareRates(): array
    {
        $c = self::TOTAL_SHARE_C;
        $b = self::TOTAL_SHARE_B - self::TOTAL_SHARE_C;
        $a = self::TOTAL_SHARE_A - self::TOTAL_SHARE_B;
        $platform = 100 - self::TOTAL_SHARE_A;

        return [
            'actual' => [
                'C' => $c,
                'B' => $b,
                'A' => $a,
                'platform' => $platform,
            ],
            'total' => $c + $b + $a + $platform,
        ];
    }
}
