对订单进行退款操作

@param array $order 订单内容
@return array
767925
public function refund(array $order)
    {
        Datasheet::set($order);
        $param_keys = ['appid', 'mch_id', 'out_trade_no', 'transaction_id', 'out_refund_no',
            'total_fee', 'refund_fee', 'nonce_str'];
        return Helper::request(Helper::GATEWAY_REFUNDORDER, $param_keys, Helper::SSL_VERIFY);
    }
1330792
public function update($order)
    {
        $orderId = "";

        if (is_array($order)) {
            $orderId = $order["id"];
        }
        elseif (is_object($order)) {
            $orderId = $order->id;
        }

        return $this->client->put("/orders/" . rawurlencode($orderId), $order, null);
    }
590304
public function sort(array $order)
    {
        $criteria = Criteria::create()->orderBy($order);

        /** @var FlexCollectionInterface $matching */
        $matching = $this->matching($criteria);

        return $matching;
    }
180158
public function create(Order $order)
    {
        $user = Auth::user();
        // 직접 입력은 무통장입금만 가능
        $paymentMethodId = DirectBank::getId();
        $paymentGatewayId = (new DirectPayGateway)->getId();
        // 미결상태면
        $isWaitingPayment = $order->status_id < OrderStatus::PENDING;
        return view('order::admin.transactions.create', compact('order', 'user', 'paymentMethodId', 'paymentGatewayId', 'isWaitingPayment'));
    }
882550
public function getData($order = self::SORT_DESC)
    {
        return array(
            'items' => array_map(
                function (Item $item) {
                    /*
                     * @var Item $item
                     */
                    return $item->toArray();
                },
                array_values($this->getItems($order))
            ),
        );
    }
925773
public function orderBy($order, $append = true, $first = false)
    {
        return $this->command->orderBy($order, $append, $first);
    }
1026617
public function show(Order $order)
    {
        Shop::instance($order->shop_id);
        $paymentMethods = Shop::getPaymentMethods()->flatten()->mapWithKeys(function($method) {
            return [$method::getId() => $method::getName()];
        })->all();
        $orderStatuses = $this->orderstatus->all()->pluck('name', 'id')->toArray();

        return view('order::admin.orders.view', compact('order', 'paymentMethods', 'orderStatuses'));
    }
1269071
public function query(array $order)
    {
        Datasheet::set($order);
        $result = Helper::request(Helper::GATEWAY_TRADEQUERY, ['AuthCode']);
        return $this->callback($result);
    }
348730
protected function parseOrder(Query $query, $order)
    {
        foreach ($order as $key => $val) {
            if ($val instanceof Expression) {
                $array[] = $val->getValue();
            } elseif (is_array($val) && preg_match('/^[\w\.]+$/', $key)) {
                $array[] = $this->parseOrderField($query, $key, $val);
            } elseif ('[rand]' == $val) {
                $array[] = $this->parseRand($query);
            } elseif (is_string($val)) {
                if (is_numeric($key)) {
                    list($key, $sort) = explode(' ', strpos($val, ' ') ? $val : $val . ' ');
                } else {
                    $sort = $val;
                }

                if (preg_match('/^[\w\.]+$/', $key)) {
                    $sort    = strtoupper($sort);
                    $sort    = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : '';
                    $array[] = $this->parseKey($query, $key, true) . $sort;
                } else {
                    throw new Exception('order express error:' . $key);
                }
            }
        }

        return empty($array) ? '' : ' ORDER BY ' . implode(',', $array);
    }
432655
public function all($order = 'ASC')
    {
        $capsule = $this->_database->getCapsule();

        $this->_model = $capsule->table($this->table)->orderBy('id', $order)->get();

        return $this->_model;
    }
1141098
public static function analyze(Order $order) {
        $orderJson = $order->toJsonArray();
        $response = self::requestApi("post", $orderJson);
        $responseJson = $response->getBodyAsJson();
        if (!key_exists("order", $responseJson))
            throw new Exceptions\UnexpectedResponseException("Response has no 'order': $responseJson");
        $newOrder = new Order(array_merge($orderJson, $responseJson["order"]));
        return $newOrder;
    }
1287373
protected function buildOrderJoin(string $order): array
    {
        list($column, $direction) = $this->formatOrderDirection($order);

        $lookupBuilder = $this->getLookupBuilder();

        $column = $lookupBuilder->fetchColumnName($column);
        $newOrder = $lookupBuilder->buildJoin($this, $column);
        if (false === $newOrder) {
            return [$column, $direction];
        }

        list($alias, $column) = $newOrder;

        return [
            $alias.'.'.$column,
            $direction,
        ];
    }
718282
public static function groupBy (string $field, string $order="DESC") : array
	{
		$order = static::validateOrder($order);
		return static::findBySql("SELECT * FROM ".static::$tableName." GROUP BY {$field} ORDER BY id {$order}");
	}
1372123
public function convert(Order $order)
    {
        $orderItems = array();

        foreach ($order->orderItems as $orderItem) {
            /* @var $orderItem OrderItem */
            $orderItems[] = array(
                'sku' => $orderItem->getSKU(),
                'quantity' => $this->formatNumber($orderItem->getQuantity()),
                'unit_price' => $this->formatNumber($orderItem->getUnitPrice()),
                'taxes' => $this->formatNumber($orderItem->getTaxes()),
                'category_or_variation' => $orderItem->getCategoryOrVariation(),
                'name' => $orderItem->getName(),
            );
        }

        return array(
            'transaction_id' => $order->getTransactionID(),
            'store_name' => $order->getStoreName(),
            'total' => $this->formatNumber($order->getTotal()),
            'taxes_total' => $this->formatNumber($order->getTaxesTotal()),
            'shipping_total' => $this->formatNumber($order->getShippingTotal()),
            'city' => $order->getCity(),
            'state_or_province' => $order->getStateOrProvince(),
            'country' => $order->getCountry(),
            'order_items' => $orderItems,
        );
    }
1107203
private function unified_order($order){
        $wx_config = $this -> config;
        $nonce_str = $this->get_nonce_Str();
        $config = [
            'appid'=>$wx_config['app_id'],
            'mch_id'=>$wx_config['mch_id'],
            'nonce_str'=>$nonce_str,
            'spbill_create_ip'=>$this->client_ip(),
            'notify_url'=>$wx_config['notify_url']
        ];
        /*合并配置数据和订单数据*/
        $data = array_merge($order,$config);
        /*生成签名*/
        $sign = $this->make_sign($data);
        $data['sign'] = $sign;
        $xml = $this->to_xml($data);
        $header[] = "Content-type: text/xml";/*定义content-type为xml,注意是数组*/
        $ch = curl_init (self::API_UNIFIED_ORDER);
        curl_setopt($ch, CURLOPT_URL, self::API_UNIFIED_ORDER);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); /*兼容本地没有指定curl.cainfo路径的错误*/
        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
        $response = curl_exec($ch);
        if(curl_errno($ch)){
            // 显示报错信息；终止继续执行
            die(curl_error($ch));
        }
        curl_close($ch);
        $result = $this->to_array($response);
        /*显示错误信息*/
        if ($result['return_code']=='FAIL') {
            if ($this->business_interface) $this->business_interface->log('unified_order fail:'.json_encode($result));
            throw new \Exception($result['return_msg']);
        }
        $result['sign']=$sign;
        $result['nonce_str']=$nonce_str;
        return $result;
    }
675656
private function getOrderAndSeed($order)
    {
        @list($order, $seed) = explode(':', $order, 2);

        if (empty($seed)) {
            $seed = $this->getRandomSeed();
        }

        if (!is_numeric($seed)) {
            $this->showError("Could not use '$seed' as seed.");
        }

        return array($order, $seed);
    }
1244527
public static function array_sort(array $array, $order, $seq = '') {
    if (!$order) {
      return $array;
    }
    if (is_array($order)) {
      $key = array_keys($order)[0];
      $seq = $order[$key];
      $order = $key;
    }
    $seq = strtoupper($seq) == 'DESC' ? -1 : 1;
    usort( $array, function ($a, $b) use ($order, $seq) {
      $a = $a[$order];
      $b = $b[$order];
      $diff = is_string($a) && is_string($b) ? strcmp($a, $b) : $a - $b;
      return $seq * ceil($diff);
    });
    return $array;
  }