mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-23 19:37:23 +08:00
unify bonus calculation
This commit is contained in:
@@ -126,11 +126,10 @@ class Test extends Command
|
||||
// $r = $rep->getContinuousDays($attendance);
|
||||
// $r = $rep->getContinuousPoints(11);
|
||||
|
||||
$data = DB::select('SHOW INDEX FROM peers');
|
||||
$array = [];
|
||||
foreach($data as $key => $item){
|
||||
dump($item);
|
||||
}
|
||||
$rep = new ExamRepository();
|
||||
$exam = Exam::query()->find(6);
|
||||
$r = $rep->fetchUserAndDoAssign($exam);
|
||||
dd($r);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -778,7 +778,7 @@ class ExamRepository extends BaseRepository
|
||||
|
||||
}
|
||||
|
||||
private function fetchUserAndDoAssign(Exam $exam): bool|int
|
||||
public function fetchUserAndDoAssign(Exam $exam): bool|int
|
||||
{
|
||||
$filters = $exam->filters;
|
||||
do_log("exam: {$exam->id}, filters: " . nexus_json_encode($filters));
|
||||
@@ -800,10 +800,16 @@ class ExamRepository extends BaseRepository
|
||||
if (!empty($filters->$filter) && count($filters->$filter) == 1) {
|
||||
$donateStatus = $filters->$filter[0];
|
||||
if ($donateStatus == User::DONATE_YES) {
|
||||
$baseQuery->where('donor', 'yes')->where("$userTable.donoruntil", ">=", Carbon::now()->toDateTimeString());
|
||||
$baseQuery->where(function (Builder $query) {
|
||||
$query->where('donor', 'yes')->where(function (Builder $query) {
|
||||
$query->where('donoruntil', '0000-00-00 00:00:00')->orWhereNull('donoruntil')->orWhere('donoruntil', '>=', Carbon::now());
|
||||
});
|
||||
});
|
||||
} elseif ($donateStatus == User::DONATE_NO) {
|
||||
$baseQuery->where(function (Builder $query) use ($userTable) {
|
||||
$query->where('donor', 'no')->orWhereNull("$userTable.donoruntil")->orWhere("$userTable.donoruntil", '<', Carbon::now()->toDateTimeString());
|
||||
$baseQuery->where(function (Builder $query) {
|
||||
$query->where('donor', 'no')->orWhere(function (Builder $query) {
|
||||
$query->where('donoruntil', '!=','0000-00-00 00:00:00')->whereNotNull('donoruntil')->where('donoruntil', '<', Carbon::now());
|
||||
});
|
||||
});
|
||||
} else {
|
||||
do_log("{$exam->id} filter $filter: $donateStatus invalid.", "error");
|
||||
|
||||
Reference in New Issue
Block a user