dever 6 years ago
parent
commit
5c65bb21a1
1 changed files with 17 additions and 6 deletions
  1. 17 6
      main/src/Content.php

+ 17 - 6
main/src/Content.php

@@ -30,6 +30,10 @@ class Content extends Core
         $where['product_id'] = 15;
         $where['type'] = Dever::input('type', 1);
         $where['buy_id'] = Dever::input('buy_id', 48);
+        $uid = Dever::input('uid');
+        if ($uid > 0) {
+            $where['uid'] = $uid;
+        }
         $id = array
         (
             48 => 10,
@@ -41,9 +45,8 @@ class Content extends Core
         $data = Dever::db('journal/order')->state($where);
         $time = Dever::maketime('2019-01-29 14:44:30');
         if ($data) {
-            print_r($data);die;
             foreach ($data as $k => $v) {
-                if ($v['cdate'] < $time && $v['type'] < 3 && isset($id[$v['buy_id']]) && $id[$v['buy_id']]) {
+                if ($v['cdate'] < $time && isset($id[$v['buy_id']]) && $id[$v['buy_id']]) {
                     $num = $id[$v['buy_id']] - 1;
                     $score = $num * $info['score'];
 
@@ -52,13 +55,21 @@ class Content extends Core
                         $update['where_id'] = $user['id'];
                         $update['score'] = $user['score'] + $score;
 
-                        print_r($update);die;
+                        print_r($update);
+                        print_r($v);die;
                         if ($v['type'] == 1) {
                             Dever::score($v['uid'], 'buy_journal', '购买小刊', 'act/lib/score.submit?method=pay&type=4&id=' . $v['product_id'], $score, false);
-                        } elseif ($v['type'] == 2) {
-                            Dever::score($v['uid'], 'dh_journal', '兑换小刊', 'act/lib/score.submit?method=code&type=4&id=' . $v['product_id'], $score, false);
+                        } elseif ($v['type'] == 3) {
+
+                            $w['type'] = 2;
+                            $w['code'] = $v['code'];
+                            $w['status'] = 2;
+                            $o = Dever::db('journal/order')->one($w);
+
+                            if ($o) {
+                                Dever::score($o['uid'], 'dh_journal', '兑换小刊', 'act/lib/score.submit?method=code&type=4&id=' . $o['product_id'], $score, false);
+                            }
                         }
-                        
                     }
                 }
             }