feat: 重构代码架构 + 新增报表/跟单/输赢统计功能
- 拆分 HomeController → TransactionController, ReportWebController, FollowPlanController - 新增 Service 层: TransactionService, ReportService, FollowPlanService - pk10.php JS 抽离为 4 个独立文件 (sound/race/bet/poll) - 前台新增报表查询页面 (/report) + 跟单计划页面 (/follow-plan) - 后台新增跟单计划管理 + 用户输赢明细统计 - 封盘状态显示倒计时 (x:xx) - 音效仅在开奖弹窗打开时播放 - 路由按模块分组整理 - autoload 支持 App\Services 命名空间
This commit is contained in:
@@ -14,26 +14,56 @@ class PK10Algorithm implements GameAlgorithmInterface {
|
||||
|
||||
/**
|
||||
* 带放水机制的开奖结果生成
|
||||
*
|
||||
* 算法策略:
|
||||
* - targetProfitRate > 0 时:选择利润最接近「总投注额 × 目标盈利率」的结果
|
||||
* - targetProfitRate == 0 时:选择平台利润最高的结果(原逻辑)
|
||||
*
|
||||
* @param array $bets 当期所有投注 [{bet_type, bet_target, amount, odds}, ...]
|
||||
* @param array $waterConfig [{bet_type => win_rate_pct}, ...]
|
||||
* 当前版本中 waterConfig 的 win_rate_pct 未直接参与结果选择,
|
||||
* 因为开奖结果是全局排列,无法单独控制某个投注类型的胜率。
|
||||
* 保留此参数供未来扩展(如按类型加权评分、分类型概率偏移等)。
|
||||
* @param int $attempts 最大尝试次数
|
||||
* @param float $targetProfitRate 目标盈利率(百分比,如 5.0 表示 5%)
|
||||
*/
|
||||
public static function generateControlledResult(array $bets, array $waterConfig, int $attempts = 100): array {
|
||||
if (empty($bets) || empty($waterConfig)) {
|
||||
public static function generateControlledResult(array $bets, array $waterConfig, int $attempts = 100, float $targetProfitRate = 0): array {
|
||||
if (empty($bets)) {
|
||||
return self::generateResult();
|
||||
}
|
||||
|
||||
// 计算目标利润(仅当 targetProfitRate > 0 时生效)
|
||||
$targetProfit = 0;
|
||||
if ($targetProfitRate > 0) {
|
||||
$totalBet = 0;
|
||||
foreach ($bets as $bet) {
|
||||
$totalBet += (float)$bet['amount'];
|
||||
}
|
||||
$targetProfit = $totalBet * ($targetProfitRate / 100);
|
||||
}
|
||||
|
||||
$bestResult = null;
|
||||
$bestProfit = PHP_INT_MIN;
|
||||
$bestDistance = PHP_FLOAT_MAX;
|
||||
|
||||
for ($i = 0; $i < $attempts; $i++) {
|
||||
$result = self::generateResult();
|
||||
$profit = self::calculatePlatformProfit($result, $bets);
|
||||
|
||||
// 选择平台利润最高的结果
|
||||
if ($profit > $bestProfit) {
|
||||
$bestProfit = $profit;
|
||||
$bestResult = $result;
|
||||
if ($targetProfitRate > 0) {
|
||||
// 目标盈利率模式:选择利润最接近目标值的结果
|
||||
$distance = abs($profit - $targetProfit);
|
||||
if ($distance < $bestDistance) {
|
||||
$bestDistance = $distance;
|
||||
$bestProfit = $profit;
|
||||
$bestResult = $result;
|
||||
}
|
||||
} else {
|
||||
// 原逻辑:选择平台利润最高的结果
|
||||
if ($profit > $bestProfit) {
|
||||
$bestProfit = $profit;
|
||||
$bestResult = $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user