You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

62 lines
2.6 KiB

  1. <?php
  2. /**
  3. *
  4. * ============================================================================
  5. * * 版权所有 蜘蛛出行 * *
  6. * 网站地址: http://www.zhizhuchuxing.com
  7. * ----------------------------------------------------------------------------
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
  9. * 使用;不允许对程序代码以任何形式任何目的的再发布。
  10. * ============================================================================
  11. * Author By: Redstop
  12. * PhpStorm GetOrderMainData.php
  13. * Create By 2017/6/2 18:16 $
  14. */
  15. namespace backend\modules\api\logic;
  16. use yii\db\Expression;
  17. use yii\db\Query;
  18. class GetOrderMainData extends Query
  19. {
  20. /**
  21. * Function Description:
  22. * Function Name:
  23. *
  24. * @author Redstop
  25. */
  26. public function getBusOrderArrayByPhone( $cus_phone, $start_date = false, $end_date = false )
  27. {
  28. $start_date = $start_date == false ? date("Y-m-d") : $start_date;
  29. $end_date = $end_date == false ? date("Y-m-d", strtotime("+2 months")) : $end_date;
  30. $select=[
  31. 'm.customer_name',
  32. 'm.customer_mobile',
  33. 'm.customer_id_no',
  34. 'm.parent_order_id',
  35. 'm.run_time',
  36. 'prod_start_station_time'=>new Expression('concat(m.run_date," ",m.prod_start_station_time)'),
  37. 'prod_end_station_time'=>new Expression('concat(m.run_date," ",m.prod_end_station_time)'),
  38. 'm.prod_start_station_res_id',
  39. 'm.prod_start_station_res_name',
  40. 'm.prod_end_station_res_id',
  41. 'm.prod_end_station_res_name',
  42. 'm.prod_start_station_area_id',
  43. 'm.prod_start_station_area_name',
  44. 'm.prod_end_station_area_id',
  45. 'm.prod_end_station_area_name',
  46. '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)',
  47. '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)',
  48. ];
  49. $res1 = (new Query())->select($select)
  50. ->from('order_main as m')
  51. ->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]] ])
  52. ->groupBy("m.parent_order_id")
  53. ->all();
  54. if( !$res1 ) {
  55. return false;
  56. }
  57. return $res1;
  58. }
  59. }