Import.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. foreach ($data as $k => $v) {
  42. $state = preg_match(Dever::rule('mobile'), $v['A']);
  43. if ($state && $v['C'] > 0) {
  44. $where['mobile'] = $v['A'];
  45. $type_name = $v['D'];
  46. if ($type_name == '期权') {
  47. $type = 1;
  48. } else {
  49. $type = 4;
  50. }
  51. $info = Dever::db('option/account')->find($where);
  52. if ($info && $info['status'] < 3) {
  53. $info = Dever::db('option/account')->find(array('key' => $info['key'], 'type' => 2));
  54. if ($info && $info['status'] < 3) {
  55. Dever::load('option/lib/cash')->up($info['id'], $type, $v['C'], $v['E'], false);
  56. }
  57. }
  58. }
  59. }
  60. }
  61. return 'ok';
  62. }
  63. # 导入发放记录
  64. public function get_fafang_api()
  65. {
  66. $file = Dever::data() . 'qiquan.xlsx';
  67. $data = Dever::excelImport($file, 3, 5, 'excel');
  68. if ($data) {
  69. foreach ($data as $k => $v) {
  70. $state = preg_match(Dever::rule('mobile'), $v['A']);
  71. if ($state && $v['C'] > 0) {
  72. $where['mobile'] = $v['A'];
  73. $type_name = $v['D'];
  74. if ($type_name == '期权') {
  75. $type = 2;
  76. } else {
  77. $type = 5;
  78. }
  79. $info = Dever::db('option/account')->find($where);
  80. if ($info && $info['status'] < 3) {
  81. $info = Dever::db('option/account')->find(array('key' => $info['key'], 'type' => 2));
  82. if ($info && $info['status'] < 3) {
  83. Dever::load('option/lib/cash')->up($info['id'], $type, $v['C'], $v['E'], false);
  84. }
  85. }
  86. }
  87. }
  88. }
  89. return 'ok';
  90. }
  91. }