openid; setcookie('user_openid', $openid, 0, '/'); } } $pdo=conn(); $sql="CALL driver_wechat_ticket('".$userId."','".$runId."','".$busOrderId."','".$stationId."','".$openid."')"; write_log("sql".$sql); if(is_object($pdo)){ $result=$pdo->query($sql); $json=$result->fetchAll(PDO::FETCH_ASSOC); $result->closeCursor(); write_log($openid."==".$sql."data:::".json_encode($json)); $sdk = new PushSDK(); // 设置消息类型为 通知类型. $opts = array ( 'msg_type' => 0 ); $data=array(); if($json){ if($json[0]['num']>0){ //$data=$json[0]; $data['info']='检票成功'; $message = array ( // 消息的标题. //'title' => 'yes', // 消息内容 'message' => "检票成功".$json[0]['num']."人" ); }else{ /*$data=$json[0]; if($data['info']=="219"){ $data['info']='检票失败'; }*/ $data['info']="检票失败"; $message = array ( // 消息的标题. //'title' => 'no', // 消息内容 'message' => "检票失败" ); } }else{ //$data['code']='1'; $data['info']='检票失败'; $message = array ( // 消息的标题. //'title' => 'no', // 消息内容 'message' => "检票失败" ); } $rs = $sdk -> pushMsgToSingleDevice($channelId, $message, $opts); write_log($channelId."==".json_encode($message)."==".json_encode($opts)); // 判断返回值,当发送失败时, $rs的结果为false, 可以通过getError来获得错误信息. if($rs === false){ write_log("云推送失败code:".$openid."==runid==".$runId."==busorderid==".$busOrderId."==station==".$stationId.json_encode($sdk->getLastErrorCode())); write_log("云推送失败msg:".$openid."==runid==".$runId."==busorderid==".$busOrderId."==station==".$stationId.json_encode($sdk->getLastErrorMsg())); }else{ // 将打印出消息的id,发送时间等相关信息. write_log("云推送成功msg: openid:".$openid."==runid==".$runId."==busorderid==".$busOrderId."==station==".$stationId.json_encode($rs)); } } if($data['info']=='检票失败'){ header("Location: http://xmwx.zhizhuchuxing.cn/check_fail.html"); }else{ $sql1="select a.PROD_NAME,a.PARENT_PROD_NAME,concat( a.RUN_DATE,' ',a.RUN_TIME)as run_date_time ,a.RUN_BUS_SEAT_NAME from order_main as a inner join( select order_id from order_weixin_bond where weixin_open_id='".$openid."' order by id desc limit 1 )as b on a.PARENT_ORDER_ID=b.order_id where a.CANCEL_FLAG=0 and a.ORDER_VALID_STATUS=1"; $result1=$pdo->query($sql1); $rowset1=$result1->fetchAll(PDO::FETCH_ASSOC); $result1->closeCursor(); $run_date_time=$prod_name=$seat_name=''; $n=0; foreach($rowset1 as $v){ if(strpos($v['PROD_NAME'],'往返专用')!==false){ continue; } if($run_date_time ==''){ $run_date_time=$v['run_date_time']; } if($prod_name==''){ $prod_name=$v['PARENT_PROD_NAME']; } $seat_name.=$v['RUN_BUS_SEAT_NAME']."、"; $n+=1; } $seat_name=rtrim($seat_name,'、'); $url="http://xmwx.zhizhuchuxing.cn/check_succeed.html?line=".$prod_name."&time=".$run_date_time."&num=".$n."&seat=".$seat_name; write_log(json_encode($rowset1)); write_log("url:".$url); header("Location: $url"); } ?>