dever 6 years ago
parent
commit
caf9688a14
1 changed files with 33 additions and 0 deletions
  1. 33 0
      main/lib/Cron.php

+ 33 - 0
main/lib/Cron.php

@@ -6,6 +6,39 @@ use Dever;
 
 class Cron
 {
+    public function buy_code_api()
+    {
+        # 根据订单的buy_id来确定生成的本数
+        $id = Dever::input('product_id', 26);
+        $where['product_id'] = $id;
+        $where['status'] = 2;
+        //$where['score_status'] = 1;
+        $order_id = Dever::input('order_id');
+        if ($order_id) {
+            $where['order_id'] = $order_id;
+        }
+        $uid = Dever::input('uid');
+        if ($uid) {
+            $where['uid'] = $uid;
+        }
+        $order = Dever::db('act/order')->state($where);
+        $test = Dever::input('test');
+        if ($test == 1) {
+            print_r($order);die;
+        }
+        if ($order) {
+            $db = Dever::load('code/lib/core');
+            foreach ($order as $k => $v) {
+                if ($v['type'] == 1 || $v['type'] == 3) {
+                    $v['code'] = '';
+                    $v['type'] = 3;
+                    $db->createCodeByOrder($v);
+                }
+            }
+        }
+
+        return 'ok';
+    }
     # 增加积分
     public function scores2_api()
     {