You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

595 line
26 KiB

  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Mricale
  5. * Date: 2016/10/26
  6. * Time: 10:12
  7. * 车辆控制类
  8. */
  9. class carControl extends base
  10. {
  11. /**
  12. * @param $web_data
  13. * @return array
  14. * 删除车辆信息
  15. */
  16. public function deleteCar($web_data)
  17. {
  18. $bus_id = isset($web_data["bus_id"]) ? trim($web_data["bus_id"]) : false;
  19. if ($bus_id === false) {
  20. $json = array();
  21. $json["code"] = "2";
  22. $json["info"] = "缺少必要参数";
  23. return $json;
  24. } else {
  25. $sql = "update base_bus set CANCEL_FLAG=1,UPDATE_USER_ID=" . $this->user_id . ",UPDATE_TIME=NOW() WHERE BUS_ID in (" . $bus_id . ")";
  26. zzcsUtils::writeLog($sql);
  27. $result = $this->exec($sql);
  28. if ($result === false) {
  29. $json["code"] = "1";
  30. $json["info"] = "车辆删除失败!";
  31. return $json;
  32. } else {
  33. $json["code"] = "0";
  34. $json["info"] = "车辆删除成功!";
  35. return $json;
  36. }
  37. }
  38. }
  39. /**
  40. * @return array
  41. * 品牌列表
  42. */
  43. public function brandList()
  44. {
  45. $sql = "SELECT res_name,res_id FROM base_resource where RES_TYPE_ID=134 AND CANCEL_FLAG=0";
  46. $brand_list = $this->query($sql);
  47. if ($brand_list === false) {
  48. $json = array();
  49. $json["code"] = "1";
  50. $json["info"] = "数据库错误";
  51. return $json;
  52. } else {
  53. $json = array();
  54. $json["code"] = "0";
  55. $json["info"] = "品牌信息";
  56. $json["data"] = $brand_list;
  57. return $json;
  58. }
  59. }
  60. /**
  61. * @param $web_data
  62. * @return array
  63. * 车辆列表
  64. */
  65. public function carList($web_data)
  66. {
  67. #region 获取渠道权限
  68. $user_id = $this->user_id;
  69. $opera_org_id_sql = "select opera_org_id from base_user where id = " . $user_id . " and cancel_flag = 0";
  70. $opera_org_id_result = $this->query($opera_org_id_sql);
  71. $opera_org_id = $opera_org_id_result[0]['opera_org_id'];
  72. if ($opera_org_id == '') {
  73. $and_sql = '';
  74. } else {
  75. $and_sql = " and org_id in (" . $opera_org_id . ") ";
  76. }
  77. #endregion
  78. $brand_id = isset($web_data["brand_id"]) ? trim($web_data["brand_id"]) : false;
  79. $car_number = isset($web_data["car_number"]) ? trim($web_data["car_number"]) : false;
  80. $current_page = isset($web_data["current_page"]) ? trim($web_data["current_page"]) : false;
  81. $page_size = isset($web_data["page_size"]) ? trim($web_data["page_size"]) : false;
  82. if ($brand_id === false || $car_number === false || $current_page === false || $page_size === false) {
  83. $json = array();
  84. $json["code"] = "2";
  85. $json["info"] = "缺少必要参数";
  86. return $json;
  87. } else {
  88. $size = ($current_page - 1) * $page_size;
  89. if ($brand_id == 0) {
  90. //没有选择品牌
  91. $sql = "select bus_id,bus_no,seat_desc,
  92. IFNULL((SELECT res_name FROM base_resource where base_bus.BRAND_ID = base_resource.res_id and res_type_id = 134 and cancel_flag = 0),'' )AS bus_brand,
  93. IFNULL((SELECT type_name FROM dict_type where base_bus.bus_state=dict_type.id),'' )AS bus_state,
  94. IFNULL((SELECT supplier_name FROM base_supplier where base_bus.org_id=base_supplier.id and cancel_flag = 0),'') as company
  95. FROM base_bus WHERE bus_no LIKE '%" . $car_number . "%' AND cancel_flag=0
  96. " . $and_sql . "
  97. LIMIT " . $size . "," . $page_size;
  98. $car_list = $this->query($sql);
  99. $sql_count = "select count(*) as count from
  100. (select bus_id,bus_no,seat_desc,
  101. IFNULL((SELECT res_name FROM base_resource where base_bus.BRAND_ID = base_resource.res_id and res_type_id = 134 and cancel_flag = 0),'' )AS bus_brand,
  102. IFNULL(
  103. (SELECT type_name
  104. FROM dict_type
  105. where base_bus.bus_state=dict_type.id),'' )AS bus_state,IFNULL(
  106. (SELECT supplier_name FROM base_supplier where base_bus.org_id=base_supplier.id and cancel_flag = 0),'') as company
  107. FROM base_bus
  108. WHERE bus_no LIKE '%" . $car_number . "%' AND cancel_flag=0 " . $and_sql . ") AS a";
  109. $page_answer = $this->query($sql_count);
  110. $total = $page_answer[0]['count'];
  111. $total_page = ceil($total / $page_size);
  112. if ($car_list === false) {
  113. $json = array();
  114. $json["code"] = "1";
  115. $json["info"] = "车辆列表获取失败";
  116. return $json;
  117. } else {
  118. $json = array();
  119. $json["code"] = "0";
  120. $json["info"] = "车辆列表获取成功";
  121. $json["data"] = $car_list;
  122. $page = array();
  123. $page["current_page"] = $current_page;
  124. $page["page_size"] = $page_size;
  125. $page["total_count"] = $total;
  126. $page["total_page"] = $total_page;
  127. $json["page"] = $page;
  128. return $json;
  129. }
  130. } else {
  131. $sql = "select bus_id,bus_no,seat_desc,
  132. IFNULL((SELECT res_name FROM base_resource where base_bus.BRAND_ID = base_resource.res_id and res_type_id = 134 and cancel_flag = 0),'' )AS bus_brand,
  133. IFNULL(
  134. (SELECT type_name
  135. FROM dict_type
  136. where base_bus.bus_state=dict_type.id),'' )AS bus_state,IFNULL(
  137. (SELECT supplier_name FROM base_supplier where base_bus.org_id=base_supplier.id and cancel_flag = 0),'') as company
  138. FROM base_bus
  139. WHERE bus_no LIKE '%" . $car_number . "%' AND brand_id=" . $brand_id . " AND cancel_flag=0
  140. " . $and_sql . "
  141. LIMIT " . $size . "," . $page_size;
  142. $car_list = $this->query($sql);
  143. $sql_count = "select count(*) as count from (select bus_id,bus_no,seat_desc,
  144. IFNULL((SELECT res_name FROM base_resource where base_bus.BRAND_ID = base_resource.res_id and res_type_id = 134 and cancel_flag = 0),'' )AS bus_brand,
  145. IFNULL(
  146. (SELECT type_name
  147. FROM dict_type
  148. where base_bus.bus_state=dict_type.id),'' )AS bus_state,IFNULL(
  149. (SELECT supplier_name FROM base_supplier where base_bus.org_id=base_supplier.id and cancel_flag = 0),'') as company
  150. FROM base_bus
  151. WHERE bus_no LIKE '%" . $car_number . "%' AND brand_id=" . $brand_id . " AND cancel_flag=0 " . $and_sql . ") as a";
  152. $page_answer = $this->query($sql_count);
  153. $total = $page_answer[0]['count'];
  154. $total_page = ceil($total / $page_size);
  155. if ($car_list === false) {
  156. $json = array();
  157. $json["code"] = "1";
  158. $json["info"] = "车辆列表获取失败";
  159. return $json;
  160. } else {
  161. $json = array();
  162. $json["code"] = "0";
  163. $json["info"] = "车辆列表获取成功";
  164. $json["data"] = $car_list;
  165. $page = array();
  166. $page["current_page"] = $current_page;
  167. $page["page_size"] = $page_size;
  168. $page["total_count"] = $total;
  169. $page["total_page"] = $total_page;
  170. $json["page"] = $page;
  171. return $json;
  172. }
  173. }
  174. }
  175. }
  176. /**
  177. * @return array
  178. *所属车队列表
  179. * */
  180. public function orgList()
  181. {
  182. #region 获取渠道权限
  183. $user_id = $this->user_id;
  184. $opera_org_id_sql = "select opera_org_id from base_user where id = " . $user_id . " and cancel_flag = 0";
  185. $opera_org_id_result = $this->query($opera_org_id_sql);
  186. $opera_org_id = $opera_org_id_result[0]['opera_org_id'];
  187. if ($opera_org_id == '') {
  188. $and_sql = '';
  189. } else {
  190. $and_sql = " and s.id in (" . $opera_org_id . ") ";
  191. }
  192. #endregion
  193. //$sql = "select res_name,res_id from base_resource where res_type_id=18";
  194. //$sql = "SELECT DISTINCT supplier_id,(SELECT supplier_name FROM base_supplier where supplier_id=base_supplier.ID) as bus_team FROM base_supplier_purchase WHERE PRODUCT_TYPE =259 AND CANCEL_FLAG=0";
  195. $sql = "select
  196. s.id as supplier_id,s.supplier_name as bus_team
  197. from
  198. base_supplier as s,base_supplier_purchase as p
  199. where
  200. s.cancel_flag = 0
  201. and s.supplier_type = 187
  202. " . $and_sql . "
  203. and p.cancel_flag = 0
  204. and p.product_type = 259
  205. group by s.id";
  206. $orgList = $this->query($sql);
  207. if ($orgList === false) {
  208. $json = array();
  209. $json["code"] = "1";
  210. $json["info"] = "数据库错误";
  211. return $json;
  212. } else {
  213. $json = array();
  214. $json["code"] = "0";
  215. $json["info"] = "公司信息";
  216. $json["data"] = $orgList;
  217. return $json;
  218. }
  219. }
  220. /**
  221. * @param $web_data
  222. * @return array
  223. * 增加车辆信息
  224. */
  225. public function addCar($web_data)
  226. {
  227. $imgMeta = zzcsUtils::uploadMultiple('bus_img');
  228. $imgType = '';
  229. $imgPath = '';
  230. if ($imgMeta) {
  231. $imgType = $imgMeta['type'];
  232. $imgPath = $imgMeta['path'];
  233. }
  234. $bus_number = isset($web_data["bus_number"]) ? trim($web_data["bus_number"]) : false;//车牌号
  235. $bus_team = isset($web_data["bus_team"]) ? trim($web_data["bus_team"]) : false;//车队
  236. $bus_brand = isset($web_data["bus_brand"]) ? trim($web_data["bus_brand"]) : false;//品牌
  237. $bus_version = isset($web_data["bus_version"]) ? trim($web_data["bus_version"]) : false;//型号
  238. $buy_date = isset($web_data["buy_date"]) ? trim($web_data["buy_date"]) : false;//购买日期
  239. $seat_type = isset($web_data["seat_type"]) ? trim($web_data["seat_type"]) : false;//座位类型
  240. $seat_number = isset($web_data["seat_number"]) ? trim($web_data["seat_number"]) : false;//座位数量
  241. $driver = isset($web_data["driver"]) ? trim($web_data["driver"]) : false;//司机
  242. $guider = isset($web_data["guider"]) ? trim($web_data["guider"]) : false;//导游
  243. $auxiliary_seat = isset($web_data["auxiliary_seat"]) ? trim($web_data["auxiliary_seat"]) : false;//辅座
  244. $consumption = isset($web_data["consumption"]) ? trim($web_data["consumption"]) : false;//油耗
  245. $day_cost = isset($web_data["day_cost"]) ? trim($web_data["day_cost"]) : false;//成本
  246. $status_select = isset($web_data["status_select"]) ? trim($web_data["status_select"]) : false;//状态
  247. $bus_color = isset($web_data["bus_color"]) ? trim($web_data["bus_color"]) : false;//颜色
  248. $bus_desc = isset($web_data["bus_desc"]) ? trim($web_data["bus_desc"]) : false;//车型描述
  249. if ($bus_number === false || $bus_team === false || $bus_brand === false || $bus_version === false || $buy_date === false || $seat_type === false || $seat_number === false || $driver === false || $guider === false || $auxiliary_seat === false || $consumption === false || $day_cost === false || $status_select === false || $bus_color === false || $bus_desc === false) {
  250. $json = array();
  251. $json["code"] = "2";
  252. $json["info"] = "缺少必要参数";
  253. return $json;
  254. } else {
  255. //座位数量前台没有传入具体数值
  256. $seat_count = preg_replace('/[^\d]/', '', $bus_desc);
  257. if (empty($driver)) {
  258. $driver = '';
  259. }
  260. if (empty($guider)) {
  261. $guider = '';
  262. }
  263. if (empty($auxiliary_seat)) {
  264. $auxiliary_seat = '';
  265. }
  266. if (empty($consumption)) {
  267. $consumption = '';
  268. }
  269. if (empty($day_cost)) {
  270. $day_cost = '';
  271. }
  272. if (empty($bus_color)) {
  273. $bus_color = 0;
  274. }
  275. $sql = "SELECT bus_id FROM base_bus WHERE 1=1 ORDER BY(bus_id) ASC";
  276. $temp = $this->query($sql);
  277. if (!empty($temp)) {
  278. $bus_id = $temp[count($temp) - 1]["bus_id"] + 1;
  279. }
  280. $tmpArray = explode(',', $imgPath);
  281. $newArray = array_reverse($tmpArray);
  282. $imgPath = implode(',', $newArray);
  283. $tmpArray = explode(',', $imgType);
  284. $newArray = array_reverse($tmpArray);
  285. $imgType = implode(',', $newArray);
  286. $sql = "INSERT INTO base_bus (BUS_ID,CREATE_USER_ID,CREATE_TIME,UPDATE_USER_ID,UPDATE_TIME,CANCEL_FLAG,BUS_NO,BUS_TYPE_RES_ID,SEAT_COUNT,BRAND_ID,ORG_ID,SEAT_DESC,BUY_DATE,BUS_LICENSE,DRIVER_COUNT,TOUR_COUNT,EXTRA_COUNT,MPG,COST,BUS_STATE,SEAT_TYPE,BUS_COLOR,BUS_IMG_PATH, BUS_IMG_TYPE)
  287. VALUES (" . $bus_id . "," . $this->user_id . ",NOW()," . $this->user_id . ",NOW(),0,' " . $bus_number . " '," . $seat_number . "," . $seat_count . "," . $bus_brand . "," . $bus_team . ",'" . $bus_desc . "','" . $buy_date . "','" . $bus_version . "','" . $driver . "','" . $guider . "','" . $auxiliary_seat . "','" . $consumption . "','" . $day_cost . "'," . $status_select . "," . $seat_type . ",'" . $bus_color . "','" . $imgPath . "','" . $imgType . "')";
  288. zzcsUtils::writeLog($sql);
  289. $res = $this->exec($sql);
  290. if ($res === false) {
  291. $json = array();
  292. $json["code"] = "1";
  293. $json["info"] = "新增车辆失败!";
  294. return $json;
  295. } else {
  296. //网络原因,图片有可能会上传失败,但是车辆信息应该保存;返回的状态有区别
  297. $json = array();
  298. $json["code"] = "0";
  299. $json["info"] = "新增车辆成功!";
  300. return $json;
  301. }
  302. }
  303. }
  304. /**
  305. * @return array
  306. * 获取颜色列表
  307. */
  308. public function getColorList()
  309. {
  310. $sql = "SELECT res_name AS color,res_id FROM base_resource where RES_TYPE_ID =338 AND CANCEL_FLAG=0";
  311. $res = $this->query($sql);
  312. if ($res === false) {
  313. $json = array();
  314. $json["code"] = "1";
  315. $json["info"] = "获取颜色列表失败!";
  316. return $json;
  317. } else {
  318. $json = array();
  319. $json["code"] = "0";
  320. $json["info"] = "获取颜色列表成功!";
  321. $json["data"] = $res;
  322. return $json;
  323. }
  324. }
  325. /**
  326. * @return array
  327. * 得到车辆当前状态
  328. */
  329. public function getSeatType()
  330. {
  331. //add by qius on 2016.11.09
  332. $normal_seat_array = array();
  333. $normal_seat_array[] = array("id" => 72, "seat_type" => "普通座");
  334. $json = array();
  335. $json["code"] = "0";
  336. $json["info"] = "获取车辆状态成功!";
  337. $json["data"] = $normal_seat_array;
  338. return $json;
  339. //end of add by qius on 2016.11.09
  340. $sql = "SELECT type_name AS seat_type,id FROM dict_type where PARENT_ID =71";
  341. $res = $this->query($sql);
  342. if ($res === false) {
  343. $json = array();
  344. $json["code"] = "1";
  345. $json["info"] = "获取座位类型失败!";
  346. return $json;
  347. } else {
  348. $json = array();
  349. $json["code"] = "0";
  350. $json["info"] = "获取座位类型成功!";
  351. $json["data"] = $res;
  352. return $json;
  353. }
  354. }
  355. /**
  356. * @return array
  357. * 得到车辆座位数类型
  358. */
  359. public function getSeatNumber()
  360. {
  361. $sql = "SELECT res_id,res_name AS seat_number FROM base_resource WHERE RES_TYPE_ID = 69 AND CANCEL_FLAG=0 ORDER BY res_name";
  362. $res = $this->query($sql);
  363. if ($res === false) {
  364. $json = array();
  365. $json["code"] = "1";
  366. $json["info"] = "获取座位数量失败!";
  367. return $json;
  368. } else {
  369. $json = array();
  370. $json["code"] = "0";
  371. $json["info"] = "获取座位数量成功!";
  372. usort($res, 'my_sort');
  373. $json["data"] = $res;
  374. return $json;
  375. }
  376. }
  377. /**
  378. * @return array
  379. * 得到车辆当前状态
  380. */
  381. public function getCarStatus()
  382. {
  383. $sql = "SELECT id,type_name AS bus_status FROM dict_type WHERE PARENT_ID =339";
  384. $res = $this->query($sql);
  385. if ($res === false) {
  386. $json = array();
  387. $json["code"] = "1";
  388. $json["info"] = "获取车辆状态失败!";
  389. return $json;
  390. } else {
  391. $json = array();
  392. $json["code"] = "0";
  393. $json["info"] = "获取车辆状态成功!";
  394. $json["data"] = $res;
  395. return $json;
  396. }
  397. }
  398. /**
  399. * @return array
  400. * 得到车辆图片类型数组
  401. */
  402. public function getImgType()
  403. {
  404. $sql = "SELECT id,type_name AS img_status FROM dict_type WHERE PARENT_ID =360";
  405. $res = $this->query($sql);
  406. if ($res === false) {
  407. $json = array();
  408. $json["code"] = "1";
  409. $json["info"] = "获取图片类型失败!";
  410. return $json;
  411. } else {
  412. $json = array();
  413. $json["code"] = "0";
  414. $json["info"] = "获取图片类型成功!";
  415. $json["data"] = $res;
  416. return $json;
  417. }
  418. }
  419. /**
  420. * @param $web_data
  421. * @return array
  422. * 修改车辆信息
  423. */
  424. public function reviseCar($web_data)
  425. {
  426. $bus_id = isset($web_data["bus_id"]) ? trim($web_data["bus_id"]) : false;//车牌号
  427. $bus_number = isset($web_data["bus_number"]) ? trim($web_data["bus_number"]) : false;//车牌号
  428. $bus_team = isset($web_data["bus_team"]) ? trim($web_data["bus_team"]) : false;//车队
  429. $bus_brand = isset($web_data["bus_brand"]) ? trim($web_data["bus_brand"]) : false;//品牌
  430. $bus_version = isset($web_data["bus_version"]) ? trim($web_data["bus_version"]) : false;//型号
  431. $buy_date = isset($web_data["buy_date"]) ? trim($web_data["buy_date"]) : false;//购买日期
  432. $seat_type = isset($web_data["seat_type"]) ? trim($web_data["seat_type"]) : false;//座位类型
  433. $seat_number = isset($web_data["seat_number"]) ? trim($web_data["seat_number"]) : false;//座位数量
  434. $driver = isset($web_data["driver"]) ? trim($web_data["driver"]) : false;//司机
  435. $guider = isset($web_data["guider"]) ? trim($web_data["guider"]) : false;//导游
  436. $auxiliary_seat = isset($web_data["auxiliary_seat"]) ? trim($web_data["auxiliary_seat"]) : false;//辅座
  437. $consumption = isset($web_data["consumption"]) ? trim($web_data["consumption"]) : false;//油耗
  438. $day_cost = isset($web_data["day_cost"]) ? trim($web_data["day_cost"]) : false;//成本
  439. $status_select = isset($web_data["status_select"]) ? trim($web_data["status_select"]) : false;//状态
  440. $bus_color = isset($web_data["bus_color"]) ? trim($web_data["bus_color"]) : false;//颜色
  441. $bus_desc = isset($web_data["bus_desc"]) ? trim($web_data["bus_desc"]) : false;//车型描述
  442. $old_path = '';
  443. $old_type = '';
  444. if (isset($web_data['bus_img_path_old'])) {
  445. foreach ($web_data['bus_img_path_old'] as $key => $item) {
  446. if ($item != '' || $web_data['bus_img_type_old'][$key] != '') {
  447. $type = $web_data['bus_img_type_old'][$key];
  448. if ($old_path == '') {
  449. $old_path .= $item;
  450. $old_type .= $type;
  451. } else {
  452. $old_path .= ',' . $item;
  453. $old_type .= ',' . $type;
  454. }
  455. }
  456. }
  457. }
  458. if ($bus_id === false || $bus_number === false || $bus_team === false || $bus_brand === false || $bus_version === false || $buy_date === false || $seat_type === false || $seat_number === false || $driver === false || $guider === false || $auxiliary_seat === false || $consumption === false || $day_cost === false || $status_select === false || $bus_color === false || $bus_desc === false) {
  459. $json = array();
  460. $json["code"] = "2";
  461. $json["info"] = "缺少必要参数";
  462. return $json;
  463. } else {
  464. //座位数量前台没有传入具体数值
  465. $seat_count = preg_replace('/[^\d]/', '', $bus_desc);
  466. //更新操作
  467. if (empty($driver)) {
  468. $driver = '';
  469. }
  470. if (empty($guider)) {
  471. $guider = '';
  472. }
  473. if (empty($auxiliary_seat)) {
  474. $auxiliary_seat = '';
  475. }
  476. if (empty($consumption)) {
  477. $consumption = '';
  478. }
  479. if (empty($day_cost)) {
  480. $day_cost = '';
  481. }
  482. if (empty($bus_color)) {
  483. $bus_color = 0;
  484. }
  485. $imgType = '';
  486. $imgPath = '';
  487. $imgMeta = zzcsUtils::uploadMultiple('bus_img');
  488. if ($imgMeta) {
  489. $imgType = $imgMeta['type'];
  490. $imgPath = $imgMeta['path'];
  491. }
  492. $imgPath = $old_path == '' ? $imgPath : $old_path . ($imgPath != '' ? (',' . $imgPath) : '');
  493. $imgType = $old_type == '' ? $imgType : $old_type . ($imgType != '' ? (',' . $imgType) : '');
  494. $tmpArray = explode(',', $imgPath);
  495. $newArray = array_reverse($tmpArray);
  496. $imgPath = implode(',', $newArray);
  497. $tmpArray = explode(',', $imgType);
  498. $newArray = array_reverse($tmpArray);
  499. $imgType = implode(',', $newArray);
  500. //删除旧图片
  501. zzcsUtils::deleteFiles($web_data['bus_img_allpath_old'], $imgPath);
  502. $sql = "UPDATE base_bus set UPDATE_USER_ID=" . $this->user_id . ",UPDATE_TIME=NOW(),BUS_NO='" . $bus_number . "',BUS_TYPE_RES_ID=" . $seat_number . "',SEAT_COUNT=" . $seat_count . ",BRAND_ID=" . $bus_brand . ",ORG_ID=" . $bus_team . ",SEAT_DESC='" . $bus_desc . "',BUY_DATE='" . $buy_date . "',
  503. BUS_LICENSE='" . $bus_version . "',DRIVER_COUNT='" . $driver . "',TOUR_COUNT='" . $guider . "',EXTRA_COUNT='" . $auxiliary_seat . "',MPG='" . $consumption . "',COST='" . $day_cost . "',BUS_STATE=" . $status_select . ",SEAT_TYPE=" . $seat_type . ",BUS_COLOR=" . $bus_color . ",BUS_IMG_PATH='" . $imgPath . "',BUS_IMG_TYPE='" . $imgType . "' WHERE
  504. bus_id=" . $bus_id;
  505. zzcsUtils::writeLog($sql);
  506. $res = $this->exec($sql);
  507. if ($res === false) {
  508. $json = array();
  509. $json["code"] = "1";
  510. $json["info"] = "更新车辆信息失败!";
  511. return $json;
  512. } else {
  513. $json = array();
  514. $json["code"] = "0";
  515. $json["info"] = "更新车辆信息成功!";
  516. return $json;
  517. }
  518. }
  519. }
  520. /**
  521. * @param $web_data
  522. * @return array
  523. * 得到车辆详细信息
  524. */
  525. public function getBusInfo($web_data)
  526. {
  527. //得到基本信息
  528. $bus_id = isset($web_data["bus_id"]) ? trim($web_data["bus_id"]) : false;//得到bus_id
  529. if ($bus_id === false) {
  530. $json = array();
  531. $json["code"] = "1";
  532. $json["info"] = "获取车辆信息失败!";
  533. return $json;
  534. } else {
  535. $sql = "SELECT bus_type_res_id, brand_id,bus_id ,bus_no,org_id,buy_date,bus_license,driver_count,tour_count,extra_count,mpg,cost,bus_state,seat_type,bus_color, bus_img_path, bus_img_type FROM base_bus WHERE bus_id = " . $bus_id . " AND cancel_flag = 0";
  536. $res = $this->query($sql);
  537. if ($res === false) {
  538. $json = array();
  539. $json["code"] = "1";
  540. $json["info"] = "获取车辆信息失败!";
  541. return $json;
  542. } else {
  543. $json = array();
  544. $json["code"] = "0";
  545. $json["info"] = "获取车辆信息成功!";
  546. $temp = $res[0]['buy_date'];
  547. $temp_arr = explode('-', $temp);
  548. $res[0]['buy_year'] = $temp_arr[0];
  549. $res[0]['buy_month'] = $temp_arr[1];
  550. $json["data"] = $res;
  551. return $json;
  552. }
  553. }
  554. }
  555. }
  556. /**
  557. * @param $a
  558. * @param $b
  559. * @return int
  560. * 自定义比较函数
  561. */
  562. function my_sort($a, $b)
  563. {
  564. $a_number = (int)mb_substr($a["seat_number"], 0, mb_strlen($a["seat_number"]) - 1);
  565. $b_number = (int)mb_substr($b["seat_number"], 0, mb_strlen($b["seat_number"]) - 1);
  566. if ($a_number == $b_number) {
  567. return 0;
  568. }
  569. return $a_number > $b_number ? +1 : -1;
  570. }