25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MyTrip.php 8.5 KiB

3 년 전
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <?php
  2. /**
  3. *
  4. * ============================================================================
  5. * * 版权所有 蜘蛛出行 * *
  6. * 网站地址: http://www.zhizhuchuxing.com
  7. * ----------------------------------------------------------------------------
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
  9. * 使用;不允许对程序代码以任何形式任何目的的再发布。
  10. * ============================================================================
  11. * Author By: 娄梦宁
  12. * PhpStorm AppMyTrip.php
  13. * Create By 2016/11/29 9:20 $
  14. */
  15. namespace MyTrip\Model;
  16. use Base\Tool\DbTable;
  17. class MyTrip extends DbTable
  18. {
  19. public $db = 'CST';
  20. public $tab='order_main';
  21. /**
  22. * Function Description:获取符合条件的行程订单order_id
  23. * Function Name: getOrderArr
  24. * @param $arr
  25. *
  26. * @return array
  27. *
  28. * @author 娄梦宁
  29. */
  30. public function getOrderArr($arr){
  31. $userId=$arr['userId'];
  32. $limit=$arr['limit'];
  33. $page=$arr['page'];
  34. $page=($page-1)*$limit;
  35. $type=$arr['type'];
  36. $today=date('Y-m-d',time());
  37. if($type==146){
  38. $today='>="'.$today.'"';
  39. }elseif ($type==147){
  40. $today='<"'.$today.'"';
  41. }
  42. $sql=''."SELECT
  43. v.PARENT_ORDER_ID AS order_id,
  44. max(v.RUN_DATE) 'rundate',
  45. v.order_prod_type AS type,
  46. min(
  47. CONCAT(v.RUN_DATE, ' ', v.RUN_TIME)
  48. ) 'mt'
  49. FROM
  50. order_main v,
  51. (
  52. SELECT
  53. order_id
  54. FROM
  55. order_main
  56. WHERE
  57. member_id = $userId
  58. AND parent_order_id = 0
  59. UNION ALL
  60. SELECT
  61. order_id
  62. FROM
  63. order_weixin_bond
  64. WHERE
  65. weixin_open_id = $userId
  66. ) v1
  67. WHERE
  68. v.PARENT_ORDER_ID = v1.order_id
  69. AND v.order_status in (146,147)
  70. GROUP BY
  71. v.PARENT_ORDER_ID
  72. HAVING
  73. rundate $today
  74. ORDER BY
  75. mt DESC
  76. LIMIT $page,$limit";
  77. $result=$this->fetchAll($sql);
  78. return $result;
  79. }
  80. /**
  81. * Function Description:获取普通订单数据
  82. * Function Name: normalDate
  83. * @param $normalOrderId
  84. *
  85. * @return array
  86. *
  87. * @author 娄梦宁
  88. */
  89. public function normalDate($normalOrderId){
  90. $sql=""."SELECT
  91. order_prod_type type,
  92. run_date,
  93. parent_order_id as order_id,
  94. prod_start_station_time as run_time,
  95. prod_start_station_res_name AS start_res_name,
  96. prod_end_station_res_name AS end_res_name,
  97. (
  98. prod_end_station_time_minutes - prod_start_station_time_minutes
  99. ) minutes,
  100. prod_start_station_area_name AS start_area_name,
  101. prod_end_station_area_name AS end_area_name
  102. FROM
  103. order_main
  104. WHERE
  105. parent_order_id IN ($normalOrderId)
  106. GROUP BY
  107. parent_order_id
  108. ORDER BY
  109. run_date DESC,
  110. run_time DESC";
  111. $result=$this->fetchAll($sql);
  112. return $result;
  113. }
  114. /**
  115. * Function Description:获取周边游订单数据
  116. * Function Name: aroundDate
  117. * @param $aroundOrderId
  118. *
  119. * @return array
  120. *
  121. * @author 娄梦宁
  122. */
  123. public function aroundDate($aroundOrderId){
  124. $sql=''."SELECT
  125. a.order_id,
  126. ifnull(d.PROPERTY, '') AS line_add,
  127. a.PROD_START_STATION_DATE AS run_date,
  128. a.PROD_START_STATION_TIME AS run_time,
  129. a.order_prod_type AS type,
  130. a.parent_prod_name as line_name
  131. FROM
  132. order_main a
  133. LEFT JOIN opera_line_group b ON a.parent_prod_id = b.line_id
  134. LEFT JOIN base_resource_property d ON b.end_res_id = d.res_id
  135. WHERE
  136. a.CANCEL_FLAG = 0
  137. AND b.CANCEL_FLAG = 0
  138. AND b.day_num = 1
  139. AND b.seq_id = 1
  140. AND d.CANCEL_FLAG = 0
  141. AND d.TYPE_ID = 279
  142. AND a.order_id IN ($aroundOrderId)
  143. GROUP BY
  144. a.order_id";
  145. $result=$this->fetchAll($sql);
  146. return $result;
  147. }
  148. /**
  149. * Function Description:电子票页面数据提取
  150. * Function Name: getEticket
  151. * @param $arr
  152. *
  153. * @return array
  154. *
  155. * @author 娄梦宁
  156. */
  157. public function getEticket($arr){
  158. $order_id=$arr['order_id'];
  159. $sql=''."SELECT
  160. c.run_date AS date,
  161. a.order_id,
  162. c.PROD_START_STATION_res_NAME AS start_res_name,
  163. c.PROD_end_STATION_res_NAME AS end_res_name,
  164. c.prod_start_station_time AS time,
  165. c.PROD_START_STATION_AREA_NAME AS start_area_name,
  166. c.PROD_END_STATION_AREA_NAME AS end_area_name,
  167. substring_index(substring_index(a.ORDER_DESCRIPTION, ',' ,- 1),'|',1) AS count,
  168. c.prod_name,
  169. a.customer_name,
  170. a.customer_mobile
  171. FROM
  172. order_main a
  173. LEFT JOIN order_main c ON c.PARENT_ORDER_ID = a.order_id
  174. WHERE
  175. a.cancel_flag = 0
  176. AND c.CANCEL_FLAG = 0
  177. AND a.PARENT_ORDER_ID = 0
  178. and a.order_id=$order_id
  179. GROUP BY
  180. a.order_id
  181. LIMIT 1 ";
  182. $result=$this->fetchRow($sql);
  183. return $result;
  184. }
  185. /**
  186. * Function Description:查询是否检票
  187. * Function Name: isCheck
  188. * @param $order_id
  189. *
  190. * @return array
  191. *
  192. * @author 娄梦宁
  193. */
  194. public function isCheck($order_id){
  195. $sql=''."select id from order_check_tickets where order_id=$order_id";
  196. $result=$this->fetchRow($sql);
  197. return $result;
  198. }
  199. /**
  200. * Function Description:获取手机号下的所有订单
  201. * Function Name: getAllOrder
  202. * @param $tel
  203. *
  204. * @return array
  205. *
  206. * @author 娄梦宁
  207. */
  208. public function getAllOrder($tel){
  209. $sql=''."select order_id from order_main where CUSTOMER_MOBILE=$tel and cancel_flag=0 and parent_order_id=0 and order_status in(146,147)";
  210. $result=$this->fetchAll($sql);
  211. return $result;
  212. }
  213. /**
  214. * Function Description:绑定订单
  215. * Function Name: tripBind
  216. * @param $arr
  217. *
  218. * @return int
  219. *
  220. * @author 娄梦宁
  221. */
  222. public function tripBind($arr){
  223. $tel=$arr['tel'] ;
  224. $userId=$arr['userId'];
  225. $nowtime=date('Y-m-d h:i:s',time());
  226. $sql=''."INSERT INTO `order_weixin_bond` (
  227. `order_id`,
  228. `tel`,
  229. `weixin_open_id`,
  230. `bond_time`
  231. ) SELECT
  232. ORDER_ID,
  233. '$tel',
  234. '$userId',
  235. '$nowtime'
  236. FROM
  237. order_main a
  238. WHERE
  239. CUSTOMER_MOBILE = '$tel'
  240. AND order_id NOT IN (
  241. SELECT
  242. order_id
  243. FROM
  244. order_weixin_bond
  245. WHERE
  246. weixin_open_id = '$userId'
  247. )
  248. AND cancel_flag = 0
  249. AND parent_order_id = 0
  250. and order_status in (146,147)
  251. ";
  252. $result=$this->execSql($sql);
  253. return $result;
  254. }
  255. /**
  256. * Function Description:更新订单表menber_id为当前id
  257. * Function Name: uptOrder
  258. * @param $orderStr
  259. * @param $userId
  260. *
  261. * @return array
  262. *
  263. * @author 娄梦宁
  264. */
  265. public function uptOrder($orderStr,$userId){
  266. $data = array(
  267. 'MEMBER_ID' => $userId
  268. );
  269. $result=$this->update($data,"MEMBER_ID=0 and (order_id in($orderStr) or parent_order_id in ($orderStr))");
  270. return $result;
  271. }
  272. }