Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

510 wiersze
17 KiB

  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: 001
  5. * Date: 2017/11/6
  6. * Time: 15:34
  7. */
  8. namespace backend\modules\zzcs\controllers;
  9. use backend\modules\zzcs\logic\LineManage;
  10. use common\models\Utils;
  11. use yii\base\Controller;
  12. use Yii;
  13. class LineManageController extends Controller
  14. {
  15. public $enableCsrfValidation = false;
  16. public $layout = '@backend/modules/zzcs/views/layouts/zzcs';
  17. public function actionIndex()
  18. {
  19. return 'Hello';
  20. }
  21. /**
  22. * Function Description:加载线路列表页面和数据
  23. * Function Name: actionGetLineList
  24. *
  25. * @return string
  26. *
  27. * @author 冒炎
  28. */
  29. public function actionGetLineList()
  30. {
  31. $logic = new LineManage();
  32. $line_code = Yii::$app->request->get('line_code', '');
  33. $line_status = Yii::$app->request->get('line_status', 0);
  34. $use_status = Yii::$app->request->get('use_status', -1);
  35. $line_type = Yii::$app->request->get('line_type', 255);
  36. $tailor_type = Yii::$app->request->get('tailor_type', 0);
  37. $current_page = Yii::$app->request->get('current_page', 1);
  38. $page_size = Yii::$app->request->get('page_size', 10);
  39. $run_duty_id = Yii::$app->request->get('run_duty_id', -1);
  40. $user_id = Yii::$app->request->cookies->getValue('user_id', 0);
  41. $run_duty_list = $logic->getRunDuty($user_id);
  42. $data = $logic->getLineList(trim($line_code), $line_status, $use_status, $line_type, $tailor_type, $run_duty_id, $current_page, $page_size);
  43. $data['run_duty_list'] = $run_duty_list;
  44. return $this->render('line-list', $data);
  45. }
  46. /**
  47. * Function Description:线路启用/停用
  48. * Function Name: actionUptLine
  49. *
  50. * @return string
  51. *
  52. * @author 冒炎
  53. */
  54. public function actionUptLine()
  55. {
  56. $opt_code = Yii::$app->request->post('opt_code', -1);
  57. $line_id_str = Yii::$app->request->post('line_id', -1);
  58. $logic = new LineManage();
  59. $data = $logic->LineUpt($opt_code, $line_id_str);
  60. return json_encode($data);
  61. }
  62. /**
  63. * Function Description:返回线路添加页面
  64. * Function Name: actionAddLine
  65. *
  66. * @return string
  67. *
  68. * @author 冒炎
  69. */
  70. public function actionAddLine()
  71. {
  72. $logic = new LineManage();
  73. $data = $logic->getBaseInfo();
  74. $user_id = Yii::$app->request->cookies->getValue('user_id', 0);
  75. $run_duty_list = $logic->getRunDuty($user_id);
  76. $data['run_duty_list'] = $run_duty_list;
  77. return $this->render('add-line', $data);
  78. }
  79. /**
  80. * Function Description:获取站点详情
  81. * Function Name: actionGetStationInfo
  82. *
  83. * @return string
  84. *
  85. * @author 冒炎
  86. */
  87. public function actionGetStationInfo()
  88. {
  89. $res_id = Yii::$app->request->post('res_id', -1);
  90. $logic = new LineManage();
  91. $data = $logic->getAreaByRes($res_id);
  92. return json_encode($data);
  93. }
  94. /**
  95. * Function Description:根据名字搜索站点名
  96. * Function Name: actionGetLineStation
  97. *
  98. * @return string
  99. *
  100. * @author 冒炎
  101. */
  102. public function actionGetLineStation()
  103. {
  104. $res_name = Yii::$app->request->post('res_name', -1);
  105. $logic = new LineManage();
  106. $data = $logic->getLineStation(trim($res_name));
  107. return json_encode($data);
  108. }
  109. /**
  110. * Function Description:添加线路数据保存接口
  111. * Function Name: actionAddLineSave
  112. *
  113. * @return mixed|string
  114. *
  115. * @author 冒炎
  116. */
  117. public function actionAddLineSave()
  118. {
  119. $line_name = Yii::$app->request->post('line_name', -1);
  120. $line_code = Yii::$app->request->post('line_code', -1);
  121. $line_type = Yii::$app->request->post('line_type', -1);
  122. $line_sub_type = Yii::$app->request->post('line_sub_type', -1);
  123. $time_type = Yii::$app->request->post('time_type', -1);
  124. $time_info = Yii::$app->request->post('time_info', -1);
  125. $supply_id = Yii::$app->request->post('supply_id', -1);
  126. $station_list = Yii::$app->request->post('station_list', -1);
  127. $allow_selected_seat = Yii::$app->request->post('allow_selected_seat', -1);
  128. $remark = Yii::$app->request->post('remark', '');
  129. $run_duty_id = Yii::$app->request->post('run_duty_id', 0);
  130. if ($line_name == -1 || $line_code == -1 || $line_type == -1 || $line_sub_type == -1 ||
  131. $time_type == -1 || $time_info == -1 || $supply_id == -1 || $station_list == -1 || $allow_selected_seat == -1) {
  132. $data = [
  133. 'code' => '1',
  134. 'info' => '参数有误'
  135. ];
  136. return json_encode($data);
  137. }
  138. $user_id = Yii::$app->request->cookies->getValue('user_id', -1);
  139. $http_data = [
  140. 'user_id' => $user_id,
  141. 'line_name' => $line_name,
  142. 'line_code' => $line_code,
  143. 'line_type' => $line_type,
  144. 'line_sub_type' => $line_sub_type,
  145. 'time_type' => $time_type,
  146. 'time_info' => $time_info,
  147. 'supply_id' => $supply_id,
  148. 'station_list' => $station_list,
  149. 'allow_selected_seat' => $allow_selected_seat,
  150. 'remark' => $remark,
  151. 'run_duty_id' => $run_duty_id
  152. ];
  153. $res = Utils::httpRequest('http://' . CS1_DOMAIN . '/api/run-edit/add-line', $http_data);
  154. return $res;
  155. }
  156. /**
  157. * Function Description:加载线路修改页面
  158. * Function Name: actionChangeLineInfo
  159. *
  160. * @return string
  161. *
  162. * @author 冒炎
  163. */
  164. public function actionChangeLineInfo()
  165. {
  166. $line_id = Yii::$app->request->get('line_id', -1);
  167. $logic = new LineManage();
  168. $data = $logic->getBaseInfo();
  169. $data['line_id'] = $line_id;
  170. $user_id = Yii::$app->request->cookies->getValue('user_id', 0);
  171. $run_duty_list = $logic->getRunDuty($user_id);
  172. $data['run_duty_list'] = $run_duty_list;
  173. return $this->render('upt-line', $data);
  174. }
  175. /**
  176. * Function Description:获取单条线路详细信息
  177. * Function Name: actionGetLineDetail
  178. *
  179. * @return array|mixed|string
  180. *
  181. * @author 冒炎
  182. */
  183. public function actionGetLineDetail()
  184. {
  185. $line_id = Yii::$app->request->post('line_id', -1);
  186. if ($line_id == -1) {
  187. $data = [
  188. 'code' => '2',
  189. 'info' => '参数有误'
  190. ];
  191. return json_encode($data);
  192. }
  193. $http_data = array(
  194. 'line_id' => $line_id
  195. );
  196. $data = Utils::httpRequest('http://' . CS1_DOMAIN . '/api/run-edit/get-line-detail', $http_data);
  197. return $data;
  198. }
  199. /**
  200. * Function Description:修改线路保存数据
  201. * Function Name: actionUptLineSave
  202. *
  203. * @return mixed|string
  204. *
  205. * @author 冒炎
  206. */
  207. public function actionUptLineSave()
  208. {
  209. $line_id = Yii::$app->request->post('line_id', -1);
  210. $line_name = Yii::$app->request->post('line_name', -1);
  211. $line_code = Yii::$app->request->post('line_code', -1);
  212. $line_type = Yii::$app->request->post('line_type', -1);
  213. $line_sub_type = Yii::$app->request->post('line_sub_type', -1);
  214. $time_type = Yii::$app->request->post('time_type', -1);
  215. $time_info = Yii::$app->request->post('time_info', -1);
  216. $supply_id = Yii::$app->request->post('supply_id', -1);
  217. $station_list = Yii::$app->request->post('station_list', -1);
  218. $tailor_flag = Yii::$app->request->post('tailor_flag', -1);
  219. $allow_selected_seat = Yii::$app->request->post('allow_selected_seat', -1);
  220. $run_duty_id = Yii::$app->request->post('run_duty_id', 0);
  221. $remark = Yii::$app->request->post('remark', '');
  222. if ($line_id == -1 || $line_name == -1 || $line_code == -1 || $line_type == -1 || $line_sub_type == -1 ||
  223. $time_type == -1 || $time_info == -1 || $supply_id == -1 || $station_list == -1 || $tailor_flag == -1 ||
  224. $allow_selected_seat == -1) {
  225. $data = [
  226. 'code' => '1',
  227. 'info' => '参数有误'
  228. ];
  229. return json_encode($data);
  230. }
  231. $user_id = Yii::$app->request->cookies->getValue('user_id', -1);
  232. $http_data = [
  233. 'user_id' => $user_id,
  234. 'line_id' => $line_id,
  235. 'line_name' => $line_name,
  236. 'line_code' => $line_code,
  237. 'line_type' => $line_type,
  238. 'line_sub_type' => $line_sub_type,
  239. 'time_type' => $time_type,
  240. 'time_info' => $time_info,
  241. 'supply_id' => $supply_id,
  242. 'station_list' => $station_list,
  243. 'tailor_flag' => $tailor_flag,
  244. 'allow_selected_seat' => $allow_selected_seat,
  245. 'remark' => $remark,
  246. 'run_duty_id' => $run_duty_id,
  247. ];
  248. $res = Utils::httpRequest('http://' . CS1_DOMAIN . '/api/run-edit/upt-line', $http_data);
  249. return $res;
  250. }
  251. /**
  252. * Function Description:加载票种管理页面
  253. * Function Name: actionLineProdManage
  254. *
  255. * @return string
  256. *
  257. * @author 冒炎
  258. */
  259. public function actionLineProdManage()
  260. {
  261. $line_id = Yii::$app->request->get('line_id', '');
  262. $line_type = Yii::$app->request->get('line_type', '');
  263. $data = [
  264. 'line_id' => $line_id,
  265. 'line_type' => $line_type
  266. ];
  267. return $this->render('line-prod', $data);
  268. }
  269. /**
  270. * Function Description:获取票种列表
  271. * Function Name: actionGetTicketList
  272. *
  273. * @return string
  274. *
  275. * @author 冒炎
  276. */
  277. public function actionGetTicketList()
  278. {
  279. $line_id = Yii::$app->request->post('line_id', -1);
  280. $current_page = Yii::$app->request->post('current_page', 1);
  281. $page_size = Yii::$app->request->post('page_size', 10);
  282. if ($line_id == -1) {
  283. $data = [
  284. 'code' => '2',
  285. 'info' => '参数有误'
  286. ];
  287. return json_encode($data);
  288. }
  289. $logic = new LineManage();
  290. $data = $logic->getTicketList($line_id, $current_page, $page_size);
  291. return json_encode($data);
  292. }
  293. /**
  294. * Function Description:获取票种配置信息
  295. * Function Name: actionGetTicketBase
  296. *
  297. * @return string
  298. *
  299. * @author 冒炎
  300. */
  301. public function actionGetTicketBase()
  302. {
  303. $line_id = Yii::$app->request->post('line_id', -1);
  304. if ($line_id == -1) {
  305. $data = [
  306. 'code' => '2',
  307. 'info' => '参数有误'
  308. ];
  309. return json_encode($data);
  310. }
  311. $logic = new LineManage();
  312. $data = $logic->getTicketBase($line_id);
  313. return json_encode($data);
  314. }
  315. /**
  316. * Function Description:根据起始站获得终点站
  317. * Function Name: actionGetTicketEndStation
  318. *
  319. * @return string
  320. *
  321. * @author 冒炎
  322. */
  323. public function actionGetTicketEndStation()
  324. {
  325. $line_id = Yii::$app->request->post('line_id', -1);
  326. $start_res_id = Yii::$app->request->post('start_res_id', -1);
  327. if ($line_id == -1 || $start_res_id == -1) {
  328. $data = [
  329. 'code' => '2',
  330. 'info' => '参数有误'
  331. ];
  332. return json_encode($data);
  333. }
  334. if (empty($line_id) || empty($start_res_id)) {
  335. $data = [
  336. 'code' => '3',
  337. 'info' => '部分参数为空'
  338. ];
  339. return json_encode($data);
  340. }
  341. $logic = new LineManage();
  342. $data = $logic->getTicketEndStation($line_id, $start_res_id);
  343. return json_encode($data);
  344. }
  345. /**
  346. * Function Description:添加票种数据保存
  347. * Function Name: actionAddTicketSave
  348. *
  349. * @return string
  350. *
  351. * @author 冒炎
  352. */
  353. public function actionAddTicketSave()
  354. {
  355. $line_id = Yii::$app->request->post('line_id', -1);
  356. $station_str = Yii::$app->request->post('station_str', -1);
  357. $prod_price = Yii::$app->request->post('prod_price', -1);
  358. $cus_price = Yii::$app->request->post('cus_price', -1);
  359. $cost_price = Yii::$app->request->post('cost_price', -1);
  360. $seat_type = Yii::$app->request->post('seat_type', -1);
  361. $human_type = Yii::$app->request->post('human_type', -1);
  362. $human_type = 159;
  363. $line_type = 1;
  364. $user_id = Yii::$app->request->cookies->getValue('user_id', -1);
  365. $create_time = date("Y-m-d H:i:s", time());
  366. if ($line_id == -1 || $station_str == -1 || $prod_price == -1 || $cus_price == -1 || $cost_price == -1 || $seat_type == -1 || $human_type == -1) {
  367. $json['code'] = '2';
  368. $json['info'] = '缺少必要参数';
  369. return json_encode($json);
  370. }
  371. if (empty($line_id) || empty($station_str) || empty($prod_price) || empty($cus_price) || empty($seat_type) || empty($human_type)) {
  372. $json['code'] = '2';
  373. $json['info'] = '部分参数为空';
  374. return json_encode($json);
  375. }
  376. $logic = new LineManage();
  377. $data = $logic->addTicketSave($line_id, $station_str, $prod_price, $cus_price, $cost_price, $seat_type, $human_type, $user_id, $create_time);
  378. return json_encode($data);
  379. }
  380. /**
  381. * Function Description:票种修改数据保存
  382. * Function Name: actionUptTicketSave
  383. *
  384. * @return string
  385. *
  386. * @author 冒炎
  387. */
  388. public function actionUptTicketSave()
  389. {
  390. $line_id = Yii::$app->request->post('line_id', -1);
  391. $group_id = Yii::$app->request->post('group_id', -1);
  392. $ticket_id = Yii::$app->request->post('ticket_id', -1);
  393. $prod_price = Yii::$app->request->post('prod_price', -1);
  394. $cus_price = Yii::$app->request->post('cus_price', -1);
  395. $cost_price = Yii::$app->request->post('cost_price', -1);
  396. $user_id = Yii::$app->request->cookies->getValue('user_id', -1);
  397. $update_time = date("Y-m-d H:i:s", time());
  398. if ($line_id == -1 || $ticket_id == -1 || $prod_price == -1 || $cus_price == -1 || $cost_price == -1 || $group_id == -1) {
  399. $json['code'] = '2';
  400. $json['info'] = '缺少必要参数';
  401. return json_encode($json);
  402. }
  403. $logic = new LineManage();
  404. $data = $logic->uptTicketSave($line_id, $group_id, $ticket_id, $prod_price, $cus_price, $cost_price, $user_id, $update_time);
  405. return json_encode($data);
  406. }
  407. /**
  408. * Function Description:票种删除
  409. * Function Name: actionDeleteTicket
  410. *
  411. * @return string
  412. *
  413. * @author 冒炎
  414. */
  415. public function actionDeleteTicket()
  416. {
  417. $line_id = Yii::$app->request->post('line_id', -1);
  418. $group_id = Yii::$app->request->post('group_id', -1);
  419. $ticket_id = Yii::$app->request->post('ticket_id', -1);
  420. $user_id = Yii::$app->request->cookies->getValue('user_id', -1);
  421. $update_time = date("Y-m-d H:i:s", time());
  422. if ($line_id == -1 || $ticket_id == -1) {
  423. $json['code'] = '2';
  424. $json['info'] = '缺少必要参数';
  425. return json_encode($json);
  426. }
  427. $current_day = date("Y-m-d");
  428. $logic = new LineManage();
  429. $data = $logic->deleteTicket($line_id, $group_id, $ticket_id, $user_id, $update_time, $current_day);
  430. return json_encode($data);
  431. }
  432. /**
  433. * Function Description:票种上下架
  434. * Function Name: actionSendInfo
  435. *
  436. * @return string
  437. *
  438. * @author 冒炎
  439. */
  440. public function actionSendInfo()
  441. {
  442. $ticket_list = Yii::$app->request->post('ticket_list', -1);
  443. $is_onsale = Yii::$app->request->post('is_onsale', -1);
  444. if ($ticket_list == -1 || $is_onsale == -1) {
  445. $json['code'] = '2';
  446. $json['info'] = '缺少必要参数';
  447. return json_encode($json);
  448. }
  449. $logic = new LineManage();
  450. $data = $logic->sendInfo($ticket_list, $is_onsale);
  451. return json_encode($data);
  452. }
  453. /**
  454. * Function Description:修改票种是否需要检票属性
  455. * Function Name: actionCheckChange
  456. *
  457. * @return string
  458. *
  459. * @author 冒炎
  460. */
  461. public function actionCheckChange()
  462. {
  463. $ticket_list = Yii::$app->request->post('ticket_list', -1);
  464. $is_check = Yii::$app->request->post('is_check', -1);
  465. if ($ticket_list == -1 || $is_check == -1) {
  466. $json['code'] = '2';
  467. $json['info'] = '缺少必要参数';
  468. return json_encode($json);
  469. }
  470. $logic = new LineManage();
  471. $data = $logic->CheckChange($ticket_list, $is_check);
  472. return json_encode($data);
  473. }
  474. }