|
- <?php
- /**
- *
- * ============================================================================
- * * 版权所有 蜘蛛出行 * *
- * 网站地址: http://www.zhizhuchuxing.com
- * ----------------------------------------------------------------------------
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
- * 使用;不允许对程序代码以任何形式任何目的的再发布。
- * ============================================================================
- * Author By: Redstop
- * PhpStorm GetOrderMainData.php
- * Create By 2017/6/2 18:16 $
- */
-
- namespace backend\modules\api\logic;
-
- use yii\db\Expression;
- use yii\db\Query;
-
- class GetOrderMainData extends Query
- {
- /**
- * Function Description:
- * Function Name:
- *
- * @author Redstop
- */
- public function getBusOrderArrayByPhone( $cus_phone, $start_date = false, $end_date = false )
- {
- $start_date = $start_date == false ? date("Y-m-d") : $start_date;
- $end_date = $end_date == false ? date("Y-m-d", strtotime("+2 months")) : $end_date;
- $select=[
- 'm.customer_name',
- 'm.customer_mobile',
- 'm.customer_id_no',
- 'm.parent_order_id',
- 'm.run_time',
- 'prod_start_station_time'=>new Expression('concat(m.run_date," ",m.prod_start_station_time)'),
- 'prod_end_station_time'=>new Expression('concat(m.run_date," ",m.prod_end_station_time)'),
- 'm.prod_start_station_res_id',
- 'm.prod_start_station_res_name',
- 'm.prod_end_station_res_id',
- 'm.prod_end_station_res_name',
- 'm.prod_start_station_area_id',
- 'm.prod_start_station_area_name',
- 'm.prod_end_station_area_id',
- 'm.prod_end_station_area_name',
- 'start_longitude'=>'(select property from base_resource_property where res_id=m.prod_start_station_res_id and type_id=212 and cancel_flag=0 limit 1)',
- 'start_latitude'=>'(select property from base_resource_property where res_id=m.prod_start_station_res_id and type_id=213 and cancel_flag=0 limit 1)',
- ];
- $res1 = (new Query())->select($select)
- ->from('order_main as m')
- ->where(['and', ['=', 'm.customer_mobile', $cus_phone], ['=', 'm.agent_level', 1], ['>=', 'm.run_date', $start_date], ['<=', 'm.run_date', $end_date],['>', 'm.parent_order_id', 0],['=', 'm.order_prod_type', 82],['=', 'm.cancel_flag', 0],['in', 'm.order_status', [146,147]] ])
- ->groupBy("m.parent_order_id")
- ->all();
- if( !$res1 ) {
- return false;
- }
- return $res1;
- }
- }
|