|
- <?php
- /**
- *
- * ============================================================================
- * * 版权所有 蜘蛛出行 * *
- * 网站地址: http://www.zhizhuchuxing.com
- * ----------------------------------------------------------------------------
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
- * 使用;不允许对程序代码以任何形式任何目的的再发布。
- * ============================================================================
- * Author By: 倪宗锋
- * PhpStorm SendRunBusWxMsg.php
- * Create By 2017/12/4 16:22 $
- */
-
- namespace console\controllers;
-
-
- use common\models\OrderMain;
- use common\util\Util;
- use yii\base\Exception;
- use yii\console\Controller;
-
- class SendRunBusWxMsgController extends Controller
- {
- /**
- * Des:发送通知入口
- * Name: actionIndex
- * @author 倪宗锋
- */
- public function actionIndex()
- {
- $orderMain = new OrderMain();
- $getList = $orderMain->getSendWxMsgOrderForRunBus();//获取需要发送通知的订单
- foreach ($getList as $orderInfo) {
- if (empty($orderInfo['open_id'])) {//没有openid不发送通知
- continue;
- }
- try {
- //获取车辆信息及座位号
- $param = [
- 'order_id' => $orderInfo['spider_order_id'],//订单ID
- 'travel_id' => 1,
- 'run_date' => date('Y-m-d', strtotime($orderInfo['run_date'])),//出发时间
- 'action' => 'get_bus_position'
- ];
- $getResult = Util::sendCs($param, '/api/wx/', 2);
- $csInfo = empty($getResult['data']['list']) ? [] : $getResult['data']['list'];
- $data = [
- 'type' => 4,
- 'bus_no' => empty($csInfo['bus']['bus_no']) ? '-' : $csInfo['bus']['bus_no'],//
- 'seat_name' => empty($csInfo['bus']['seat_no']['0']) ? '-' : implode(',', $csInfo['bus']['seat_no']),
- 'area' => empty($csInfo['res']['res_name']) ? $orderInfo['start_area'] : $csInfo['res']['res_name'],
- 'run_date' => $orderInfo['run_date'],
- 'open_id' => $orderInfo['open_id'],
- 'order_id' => $orderInfo['order_id']
- ];
- Util::sendWxMsg($data);
- } catch (Exception $e) {
- }
- }
-
- }
-
- }
|