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.
 
 
 
 
 
 

162 wiersze
6.1 KiB

  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: wangxj
  5. * Date: 2016/11/18
  6. * Time: 10:41
  7. */
  8. namespace WeChatUser\Model;
  9. use Base\Tool\DbTable;
  10. use Util\Util\Util;
  11. class User extends DbTable
  12. {
  13. public $tab = 'wechat_user';
  14. public $db = 'CST';
  15. /**
  16. * Des:用户订单列表
  17. * Name: getOrder
  18. * @param string $user_id
  19. * @param string $where
  20. * @return array
  21. * @author wangxj
  22. */
  23. public function getOrder($user_id = '', $where = '')
  24. {
  25. //订单类型 dict_type 80子类型 取81客运线路 82客运车票 ??周边游
  26. //ORDER_STATUS订单状态
  27. //resource_property 279 具体地址
  28. if ($where == '')
  29. $where = "1=1 and o.cancel_flag=0 ";
  30. else
  31. $where = "1=1 and o.cancel_flag=0 and $where";
  32. //周边游order_prod_type 改为369
  33. $prod_list = "82,369";
  34. $select = "order_prod_type type,
  35. order_id,
  36. parent_order_id,
  37. run_date,
  38. run_time,
  39. prod_end_station_time,
  40. prod_start_station_time,
  41. (prod_end_station_time_minutes - prod_start_station_time_minutes) minutes,
  42. prod_start_station_area_name start_res_area_name,
  43. prod_start_station_res_name start_res_name,
  44. prod_end_station_area_name end_res_area_name,
  45. prod_end_station_res_name end_res_name,
  46. line_name,
  47. ifnull(p.PROPERTY,'') line_add";
  48. $from = " order_main o
  49. left join opera_line l on o.PARENT_PROD_ID = l.line_id
  50. left join opera_line_group g on o.PARENT_PROD_ID = g.SUB_LINE_ID
  51. LEFT JOIN base_resource_property p on g.end_res_id = p.RES_ID and
  52. p.TYPE_ID = 279";
  53. $where .= "AND MEMBER_ID = $user_id and PARENT_ORDER_ID <> 0
  54. and order_prod_type in ($prod_list)";
  55. $groupBy = ' GROUP BY PARENT_ORDER_ID';
  56. $orderBy = ' ORDER BY RUN_DATE, RUN_TIME,MINUTES';
  57. $sql = '' . "select $select from $from where $where $groupBy $orderBy";
  58. $result = $this->fetchAll($sql);
  59. $return_result = array();
  60. foreach ($result as $order_info) {
  61. $diff_time = (strtotime($order_info["prod_end_station_time"]) - strtotime($order_info["prod_start_station_time"])) / 60;
  62. $diff_hour = floor($diff_time / 60);
  63. $diff_minuts = $diff_time - $diff_hour * 60;
  64. $disp_minutes = $diff_hour . "小时";
  65. if ($diff_minuts > 0) {
  66. $disp_minutes .= $diff_minuts . "分";
  67. }
  68. $order_info["minutes"] = $disp_minutes;
  69. $return_result[] = $order_info;
  70. }
  71. return $return_result;
  72. }
  73. /**
  74. * Des:绑定订单,用原微信接口逻辑
  75. * Name: bindOrder
  76. * @param $para_order_id
  77. * @param $para_tel
  78. * @param $para_open_id
  79. * @param $user_id
  80. * @return array
  81. * @author 倪宗锋
  82. */
  83. public function bindOrder($para_order_id, $para_tel, $para_open_id, $user_id)
  84. {
  85. $sql = "CALL DRIVER_WEICHAT_BOND($para_order_id, '$para_tel', '$para_open_id')";
  86. $result = $this->fetchAll($sql);
  87. $update_sql = '' . "UPDATE order_main SET MEMBER_ID = {$user_id} WHERE ORDER_ID = {$para_order_id} OR PARENT_ORDER_ID = {$para_order_id}";
  88. $this->execSql($update_sql);
  89. return $result;
  90. }
  91. public function getWeChatOpenId($user_id)
  92. {
  93. $sql = '' . "select openid from wechat_user where id=$user_id";
  94. $openid = $this->fetchOne($sql);
  95. if (empty($openid))
  96. $openid = 0;
  97. return $openid;
  98. }
  99. /**
  100. * Des:我要找车
  101. * Name: getCar
  102. * @param $order_id
  103. * @param $date
  104. * @return array
  105. * @author 张帅
  106. */
  107. public function getCar($order_id, $date)
  108. {
  109. $sql = '' . "SELECT
  110. b.send_bus_res_id as bus_id,
  111. b.send_bus_org_id as bus_org_id,
  112. b.send_driver_name as driver_name,
  113. b.send_driver_mobile as driver_mobile,
  114. (SELECT bus_no from base_bus WHERE bus_id = b.send_bus_res_id) as bus_no,
  115. m.res_id,
  116. (SELECT res_name from base_resource where res_id = m.res_id) as res_name,
  117. (SELECT property from base_resource_property where cancel_flag = 0 and res_id = m.res_id and type_id = 212) as res_x,
  118. (SELECT property from base_resource_property where cancel_flag = 0 and res_id = m.res_id and type_id = 213) as res_y,
  119. (SELECT property from base_resource_property where cancel_flag = 0 and res_id = m.res_id and type_id = 279 limit 1) as address,
  120. a.res_name as bus_name,
  121. ifnull((select res_name from base_resource where res_id=c.bus_color),'暂无') as color,
  122. if(c.bus_img_path='','http://img.zhizhuchuxing.cn/zzwx/busimg/no_bus_img.png',c.bus_img_path) as img_url
  123. FROM
  124. run_bus AS b,
  125. (
  126. SELECT
  127. run_id,
  128. run_bus_order_id AS bus_order_id,
  129. prod_start_station_res_id as res_id
  130. FROM
  131. order_main
  132. WHERE
  133. parent_order_id = $order_id
  134. AND prod_start_station_date ='$date'
  135. GROUP BY
  136. run_id,
  137. run_bus_order_id
  138. ) AS m,base_resource a,base_bus c
  139. WHERE
  140. c.bus_id=b.send_bus_res_id
  141. and a.id=c.brand_id
  142. and b.run_id = m.run_id
  143. AND b.bus_order_id = m.bus_order_id";
  144. $result = $this->fetchRow($sql);
  145. if ($result) {
  146. return Util::returnArrSu('', $result);
  147. } else {
  148. return Util::returnArrEr('数据库错误');
  149. }
  150. }
  151. }