dever 6 years ago
parent
commit
4b89d28fc6
2 changed files with 91 additions and 1 deletions
  1. 1 1
      journal/database/order.php
  2. 90 0
      main/lib/Cron.php

+ 1 - 1
journal/database/order.php

@@ -540,7 +540,7 @@ return array
             'option' => array
             (
                 'status' => 'yes',
-                'type' => array('yes', '<='),
+                'type' => array('yes', 'in'),
                 'product_id' => 'yes',
                 'order_id' => 'yes',
                 'uid' => 'yes',

+ 90 - 0
main/lib/Cron.php

@@ -90,6 +90,96 @@ class Cron
         return 'ok';
     }
 
+    # 重新计算排行榜
+    public function pai4_api()
+    {
+        $id = Dever::input('product_id', 28);
+
+        # 购买小刊
+        $where['product_id'] = $id;
+        $where['status'] = 2;
+        $order_id = Dever::input('order_id');
+        if ($order_id) {
+            $where['order_id'] = $order_id;
+        }
+        $uid = Dever::input('uid');
+        if ($uid) {
+            $where['uid'] = $uid;
+        }
+        $where['type'] = array(1,3);
+        //$where['score_status'] = 1;
+        $order = Dever::db('journal/order')->getBuy($where);
+
+        if ($order) {
+            $user = array();
+            foreach ($order as $k => $v) {
+                $this->paiOrder1($v, $user);
+                
+            }
+        }
+
+        $test = Dever::input('test');
+        if ($test == 1) {
+            print_r($user);die;
+        }
+
+        # 重建积分排行
+        foreach ($user as $k => $v) {
+            print_r($v);
+            $info = Dever::db('act/score')->one(array('uid' => $v['uid'], 'type' => 4, 'data_id' => $id));
+            if (!$info) {
+                $insert['uid'] = $v['uid'];
+                $insert['type'] = 4;
+                $insert['data_id'] = $id;
+                $insert['score'] = $v['score'];
+                Dever::db('act/score')->insert($insert);
+            } else {
+                $update['where_id'] = $info['id'];
+                $update['uid'] = $v['uid'];
+                $update['type'] = 4;
+                $update['data_id'] = $id;
+                $update['score'] = $v['score'] + $info['score'];
+                Dever::db('act/score')->update($update);
+            }
+        }
+
+        return 'ok';
+
+        
+    }
+
+    public function paiOrder1($order, &$user)
+    {
+        if (!isset($user[$order['uid']])) {
+            $user[$order['uid']] = array();
+            $user[$order['uid']]['uid'] = $order['uid'];
+            $user[$order['uid']]['score'] = 0;
+        }
+
+        $score = 0;
+        if ($order['cash'] == 6) {
+            $score = 20;
+        }
+
+        if ($order['cash'] == 60) {
+            $score = 20*10;
+        }
+
+        if ($order['cash'] == 588) {
+            $score = 20*100;
+        }
+
+        if ($order['cash'] == 1728) {
+            $score = 20*300;
+        }
+
+        if ($order['cash'] == 3348) {
+            $score = 20*600;
+        }
+
+        $user[$order['uid']]['score'] += $num*20;
+    }
+
     # 重新计算排行榜
     public function pai3_api()
     {