예제 #1
0
<?php

/**
 * 订单查询
 * @author www.linauror.com
 * @copyright 2014
 */
include 'config.php';
include 'lib.php';
$wechat = new Wechat();
$result = $wechat->orderquery($config, $out_trade_no);
// 这里仅需要本站订单号
print_r($result);
 public function orderWxQuery($num = "")
 {
     $num = $num == "" ? $_GET['orderId'] : $num;
     $zhifuhao = M('order_merge')->where(array('orderid' => $num))->getField('mergeid');
     if ($zhifuhao != "") {
         header('Content-Type:text/html;charset=utf-8');
         $wetallroute = dirname(dirname(dirname(dirname(dirname(__FILE__)))));
         include $wetallroute . "/wxpay/config.php";
         //dump($config);exit;
         include $wetallroute . "/wxpay/lib.php";
         $wechat = new Wechat();
         $result = $wechat->orderquery($config, $zhifuhao);
         if ($result['errcode'] == 0 && $result['errmsg'] == 'ok') {
             //成功返回
             if ($result['order_info']['ret_code'] == 0 && $result['order_info']['trade_state'] == "0") {
                 $this->success('该订单已支付成功!');
             } else {
                 $this->error('该订单支付失败!' . '[' . $result['order_info']['ret_code'] . ']' . $result['order_info']['ret_msg']);
             }
         } else {
             $this->error('该订单查询失败!' . '[' . $result['errcode'] . ']' . $result['errmsg']);
         }
     } else {
         $this->error("没有取到订单号!");
     }
 }