VM暫存
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Query_in_fuzzy.php 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. /*
  3. file: cars.php 宏奇 API 查詢入場時間及費用
  4. */
  5. class Query_in_fuzzy extends CI_Controller
  6. {
  7. function __construct()
  8. {
  9. parent::__construct();
  10. }
  11. public function index()
  12. {
  13. $post_data= $this->input->post(NULL, TRUE);
  14. $get_data= $this->input->get(NULL, TRUE);;
  15. if($post_data){
  16. $lpr=$post_data['lpr'];
  17. }elseif($get_data){
  18. $lpr=$get_data['lpr'];
  19. }else{
  20. $lpr='';
  21. }
  22. if($lpr!=''){
  23. $this->load->model('api/Master_db_model','master_db');
  24. $sel_cario_like=$this->master_db->sel_cario_like($lpr);
  25. if(count($sel_cario_like)>0){
  26. $i=0;
  27. foreach($sel_cario_like as $key0 => $value0){
  28. $lpr0=$value0['obj_id'];
  29. $chk_carioseat=$this->master_db->chk_carioseat($lpr0);
  30. $sel_carioseat=$this->master_db->sel_carioseat($lpr0);
  31. $in_date = new DateTime($sel_carioseat[0]['in_time']);
  32. $in_date= $in_date->format('Ymd');
  33. $in_pic_name = "http://192.168.10.201/carpic/".$in_date."/".$sel_carioseat[0]['in_pic_name'];
  34. $station_no=$sel_carioseat[0]['station_no'];
  35. $chk_in_time=isset($chk_carioseat[0]['in_time']) ? $chk_carioseat[0]['in_time']: "0000-00-00 00:00:00" ; //車輛最後出場之入場時間
  36. $in_time=$sel_carioseat[0]['in_time'];
  37. if($in_time>$chk_in_time){
  38. $end_time=$sel_carioseat[0]['station_no'];
  39. $Get_billing_fee= "http://altapi.altob.com.tw/fee_api/Get_billing_fee"; //檢查現場入場時間
  40. $start_time=$in_time;
  41. $end_time=date('Y-m-d H:i:s');
  42. $ch0 = curl_init();
  43. curl_setopt($ch0, CURLOPT_HEADER, 0);
  44. curl_setopt($ch0, CURLOPT_RETURNTRANSFER, true);
  45. curl_setopt($ch0, CURLOPT_URL, $Get_billing_fee);
  46. curl_setopt($ch0, CURLOPT_POST, true);
  47. curl_setopt($ch0, CURLOPT_POSTFIELDS, http_build_query(array("station_no"=>$station_no, "start_time"=>$in_time, "end_time"=>$end_time)));
  48. $totalfee0 = curl_exec($ch0);
  49. curl_close($ch0);
  50. $totalfee=isset($totalfee0) ? $totalfee0:0 ;
  51. $dataarray[]=array(
  52. "lpr" => $lpr0,
  53. "in_time" => $in_time,
  54. "pay_time" => $end_time,
  55. "fee" => $totalfee0,
  56. "in_pic_name" => $in_pic_name,
  57. "success" => true
  58. );
  59. $i++;
  60. }else{
  61. }
  62. if($i==0){
  63. $dataarray[]=array(
  64. "lpr" => $lpr,
  65. "in_time" => "0000-00-00 00:00:00",
  66. "pay_time" => "0000-00-00 00:00:00",
  67. "fee" => 0,
  68. "in_pic_name" => "",
  69. "success" => false
  70. );
  71. }
  72. }
  73. }else{
  74. $dataarray[]=array(
  75. "lpr" => $lpr,
  76. "in_time" => "0000-00-00 00:00:00",
  77. "pay_time" => "0000-00-00 00:00:00",
  78. "fee" => 0,
  79. "in_pic_name" => "",
  80. "success" => false
  81. );
  82. }
  83. }else{
  84. $dataarray[]=array(
  85. "lpr" => "",
  86. "in_time" => "0000-00-00 00:00:00",
  87. "pay_time" => "0000-00-00 00:00:00",
  88. "fee" => 0,
  89. "in_pic_name" => "",
  90. "success" => false
  91. );
  92. }
  93. print_r(json_encode($dataarray,true));exit;
  94. }
  95. }