Browse Source

修改bug

chenbo 4 years ago
parent
commit
8ff4446670
2 changed files with 9 additions and 3 deletions
  1. 7 1
      lib/reader.class.php
  2. 2 2
      lib/table/table_reader.class.php

+ 7 - 1
lib/reader.class.php

@@ -54,7 +54,13 @@ class Reader{
     static public function addCountByOpenId($openId)
     {
         $Table_reader = new Table_reader();
-        return $Table_reader->addCountByOpenId($openId);
+
+        $rs = $Table_reader->getInfoByOpenId($openId);
+        if (empty($rs)) {
+            return 0;
+        }
+
+        return $Table_reader->addCountByOpenId($openId, $rs['count']+1);
     }
 
     static public function del($id)

+ 2 - 2
lib/table/table_reader.class.php

@@ -99,11 +99,11 @@ class Table_reader extends Table
         return $this->pdo->sqlupdate($this->table_fullname, $param, $where);
     }
 
-    public function addCountByOpenId($openId)
+    public function addCountByOpenId($openId, $newCount)
     {
         $param = array(
             'reader_addtime'    => array('number', time()),
-            'reader_count'      => array('string', 'reader_count+1'),
+            'reader_count'      => array('string', $newCount),
         );
 
         $where = array(