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.
 
 
 
 
 
 

65 lines
2.4 KiB

  1. <?php
  2. /**
  3. *
  4. * ============================================================================
  5. * * 版权所有 蜘蛛出行 * *
  6. * 网站地址: http://www.zhizhuchuxing.com
  7. * ----------------------------------------------------------------------------
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
  9. * 使用;不允许对程序代码以任何形式任何目的的再发布。
  10. * ============================================================================
  11. * Author By: 倪宗锋
  12. * PhpStorm SendRunBusWxMsg.php
  13. * Create By 2017/12/4 16:22 $
  14. */
  15. namespace console\controllers;
  16. use common\models\OrderMain;
  17. use common\util\Util;
  18. use yii\base\Exception;
  19. use yii\console\Controller;
  20. class SendRunBusWxMsgController extends Controller
  21. {
  22. /**
  23. * Des:发送通知入口
  24. * Name: actionIndex
  25. * @author 倪宗锋
  26. */
  27. public function actionIndex()
  28. {
  29. $orderMain = new OrderMain();
  30. $getList = $orderMain->getSendWxMsgOrderForRunBus();//获取需要发送通知的订单
  31. foreach ($getList as $orderInfo) {
  32. if (empty($orderInfo['open_id'])) {//没有openid不发送通知
  33. continue;
  34. }
  35. try {
  36. //获取车辆信息及座位号
  37. $param = [
  38. 'order_id' => $orderInfo['spider_order_id'],//订单ID
  39. 'travel_id' => 1,
  40. 'run_date' => date('Y-m-d', strtotime($orderInfo['run_date'])),//出发时间
  41. 'action' => 'get_bus_position'
  42. ];
  43. $getResult = Util::sendCs($param, '/api/wx/', 2);
  44. $csInfo = empty($getResult['data']['list']) ? [] : $getResult['data']['list'];
  45. $data = [
  46. 'type' => 4,
  47. 'bus_no' => empty($csInfo['bus']['bus_no']) ? '-' : $csInfo['bus']['bus_no'],//
  48. 'seat_name' => empty($csInfo['bus']['seat_no']['0']) ? '-' : implode(',', $csInfo['bus']['seat_no']),
  49. 'area' => empty($csInfo['res']['res_name']) ? $orderInfo['start_area'] : $csInfo['res']['res_name'],
  50. 'run_date' => $orderInfo['run_date'],
  51. 'open_id' => $orderInfo['open_id'],
  52. 'order_id' => $orderInfo['order_id']
  53. ];
  54. Util::sendWxMsg($data);
  55. } catch (Exception $e) {
  56. }
  57. }
  58. }
  59. }