<?php
defined( 'IN_WEB') or die( 'Include Error!');
/**
 * 挖矿
 */
class Mining{

    /**
     * 矿工信息
     * @param $param
     * @return false|string
     * Created by: Owen
     * Created on: 2020/3/27 19:08
     */
    public function info($param){
        $uid = oo::functions()->uint($param['uid']);
        if(empty($uid)){
            return oo::response(-1,[],"参数异常");
        }
        $data = oo::commonOprModel('mining')->getInfo($uid);
        return json_encode($data,JSON_NUMERIC_CHECK);
    }

    /**
     * 升级矿岛旷工等级
     * @param $param
     * @return false|string
     * Created by: Owen
     * Created on: 2020/3/27 19:08
     */
    public function UpLevel($param){
        $uid = oo::functions()->uint($param['uid']);
        $levelId = oo::functions()->uint($param['levelId']);  //岛id
        if( empty($uid) ||  empty($levelId) ){
            return oo::response(-1,[],"参数异常");
        }
        $data = oo::commonOprModel('mining')->UpdateMining($uid,$levelId);
        return json_encode($data,JSON_NUMERIC_CHECK);

    }

    /**
     * 矿工领取收益
     * @param $param
     * @return false|string
     * Created by: Owen
     * Created on: 2020/3/27 19:08
     */
    public function receive($param){
        $uid = oo::functions()->uint($param['uid']);
        $money = oo::functions()->uint($param['coins']);
        if( empty($uid) || empty($money) ){
            return oo::response(-1,[],"参数异常");
        }
        $data = oo::commonOprModel('mining')->receiveUserIncome($uid,$money);
        return json_encode($data,JSON_NUMERIC_CHECK);
    }

    /**
     * 获取矿工游戏信息
     * @param $param
     * @return string
     * Created by: Owen
     * Created on: 2020/3/5 19:53
     */
    public function gameInfo($param){
        $uid = oo::functions()->uint($param['uid']);
        if(empty($uid)){
            return oo::response(-1,[],"参数异常");
        }
        $data = oo::commonOprModel('mining')->getGameInfo($uid,2);
        return oo::response(1,$data,"",true);
    }
}
?>