dever 6 years ago
parent
commit
d2bc3d6ef5
3 changed files with 92 additions and 1 deletions
  1. 11 1
      journal/database/order.php
  2. 2 0
      journal/lib/Pay.php
  3. 79 0
      main/lib/Cron.php

+ 11 - 1
journal/database/order.php

@@ -417,7 +417,17 @@ return array
             'default'   => '1',
             'desc'      => '支付方式',
             'match'     => 'is_numeric',
-            'list'      => true,
+            //'list'      => true,
+        ),
+
+        'refund_status'      => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '支付方式',
+            'default'   => '1',
+            'desc'      => '支付方式',
+            'match'     => 'is_numeric',
+            //'list'      => true,
         ),
     ),
 

+ 2 - 0
journal/lib/Pay.php

@@ -66,6 +66,8 @@ class Pay
             $send['pay_status'] = $status;
             $send['dever_token'] = $this->key;
 
+            # 减少积分
+
             Dever::load('pay/lib/set.updateStatus', $send);
         }
     }

+ 79 - 0
main/lib/Cron.php

@@ -6,6 +6,85 @@ use Dever;
 
 class Cron
 {
+    public function refund_api()
+    {
+        $order_id = Dever::input('order_id');
+        if ($order_id) {
+            $where['order_id'] = $order_id;
+        }
+        $where['product_id'] = 28;
+        $where['status'] = 5;
+        $where['refund_status'] = 1;
+        $data = Dever::db('journal/order')->state($where);
+
+        $test = Dever::input('test');
+        if ($test == 1) {
+            print_r($data);die;
+        }
+        if ($data) {
+            foreach ($data as $k => $v) {
+                $this->refundScore($v);
+            }
+        }
+    }
+
+    private function refundScore($data)
+    {
+        $score = 0;
+        if ($data['cash'] == 6) {
+            $score = 20;
+        }
+
+        if ($data['cash'] == 60) {
+            $score = 20*10;
+        }
+
+        if ($data['cash'] == 588) {
+            $score = 20*100;
+        }
+
+        if ($data['cash'] == 1728) {
+            $score = 20*300;
+        }
+
+        if ($data['cash'] == 3348) {
+            $score = 20*600;
+        }
+
+        if ($score > 0) {
+            $where['uid'] = $v['uid'];
+            $user = Dever::db('score/user')->one($where);
+            if ($user) {
+                $user_score = $user['score'] - $score;
+                if ($user_score < 0) {
+                    $user_score = 0;
+                }
+                Dever::db('score/user')->update(array('where_id' => $user['id'], 'score' => $user_score));
+            }
+
+            $where['type'] = 4;
+            $where['data_id'] = 28;
+            $user = Dever::db('act/score')->one($where);
+            if ($user) {
+                $user_score = $user['score'] - $score;
+                if ($user_score < 0) {
+                    $user_score = 0;
+                }
+                Dever::db('act/score')->update(array('where_id' => $user['id'], 'score' => $user_score));
+            }
+
+            Dever::db('journal/order')->update(array('where_id' => $data['id'], 'refund_status' => 2));
+        }
+
+        print_r($data);
+
+        print_r($score);
+
+        echo "\r\n";
+
+        return $score;
+    }
+
     public function pays_api()
     {
         $where['product_id'] = 28;