Implementation of final round (Ranking Payouts) incl. extension of Geldrangliste Display
This commit is contained in:
parent
27dd7d97f3
commit
50cc4c75bf
5 changed files with 8400 additions and 31 deletions
8304
d0274241_2017-09-05_1146.sql
Normal file
8304
d0274241_2017-09-05_1146.sql
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -211,13 +211,9 @@ class UsersController extends Controller
|
|||
return view('users.no_payment');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$response = Tipp::getRoundTipps($max_round_id);
|
||||
$roundtipps = $response['roundtipps'];
|
||||
|
||||
$roundData = $response['roundData'];
|
||||
$user_ids = $response['user_ids'];
|
||||
$round_ids = $response['round_ids'];
|
||||
|
|
@ -232,6 +228,8 @@ class UsersController extends Controller
|
|||
// Loop through games and users (again)
|
||||
$rankingDisplay=array();
|
||||
|
||||
$isFinalRound=false;
|
||||
|
||||
foreach ($user_ids as $user_id) {
|
||||
$rankscore_total= 0;
|
||||
$payout_sum = 0;
|
||||
|
|
@ -254,6 +252,11 @@ class UsersController extends Controller
|
|||
//Log::info("Dayscorewinner: ".$roundtipps[$key]["user_name"]);
|
||||
}
|
||||
|
||||
|
||||
$rankingDisplay[$user_id]["ranking_payout"] = $roundtipps[$key]["ranking_payout"];
|
||||
if ($roundtipps[$key]["ranking_payout"]>0) {
|
||||
$isFinalRound=true;
|
||||
}
|
||||
$rankingDisplay[$user_id]["rankscore"] = $roundtipps[$key]["rankscore"]; // Summe Rangwertung alle 4 Spiele/Tipps der letzten durchlaufenen Runde, NICHT in init stellen !!
|
||||
$rankingDisplay[$user_id]["dayscore"] = $roundtipps[$key]["dayscore"]; // Dayscore der letzten durchlaufenen Runde, NICHT in init stellen !!
|
||||
$rankingDisplay[$user_id]["dayScoreWithRankScore"] = $roundtipps[$key]["dayScoreWithRankScore"]; // Dayscore der letzten durchlaufenen Runde, NICHT in init stellen !!
|
||||
|
|
@ -330,7 +333,7 @@ class UsersController extends Controller
|
|||
|
||||
|
||||
Log::info("UserController::ranking: ExecutionTime: " . number_format(( microtime(true) - $startTime), 4) . " Seconds\n");
|
||||
return view('users.ranking', compact('all_rounds','rankingDisplay','userids','round','games','game_results'));
|
||||
return view('users.ranking', compact('all_rounds','rankingDisplay','userids','round','games','game_results','isFinalRound'));
|
||||
}
|
||||
|
||||
public function cmp($user1, $user2) {
|
||||
|
|
@ -469,18 +472,20 @@ class UsersController extends Controller
|
|||
foreach($round_ids as $round_id) {
|
||||
foreach($user_ids as $user_id) {
|
||||
$key=$round_id."_".$user_id;
|
||||
|
||||
$payout = str_replace(",",".",$roundtipps[$key]['payout']);
|
||||
if (strlen( $payout )>0) {
|
||||
if (strlen($payout)==0) { $payout=0; }
|
||||
|
||||
if ($user_id==68) { Log::info('round_id '.$round_id.", payout=".$payout);}
|
||||
|
||||
if (!array_key_exists($user_id, $payoutTotal)) {
|
||||
$payoutTotal[$user_id]['amount']=0;
|
||||
$payoutTotal[$user_id]['name']=$roundtipps[$key]['user_name'];
|
||||
$payoutTotal[$user_id]['user_id']=$roundtipps[$key]['user_id'];
|
||||
}
|
||||
$payoutTotal[$user_id]['amount'] += $payout;
|
||||
if (!array_key_exists($user_id, $payoutTotal)) {
|
||||
$payoutTotal[$user_id]['amount']=0;
|
||||
$payoutTotal[$user_id]['name']=$roundtipps[$key]['user_name'];
|
||||
$payoutTotal[$user_id]['user_id']=$roundtipps[$key]['user_id'];
|
||||
}
|
||||
|
||||
$payoutTotal[$user_id]['amount'] += $payout;
|
||||
|
||||
$payout_ranking = $roundtipps[$key]['ranking_payout'];
|
||||
$payoutTotal[$user_id]['amount'] += $payout_ranking;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -532,6 +537,13 @@ class UsersController extends Controller
|
|||
$item['payout'] =$payout;
|
||||
array_push($payouts,$item);
|
||||
}
|
||||
|
||||
if ($roundtipps[$key]['ranking_payout']>0) {
|
||||
$item=array();
|
||||
$item['roundname']="Platzierungssieg Rang ".$roundtipps[$key]['rank'];
|
||||
$item['payout']=$roundtipps[$key]['ranking_payout'];
|
||||
array_push($payouts,$item);
|
||||
}
|
||||
}
|
||||
|
||||
$user = User::where('id','=',$user_id)->first();
|
||||
|
|
|
|||
|
|
@ -82,7 +82,18 @@ class Quota extends Model
|
|||
|
||||
}
|
||||
|
||||
// Subfunction of setQuotas
|
||||
public static function setQuota($name, $value, $season_id) {
|
||||
$quota = Quota::all()->where('season_id','=',$season_id)->where('name','=',$name)->first();
|
||||
if (!$quota) {
|
||||
$quota = new Quota();
|
||||
}
|
||||
$quota->season_id = $season_id;
|
||||
$quota->name = $name;
|
||||
$quota->prc = $value;
|
||||
|
||||
$quota->save();
|
||||
}
|
||||
|
||||
public static function getQuota($season_id,$quota_name) {
|
||||
$quota=Quota::all()->where('season_id','=', $season_id)->where('name','=', $quota_name)->first();
|
||||
|
|
@ -104,20 +115,7 @@ class Quota extends Model
|
|||
}
|
||||
}
|
||||
|
||||
// Subfunction of setQuotas
|
||||
public static function setQuota($name, $value, $season_id) {
|
||||
$quota = Quota::all()->where('season_id','=',$season_id)->where('name','=',$name)->first();
|
||||
if (!$quota) {
|
||||
$quota = new Quota();
|
||||
|
||||
}
|
||||
$quota->season_id = $season_id;
|
||||
$quota->name = $name;
|
||||
$quota->prc = $value;
|
||||
|
||||
$quota->save();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function createDefaultQuota($season_id)
|
||||
|
|
|
|||
|
|
@ -296,6 +296,7 @@ class Tipp extends Model
|
|||
$roundtipps[$key]['earliest_kickoff']=$entry->game_kickoff;
|
||||
$roundtipps[$key]['hits']=0; // Wenigstens Tendenz getroffen. Wenn 4, dann 2 Punkte Bonus auf rankscore
|
||||
$roundtipps[$key]['is_dayscorewinner']=0;
|
||||
$roundtipps[$key]["ranking_payout"]=0; // Existiert nur in der letzten Runde
|
||||
}
|
||||
if (!array_key_exists('is_completed',$roundData[$round_id])) {
|
||||
$roundData[$round_id]['is_completed'] = true;
|
||||
|
|
@ -389,7 +390,9 @@ class Tipp extends Model
|
|||
$payouts = Quota::getPayouts($currentSeason->id);
|
||||
$totalDayWinPayout = 0;
|
||||
|
||||
$round_count=0;
|
||||
foreach ($round_ids as $round_id) {
|
||||
$round_count +=1;
|
||||
$totalDayWinPayout += $payouts["tagessieg"];
|
||||
|
||||
$highestDayScore = $highestDayscores[$round_id];
|
||||
|
|
@ -443,6 +446,47 @@ class Tipp extends Model
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
$quotas=Quota::getQuotas($currentSeason->id);
|
||||
if ($round_count==$quotas["Runden"]) {
|
||||
// Ranking Payout ausschütten
|
||||
$payout_groups =array();
|
||||
|
||||
foreach($user_ids as $user_id) {
|
||||
$key = $round_count."_".$user_id;
|
||||
$rank = $roundtipps[$key]["rank"];
|
||||
//Log::info("Setting ranking_payout for user_id ".$user_id);
|
||||
//TODO: Do it for any number of rank payouts
|
||||
if ($rank<11) {
|
||||
if (!array_key_exists($rank,$payout_groups)) {
|
||||
$payout_groups[$rank]=array();
|
||||
}
|
||||
array_push($payout_groups[$rank],$user_id);
|
||||
}
|
||||
}
|
||||
|
||||
// platz0= unsused, just for getting place equal to rank position.
|
||||
$rank_names=['platz0','platz1','platz2','platz3','platz4','platz5','platz6','platz7','platz8','platz9','platz10'];
|
||||
|
||||
// Ausschüttungsgruppen für Platzierung bilden
|
||||
foreach([1,2,3,4,5,6,7,8,9,10] as $rank) { // Jedes Payout, das verteilt werden muss
|
||||
$current_rank = $rank;
|
||||
$rankPayout=$payouts[$rank_names[$rank]];
|
||||
|
||||
while($current_rank) {
|
||||
while (!array_key_exists($current_rank, $payout_groups)) { $current_rank -=1; }
|
||||
$groupsize = sizeof($payout_groups[$current_rank]);
|
||||
|
||||
$single_payout = $rankPayout / $groupsize;
|
||||
foreach($payout_groups[$current_rank] as $user_id) {
|
||||
$key = $round_count."_".$user_id;
|
||||
$roundtipps[$key]["ranking_payout"] += $single_payout;
|
||||
}
|
||||
$current_rank=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////// END OF ROUNDTIPPS CREATION ///////////////////
|
||||
|
||||
$response = array();
|
||||
|
|
|
|||
|
|
@ -142,10 +142,16 @@
|
|||
<th> </th><!-- Spacer Column -->
|
||||
<th style="height:140px;white-space: nowrap;">
|
||||
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;">
|
||||
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Ausschüttung</span>
|
||||
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Ausschüttung Tagessieg</span>
|
||||
</div>
|
||||
</th>
|
||||
|
||||
@if($isFinalRound)
|
||||
<th style="height:140px;white-space: nowrap;">
|
||||
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;">
|
||||
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Aussch.Platzierung</span>
|
||||
</div>
|
||||
</th>
|
||||
@endif
|
||||
@foreach($rankingDisplay as $entry)
|
||||
<tr>
|
||||
<td class="table-bordered" > <span class="text list-unstyled" href="#" > {{ $entry["rank"] }} </span></td>
|
||||
|
|
@ -169,6 +175,9 @@
|
|||
<td class="table-bordered"><div style="margin: 0 auto; width: 32px;"><img src="/img/joker.png" style="{{ ($entry["joker4"] ? 'float:left;width:32px;height:32px' : 'display: none;') }}"></div></td>
|
||||
<td class="table-bordered" align="center" style="border: 0px"> </td> <!-- Spacer column -->
|
||||
<td class="table-bordered" align="center" > {{ $entry["payout"] }} {{ $entry["payout"]>0 ? '€': '' }}</td>
|
||||
@if($isFinalRound)
|
||||
<td class="table-bordered" align="center" > {{ $entry["ranking_payout"]>0 ? $entry["ranking_payout"].'€': '' }} </td>
|
||||
@endif
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
|
|
@ -216,7 +225,9 @@
|
|||
<td style="width:50px;"> <div></div></td>
|
||||
<td style="width:50px;"> <div></div></td>
|
||||
<td style="width:50px;"> <div></div></td>
|
||||
|
||||
@if($isFinalRound)
|
||||
<td style="width:50px;"> <div></div></td>
|
||||
@endif
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue