-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProviderController.php
More file actions
22 lines (22 loc) · 911 Bytes
/
ProviderController.php
File metadata and controls
22 lines (22 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
class ProviderController {
function __construct ($processor, $db, $logger){
$this->processor = $processor;
$this->db = $db;
$this->logger = $logger;
}
function process($params) {
$params=$this->processor->normalizeFormat($params);
$responseCode = $this->processor->checkParams($params) ? true : false;
if ($responseCode) {
$this->updateDB($params['userid'], $params['amount']);
}
return $this->processor->formatOutput($responseCode);
}
function updateDB($userId, $amount) {
$this->db->query("UPDATE user SET balance = balance + $amount datetime = now() WHERE id = $userId");
$this->db->query("INSERT INTO user_transation (user_id, amount) VALUES ($userId, $amount)");
$this->logger->log('обновили баланс пользователя'.$userId);
}
}
?>