rabin 3 years ago
parent
commit
e049ae6653

+ 1 - 1
service/bill/database/sell.php

@@ -234,7 +234,7 @@ return array
             (
                 'start' => array('yes-cdate', '>='),
                 'end' => array('yes-cdate', '<='),
-                //'type' => array('yes', 'in'),
+                'type' => array('yes', 'in'),
                 'state' => 1,
             ),
             'type' => 'all',

+ 1 - 1
service/option/database/member.php

@@ -122,7 +122,7 @@ return array
             'default'   => '',
             'desc'      => '身份证号码',
             'match'     => Dever::rule('idcard'),
-            //'match'     => 'is_string',
+            'match'     => 'is_string',
             'search'    => 'fulltext',
             'update'    => 'text',
             'list'      => true,

+ 2 - 0
service/option/lib/Cash.php

@@ -73,6 +73,7 @@ class Cash
                         if ($alert) {
                             Dever::alert('交付期权价值不足发放');
                         } else {
+                            return false;
                             $data['status'] = 2;
                         }
                     }
@@ -83,6 +84,7 @@ class Cash
                         if ($alert) {
                             Dever::alert('发放期权价值不足兑付');
                         } else {
+                            return false;
                             $data['status'] = 2;
                         }
                     }

+ 126 - 41
service/option/lib/Import.php

@@ -12,7 +12,7 @@ class Import
     public function get_api()
     {
         Dever::config('base')->hook = true;
-        $file = Dever::data() . 'q.xlsx';
+        $file = Dever::data() . 'qiquan.xlsx';
 
         $data = Dever::excelImport($file, 1, 5, 'excel');
 
@@ -26,6 +26,10 @@ class Import
         $table_status['body'][0][0] = 0;
         $table_status['body'][0][1] = 0;
 
+        $table_error = array();
+        $table_error['head'] = array('序列号', '说明');
+        $table_error['body'] = array();
+
         $check = array();
 
         if ($data) {
@@ -56,7 +60,11 @@ class Import
                             $table_status['body'][0][1] += 1;
                         }
                     }
-                    $check[$key] = 2;
+                    if (isset($check[$key]) && $check[$key] == 1) {
+
+                    } else {
+                        $check[$key] = 2;
+                    }
                     if ($id && $update['main'] == 1) {
                         $check[$key] = 1;
                         if (!isset($member[$key])) {
@@ -97,6 +105,18 @@ class Import
             'type' => 'table',
             'content' => $table,
         );
+
+        foreach ($check as $k => $v) {
+            if ($v == 2) {
+                $table_error['body'][$k] = array($k, '无主账号');
+            }
+        }
+        $result['数据异常'] = array
+        (
+            'type' => 'table',
+            'content' => $table_error,
+        );
+
         $html = Dever::show('', $result, false, false);
         return $html;
     }
@@ -105,7 +125,7 @@ class Import
     public function check_api()
     {
         Dever::config('base')->hook = true;
-        $file = Dever::data() . 'q.xlsx';
+        $file = Dever::data() . 'qiquan.xlsx';
 
         $data = Dever::excelImport($file, 1, 5, 'excel');
 
@@ -129,7 +149,12 @@ class Import
                     $key = $v['A'];
                     $update = array();
                     $update['main'] = $v['E'] == 1 ? 1 : 2;
-                    $check[$key] = 2;
+                    if (isset($check[$key]) && $check[$key] == 1) {
+
+                    } else {
+                        $check[$key] = 2;
+                    }
+                    
                     if ($update['main'] == 1) {
                         $check[$key] = 1;
                         $table_status['body'][0][0] += 1;
@@ -148,18 +173,19 @@ class Import
                 }
             }
         }
+
         $result['数据统计'] = array
         (
             'type' => 'table',
             'content' => $table_status,
         );
 
+
         foreach ($check as $k => $v) {
             if ($v == 2) {
-                $table[$k] = array($k, '无主账号');
+                $table['body'][$k] = array($k, '无主账号');
             }
         }
-
         $result['数据异常'] = array
         (
             'type' => 'table',
@@ -174,6 +200,8 @@ class Import
     {
         Dever::config('base')->hook = true;
 
+        $check = Dever::input('check');
+
         $file = Dever::data() . 'qiquan.xlsx';
 
         $data = Dever::excelImport($file, 2, 5, 'excel');
@@ -182,38 +210,54 @@ class Import
         $table['head'] = array('手机号', '身份证号', '交付金额', '期权类型', '说明');
         $table['body'] = array();
 
-        $error_table = array();
-        $error_table['head'] = array('手机号', '身份证号', '交付金额', '期权类型', '说明');
-        $error_table['body'] = array();
+        $table_status = array();
+        $table_status['head'] = array('总条数', '总价值');
+        $table_status['body'] = array();
+        $table_status['body'][0][0] = 0;
+        $table_status['body'][0][1] = 0;
 
         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 = 1;
-                    } else {
-                        $type = 4;
-                    }
-                    $info = Dever::db('option/member')->find($where);
-                    if ($info) {
-                        $account = Dever::db('option/account')->find($info['aid']);
-                        if ($account && $account['status'] < 3) {
-                            $state = Dever::load('option/lib/cash')->up($info['id'], $account['id'], $type, $v['C'], $v['E'], false);
-                            if ($state) {
-
+                if ($state) {
+                    if ($v['C'] > 0) {
+                        $where['mobile'] = $v['A'];
+                        $type_name = $v['D'];
+                        if ($type_name == '期权') {
+                            $type = 1;
+                        } else {
+                            $type = 4;
+                        }
+                        $info = Dever::db('option/member')->find($where);
+                        if ($info) {
+                            $account = Dever::db('option/account')->find($info['aid']);
+                            if ($account && $account['status'] < 3) {
+                                if ($check == 1) {
+                                    $state = true;
+                                } else {
+                                    $state = Dever::load('option/lib/cash')->up($info['id'], $account['id'], $type, $v['C'], $v['E'], false);
+                                }
+                                
+                                if ($state) {
+                                    $table_status['body'][0][0] += 1;
+                                    $table_status['body'][0][1] += $v['C'];
+                                } else {
+                                    $table['body'][] = array($info['mobile'], $info['idcard'], $v['C'], $type_name, '导入到数据表失败');
+                                }
                             } else {
-
+                                $table['body'][] = array($info['mobile'], $info['idcard'], $v['C'], $type_name, '未找到主账户');
                             }
+                        } else {
+                            $table['body'][] = array($where['mobile'], $v['B'], $v['C'], $type_name, '未找到期权账户');
                         }
+                    } else {
+                        $table['body'][] = array($v['A'], $v['B'], $v['C'], $v['D'], '交付金额为0');
                     }
                 }
             }
         }
         
-        $result['导入状态'] = array
+        $result['导入成功'] = array
         (
             'type' => 'table',
             'content' => $table_status,
@@ -232,31 +276,72 @@ class Import
     public function get_fafang_api()
     {
         Dever::config('base')->hook = true;
+        $check = Dever::input('check');
         $file = Dever::data() . 'qiquan.xlsx';
 
         $data = Dever::excelImport($file, 3, 5, 'excel');
 
+        $table = array();
+        $table['head'] = array('手机号', '身份证号', '发放金额', '期权类型', '说明');
+        $table['body'] = array();
+
+        $table_status = array();
+        $table_status['head'] = array('总条数', '总价值');
+        $table_status['body'] = array();
+        $table_status['body'][0][0] = 0;
+        $table_status['body'][0][1] = 0;
+
         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/member')->find($where);
-                    if ($info) {
-                        $account = Dever::db('option/account')->find($info['aid']);
-                        if ($account && $account['status'] < 3) {
-                            Dever::load('option/lib/cash')->up($info['id'], $account['id'], $type, $v['C'], $v['E'], false);
+                if ($state) {
+                    if ($v['C'] > 0) {
+                        $where['mobile'] = $v['A'];
+                        $type_name = $v['D'];
+                        if ($type_name == '期权') {
+                            $type = 2;
+                        } else {
+                            $type = 5;
+                        }
+                        $info = Dever::db('option/member')->find($where);
+                        if ($info) {
+                            $account = Dever::db('option/account')->find($info['aid']);
+                            if ($account && $account['status'] < 3) {
+                                if ($check == 1) {
+                                    $state = true;
+                                } else {
+                                    $state = Dever::load('option/lib/cash')->up($info['id'], $account['id'], $type, $v['C'], $v['E'], false);
+                                }
+                                if ($state) {
+                                    $table_status['body'][0][0] += 1;
+                                    $table_status['body'][0][1] += $v['C'];
+                                } else {
+                                    $table['body'][] = array($info['mobile'], $info['idcard'], $v['C'], $type_name, '导入到数据表失败');
+                                }
+                            } else {
+                                $table['body'][] = array($info['mobile'], $info['idcard'], $v['C'], $type_name, '未找到主账户');
+                            }
+                        } else {
+                            $table['body'][] = array($where['mobile'], $v['B'], $v['C'], $type_name, '未找到期权账户');
                         }
+                    } else {
+                        $table['body'][] = array($v['A'], $v['B'], $v['C'], $v['D'], '发放金额为0');
                     }
-                }
+                } 
             }
         }
-        return 'ok';
+        $result['导入成功'] = array
+        (
+            'type' => 'table',
+            'content' => $table_status,
+        );
+
+        $result['导入异常'] = array
+        (
+            'type' => 'table',
+            'content' => $table,
+        );
+        $html = Dever::show('', $result, false, false);
+        return $html;
     }
 }