覆现了 两个比较核心的token和customer的数据库逻辑

This commit is contained in:
2024-04-11 17:21:44 +08:00
parent 43c9890f06
commit 90743bfdc4
3 changed files with 154 additions and 106 deletions

View File

@@ -41,7 +41,7 @@ class Model_Customer_Token extends \application\Model\Base\BaseModel
if (!empty($data['customer_id']) && !empty($data['platform'])) {
$this->db->query('DELETE FROM ' . $this->_customerTokenTable . ' WHERE customer_id = '
. $this->db->quote($data['customer_id']) . ' AND platform = ' . $this->db->quote($data['platform']));
. $data['customer_id'] . ' AND platform = ' . $data['platform']);
}
$this->db->insert($this->_customerTokenTable, $data);
@@ -128,7 +128,7 @@ class Model_Customer_Token extends \application\Model\Base\BaseModel
{
return $this->db->fetchRow('SELECT * FROM ' . $this->_customerTokenTable
. ' WHERE token = ' . $this->db->quote($token));
. ' WHERE token = ' . $token);
}
@@ -143,7 +143,7 @@ class Model_Customer_Token extends \application\Model\Base\BaseModel
{
$result = $this->db->fetchRow('SELECT * FROM ' . $this->_customerTokenTable
. ' WHERE token = ' . $this->db->quote($token));
. ' WHERE token = ' . $token);
if ($result) {
if ($result['expiry'] > time()) {
@@ -170,7 +170,7 @@ class Model_Customer_Token extends \application\Model\Base\BaseModel
public function clearDuplicateToken($customer_id, $current_token, $platform = 1)
{
$results = $this->db->fetchAll('SELECT * FROM ' . $this->_customerTokenTable
. ' WHERE customer_id = ' . $this->db->quote($customer_id) . 'AND platform = ' . $this->db->quote($platform));
. ' WHERE customer_id = ' . $customer_id . 'AND platform = ' . $platform);
foreach ($results as $result) {
if ($result['token'] != $current_token) {
@@ -184,13 +184,13 @@ class Model_Customer_Token extends \application\Model\Base\BaseModel
public function getTokenByCustomerId($customer_id)
{
return $this->db->fetchOne('SELECT token FROM ' . $this->_customerTokenTable
. ' WHERE customer_id = ' . $this->db->quote($customer_id));
. ' WHERE customer_id = ' . $customer_id);
}
public function getTokenDataByCustomerId($customer_id)
{
$token_data = $this->db->fetchOne('SELECT data FROM ' . $this->_customerTokenTable
. ' WHERE customer_id = ' . $this->db->quote($customer_id));
. ' WHERE customer_id = ' . $customer_id);
return json_decode($token_data, true);
}