Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 

202 Zeilen
7.3 KiB

  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Steven
  5. * Date: 2016/10/15
  6. * Time: 14:39
  7. * 组合线路票种相关
  8. */
  9. class groupTicket extends base
  10. {
  11. /**
  12. * 获取组合线路票种列表
  13. * @param $param
  14. * @return mixed
  15. */
  16. public function getTicketList($param)
  17. {
  18. $line_id = isset($param['line_id']) ? $param['line_id'] : false;
  19. $current_page = isset($param['current_page']) ? $param['current_page'] : false;
  20. $page_size = isset($param['page_size']) ? $param['page_size'] : false;
  21. if (!$line_id || $current_page === false || $page_size === false) {
  22. $result['code'] = '2';
  23. $result['info'] = "缺少必要参数";
  24. return $result;
  25. }
  26. $start_row = ($current_page - 1) * $page_size;
  27. $sql_page = "SELECT COUNT(*) as count FROM opera_tickets as t WHERE cancel_flag = 0 AND line_id = $line_id";
  28. $res_page = $this->query($sql_page);
  29. $total_count = $res_page[0]['count'];
  30. $total_page = ceil($total_count / $page_size);
  31. $sql = "SELECT
  32. ticket_id,
  33. seat_type,
  34. (select type_name from dict_type where id = t.seat_type) as seat_type_name,
  35. human_type,
  36. (select type_name from dict_type where id = t.human_type) as human_type_name,
  37. prod_price,
  38. cus_price
  39. FROM
  40. opera_tickets as t
  41. WHERE
  42. line_id = $line_id
  43. AND cancel_flag = 0 ORDER BY t.CREATE_TIME DESC LIMIT $start_row,$page_size";
  44. $res = $this->query($sql);
  45. $result['code'] = '0';
  46. $result['info'] = '获取' . $line_id . '线路的票种列表成功';
  47. $result['page'] = array(
  48. 'page_size' => $page_size,
  49. 'current_page' => $current_page,
  50. 'total_count' => $total_count,
  51. 'total_page' => $total_page
  52. );
  53. $result['ticket'] = $res;
  54. return $result;
  55. }
  56. /**
  57. * 根据票种ID获取票种信息
  58. * @param $param
  59. * @return mixed
  60. */
  61. public function getTicketById($param)
  62. {
  63. $ticketId = isset($param['ticket_id']) ? $param['ticket_id'] : false;
  64. if (!$ticketId) {
  65. $result['code'] = '2';
  66. $result['info'] = "缺少必要参数";
  67. return $result;
  68. }
  69. $sql = "SELECT ticket_id,seat_type,human_type,prod_price,cus_price FROM opera_tickets WHERE cancel_flag = 0 AND TICKET_ID=$ticketId";
  70. $res = $this->query($sql);
  71. if ($res) {
  72. $code = 0;
  73. $msg = '获取' . $ticketId . '票种信息成功';
  74. } else {
  75. $code = 1;
  76. $msg = '获取' . $ticketId . '票种信息失败';
  77. }
  78. $result['code'] = (string)$code;
  79. $result['info'] = $msg;
  80. $result['base_info'] = $this->getBaseInfo();
  81. $result['data'] = $res[0];
  82. return $result;
  83. }
  84. /**
  85. * 添加票种信息
  86. * @param $param
  87. * @return mixed
  88. */
  89. public function addTicket($param)
  90. {
  91. $userID = $this->user_id;
  92. $line_id = isset($param['line_id']) ? $param['line_id'] : false; //线路ID
  93. $seat_type = isset($param['seat_type']) ? $param['seat_type'] : false; //座位等级
  94. $human_type = isset($param['human_type']) ? $param['human_type'] : false; //人群类型
  95. $prod_price = isset($param['prod_price']) ? $param['prod_price'] : false; //分销价
  96. $cus_price = isset($param['cus_price']) ? $param['cus_price'] : false; //
  97. if (!$userID || !$line_id || !$seat_type || $human_type === false || !$prod_price || !$cus_price) {
  98. $result['code'] = '2';
  99. $result['info'] = "缺少必要参数";
  100. return $result;
  101. }
  102. $sql = "INSERT INTO opera_tickets(TICKET_ID,CREATE_USER_ID,CREATE_TIME,UPDATE_USER_ID,LINE_ID,TICKET_NAME,TICKET_TYPE,SEAT_TYPE,HUMAN_TYPE,PROD_PRICE,CUS_PRICE) VALUES((SELECT MAX(TICKET_ID)+1 FROM opera_tickets ot),$userID,NOW(),$userID,$line_id,(SELECT TYPE_NAME FROM dict_type WHERE ID=$seat_type),1,$seat_type,$human_type,$prod_price,$cus_price)";
  103. zzcsUtils::writeLog($sql);
  104. $res = $this->exec($sql);
  105. if ($res) {
  106. $code = 0;
  107. $msg = '添加票种成功';
  108. } else {
  109. $code = 1;
  110. $msg = '添加票种失败';
  111. }
  112. $result['code'] = (string)$code;
  113. $result['info'] = $msg;
  114. return $result;
  115. }
  116. /**
  117. * 更新票种信息
  118. * @param $param
  119. * @return mixed
  120. */
  121. public function updateTicket($param)
  122. {
  123. $user_id = $this->user_id;
  124. $ticketId = isset($param['ticket_id']) ? $param['ticket_id'] : false;
  125. $seat_type = isset($param['seat_type']) ? $param['seat_type'] : false;
  126. $human_type = isset($param['human_type']) ? $param['human_type'] : false;
  127. $prod_price = isset($param['prod_price']) ? $param['prod_price'] : false;
  128. $cus_price = isset($param['cus_price']) ? $param['cus_price'] : false;
  129. if (!$user_id || !$ticketId || !$seat_type || $human_type === false || $prod_price === false || $cus_price === false) {
  130. $result['code'] = '2';
  131. $result['info'] = "缺少必要参数";
  132. return $result;
  133. }
  134. $sql = "UPDATE opera_tickets SET UPDATE_USER_ID=$user_id,UPDATE_TIME = NOW(),TICKET_NAME=(SELECT TYPE_NAME FROM dict_type WHERE ID=$seat_type),SEAT_TYPE = $seat_type,HUMAN_TYPE = $human_type,PROD_PRICE = $prod_price,CUS_PRICE = $cus_price WHERE CANCEL_FLAG=0 AND TICKET_ID=$ticketId";
  135. zzcsUtils::writeLog($sql);
  136. $res = $this->exec($sql);
  137. if ($res) {
  138. $code = 0;
  139. $msg = '票种信息修改成功';
  140. } else {
  141. $code = 1;
  142. $msg = '票种信息修改失败';
  143. }
  144. $result['code'] = (string)$code;
  145. $result['info'] = $msg;
  146. $result['data'] = array(
  147. 'ticket_id' => $ticketId,
  148. 'seat_type' => $seat_type,
  149. 'human_type' => $human_type,
  150. 'prod_price' => $prod_price,
  151. 'cus_price' => $cus_price
  152. );
  153. return $result;
  154. }
  155. /**
  156. * 删除票种信息
  157. * @param $param
  158. * @return mixed
  159. */
  160. public function deleteTicket($param)
  161. {
  162. $user_id = $this->user_id;
  163. $ticket_id = isset($param['ticket_id']) ? $param['ticket_id'] : false;
  164. if (!$user_id || !$ticket_id) {
  165. $result['code'] = '2';
  166. $result['info'] = "缺少必要参数";
  167. return $result;
  168. }
  169. $sql = "UPDATE opera_tickets SET UPDATE_USER_ID=$user_id,UPDATE_TIME=NOW(),CANCEL_FLAG=1 WHERE TICKET_ID=$ticket_id";
  170. zzcsUtils::writeLog($sql);
  171. $res = $this->exec($sql);
  172. if ($res) {
  173. $code = 0;
  174. $msg = '票种信息删除成功';
  175. } else {
  176. $code = 1;
  177. $msg = '票种信息删除失败';
  178. }
  179. $result['code'] = (string)$code;
  180. $result['info'] = $msg;
  181. return $result;
  182. }
  183. /**
  184. * 获取基础数据
  185. */
  186. public function getBaseInfo()
  187. {
  188. $result['code'] = '0';
  189. $result['info'] = '基础数据获取成功';
  190. $result['seat_type'] = Dictionary::getSeatType();
  191. $result['human_type'] = Dictionary::getHumanType();
  192. return $result;
  193. }
  194. }