dever 6 years ago
parent
commit
891bb72747
4 changed files with 45 additions and 3 deletions
  1. 19 0
      act/lib/Num.php
  2. 1 2
      act/lib/Pay.php
  3. 1 1
      journal/database/info.php
  4. 24 0
      main/src/Journal_v1.php

+ 19 - 0
act/lib/Num.php

@@ -77,6 +77,25 @@ class Num
         return true;
     }
 
+    # 订阅数计数器
+    public function increment($id, $num = 0)
+    {
+        $key = 'journal_buy_num_' . $id;
+        $buy_num = Dever::cache($key);
+        if (!$buy_num) {
+            if ($num > 0) {
+                $journal = Dever::db('journal/info')->one($id);
+                $num = $journal['num_ding'] + $num;
+            } else {
+                return $buy_num;
+            }
+        } elseif ($num <= 0) {
+            return $buy_num;
+        }
+        Dever::increment($key, $num);
+        return true;
+    }
+
     /**
      * 导出成excel
      *

+ 1 - 2
act/lib/Pay.php

@@ -225,8 +225,7 @@ class Pay
                         }
 
                         # 增加订阅数
-                        //$key = 'journal_buy_num_' . $order['product_id'];
-                        //Dever::increment($key, $buy['num']);
+                        Dever::load('act/lib/num')->increment($order['product_id'], $buy['num']);
                     }
                 }
                 # 积分

+ 1 - 1
journal/database/info.php

@@ -62,7 +62,7 @@ $hot = array
 $page = 15;
 
 # 常用的col
-$col = 'id,name,subname,pic_cover,pic_view_cover,pic_view_bg,pdate,num_view,num_ding,num_add_ding,num_ratio_ding,num_comment,num_up,buy,share_yes,share_title,share_pic,share_content,pic_gd,cate_id,cash,bgmusic,top';
+$col = 'id,name,subname,pic_cover,pic_view_cover,pic_view_bg,pdate,num_view,num_ding,num_add_ding,num_ratio_ding,num_comment,num_up,buy,share_yes,share_title,share_pic,share_content,pic_gd,cate_id,cash,bgmusic,top,hot';
 
 $config = array
 (

+ 24 - 0
main/src/Journal_v1.php

@@ -60,9 +60,33 @@ class Journal_v1 extends Core
             $this->data['journal'] = array();
         }
 
+        $this->data['end']['call'] = 'main/journal_v1.getList_noCache';
+
         return $this->data;
     }
 
+    public function getList_noCache($data)
+    {
+        if ($data['push'] && $data['push']['hot'] == 1) {
+            $data['push']['num_ding'] = Dever::load('act/lib/num')->increment($data['push']['id']);
+            $data['push'] = $this->ding($data['push']);
+        }
+
+        if ($data['journal']) {
+            foreach ($data['journal'] as $k => $v) {
+                if ($v['hot'] == 1) {
+                    $data['journal'][$k]['num_ding'] = Dever::load('act/lib/num')->increment($v['id']);
+                    $data['journal'][$k] = $this->ding($data['journal'][$k]);
+                }
+            }
+        }
+
+        Dever::load('act/lib/num')->increment(2, 10);
+
+        print_r($data);die;
+        return $data;
+    }
+
     # 根据分类获取小刊列表 app
     public function getAppList()
     {