dever 4 年之前
父节点
当前提交
64008a97b1

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

@@ -4,8 +4,11 @@ $type = array
 (
     1 => '门票榜单',
     2 => '购物榜单',
-    3 => '贡献榜单',
+    3 => '邀请榜单',
     4 => '积分榜单',
+    //5 => '赞赏榜单',
+    //6 => '贡献榜单',
+    //7 => '成员榜单',
 );
 
 $periods = array
@@ -14,6 +17,7 @@ $periods = array
     2 => '周',
     3 => '月',
     4 => '年',
+    5 => '永久(持续到总榜结束时间)',
 );
 
 $status = array
@@ -99,18 +103,6 @@ return array
             'list'      => true,
         ),
 
-        'periods'     => array
-        (
-            'type'      => 'int-11',
-            'name'      => '榜单周期',
-            'default'   => '1',
-            'desc'      => '榜单周期',
-            'match'     => 'is_numeric',
-            'update'    => 'radio',
-            'option'    => $periods,
-            'list'      => true,
-        ),
-
         'start'       => array
         (
             'type'      => 'int-11',
@@ -135,6 +127,18 @@ return array
             'callback'  => 'maketime',
         ),
 
+        'periods'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '榜单周期',
+            'default'   => '1',
+            'desc'      => '榜单周期',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $periods,
+            'list'      => true,
+        ),
+
         'desc'      => array
         (
             'type'      => 'text-255',

+ 3 - 3
app/collection/database/ranking_periods.php

@@ -106,7 +106,7 @@ return array
             'match'     => 'option',
             'desc'      => '本期结束时间',
             'update'    => 'date',
-            'list'      => 'date("Y-m-d H:i:s", {end})',
+            'list'      => '{end} ? date("Y-m-d H:i:s", {end}) : "无"',
             'callback'  => 'maketime',
         ),
 
@@ -147,11 +147,11 @@ return array
             (
                 'info_id' => 'yes',
                 'ranking_id' => 'yes',
-                'status' => 1,
+                //'status' => 1,
                 'state' => 1,
             ),
             'type' => 'all',
-            'order' => array('periods' => 'desc', 'cdate' => 'desc'),
+            'order' => array('status' => 'asc', 'periods' => 'desc', 'cdate' => 'desc'),
             'limit' => '0,20',
             'col' => '*',
         ),

+ 9 - 0
app/collection/lib/Core.php

@@ -146,6 +146,7 @@ class Core
                 $this->id = Dever::load('collection/lib/common')->decode($this->id_code);
             }
         }
+
         if ($this->share_uid == $this->uid) {
             $this->share_uid = 0;
         }
@@ -228,6 +229,14 @@ class Core
             $day = 0;
         }
 
+        if (!$day) {
+            # 从用户的时光获取
+            $my_times = Dever::load('user/lib/times')->getData($this->uid, $this->id);
+            if ($my_times && $my_times['day']) {
+                $day = str_replace('-', '', $my_times['day']);
+            }
+        }
+
         # 获取门票
         $ticket = Dever::load('user/lib/ticket')->check($this->uid, $this->id);
         if ($ticket) {

+ 31 - 8
app/collection/lib/Ranking.php

@@ -7,6 +7,12 @@ use Dever;
 class Ranking
 {
 
+    # 积分回调,增加积分榜单
+    public function score($log)
+    {
+        $this->up($log['uid'], $log['type_id'], 4, $log['num']);
+    }
+
 	# 获取最新的总榜
     public function getInfo($info_id, $type = 1)
     {
@@ -52,7 +58,12 @@ class Ranking
         	$update['ranking_id'] = $periods['ranking_id'];
         	if ($data) {
         		$update['where_id'] = $data['id'];
-        		$update['num'] = $data['num'] + $num;
+                if ($num < 0) {
+                    $update['num'] = $data['num'] - $num;
+                } else {
+                    $update['num'] = $data['num'] + $num;
+                }
+        		
         		Dever::db('collection/ranking_data')->update($update);
         	} else {
         		$update['num'] = $num;
@@ -76,7 +87,7 @@ class Ranking
 	        		$this->createPeriods(1, $cur, $v);
 	        	} else {
 	        		# 如果有,检查结束时间到没到期,如果到了,就把这一期置为已结束,重新建立新的期数
-	        		if ($cur > $info['end']) {
+	        		if ($info['end'] > 0 && $cur > $info['end']) {
 	        			Dever::db('collection/ranking_periods')->update(array('where_id' => $info['id'], 'status' => 2));
 	        			$this->createPeriods($info['periods'] + 1, $cur, $v);
 	        		}
@@ -100,17 +111,29 @@ class Ranking
     	$data['users'] = 0;
     	$data['status'] = 1;
     	$data['start'] = $cur;
-    	if ($info['periods'] == 2) {
+        $day = 86400;
+        if ($info['periods'] == 1) {
+            # 天
+            $time = $day;
+        } elseif ($info['periods'] == 2) {
     		# 周
-    		$time = 3600*24*7;
+    		$time = $day * 7;
     	} elseif ($info['periods'] == 3) {
     		# 月
-    		$time = 3600*24*30;
+    		$time = $day * 30;
     	} elseif ($info['periods'] == 4) {
     		# 年
-    		$time = 3600*24*365;
-    	}
-    	$data['end'] = $data['start'] + $time;
+    		$time = $day * 365;
+    	} elseif ($info['periods'] == 5) {
+            # 永久
+            $time = 0;
+        }
+        if ($time > 0) {
+            $data['end'] = $data['start'] + $time;
+        } else {
+            $data['end'] = 0;
+        }
+    	
     	Dever::db('collection/ranking_periods')->insert($data);
     }
 }

+ 4 - 1
app/collection/src/Api.php

@@ -314,6 +314,9 @@ class Api extends Core
 
         $data['share'] = $this->getInfoShare($data['info']);
 
+        $num = Dever::load('user/lib/collection')->getNum($this->id);
+        $data['info']['desc'] .= '<p>成员:'.$num.'人</p>';
+
         return $data;
     }
 
@@ -370,7 +373,7 @@ class Api extends Core
 
             if ($data['ranking_data']) {
                 foreach ($data['ranking_data'] as $k => $v) {
-                    $data['ranking_data'][$k]['user'] = $this->getUser($v['uid'], $this->id);
+                    $data['ranking_data'][$k]['user'] = $this->getUser($v['uid'], $this->id, true);
                 }
             }
         }

+ 2 - 0
app/user/lib/Collection.php

@@ -44,6 +44,8 @@ class Collection
             $where['num'] = $num;
             if ($source_uid) {
                 $where['source_uid'] = $source_uid;
+                # 更新邀请榜单
+                Dever::load('collection/lib/ranking')->up($source_uid, $info_id, 3, 1);
             }
             if ($ticket_id) {
                 $where['ticket_id'] = $ticket_id;

+ 7 - 0
app/user/lib/Seat.php

@@ -164,6 +164,13 @@ class Seat
         $order_data['system_source'] = $system_source;
         $order_data['order_id'] = $this->getOrderId();
 
+        if (!$parent_uid && Dever::project('invite')) {
+            $parent = Dever::load('invite/api')->getParent($uid, 1);
+            if ($parent) {
+                $parent_uid = $parent['uid'];
+            }
+        }
+        
         if ($parent_uid) {
             $order_data['parent_uid'] = $parent_uid;
         }

+ 7 - 0
app/user/lib/Ticket.php

@@ -80,6 +80,13 @@ class Ticket
         $order_data['system_source'] = $system_source;
         $order_data['order_id'] = $this->getOrderId();
 
+        if (!$parent_uid && Dever::project('invite')) {
+            $parent = Dever::load('invite/api')->getParent($uid, 1);
+            if ($parent) {
+                $parent_uid = $parent['uid'];
+            }
+        }
+        
         if ($parent_uid) {
             $order_data['parent_uid'] = $parent_uid;
         }

+ 7 - 0
app/user/src/Api.php

@@ -154,6 +154,13 @@ class Api extends Core
         } else {
             $where['day'] = $this->day;
         }
+        if (!$where['day']) {
+            # 从用户的时光获取
+            $my_times = Dever::load('user/lib/times')->getData($this->uid, $this->id);
+            if ($my_times && $my_times['day']) {
+                $where['day'] = str_replace('-', '', $my_times['day']);
+            }
+        }
         $where['content_id'] = Dever::input('content_id');
         $where['index'] = Dever::input('index', 0);
         if ($record) {

+ 16 - 0
app/user/src/Pay.php

@@ -7,6 +7,16 @@ use Collection\Lib\Core;
 
 class Pay extends Core
 {
+    private function getParent()
+    {
+        if (!$this->share_uid) {
+            $info = Dever::load('user/lib/collection')->check($this->uid, $this->id);
+            if ($info && $info['source_uid']) {
+                $this->share_uid = $info['source_uid'];
+            }
+        }
+    }
+
     # 购买产品 下单
     public function product()
     {
@@ -36,6 +46,8 @@ class Pay extends Core
             Dever::alert('请传入购买数量');
         }
 
+        $this->getParent();
+
         $pay = Dever::load('goods/lib/pay')->action($this->share_uid, $this->user, $goods_id, $sku, $num, $mode, $store_id, $this->system_source, 'collection/info', $this->id, $refer);
 
         return $pay;
@@ -59,6 +71,8 @@ class Pay extends Core
         $object_id = Dever::input('object_id');
         $refer = Dever::input('refer');
 
+        $this->getParent();
+
         $pay = Dever::load('user/lib/ticket')->action($this->share_uid, $uid, $buy_id, $object_id, $this->system_source, $refer);
 
         return $pay;
@@ -93,6 +107,8 @@ class Pay extends Core
             Dever::alert('请选择正确的座位');
         }
 
+        $this->getParent();
+
         $refer = Dever::input('refer');
         $location = Dever::input('location');
         $code = $this->getCode($this->id, $this->parent_page_id, $this->page_id, $index, $this->times, $this->day);