JjhcController.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace App\Http\Controllers\Web\Talent;
  3. use App\Http\Controllers\Web\WebBaseController;
  4. use App\Services\Common\SmsService;
  5. use PhpOffice\PhpSpreadsheet\Spreadsheet;
  6. use PhpOffice\PhpSpreadsheet\IOFactory;
  7. use Illuminate\Support\Facades\DB;
  8. use App\Exceptions\ResponseException;
  9. class JjhcController extends WebBaseController
  10. {
  11. private $smsService;
  12. public function __construct(SmsService $smsService)
  13. {
  14. $this->smsService = $smsService;
  15. }
  16. public function test()
  17. {
  18. $a = $this->smsService->sendSms('13313826760', 'sms_buyhouse_supply', ['username'=>'林武','phone'=>'06','content'=>'25']);
  19. dd($a);
  20. throw new ResponseException("who are you?", [], 404);
  21. // $list = DB::table('lt_apppointment')->distinct()->pluck('card')->toArray();
  22. // $all = DB::table('lt_apppointment')->pluck('card')->toArray();
  23. // $all = array_count_values($all);
  24. // $time = time();
  25. // $data = [
  26. // 'idCards' => $list,
  27. // 'sign' => strtoupper(md5("timestr={$time}&key=rsKVyec52fqEKpk4RRD2TU8fKvPxt6ombKg0qSq1velPQtBHVi")),
  28. // 'timeStr' => $time,
  29. // ];
  30. // $data_string = json_encode($data);
  31. // $ch = curl_init ();
  32. // curl_setopt( $ch, CURLOPT_URL, "http://rc.jucai.gov.cn/api/dataInterface/findTalentInfoByIdCards" );
  33. // curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  34. // 'Content-Type: application/json',
  35. // 'Content-Length: ' . strlen($data_string))
  36. // );
  37. // curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); //若果报错 name lookup timed out 报错时添加这一行代码
  38. // curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
  39. // curl_setopt( $ch, CURLOPT_TIMEOUT,60);
  40. // curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0);
  41. // curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0);
  42. // curl_setopt( $ch, CURLOPT_POST, 1);
  43. // curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
  44. // $result = curl_exec ( $ch );
  45. // curl_close ( $ch );
  46. // $ret = json_decode($result,true);
  47. // $res = [];
  48. // if(count($ret['obj']) > 0){
  49. // foreach ($ret['obj'] as $k => $v){
  50. // if(array_key_exists($v['street'],$res)){
  51. // $res[$v['street']]['number']++;
  52. // $res[$v['street']]['count'] += $all[$v['idCard']];
  53. // }else{
  54. // $res[$v['street']] = [
  55. // 'number' => 1,
  56. // 'count' => $all[$v['idCard']]
  57. // ];
  58. // }
  59. // }
  60. // }
  61. //
  62. // $spreadsheet = new Spreadsheet();
  63. // $sheet = $spreadsheet->getActiveSheet();
  64. // $header = ['镇街','使用人数','使用次数'];
  65. // foreach ($header as $key => $value) {
  66. // $sheet->setCellValueByColumnAndRow($key+1, 1, $value);
  67. // }
  68. // $row = 2;
  69. // foreach ($res as $k => $v){
  70. // $sheet->setCellValueByColumnAndRow(1, $row, $k);
  71. // $sheet->setCellValueByColumnAndRow(2, $row, $v['number']);
  72. // $sheet->setCellValueByColumnAndRow(3, $row, $v['count']);
  73. // $row++;
  74. // }
  75. // $file_name = date("Y-m-d",time()) . '码上服务数据';
  76. // header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  77. // header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
  78. // header('Cache-Control: max-age=0');
  79. // // If you're serving to IE 9, then the following may be needed
  80. // header('Cache-Control: max-age=1');
  81. // // If you're serving to IE over SSL, then the following may be needed
  82. // header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  83. // header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  84. // header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  85. // header('Pragma: public'); // HTTP/1.0
  86. // $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  87. // $writer->save('php://output');
  88. //
  89. // //dd($res);
  90. }
  91. }