dever 5 سال پیش
والد
کامیت
8116f42621
3فایلهای تغییر یافته به همراه275 افزوده شده و 108 حذف شده
  1. 17 5
      app/collection/database/ranking.php
  2. 17 103
      app/collection/src/Api.php
  3. 241 0
      app/collection/src/Old.php

+ 17 - 5
app/collection/database/ranking.php

@@ -147,6 +147,20 @@ return array
             //'list'        => true,
         ),
 
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排序(数值越大越靠前)',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            //'update'  => 'text',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+            'edit'      => true,
+        ),
+
         'state'     => array
         (
             'type'      => 'tinyint-1',
@@ -181,19 +195,17 @@ return array
 
     'request' => array
     (
-        # 获取提交订单超过12个小时
-        'getDataByTime' => array
+        'getAll' => array
         (
             # 匹配的正则或函数 选填项
             'option' => array
             (
-                'end' => array('yes', '<='),
-                'ends' => array('yes-end', '>'),
+                'info_id' => 'yes',
                 'state' => 1,
                 'status' => 1,
             ),
             'type' => 'all',
-            'order' => array('id' => 'desc'),
+            'order' => array('recorder' => 'desc', 'id' => 'desc'),
             'col' => '*',
         ),
     ),

+ 17 - 103
app/collection/src/Api.php

@@ -7,16 +7,9 @@ use Collection\Lib\Core;
 
 class Api extends Core
 {
-    public function test1()
+    public function __construct()
     {
-        $list = Dever::db('content/news')->state();
-        return $list;
-        $test = '😀 😀';
-        $test = Dever::input('test');
-
-        $data['name'] = 'test';
-        $data['desc'] = $test;
-        return Dever::db('content/news')->insert($data);
+        $this->id = Dever::input('id');
     }
 
     public function data()
@@ -27,7 +20,6 @@ class Api extends Core
     # 获取合集内容
     public function getInfo()
     {
-        $id = Dever::input('id');
         # 是否已经购买
         $data['is_buy'] = false;
         $data['button'] = array(
@@ -35,7 +27,7 @@ class Api extends Core
             'color' => 'color:#fff',
             'name' => array('入口', '排行榜')
         );
-        $data['info'] = Dever::db('collection/info')->one($id);
+        $data['info'] = Dever::db('collection/info')->one($this->id);
         if ($data['info']) {
             $data['info']['pic_bg'] = explode(',', $data['info']['pic_bg']);
 
@@ -72,24 +64,30 @@ class Api extends Core
     # 获取合集下的购买内容
     public function getBuy()
     {
-        $id = Dever::input('id');
-        $data['info'] = Dever::db('collection/info')->one($id);
-        $where['info_id'] = $id;
+        $data['info'] = Dever::db('collection/info')->one($this->id);
+        $where['info_id'] = $this->id;
         $data['buy'] = Dever::db('collection/buy')->getAll($where);
 
         return $data;
     }
 
+    # 获取合集下的榜单列表
+    public function getRanking()
+    {
+        $where['info_id'] = $this->id;
+        $data['ranking'] = Dever::db('collection/ranking')->getAll($where);
+
+        return $data;
+    }
+
     # 获取合集下的内容
     public function getContent()
     {
-        $this->uid = 1;
-        $id = Dever::input('id');
         $page_id = Dever::input('page_id');
-        $data['items'] = Dever::load('collection/lib/content')->getList($id, $page_id);
+        $data['items'] = Dever::load('collection/lib/content')->getList($this->id, $page_id);
 
         $page = Dever::db('collection/page')->one($page_id);
-        $data['info_id'] = $id;
+        $data['info_id'] = $this->id;
         $data['page_id'] = $page_id;
         $data['parent_page_id'] = $page['page_id'];
 
@@ -103,7 +101,7 @@ class Api extends Core
     {
         $parent_page_id = Dever::input('parent_page_id');
         $page_id = Dever::input('page_id');
-        $where['info_id'] = Dever::input('id');
+        $where['info_id'] = $this->id;
         $data['cate'] = Dever::db('collection/page')->main($where);
         if ($data['cate']) {
             $data['child'] = Dever::db('collection/page')->child($where);
@@ -156,88 +154,4 @@ class Api extends Core
 
         return $data;
     }
-
-    # 解析元信息
-    public function avinfo($data, $url = 'video', $table = 'video/vod')
-    {
-        # 解析视频元信息
-        if (!$data['video_info']) {
-            $video_info = Dever::curl($data[$url] . '?avinfo');
-            if ($video_info) {
-                Dever::db($table)->update(array('where_id' => $data['id'], 'video_info' => $video_info));
-            }
-            
-            $video_info = Dever::json_decode($video_info);
-        } else {
-            $video_info = Dever::json_decode($data['video_info']);
-        }
-
-        unset($data['video_info']);
-
-        $data['video_width'] = 0;
-        $data['video_height'] = 0;
-        # 默认横屏
-        $data['video_type'] = 1;
-        if (isset($video_info['streams']) && $video_info['streams']) {
-            foreach ($video_info['streams'] as $k => $v) {
-                if (isset($v['width']) && isset($v['height'])) {
-                    $data['video_width'] = $v['width'];
-                    $data['video_height'] = $v['height'];
-                    if ($data['video_width'] >= $data['video_height']) {
-                        $data['video_type'] = 1;
-                    } else {
-                        $data['video_type'] = 2;
-                    }
-                    
-                    break;
-                }
-            }
-        }
-
-        return $data;
-    }
-
-    public function test()
-    {
-        $limit = Dever::input('start', 0);
-        $num = 10000;
-        $state = true;
-        while($state) {
-            $data = $this->tdata($limit, $num);
-            if ($data) {
-                $state = true;
-                foreach ($data as $k => $v) {
-                    if ($v['mobile'] && strstr($v['mobile'], '1')) {
-                        $this->tupdate($v['id'], $v['mobile']);
-                    }
-                }
-            } else {
-                $state = false;
-            }
-        }
-
-        return 'ok';
-    }
-
-    public function tupdate($id, $mobile)
-    {
-        $url = 'https://sp0.baidu.com/8aQDcjqpAAV3otqbppnN2DJv/api.php?query={mobile}&resource_id=6004&ie=utf8&oe=utf8&format=json';
-        $url = str_replace('{mobile}', $mobile, $url);
-        $result = Dever::curl($url);
-        $result = json_decode($result, true);
-        if (isset($result['data'][0]['city'])) {
-            if (!$result['data'][0]['prov']) {
-                $result['data'][0]['prov'] = $result['data'][0]['city'];
-            }
-            $sql = 'update huala_member set mobile_city = "'.$result['data'][0]['city'].'", mobile_prov = "'.$result['data'][0]['prov'].'" where id = ' . $id;
-            Dever::db('collection/info')->query($sql);
-        }
-    }
-
-    public function tdata($limit, $num)
-    {
-        $sql = 'select * from huala_member where mobile_prov is null order by id asc limit ' . $limit . ',' . $num;
-        $data = Dever::db('collection/info')->fetchAll($sql);
-        return $data;
-    }
 }

+ 241 - 0
app/collection/src/Old.php

@@ -0,0 +1,241 @@
+<?php
+
+namespace Collection\Src;
+
+use Dever;
+use Collection\Lib\Core;
+
+class Api extends Core
+{
+    public function __construct()
+    {
+        $this->id = Dever::input('id');
+    }
+
+    public function data()
+    {
+        return Dever::db('collection/info')->state();
+    }
+
+    # 获取合集内容
+    public function getInfo()
+    {
+        # 是否已经购买
+        $data['is_buy'] = false;
+        $data['button'] = array(
+            'bgcolor' => 'background: linear-gradient(to right, #000000,#000000) !important;color:#fff;',
+            'color' => 'color:#fff',
+            'name' => array('入口', '排行榜')
+        );
+        $data['info'] = Dever::db('collection/info')->one($this->id);
+        if ($data['info']) {
+            $data['info']['pic_bg'] = explode(',', $data['info']['pic_bg']);
+
+            if ($data['info']['buy'] == 1) {
+                # 收费 从订单中读取是否已经购买
+                $data['is_buy'] = false;
+            } else {
+                # 免费
+                $data['is_buy'] = true;
+            }
+
+            $data['button']['name'] = explode(',', $data['info']['button']);
+            if ($data['info']['button_bgcolor'] && $data['info']['button_bgjcolor']) {
+                $data['button']['bgcolor'] = 'background: linear-gradient(to right, '.$data['info']['button_bgcolor'].','.$data['info']['button_bgjcolor'].') !important;';
+            }
+            if ($data['info']['button_ftcolor']) {
+                $data['button']['color'] = 'color:' . $data['info']['button_ftcolor'];
+                $data['button']['bgcolor'] .= $data['button']['color'];
+            }
+
+            # 获取最新的章节页id
+            $page_where['info_id'] = $data['info']['id'];
+            $page_where['year'] = $this->year;
+            $data['page'] = Dever::db('collection/page')->child($page_where);
+            $data['page_id'] = 0;
+            if ($data['page']) {
+                $data['page_id'] = $data['page'][0]['id'];
+            }
+        }
+
+        return $data;
+    }
+
+    # 获取合集下的购买内容
+    public function getBuy()
+    {
+        $data['info'] = Dever::db('collection/info')->one($this->id);
+        $where['info_id'] = $this->id;
+        $data['buy'] = Dever::db('collection/buy')->getAll($where);
+
+        return $data;
+    }
+
+    # 获取合集下的榜单列表
+    public function getRanking()
+    {
+        $where['info_id'] = $this->id;
+        $data['ranking'] = Dever::db('collection/ranking')->getAll($where);
+
+        return $data;
+    }
+
+    # 获取合集下的内容
+    public function getContent()
+    {
+        $page_id = Dever::input('page_id');
+        $data['items'] = Dever::load('collection/lib/content')->getList($this->id, $page_id);
+
+        $page = Dever::db('collection/page')->one($page_id);
+        $data['info_id'] = $this->id;
+        $data['page_id'] = $page_id;
+        $data['parent_page_id'] = $page['page_id'];
+
+        # 获取用户信息
+        $data['user'] = Dever::load('passport/api')->info($this->uid);
+        return $data;
+    }
+
+    # 获取合集下的分类
+    public function category()
+    {
+        $parent_page_id = Dever::input('parent_page_id');
+        $page_id = Dever::input('page_id');
+        $where['info_id'] = $this->id;
+        $data['cate'] = Dever::db('collection/page')->main($where);
+        if ($data['cate']) {
+            $data['child'] = Dever::db('collection/page')->child($where);
+            $content = Dever::db('collection/content')->child($where);
+            $data['show'] = array();
+            foreach ($data['cate'] as $k => $v) {
+                if ($v['id'] == $parent_page_id) {
+                    $data['show'][$v['id']] = 1;
+                } else {
+                    $data['show'][$v['id']] = 2;
+                }
+            }
+            foreach ($data['child'] as $k => $v) {
+                
+                if (isset($content[$v['id']])) {
+                    $data['child'][$k]['content'] = $content[$v['id']];
+                }
+            }
+        }
+
+        return $data;
+    }
+
+    public function ding($data)
+    {
+        if (isset($data['num_add_buy']) && isset($data['num_ratio_buy'])) {
+
+            if ($data['buy'] == 1) {
+                /*
+                if (!$data['num_buy']) {
+                    $stat = Dever::db('stat/collection')->getNumBycollection(array('collection_id' => $data['id']));
+                    if (!$stat) {
+                        $stat['buy_num'] = 0;
+                    }
+
+                    if (!$stat['buy_num']) {
+                        $stat['buy_num'] = 0;
+                    }
+                    $data['num_buy'] = $stat['buy_num'];
+                }
+                */
+
+                $data['num_up'] = 0;
+            }
+
+            $data['num_buy'] = $data['num_buy'] + $data['num_up'];
+            $data['buy_num'] = $data['num_buy'];
+            $data['num_buy'] = round(($data['num_buy']+$data['num_add_buy'])*$data['num_ratio_buy']);
+        }
+
+        return $data;
+    }
+
+    # 解析元信息
+    public function avinfo($data, $url = 'video', $table = 'video/vod')
+    {
+        # 解析视频元信息
+        if (!$data['video_info']) {
+            $video_info = Dever::curl($data[$url] . '?avinfo');
+            if ($video_info) {
+                Dever::db($table)->update(array('where_id' => $data['id'], 'video_info' => $video_info));
+            }
+            
+            $video_info = Dever::json_decode($video_info);
+        } else {
+            $video_info = Dever::json_decode($data['video_info']);
+        }
+
+        unset($data['video_info']);
+
+        $data['video_width'] = 0;
+        $data['video_height'] = 0;
+        # 默认横屏
+        $data['video_type'] = 1;
+        if (isset($video_info['streams']) && $video_info['streams']) {
+            foreach ($video_info['streams'] as $k => $v) {
+                if (isset($v['width']) && isset($v['height'])) {
+                    $data['video_width'] = $v['width'];
+                    $data['video_height'] = $v['height'];
+                    if ($data['video_width'] >= $data['video_height']) {
+                        $data['video_type'] = 1;
+                    } else {
+                        $data['video_type'] = 2;
+                    }
+                    
+                    break;
+                }
+            }
+        }
+
+        return $data;
+    }
+
+    public function test()
+    {
+        $limit = Dever::input('start', 0);
+        $num = 10000;
+        $state = true;
+        while($state) {
+            $data = $this->tdata($limit, $num);
+            if ($data) {
+                $state = true;
+                foreach ($data as $k => $v) {
+                    if ($v['mobile'] && strstr($v['mobile'], '1')) {
+                        $this->tupdate($v['id'], $v['mobile']);
+                    }
+                }
+            } else {
+                $state = false;
+            }
+        }
+
+        return 'ok';
+    }
+
+    public function tupdate($id, $mobile)
+    {
+        $url = 'https://sp0.baidu.com/8aQDcjqpAAV3otqbppnN2DJv/api.php?query={mobile}&resource_id=6004&ie=utf8&oe=utf8&format=json';
+        $url = str_replace('{mobile}', $mobile, $url);
+        $result = Dever::curl($url);
+        $result = json_decode($result, true);
+        if (isset($result['data'][0]['city'])) {
+            if (!$result['data'][0]['prov']) {
+                $result['data'][0]['prov'] = $result['data'][0]['city'];
+            }
+            $sql = 'update huala_member set mobile_city = "'.$result['data'][0]['city'].'", mobile_prov = "'.$result['data'][0]['prov'].'" where id = ' . $id;
+            Dever::db('collection/info')->query($sql);
+        }
+    }
+
+    public function tdata($limit, $num)
+    {
+        $sql = 'select * from huala_member where mobile_prov is null order by id asc limit ' . $limit . ',' . $num;
+        $data = Dever::db('collection/info')->fetchAll($sql);
+        return $data;
+    }
+}