示例#1
0
 public function initOrders()
 {
     $cutomerOrders = new OrderQuery($this->doorGets);
     $cutomerOrders->filterByUserId($this->id);
     $cutomerOrders->find();
     $data = $cutomerOrders->_getEntities('array');
     $counter = 0;
     $amounts = array();
     $amountsProfit = array();
     if (!empty($data)) {
         foreach ($data as $order) {
             if ($order['status'] === 'payment_success') {
                 $counter++;
                 if (!array_key_exists($order['currency'], $amounts)) {
                     $amounts[$order['currency']] = 0.0;
                 }
                 $amounts[$order['currency']] += (double) $order['amount_with_shipping'];
                 if (!array_key_exists($order['currency'], $amountsProfit)) {
                     $amountsProfit[$order['currency']] = 0.0;
                 }
                 $amountsProfit[$order['currency']] += (double) $order['amount_profit'];
             }
         }
     }
     $this->countSuccess = $counter;
     if (!empty($amounts)) {
         foreach ($amounts as $currency => $amount) {
             $this->amountSuccess .= $this->doorGets->setCurrencyIcon($amount, $currency) . ' | ';
         }
         $this->amountSuccess = substr($this->amountSuccess, 0, -2);
     }
     if (!empty($amountsProfit)) {
         foreach ($amountsProfit as $currency => $amount) {
             $this->amountProfit .= $this->doorGets->setCurrencyIcon($amount, $currency) . ' | ';
         }
         $this->amountProfit = substr($this->amountProfit, 0, -2);
     }
     return $data;
 }
示例#2
0
文件: Api.php 项目: wayhood/wxpay
 /**
  * 
  * 查询订单,OrderQuery中out_trade_no、transaction_id至少填一个
  * appid、mchid、spbill_create_ip、nonce_str不需要填入
  * @param OrderQuery $inputObj
  * @param int $timeOut
  * @throws Exception
  * @return 成功时返回,其他抛异常
  */
 public static function orderQuery($inputObj, $timeOut = 6)
 {
     $url = "https://api.mch.weixin.qq.com/pay/orderquery";
     //检测必填参数
     if (!$inputObj->IsOut_trade_noSet() && !$inputObj->IsTransaction_idSet()) {
         throw new Exception("订单查询接口中,out_trade_no、transaction_id至少填一个!");
     }
     $inputObj->SetAppid(Config::APPID);
     //公众账号ID
     $inputObj->SetMch_id(Config::MCHID);
     //商户号
     $inputObj->SetNonce_str(self::getNonceStr());
     //随机字符串
     $inputObj->SetSign();
     //签名
     $xml = $inputObj->ToXml();
     $startTimeStamp = self::getMillisecond();
     //请求开始时间
     $response = self::postXmlCurl($xml, $url, false, $timeOut);
     $result = Results::Init($response);
     self::reportCostTime($url, $startTimeStamp, $result);
     //上报请求花费时间
     return $result;
 }
示例#3
0
<?php 
/**
 * 订单查询-demo
 * ====================================================
 * 该接口提供所有微信支付订单的查询。
 * 当支付通知处理异常或丢失的情况,商户可以通过该接口查询订单支付状态。
 * 
*/
include_once "./WxPayHelper/WxPayHelper.php";
//退款的订单号
if (!isset($_POST["out_trade_no"])) {
    $out_trade_no = " ";
} else {
    $out_trade_no = $_POST["out_trade_no"];
    //使用订单查询接口
    $orderQuery = new OrderQuery();
    //设置必填参数
    //appid已填,商户无需重复填写
    //mch_id已填,商户无需重复填写
    //noncestr已填,商户无需重复填写
    //sign已填,商户无需重复填写
    $orderQuery->setParameter("out_trade_no", "{$out_trade_no}");
    //商户订单号
    //非必填参数,商户可根据实际情况选填
    //$orderQuery->setParameter("sub_mch_id","XXXX");//子商户号
    //$orderQuery->setParameter("transaction_id","XXXX");//微信订单号
    //获取订单查询结果
    $orderQueryResult = $orderQuery->getResult();
    //商户根据实际情况设置相应的处理流程,此处仅作举例
    if ($orderQueryResult["return_code"] == "FAIL") {
        echo "通信出错:" . $orderQueryResult['return_msg'] . "<br>";