From 3ad8fabe7b44f10552c134a8a2e311e849e54a43 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Mon, 14 Mar 2022 20:21:24 +0800 Subject: [PATCH] fix new user attendance don't increase bonus --- app/Repositories/AttendanceRepository.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Repositories/AttendanceRepository.php b/app/Repositories/AttendanceRepository.php index 517902094..b1ef38c1a 100644 --- a/app/Repositories/AttendanceRepository.php +++ b/app/Repositories/AttendanceRepository.php @@ -27,6 +27,7 @@ public function attend($uid) 'days' => 1, 'total_days' => 1, ]; + $update = $initialData; if (!$attendance) { //first time do_log("[DO_INSERT]: " . nexus_json_encode($initialData)); @@ -52,14 +53,15 @@ public function attend($uid) } else { //not continuous do_log("[NOT_CONTINUOUS]"); - $update = $initialData; $update['total_days'] = $attendance->total_days + 1; } do_log("[DO_UPDATE]: " . nexus_json_encode($update)); $attendance->update($update); - User::query()->where('id', $uid)->increment('seedbonus', $update['points']); } } + if ($isUpdated) { + User::query()->where('id', $uid)->increment('seedbonus', $update['points']); + } $attendance->added_time = $now->toTimeString(); $attendance->is_updated = $isUpdated; do_log("[FINAL_ATTENDANCE]: " . $attendance->toJson());