Import.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace Option\Lib;
  3. use Dever;
  4. include('/share/lib/php/dever_package/excel/src/PHPExcel.php');
  5. class Import
  6. {
  7. public function get_api()
  8. {
  9. $file = Dever::data() . 'qiquan.xlsx';
  10. $data = Dever::excelImport($file, 1, 5, 'excel');
  11. # 主账户表
  12. if ($data) {
  13. foreach ($data as $k => $v) {
  14. $state = preg_match(Dever::rule('mobile'), $v['C']);
  15. if ($state) {
  16. $where['key'] = $v['A'];
  17. $where['mobile'] = $v['C'];
  18. $info = Dever::db('option/account')->find($where);
  19. $update = $where;
  20. $update['idcard'] = $v['D'];
  21. $update['name'] = $v['B'];
  22. $update['type'] = $v['E'] ? 2 : 1;
  23. if (!$info) {
  24. $update['audit'] = 1;
  25. Dever::db('option/account')->insert($update);
  26. } else {
  27. $update['where_id'] = $info['id'];
  28. Dever::db('option/account')->update($update);
  29. }
  30. }
  31. }
  32. }
  33. return 'ok';
  34. }
  35. }