<?php
/**
 *------Create thems Controller------
 *------SCWPHP  Version 1.0.0------
 *------Dev Model Jions------
 *------Create Time 2017-06-08 10:07:19------
 */

namespace App\Api\Controller;

use App\Api\Model\Lottery_money;
use App\Api\Model\Lottery_money_log;

use App\Api\Model\MoneyBuy;
use App\Api\Model\MoneyRecharge;
use App\Api\Model\MoneyPrize;
use App\Api\Model\Withdraw;
use Biz\Common\Common;
use Biz\Game\GameList;
use System\Lang;
use \Exception;


class UserBuy extends BaseController {

    public function init() {}

    /**
     * 投注记录
     *
     * @access public
     * @return array JsonString
     */
    public function bettingRecord() {
        $code = 0;
        $msg = lang('Common','Api') -> get('error');
        try{
            $moneyBuyClass = new MoneyBuy();
            // 获取下注信息
            if ($_POST['type'] == 2) {
                $result = $moneyBuyClass -> stringBetRecord();
            } else {
                $result = $moneyBuyClass -> singleBetRecord();
            }
            $code = 1;
            $msg = lang('Index','Api') -> get('success');

            Render($result, $code, $msg);
        } catch (Exception $e) {
            Render([], $code, $msg);
        }
    }

    /**
     * 盈亏记录
     *
     * @access public
     * @return array JsonString
     */
    public function moneyRecord() {
        $code = 0;
        $msg = lang('Common','Api') -> get('error');
        try{
            $moneyBuyClass = new MoneyBuy();
            // 获取盈亏记录
            $result = $moneyBuyClass -> moneyRecord();
            $code = 1;
            $msg = lang('Index','Api') -> get('success');

            Render($result, $code, $msg);
        } catch (Exception $e) {
            Render([], $code, $msg);
            //Render([], $code, $e->getMessage());
        }
    }

    /**
     * 充值记录
     *
     * @access public
     * @return array JsonString
     */
    public function rechargeRecord() {
        $code = 0;
        $msg = lang('Common','Api') -> get('error');
        try{
            $moneyRechargeClass = new MoneyRecharge();
            // 获取充值记录
            $result = $moneyRechargeClass -> rechargeRecord();
            $result['code'] = 1;
            $code = 1;
            $msg = lang('Index','Api') -> get('success');

            Render($result, $code, $msg);
        } catch (Exception $e) {
            Render([], $code, $msg);
            //Render([], $code, $e->getMessage());
        }
    }

    /**
     * 取款记录
     *
     * @access public
     * @return array JsonString
     */
    public function moneyOutRecord() {
        $code = 0;
        $msg = lang('Common','Api') -> get('error');
        try{
            $moneyRechargeClass = new MoneyRecharge();
            // 获取取款记录
            $result = $moneyRechargeClass -> moneyOutRecord();
            $code = 1;
            $msg = lang('Index','Api') -> get('success');

            Render($result, $code, $msg);
        } catch (Exception $e) {
            Render([], $code, $msg);
        }
    }

    /**
     * 中奖记录
     *
     * @access public
     * @return array JsonString
     */
    public function prizeRecord() {
        $code = 0;
        $msg = lang('Common','Api') -> get('error');
        try{
            $moneyRechargeClass = new MoneyPrize();
            // 获取充值记录
            $result = $moneyRechargeClass -> prizeRecord();
            $code = 1;
            $msg = lang('Index','Api') -> get('success');

            Render($result, $code, $msg);
        } catch (Exception $e) {
            Render([], $code, $msg);
            //Render([], $code, $e->getMessage());
        }
    }

    /**
     * 提款申请
     *
     * @access public
     * @return array JsonString
     */
    public function withdrawalRequest() {
        $code = 0;
        $msg = lang('Common','Api') -> get('error');
        try{
            $withdrawClass = new Withdraw();
            // 提款申请
            $result = $withdrawClass -> withdrawalRequest();
            $code = 1;
            $msg = lang('Index','Api') -> get('success');

            Render($result, $code, $msg);
        } catch (Exception $e) {
            Render([], $code, $msg);
            //Render([], $code, $e->getMessage());
        }
    }

    /**
     * 个人中心初始显示
     *
     * @access public
     * @return array JsonString
     */
    public function index() {
        $code = 0;
        $msg = lang('Common','Api') -> get('error');
        try{
            $MoneyBuyModel = new MoneyBuy();
            // 数据获取
            $result = $MoneyBuyModel -> monthRecord();
            $code = 1;
            $msg = lang('Index','Api') -> get('success');

            Render($result, $code, $msg);
        } catch (Exception $e) {
            Render([], $code, $msg);
            //Render([], $code, $e->getMessage());
        }
    }
}
