Import.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. # 导入账户
  8. public function get_api()
  9. {
  10. $file = Dever::data() . 'qiquan.xlsx';
  11. $data = Dever::excelImport($file, 1, 5, 'excel');
  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. # 导入交付记录
  36. public function get_jiaofu_api()
  37. {
  38. $file = Dever::data() . 'qiquan.xlsx';
  39. $data = Dever::excelImport($file, 2, 5, 'excel');
  40. if ($data) {
  41. $update = array();
  42. foreach ($data as $k => $v) {
  43. $state = preg_match(Dever::rule('mobile'), $v['A']);
  44. if ($state) {
  45. $where['mobile'] = $v['A'];
  46. $type_name = $v['D'];
  47. if ($type_name == '期权') {
  48. $type = 1;
  49. } else {
  50. $type = 2;
  51. }
  52. $info = Dever::db('option/account')->find($where);
  53. if ($info && $info['status'] < 3) {
  54. $info = Dever::db('option/account')->find(array('key' => $info['key'], 'type' => 2));
  55. if ($info && $info['status'] < 3) {
  56. if (!isset($update[$info['id']][$type])) {
  57. $update[$info['id']][$type] = array();
  58. $update[$info['id']][$type]['total'] = 0;
  59. $update[$info['id']][$type]['desc'] = array();
  60. }
  61. $update[$info['id']][$type]['total'] += $v['C'];
  62. if ($v['E']) {
  63. $update[$info['id']][$type]['desc'][] = $v['E'];
  64. }
  65. }
  66. }
  67. }
  68. }
  69. if ($update) {
  70. }
  71. }
  72. return 'ok';
  73. }
  74. }