Payout bugfix
This commit is contained in:
parent
922db48c36
commit
622ecaf97c
8 changed files with 73 additions and 54 deletions
|
|
@ -88,7 +88,7 @@ class LeaguesController extends Controller
|
|||
|
||||
$roundNames = Round::getNames();
|
||||
$leagueNames = League::getNames();
|
||||
$leagues = League::where('season_id','=',$season->id)->where('rank','<', 4)->orderBy('id')->get();
|
||||
$leagues = League::where('season_id','=',$season->id)->where('rank','<=', 4)->orderBy('id')->get();
|
||||
$matchesTotal = array();
|
||||
|
||||
foreach ($leagues as $league) {
|
||||
|
|
@ -114,6 +114,9 @@ class LeaguesController extends Controller
|
|||
//$leagues = array_reverse(League::getRanking($rank));
|
||||
$leagueNames = League::getNames();
|
||||
$userNames = User::getNames();
|
||||
|
||||
$leagues = League::where('season_id','=',$season->id)->where('rank','<=', 4)->orderBy('id')->get();
|
||||
if (!sizeof($leagues)) return redirect("/");
|
||||
|
||||
$totalRanking = League::getTotalRankingOverall(); // Nur für Auf/Abstiegsinfo benötigt.
|
||||
$rankInfo=array();
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ class RoundsController extends Controller
|
|||
$rounds = Round::all()->where('season_id', '=', $activeSeasonId);
|
||||
}
|
||||
|
||||
$quotas = Quota::getQuotas($activeSeason->id);
|
||||
$round_count = $quotas['Runden'];
|
||||
$quotas = Quota::getQuotas();
|
||||
$round_count = Round::getCount();
|
||||
|
||||
return view('rounds.index', compact('rounds','activeSeason', 'round_count'));
|
||||
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ class SeasonsController extends Controller
|
|||
|
||||
$currentSeasonId=-1;
|
||||
if ($currentSeason) {
|
||||
$quotas = Quota::getQuotas($currentSeason->id);
|
||||
$payouts = Quota::getPayouts($currentSeason->id);
|
||||
$quotas = Quota::getQuotas();
|
||||
$payouts = Quota::getPayouts();
|
||||
}
|
||||
|
||||
return view('seasons.index', compact('seasons','currentSeason','active_user_count','quotas','payouts'));
|
||||
|
|
@ -60,7 +60,7 @@ class SeasonsController extends Controller
|
|||
Season::setCurrent($season->id);
|
||||
Log::info('Setting season id=' .$season->id);
|
||||
|
||||
Quota::createDefaultQuota($season->id);
|
||||
Quota::createDefaultQuota();
|
||||
|
||||
$nr=1;
|
||||
$roundcount=request('roundcount');
|
||||
|
|
@ -155,26 +155,26 @@ class SeasonsController extends Controller
|
|||
|
||||
// Create and save the season
|
||||
|
||||
Quota::setQuota('Runden',request('round_count'), $currentSeason->id);
|
||||
Quota::setQuota('Einsatz',request('einsatz'), $currentSeason->id);
|
||||
Quota::setQuota('Tagessieg',request('tagessieg'), $currentSeason->id);
|
||||
Quota::setQuota('Gruenes Trikot',request('gruenes_trikot'), $currentSeason->id);
|
||||
Quota::setQuota('Pokal',request('pokal'), $currentSeason->id);
|
||||
Quota::setQuota('Platzierung',request('platzierung'), $currentSeason->id);
|
||||
Quota::setQuota('Platz 1',request('platz1'), $currentSeason->id);
|
||||
Quota::setQuota('Platz 2',request('platz2'), $currentSeason->id);
|
||||
Quota::setQuota('Platz 3',request('platz3'), $currentSeason->id);
|
||||
Quota::setQuota('Platz 4',request('platz4'), $currentSeason->id);
|
||||
Quota::setQuota('Platz 5',request('platz5'), $currentSeason->id);
|
||||
Quota::setQuota('Platz 6',request('platz6'), $currentSeason->id);
|
||||
Quota::setQuota('Platz 7',request('platz7'), $currentSeason->id);
|
||||
Quota::setQuota('Platz 8',request('platz8'), $currentSeason->id);
|
||||
Quota::setQuota('Platz 9',request('platz9'), $currentSeason->id);
|
||||
Quota::setQuota('Platz 10',request('platz10'), $currentSeason->id);
|
||||
Quota::setQuota('Liga-Wertung',request('liga'), $currentSeason->id);
|
||||
Quota::setQuota('Liga Platz 1',request('liga_platz1'), $currentSeason->id);
|
||||
Quota::setQuota('Liga Platz 2',request('liga_platz2'), $currentSeason->id);
|
||||
Quota::setQuota('Liga Platz 3',request('liga_platz3'), $currentSeason->id);
|
||||
Quota::setQuota('Runden', request('round_count'));
|
||||
Quota::setQuota('Einsatz', request('einsatz'));
|
||||
Quota::setQuota('Tagessieg', request('tagessieg'));
|
||||
Quota::setQuota('Gruenes Trikot', request('gruenes_trikot'));
|
||||
Quota::setQuota('Pokal', request('pokal'));
|
||||
Quota::setQuota('Platzierung', request('platzierung'));
|
||||
Quota::setQuota('Platz 1', request('platz1'));
|
||||
Quota::setQuota('Platz 2', request('platz2'));
|
||||
Quota::setQuota('Platz 3', request('platz3'));
|
||||
Quota::setQuota('Platz 4', request('platz4'));
|
||||
Quota::setQuota('Platz 5', request('platz5'));
|
||||
Quota::setQuota('Platz 6', request('platz6'));
|
||||
Quota::setQuota('Platz 7', request('platz7'));
|
||||
Quota::setQuota('Platz 8', request('platz8'));
|
||||
Quota::setQuota('Platz 9', request('platz9'));
|
||||
Quota::setQuota('Platz 10', request('platz10'));
|
||||
Quota::setQuota('Liga-Wertung', request('liga'));
|
||||
Quota::setQuota('Liga Platz 1', request('liga_platz1'));
|
||||
Quota::setQuota('Liga Platz 2', request('liga_platz2'));
|
||||
Quota::setQuota('Liga Platz 3', request('liga_platz3'));
|
||||
|
||||
// Redirect to the home page
|
||||
return redirect('/seasons');
|
||||
|
|
|
|||
|
|
@ -362,8 +362,8 @@ class UsersController extends Controller
|
|||
$currentSeason = Season::getCurrent();
|
||||
|
||||
$active_user_count = sizeof(User::getActives());
|
||||
$quotas = Quota::getQuotas($currentSeason->id);
|
||||
$payouts = Quota::getPayouts($currentSeason->id);
|
||||
$quotas = Quota::getQuotas();
|
||||
$payouts = Quota::getPayouts();
|
||||
|
||||
return view('users.show_payouts', compact('payouts','active_user_count','quotas','currentSeason'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,21 +8,25 @@ use DB;
|
|||
|
||||
class Quota extends Model
|
||||
{
|
||||
public static function getPayouts($season_id) {
|
||||
$quotas = Quota::getQuotas($season_id);
|
||||
public static function getPayouts() {
|
||||
$season_id = Season::getCurrent()->id;
|
||||
|
||||
$quotas = Quota::getQuotas();
|
||||
|
||||
$roundCount=Round::getCount();
|
||||
|
||||
//Quotas fuer Season wegwerfen falls vorhanden und default Wert reinschreiben
|
||||
if (sizeof($quotas)==0) {
|
||||
Quota::createDefaultQuota($season_id->id);
|
||||
$quotas = Quota::getQuotas($season_id);
|
||||
Quota::createDefaultQuota();
|
||||
$quotas = Quota::getQuotas();
|
||||
}
|
||||
|
||||
$active_user_count = sizeof(User::getActives());
|
||||
|
||||
$euro_pott = $active_user_count * $quotas["Einsatz"];
|
||||
|
||||
$euro_tagessieg_sum = intval ($euro_pott * ( $quotas["Tagessieg"] / 100 ) );
|
||||
$euro_tagessieg = Quota::get6Divisor( intval($euro_tagessieg_sum / $quotas['Runden']));
|
||||
|
||||
$euro_tagessieg = Quota::get6Divisor( intval($euro_tagessieg_sum / $roundCount));
|
||||
|
||||
$euro_gruenes_trikot = intval($euro_pott * (($quotas["Gruenes Trikot"] / 100)));
|
||||
$euro_gruenes_trikot = Quota::get6Divisor($euro_gruenes_trikot);
|
||||
|
|
@ -30,7 +34,7 @@ class Quota extends Model
|
|||
$euro_pokal= Quota::get6Divisor($euro_pokal);
|
||||
|
||||
$euro_platzierung = intval ( $euro_pott * (($quotas["Platzierung"] / 100)));
|
||||
$tagessieg_rest = $euro_tagessieg_sum - ($euro_tagessieg * $quotas['Runden']);
|
||||
$tagessieg_rest = $euro_tagessieg_sum - ($euro_tagessieg * $roundCount);
|
||||
|
||||
//Log::info("Tagessieg Rest=".$tagessieg_rest." €");
|
||||
$euro_platzierung += $tagessieg_rest;
|
||||
|
|
@ -52,7 +56,7 @@ class Quota extends Model
|
|||
$euro_liga_platz2 = Quota::get6Divisor(intval($euro_liga*(($quotas["Liga Platz 2"] / 100))));
|
||||
$euro_liga_platz3 = Quota::get6Divisor(intval($euro_liga*(($quotas["Liga Platz 3"] / 100))));
|
||||
|
||||
$finaler_rest = $euro_pott - ( $quotas['Runden']*$euro_tagessieg + $euro_gruenes_trikot + $euro_pokal + $euro_platz1
|
||||
$finaler_rest = $euro_pott - ( $roundCount*$euro_tagessieg + $euro_gruenes_trikot + $euro_pokal + $euro_platz1
|
||||
+ $euro_platz2 + $euro_platz3+ $euro_platz4 + $euro_platz5
|
||||
+ $euro_platz6 + $euro_platz7 + $euro_platz8 + $euro_platz9 + $euro_platz10
|
||||
+ $euro_liga_platz1 + $euro_liga_platz2 + $euro_liga_platz3);
|
||||
|
|
@ -83,7 +87,8 @@ class Quota extends Model
|
|||
}
|
||||
|
||||
// Subfunction of setQuotas
|
||||
public static function setQuota($name, $value, $season_id) {
|
||||
public static function setQuota($name, $value) {
|
||||
$season_id = Season::getCurrent()->id;
|
||||
$quota = Quota::all()->where('season_id','=',$season_id)->where('name','=',$name)->first();
|
||||
if (!$quota) {
|
||||
$quota = new Quota();
|
||||
|
|
@ -94,13 +99,14 @@ class Quota extends Model
|
|||
|
||||
$quota->save();
|
||||
}
|
||||
|
||||
public static function getQuota($season_id,$quota_name) {
|
||||
/*
|
||||
public static function getQuota($quota_name) {
|
||||
$quota=Quota::all()->where('season_id','=', $season_id)->where('name','=', $quota_name)->first();
|
||||
return $quota['prc'];
|
||||
}
|
||||
|
||||
public static function getQuotas($season_id) {
|
||||
*/
|
||||
public static function getQuotas() {
|
||||
$season_id = Season::getCurrent()->id;
|
||||
$quotas=Quota::all()->where('season_id','=', $season_id);
|
||||
$arr=array();
|
||||
foreach($quotas as $quota) {
|
||||
|
|
@ -110,15 +116,17 @@ class Quota extends Model
|
|||
}
|
||||
|
||||
|
||||
public static function setQuotas($quotas,$season_id) {
|
||||
public static function setQuotas($quotas) {
|
||||
$season_id = Season::getCurrent()->id;
|
||||
foreach ($quotas as $key => $quota) {
|
||||
setQuota($key, $quota, $season_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function createDefaultQuota($season_id)
|
||||
public static function createDefaultQuota()
|
||||
{
|
||||
$season_id = Season::getCurrent()->id;
|
||||
Log::info('Creating default quotas');
|
||||
DB::table('quotas')->where('season_id', '=', $season_id)->delete();
|
||||
|
||||
|
|
@ -126,13 +134,6 @@ class Quota extends Model
|
|||
$roundCount=Season::getCurrent()->rounds;
|
||||
Log::info("Creating new Quota");
|
||||
|
||||
$quota = new Quota;
|
||||
$quota->season_id = $season_id;
|
||||
$quota->name = "Runden";
|
||||
$quota->prc = $roundCount;
|
||||
$quota->save();
|
||||
|
||||
|
||||
$quota = new Quota;
|
||||
$quota->season_id = $season_id;
|
||||
$quota->name = "Einsatz";
|
||||
|
|
|
|||
|
|
@ -156,6 +156,21 @@ class Round extends Model
|
|||
return null;
|
||||
}
|
||||
|
||||
public static function getCount($seasonId=-1) {
|
||||
$season=null;
|
||||
if ($seasonId==-1) {
|
||||
$season=Season::getCurrent();
|
||||
} else {
|
||||
$season=Season::where('id','=', $seasonId)->first();
|
||||
}
|
||||
if (!$season) return 0;
|
||||
|
||||
$rounds=Round::where('season_id','=',$season->id)->get();
|
||||
|
||||
|
||||
return sizeof($rounds);
|
||||
}
|
||||
|
||||
// TODO: CHeck : Unused ??
|
||||
public static function getClosestRoundToNow() {
|
||||
$sql="select round_id,DATEDIFF(NOW(),kickoff) from games order by 2 desc limit 1;";
|
||||
|
|
|
|||
|
|
@ -398,7 +398,7 @@ class Tipp extends Model
|
|||
// Compute highest dayscore
|
||||
|
||||
// Addition: no dayscorewinner && round_completed: Payout goes to next round
|
||||
$payouts = Quota::getPayouts($currentSeason->id);
|
||||
$payouts = Quota::getPayouts();
|
||||
$totalDayWinPayout = 0;
|
||||
|
||||
$round_count=0;
|
||||
|
|
@ -476,11 +476,11 @@ class Tipp extends Model
|
|||
}
|
||||
}
|
||||
|
||||
$quotas=Quota::getQuotas($currentSeason->id);
|
||||
$quotas=Quota::getQuotas();
|
||||
|
||||
error_log("Round-Count=".$round_count);
|
||||
|
||||
if ($round_count==$quotas["Runden"]) {
|
||||
if ($round_count==Round::getCount()) {
|
||||
// Ranking Payout ausschütten
|
||||
$payout_groups =array();
|
||||
$lastRoundId= array_values(array_slice($round_ids,-1))[0];
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
<div class="form-group" >
|
||||
<h4>
|
||||
<label style="float:left; width:200px;">Anzahl Runden:</label>
|
||||
<input type="text" class="form-control" id="round_count" name="round_count" value="{{ $quotas['Runden'] }}" style="float:left; width:50px;"required>
|
||||
<input type="text" class="form-control" id="round_count" name="round_count" value="{{ App\Round::getCount() }}" style="float:left; width:50px;"required>
|
||||
|
||||
</h4>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue