| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347 | 
							- <?php
 
- namespace Option\Lib;
 
- use Dever;
 
- include('/share/lib/php/dever_package/excel/src/PHPExcel.php');
 
- class Import
 
- {
 
-     # 导入账户
 
-     public function get_api()
 
-     {
 
-         Dever::config('base')->hook = true;
 
-         $file = Dever::data() . 'qiquan.xlsx';
 
-         $data = Dever::excelImport($file, 1, 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;
 
-         $table_error = array();
 
-         $table_error['head'] = array('序列号', '说明');
 
-         $table_error['body'] = array();
 
-         $check = array();
 
-         if ($data) {
 
-             $member = array();
 
-             foreach ($data as $k => $v) {
 
-                 $state = preg_match(Dever::rule('mobile'), $v['C']);
 
-                 if ($state) {
 
-                     $key = $v['A'];
 
-                     $where['key'] = $v['A'];
 
-                     $where['mobile'] = $v['C'];
 
-                     $where['clear'] = true;
 
-                     $info = Dever::db('option/member')->find($where);
 
-                     $update = $where;
 
-                     $update['idcard'] = $v['D'];
 
-                     $update['name'] = $v['B'];
 
-                     $update['main'] = $v['E'] == 1 ? 1 : 2;
 
-                     if (!$info) {
 
-                         $update['status'] = 2;
 
-                         $id = Dever::db('option/member')->insert($update);
 
-                     } else {
 
-                         $update['where_id'] = $info['id'];
 
-                         $id = Dever::db('option/member')->update($update);
 
-                     }
 
-                     if (!$id) {
 
-                         $table['body'][] = array($update['key'], $update['name'], $update['mobile'], $update['idcard'], '账户导入失败,请重新导入');
 
-                     } else {
 
-                         if ($update['main'] == 2) {
 
-                             $table_status['body'][0][1] += 1;
 
-                         }
 
-                     }
 
-                     if (isset($check[$key]) && $check[$key] == 1) {
 
-                     } else {
 
-                         $check[$key] = 2;
 
-                     }
 
-                     if ($id && $update['main'] == 1) {
 
-                         $check[$key] = 1;
 
-                         if (!isset($member[$key])) {
 
-                             $member[$key] = array();
 
-                         }
 
-                         $account = Dever::db('option/account')->find(array('mid' => $id));
 
-                         if (!$account) {
 
-                             $member[$key] = Dever::db('option/account')->insert(array('mid' => $id, 'audit' => 1));
 
-                         } else {
 
-                             $member[$key] = $account['id'];
 
-                         }
 
-                         if (!$member[$key]) {
 
-                             $table['body'][] = array($update['key'], $update['name'], $update['mobile'], $update['idcard'], '生成主账户失败');
 
-                         } else {
 
-                             $table_status['body'][0][0] += 1;
 
-                         }
 
-                     }
 
-                 }
 
-             }
 
-             if ($member) {
 
-                 foreach ($member as $k => $v) {
 
-                     $where = array();
 
-                     $where['option_key'] = $k;
 
-                     $where['set_aid'] = $v;
 
-                     $state = Dever::db('option/member')->updates($where);
 
-                 }
 
-             }
 
-         }
 
-         $result['导入状态'] = array
 
-         (
 
-             'type' => 'table',
 
-             'content' => $table_status,
 
-         );
 
-         $result['导入异常'] = array
 
-         (
 
-             '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;
 
-     }
 
-     # 检测文档
 
-     public function check_api()
 
-     {
 
-         Dever::config('base')->hook = true;
 
-         $file = Dever::data() . 'qiquan.xlsx';
 
-         $data = Dever::excelImport($file, 1, 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;
 
-         $check = array();
 
-         if ($data) {
 
-             $member = array();
 
-             foreach ($data as $k => $v) {
 
-                 $state = preg_match(Dever::rule('mobile'), $v['C']);
 
-                 if ($state) {
 
-                     $key = $v['A'];
 
-                     $update = array();
 
-                     $update['main'] = $v['E'] == 1 ? 1 : 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;
 
-                     } else {
 
-                         $table_status['body'][0][1] += 1;
 
-                     }
 
-                 }
 
-             }
 
-             if ($member) {
 
-                 foreach ($member as $k => $v) {
 
-                     $where = array();
 
-                     $where['option_key'] = $k;
 
-                     $where['set_aid'] = $v;
 
-                     $state = Dever::db('option/member')->updates($where);
 
-                 }
 
-             }
 
-         }
 
-         $result['数据统计'] = array
 
-         (
 
-             'type' => 'table',
 
-             'content' => $table_status,
 
-         );
 
-         foreach ($check as $k => $v) {
 
-             if ($v == 2) {
 
-                 $table['body'][$k] = array($k, '无主账号');
 
-             }
 
-         }
 
-         $result['数据异常'] = array
 
-         (
 
-             'type' => 'table',
 
-             'content' => $table,
 
-         );
 
-         $html = Dever::show('', $result, false, false);
 
-         return $html;
 
-     }
 
-     # 导入交付记录
 
-     public function get_jiaofu_api()
 
-     {
 
-         Dever::config('base')->hook = true;
 
-         $check = Dever::input('check');
 
-         $file = Dever::data() . 'qiquan.xlsx';
 
-         $data = Dever::excelImport($file, 2, 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) {
 
-                     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
 
-         (
 
-             'type' => 'table',
 
-             'content' => $table_status,
 
-         );
 
-         $result['导入异常'] = array
 
-         (
 
-             'type' => 'table',
 
-             'content' => $table,
 
-         );
 
-         $html = Dever::show('', $result, false, false);
 
-         return $html;
 
-     }
 
-     # 导入发放记录
 
-     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) {
 
-                     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');
 
-                     }
 
-                 } 
 
-             }
 
-         }
 
-         $result['导入成功'] = array
 
-         (
 
-             'type' => 'table',
 
-             'content' => $table_status,
 
-         );
 
-         $result['导入异常'] = array
 
-         (
 
-             'type' => 'table',
 
-             'content' => $table,
 
-         );
 
-         $html = Dever::show('', $result, false, false);
 
-         return $html;
 
-     }
 
- }
 
 
  |