dever 3 years ago
parent
commit
c7c6bf5de1
1 changed files with 31 additions and 13 deletions
  1. 31 13
      service/option/lib/Import.php

+ 31 - 13
service/option/lib/Import.php

@@ -48,37 +48,55 @@ class Import
         $data = Dever::excelImport($file, 2, 5, 'excel');
 
         if ($data) {
-            $update = array();
             foreach ($data as $k => $v) {
                 $state = preg_match(Dever::rule('mobile'), $v['A']);
-                if ($state) {
+                if ($state && $v['C'] > 0) {
                     $where['mobile'] = $v['A'];
                     $type_name = $v['D'];
                     if ($type_name == '期权') {
                         $type = 1;
                     } else {
-                        $type = 2;
+                        $type = 4;
                     }
                     $info = Dever::db('option/account')->find($where);
                     if ($info && $info['status'] < 3) {
                         $info = Dever::db('option/account')->find(array('key' => $info['key'], 'type' => 2));
                         if ($info && $info['status'] < 3) {
-                            if (!isset($update[$info['id']][$type])) {
-                                $update[$info['id']][$type] = array();
-                                $update[$info['id']][$type]['total'] = 0;
-                                $update[$info['id']][$type]['desc'] = array();
-                            }
-                            $update[$info['id']][$type]['total'] += $v['C'];
-                            if ($v['E']) {
-                                $update[$info['id']][$type]['desc'][] = $v['E'];
-                            }
+                            Dever::load('option/lib/cash')->up($info['id'], $type, $v['C'], $v['E'], false);
                         }
                     }   
                 }
             }
+        }
+        return 'ok';
+    }
+
+    # 导入发放记录
+    public function get_fafang_api()
+    {
+        $file = Dever::data() . 'qiquan.xlsx';
 
-            if ($update) {
+        $data = Dever::excelImport($file, 3, 5, 'excel');
 
+        if ($data) {
+            foreach ($data as $k => $v) {
+                $state = preg_match(Dever::rule('mobile'), $v['A']);
+                if ($state && $v['C'] > 0) {
+                    $where['mobile'] = $v['A'];
+                    $type_name = $v['D'];
+                    if ($type_name == '期权') {
+                        $type = 2;
+                    } else {
+                        $type = 5;
+                    }
+                    $info = Dever::db('option/account')->find($where);
+                    if ($info && $info['status'] < 3) {
+                        $info = Dever::db('option/account')->find(array('key' => $info['key'], 'type' => 2));
+                        if ($info && $info['status'] < 3) {
+                            Dever::load('option/lib/cash')->up($info['id'], $type, $v['C'], $v['E'], false);
+                        }
+                    }   
+                }
             }
         }
         return 'ok';