medal add bonus addition duration

This commit is contained in:
xiaomlove
2025-07-14 21:03:09 +07:00
parent b81cf0c1c6
commit 3ffdec1f4a
11 changed files with 78 additions and 17 deletions
+2 -5
View File
@@ -70,11 +70,8 @@ class BonusRepository extends BaseRepository
], $user->locale);
do_log("comment: $comment");
$this->consumeUserBonus($user, $requireBonus, BonusLogs::BUSINESS_TYPE_BUY_MEDAL, "$comment(medal ID: {$medal->id})");
$expireAt = null;
if ($medal->duration > 0) {
$expireAt = Carbon::now()->addDays((int)$medal->duration)->toDateTimeString();
}
$user->medals()->attach([$medal->id => ['expire_at' => $expireAt, 'status' => UserMedal::STATUS_NOT_WEARING]]);
$medalRep = new MedalRepository();
$medalRep->userAttachMedal($user, $medal);
if ($medal->inventory !== null) {
$affectedRows = NexusDB::table('medals')
->where('id', $medal->id)