public function beforeDelete() { if ($this->id) { Wallet\History::deleteList(['wallet_id', $this->id]); Wallet\Block::deleteList(['wallet_id', $this->id]); } }
public function checkBlocked() { $blocked = Wallet\Block::getList(['where' => [['data', 'reward:' . $this->id], [['date_expired', '0000-00-00 00:00:00'], ['date_expired', date('Y-m-d H:i:s'), '>', 'OR']]]]); $usersCompleted = []; foreach ($blocked as $block) { if (!isset($usersCompleted[$block->wallet->user_id])) { $complete = true; foreach ($this->conditions as $condition) { if (!$condition->checkComplete($block->wallet->user_id)) { $complete = false; break; } } if ($complete) { $usersCompleted[$block->wallet->user_id] = true; } else { $usersCompleted[$block->wallet->user_id] = false; } } if ($usersCompleted[$block->wallet->user_id]) { $block->wallet->diff($block->amount, $block->comment); $block->delete(); } } }