rabin 2 years ago
parent
commit
a3d83a7779
1 changed files with 51 additions and 0 deletions
  1. 51 0
      service/agent/lib/Import.php

+ 51 - 0
service/agent/lib/Import.php

@@ -520,6 +520,57 @@ class Import
         }
     }
 
+    # 导入创客名额
+    public function chuangke_api()
+    {
+        $data = Dever::db('agent/member')->select();
+        $type = 3;
+        $type_id = 1;
+        $desc = '自动发放';
+        if ($data) {
+            foreach ($data as $k => $v) {
+
+                $info = $this->db->fetch('select * from ims_ewei_shop_member where id =' . $v['id']);
+                if (!$info) {
+                    continue;
+                }
+                if (!$info['direct_num']) {
+                    continue;
+                }
+                $direct_num = json_decode($info['direct_num'], true);
+                if (isset($direct_num[4]) && $direct_num[4]) {
+                    $total = $direct_num[4];
+
+                    $prize = Dever::db('setting/prize')->find($type_id);
+                    $price = $prize['price'];
+                    $cash = $prize['price'] * $total;
+                    $name = $prize['name'];
+
+                    $w = array();
+                    $w['type'] = $type;
+                    $w['type_id'] = $type_id;
+                    $w['sku_id'] = -1;
+                    $w['mid'] = $v['id'];
+
+                    $state = Dever::db('agent/member_goods')->one($w);
+                    $w['total_num'] = $total;
+                    $w['cash'] = $cash;
+                    $w['price'] = $price;
+                    $w['name'] = $name;
+                    if (!$state) {
+                        $state = Dever::db('agent/member_goods')->insert($w);
+                        if ($state) {
+                            Dever::load('agent/lib/member_set')->log($w['mid'], '', $w['type'], $w['type_id'], $w['sku_id'], $v['total'], 0, $w['total_num'], $name, $desc);
+                        }
+                    }
+
+                    echo $v['id'];
+                    echo "\r\n";
+                }
+            }
+        }
+    }
+
     # 导入日志记录
     public function log($mid, $type, $before, $after, $update = false)
     {