<?php


namespace App\Services\order;

use App\Exception\custom\CodeSpecialException;
use Helpers\Sdk;

class OrderService
{
    /**
     * @param $orderId
     * @param $userId
     * 调用内部服务获取用户订单、子单、分润信息
     */
    public static function getFullOrderData($order_id) {

        $url = config('interface', 'order.order.pay_order');
        if (!$url) {
            throw new CodeSpecialException("failed" . __METHOD__ );
        }

        $params = ['order_id'=>$order_id];
        return Sdk::call($url, $params);
    }

    public static function getOrderInfo($order_id, $user_id) {
        //pay_order_info
        $url = config('interface', 'order.order.pay_order_info');
        if (!$url) {
            throw new CodeSpecialException("failed" . __METHOD__ );
        }

        $params = ['order_id'=>$order_id, 'user_id'=>$user_id];
        return Sdk::call($url, $params);
    }

    /**
     * @param $order_item_id
     * @param $user_id
     * @return bool|mixed
     * @throws CodeSpecialException
     * 获取订单子单信息
     */
    public static function getOrderItemData($order_item_id) {
        //merchant.account.get_role_list
        $url = config('interface', 'order.order.pay_order_item');
        if (!$url) {
            throw new CodeSpecialException("failed" . __METHOD__ );
        }

        $params = ['order_item_id'=>$order_item_id];
        return Sdk::call($url, $params);
    }
}