<?php 
namespace backend\models;

class OpenApi extends BaseApi
{
    public $apiUrl = 'open';

    /**
     * 真实账户申请
     * @param array $data
     * @return array
     */
    public function open($data)
    {
        $result = $this->post($this->apiUrl . '/open', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], '真实账户申请成功');
        } else {
            return $this->returnArray(0, $result['data'], $result['message']);
        }
    }

    /**
     * 模拟账户申请
     * @param array $data
     * @return array
     */
    public function openDemo($data)
    {
        $result = $this->post($this->apiUrl . '/opendemo', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], '模拟账户申请成功');
        } else {
            return $this->returnArray(0, [], $result['message']);
        }
    }

    /**
     * 开户申请列表
     * @param array $data
     * @return array
     */
    public function getOpenList($data = [])
    {
        $result = $this->get($this->apiUrl.'/get-open-list', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], '获取开户申请记录成功');
        } else {
            return $this->returnArray(0, [], '获取开户申请记录失败');
        }
    }

    /**
     * 开户申请详情
     * @param array $data
     * @return array
     */
    public function view($data = [])
    {
        $result = $this->get($this->apiUrl.'/view', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], '获取开户申请详情成功');
        } else {
            return $this->returnArray(0, [], '获取开户详情失败');
        }
    }

    /**
     * 删除开户申请
     * @param array $data
     * @return array
     */
    public function openDelete($data = [])
    {
        $result = $this->post($this->apiUrl.'/open-delete', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], '删除开户申请成功');
        } else {
            return $this->returnArray(0, [], '删除开户申请失败');
        }
    }

    /**
     * 开户申请审核
     * @param array $data
     * @return array
     */
    public function openAction($data = [])
    {
        $result = $this->get($this->apiUrl.'/open-action', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], '审核成功');
        } else {
            return $this->returnArray(0, $result['data'], '审核失败');
        }
    }

    /**
     * 开设MT4账户
     * @param array $data
     * @return array
     */
    public function openAccount($data = [])
    {
        $result = $this->post($this->apiUrl.'/open-account', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], $result['message']);
        } else {
            return $this->returnArray(0, $result['data'], $result['message']);
        }
    }

    /**
     * 开设xtrader账户
     * @param array $data
     * @return array
     */
    public function openMember($data = [])
    {
        $result = $this->post($this->apiUrl.'/open-member', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], $result['message']);
        } else {
            return $this->returnArray(0, [], $result['message']);
        }
    }

    /**
     * 开设xbroker账户
     * @param array $data
     * @return array
     */
    public function openIbMember($data = [])
    {
        $result = $this->post($this->apiUrl.'/open-ib-member', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], $result['message']);
        } else {
            return $this->returnArray(0,$result['data'], $result['message']);
        }
    }

    /**
     * 更新MT4账户
     * @param array $data
     * @return array
     */
    public function updateOpen($data = [])
    {
        $result = $this->post($this->apiUrl.'/update-open', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], $result['message']);
        } else {
            return $this->returnArray(0, [], $result['message']);
        }
    }
}