<?php
namespace backend\models;

class Mt4tradeApi extends BaseApi
{
    public $apiUrl = 'mt4trade';

    /**
     * 总笔数
     * @param int $login
     * @return array
     */
    public function getHistoryTotalCount($login)
    {
        $result = $this->get($this->apiUrl . '/get-history-total-count', ['login' => $login]);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], 'OK');
        } else {
            return $this->returnArray(0, [], 'FAILED');
        }
    }

    /**
     * 盈利交易笔数
     * @param int $login
     * @return array
     */
    public function getHistoryWinCount($login)
    {
        $result = $this->get($this->apiUrl . '/get-history-win-count', ['login' => $login]);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], 'OK');
        } else {
            return $this->returnArray(0, [], 'FAILED');
        }
    }

    /**
     * 亏损交易笔数
     * @param int $login
     * @return array
     */
    public function getHistoryLossCount($login)
    {
        $result = $this->get($this->apiUrl . '/get-history-loss-count', ['login' => $login]);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], 'OK');
        } else {
            return $this->returnArray(0, [], 'FAILED');
        }
    }

    /**
     * 收益图
     * @param int $login
     * @return array
     */
    public function sumProfitByDay($login)
    {
        $result = $this->get($this->apiUrl . '/sum-profit-by-day', ['login' => $login]);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], 'OK');
        } else {
            return $this->returnArray(0, [], 'FAILED');
        }
    }

    /**
     * 总入金 总出金
     * @param array $data
     * @return array
     */
    public function sumProfit($data)
    {
        $result = $this->get($this->apiUrl . '/sum-profit', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], 'OK');
        } else {
            return $this->returnArray(0, [], 'FAILED');
        }
    }

    /**
     * 交易手数图
     * @param int $login
     * @return array
     */
    public function volumeSumByDay($login)
    {
        $result = $this->get($this->apiUrl . '/volume-sum-by-day', ['login' => $login]);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], 'OK');
        } else {
            return $this->returnArray(0, [], 'FAILED');
        }
    }

    /**
     * 交易货币分布图
     * @param int $login
     * @return array
     */
    public function symbolCount($login)
    {
        $result = $this->get($this->apiUrl . '/symbol-count', ['login' => $login]);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], 'OK');
        } else {
            return $this->returnArray(0, [], 'FAILED');
        }
    }

    /**
     * 交易来源分布图
     * @param int $login
     * @return array
     */
    public function reasonCount($login)
    {
        $result = $this->get($this->apiUrl . '/reason-count', ['login' => $login]);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], 'OK');
        } else {
            return $this->returnArray(0, [], 'FAILED');
        }
    }

    /**
     * MT4交易报表
     * @param array $data
     * @return array
     */
    public function getTradeList($data)
    {
        $result = $this->get($this->apiUrl . '/list', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], 'OK');
        } else {
            return $this->returnArray(0, [], 'FAILED');
        }
    }

    /**
     * 代理商MT4交易报表
     * @param array $data
     * @return array
     */
    public function getIbTradeList($data)
    {
        $result = $this->get($this->apiUrl . '/ib-list', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], 'OK');
        } else {
            return $this->returnArray(0, [], 'FAILED');
        }
    }

    /**
     * @param array $data
     * @return array
     */
    public function getAdminTradeList($data)
    {
        $result = $this->post($this->apiUrl . '/admin-list', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], 'OK');
        } else {
            return $this->returnArray(0, [], 'FAILED');
        }
    }
    
}