/** * * 查询订单,OrderQuery中out_trade_no、transaction_id至少填一个 * appid、mchid、spbill_create_ip、nonce_str不需要填入 * @param OrderQuery $input * @param int $time_out * @throws WxPayException * @return 成功时返回,其他抛异常 */ public function orderQuery($input, $time_out = 6) { $url = 'https://api.mch.weixin.qq.com/pay/orderquery'; //检测必填参数 if (!$input->isOutTradeNoSet() && !$input->isTransactionIdSet()) { throw new WxPayException('订单查询接口中,out_trade_no、transaction_id至少填一个!'); } $input->setAppid(Wxpay::getConfig('appid')); //公众账号ID $input->setMchId(Wxpay::getConfig('mchid')); //商户号 $input->setSubMchId(Wxpay::getConfig('sub_mch_id')); //子商户号 $input->setNonceStr($this->getNonceStr()); //随机字符串 $input->setSign(); //签名 $xml = $input->toXml(); $start_time_stamp = $this->getMillisecond(); //请求开始时间 $response = $this->postXmlCurl($xml, $url, false, $time_out); $result = Results::Init($response); $this->reportCostTime($url, $start_time_stamp, $result); //上报请求花费时间 return $result; }