|
|
|
@ -40,7 +40,7 @@ class PromoteGradeService
|
|
|
|
|
|
|
|
|
|
$config = [];
|
|
|
|
|
$config['reach_level'] = $params['level'];
|
|
|
|
|
$config['grades'] = $params['grades'];
|
|
|
|
|
$config['grades'] = $this->sortGrades($params['grades']);
|
|
|
|
|
$config['default_grade_name'] = $params['default_grade_name'];
|
|
|
|
|
|
|
|
|
|
$data = [];
|
|
|
|
@ -59,9 +59,20 @@ class PromoteGradeService
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function checkGrades($grades)
|
|
|
|
|
private function sortGrades($grades)
|
|
|
|
|
{
|
|
|
|
|
if (count($grades) == 0) {
|
|
|
|
|
return $grades;
|
|
|
|
|
}
|
|
|
|
|
$values = [];
|
|
|
|
|
$symbols = [];
|
|
|
|
|
foreach ($grades as $key => $row) {
|
|
|
|
|
$values[$key] = $row['value'];
|
|
|
|
|
$symbols[$key] = $row['symbol'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
array_multisort($values, SORT_ASC, $symbols, SORT_ASC, $grades);
|
|
|
|
|
return $grades;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getCurrentSetting($promote)
|
|
|
|
@ -145,7 +156,7 @@ class PromoteGradeService
|
|
|
|
|
$gradeName = $config['default_grade_name'];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
$nextGrade = $grade[$key + 1] ?? null;
|
|
|
|
|
$nextGrade = $grades[$key + 1] ?? null;
|
|
|
|
|
if ($this->isBigger($value, $grade) && !$this->isBigger($value, $nextGrade)) {
|
|
|
|
|
$gradeName = $grade['name'];
|
|
|
|
|
break;
|
|
|
|
|