Test.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace app\api\controller;
  3. use think\facade\Db;
  4. class Test
  5. {
  6. public function t1()
  7. {
  8. ajax_success();
  9. $list = import_exl('1.xlsx',['name','sex','card_type','card_no','company','post','start_time','end_time','level','mobile'],1);
  10. $level_list = [
  11. '省特级' => '第一层次',
  12. '省级A类' => '第一层次',
  13. '省级B类' => '第二层次',
  14. '省级C类' => '第三层次',
  15. ];
  16. foreach ($list as $k => $v) {
  17. // $time = explode(' - ',$v['start_time']);
  18. // $list[$k]['start_time'] = $time[0].' 00:00:00';
  19. // $list[$k]['end_time'] = $time[1].' 00:00:00';
  20. // $list[$k]['level'] = str_replace(['泉州','(自主认定)'],'',$v['level']);
  21. // $list[$k]['start_time'] = str_replace('.','-',$v['start_time']).' 00:00:00';
  22. // $end = (int) $v['end_time'];
  23. // if (empty($end)) {
  24. // $list[$k]['end_time'] = '2099-01-01 00:00:00';
  25. // } else {
  26. // $list[$k]['end_time'] = date('Y-m-d H:i:s',strtotime("+{$end} years",strtotime($list[$k]['start_time'])));
  27. // }
  28. //
  29. // $list[$k]['level'] = $level_list[$v['level']];
  30. $list[$k]['start_time'] = '2025-01-01 00:00:00';
  31. $list[$k]['end_time'] = '2099-01-01 00:00:00';
  32. }
  33. // halt($list);
  34. Db::name('talent')->insertAll($list);
  35. ajax_success();
  36. }
  37. }