|
- <?php
- /**
- * Created by PhpStorm.
- * User: wangxj
- * Date: 2016/11/18
- * Time: 10:41
- */
-
- namespace WeChatUser\Model;
-
- use Base\Tool\DbTable;
- use Util\Util\Util;
-
- class User extends DbTable
- {
- public $tab = 'wechat_user';
- public $db = 'CST';
-
- /**
- * Des:用户订单列表
- * Name: getOrder
- * @param string $user_id
- * @param string $where
- * @return array
- * @author wangxj
- */
- public function getOrder($user_id = '', $where = '')
- {
- //订单类型 dict_type 80子类型 取81客运线路 82客运车票 ??周边游
- //ORDER_STATUS订单状态
- //resource_property 279 具体地址
- if ($where == '')
- $where = "1=1 and o.cancel_flag=0 ";
- else
- $where = "1=1 and o.cancel_flag=0 and $where";
- //周边游order_prod_type 改为369
- $prod_list = "82,369";
-
- $select = "order_prod_type type,
- order_id,
- parent_order_id,
- run_date,
- run_time,
- prod_end_station_time,
- prod_start_station_time,
- (prod_end_station_time_minutes - prod_start_station_time_minutes) minutes,
- prod_start_station_area_name start_res_area_name,
- prod_start_station_res_name start_res_name,
- prod_end_station_area_name end_res_area_name,
- prod_end_station_res_name end_res_name,
- line_name,
- ifnull(p.PROPERTY,'') line_add";
- $from = " order_main o
- left join opera_line l on o.PARENT_PROD_ID = l.line_id
- left join opera_line_group g on o.PARENT_PROD_ID = g.SUB_LINE_ID
- LEFT JOIN base_resource_property p on g.end_res_id = p.RES_ID and
- p.TYPE_ID = 279";
- $where .= "AND MEMBER_ID = $user_id and PARENT_ORDER_ID <> 0
- and order_prod_type in ($prod_list)";
- $groupBy = ' GROUP BY PARENT_ORDER_ID';
- $orderBy = ' ORDER BY RUN_DATE, RUN_TIME,MINUTES';
-
- $sql = '' . "select $select from $from where $where $groupBy $orderBy";
- $result = $this->fetchAll($sql);
- $return_result = array();
- foreach ($result as $order_info) {
- $diff_time = (strtotime($order_info["prod_end_station_time"]) - strtotime($order_info["prod_start_station_time"])) / 60;
- $diff_hour = floor($diff_time / 60);
- $diff_minuts = $diff_time - $diff_hour * 60;
- $disp_minutes = $diff_hour . "小时";
- if ($diff_minuts > 0) {
- $disp_minutes .= $diff_minuts . "分";
- }
- $order_info["minutes"] = $disp_minutes;
- $return_result[] = $order_info;
- }
- return $return_result;
-
- }
-
- /**
- * Des:绑定订单,用原微信接口逻辑
- * Name: bindOrder
- * @param $para_order_id
- * @param $para_tel
- * @param $para_open_id
- * @param $user_id
- * @return array
- * @author 倪宗锋
- */
- public function bindOrder($para_order_id, $para_tel, $para_open_id, $user_id)
- {
- $sql = "CALL DRIVER_WEICHAT_BOND($para_order_id, '$para_tel', '$para_open_id')";
- $result = $this->fetchAll($sql);
- $update_sql = '' . "UPDATE order_main SET MEMBER_ID = {$user_id} WHERE ORDER_ID = {$para_order_id} OR PARENT_ORDER_ID = {$para_order_id}";
- $this->execSql($update_sql);
-
- return $result;
- }
-
- public function getWeChatOpenId($user_id)
- {
- $sql = '' . "select openid from wechat_user where id=$user_id";
- $openid = $this->fetchOne($sql);
- if (empty($openid))
- $openid = 0;
- return $openid;
- }
-
- /**
- * Des:我要找车
- * Name: getCar
- * @param $order_id
- * @param $date
- * @return array
- * @author 张帅
- */
- public function getCar($order_id, $date)
- {
- $sql = '' . "SELECT
- b.send_bus_res_id as bus_id,
- b.send_bus_org_id as bus_org_id,
- b.send_driver_name as driver_name,
- b.send_driver_mobile as driver_mobile,
- (SELECT bus_no from base_bus WHERE bus_id = b.send_bus_res_id) as bus_no,
- m.res_id,
- (SELECT res_name from base_resource where res_id = m.res_id) as res_name,
- (SELECT property from base_resource_property where cancel_flag = 0 and res_id = m.res_id and type_id = 212) as res_x,
- (SELECT property from base_resource_property where cancel_flag = 0 and res_id = m.res_id and type_id = 213) as res_y,
- (SELECT property from base_resource_property where cancel_flag = 0 and res_id = m.res_id and type_id = 279 limit 1) as address,
- a.res_name as bus_name,
- ifnull((select res_name from base_resource where res_id=c.bus_color),'暂无') as color,
- if(c.bus_img_path='','http://img.zhizhuchuxing.cn/zzwx/busimg/no_bus_img.png',c.bus_img_path) as img_url
- FROM
- run_bus AS b,
- (
- SELECT
- run_id,
- run_bus_order_id AS bus_order_id,
- prod_start_station_res_id as res_id
- FROM
- order_main
- WHERE
- parent_order_id = $order_id
- AND prod_start_station_date ='$date'
- GROUP BY
- run_id,
- run_bus_order_id
- ) AS m,base_resource a,base_bus c
- WHERE
- c.bus_id=b.send_bus_res_id
- and a.id=c.brand_id
- and b.run_id = m.run_id
- AND b.bus_order_id = m.bus_order_id";
- $result = $this->fetchRow($sql);
- if ($result) {
- return Util::returnArrSu('', $result);
- } else {
- return Util::returnArrEr('数据库错误');
- }
- }
- }
|