<?php
namespace App\Models;
class GameSfsixlotteryLog extends BaseModel {

	protected $table = "game_sfsixlottery_log";
	public $timestamps = false;
	
	
	//添加六合彩开奖日志
	function addLog($data) {
		$this->info_no = $data['info_no'];
		$this->codes = $data['codes'];
		$this->open_time = $data['open_time'];
		$this->time = $data['time'];
		$this->status = $data['status'];
		$res = $this->save();
		if (!$res) {
			return -5050000102; //添加开奖失败
		}
		return 1;

	}

	//获取往期开奖记录
    function getLog($list=20,$fild='id',$order='desc',$where=''){
        $data=$this->orderBy($fild,$order);
        if(!empty($where)&&is_array($where)){
            $data = $data->where($where);
        }
        $data = $data->paginate($list);
        if(!$data){
            return -5050000202;//没有开奖数据
        }
        return $data->toArray();
    }
	
    //获取一个游戏开奖数据
    function getOne($identity){
        $data=$this->where('id',$identity)->first();
        if(!$data){
            return -5050000302;//没有开奖数据
        }
        return $data->toArray();
    }
	
    //删除一个游戏开奖数据
    function deleteOpendata($identity){
        $data=$this->where('status','未开奖')->where('id',$identity)->delete();
        if(!$data){
            return -5050000402;//删除失败
        }
        return 1;
    }
    //修改开奖信息
    function updateOpendata($data,$identity){
        $data=$this->where('status','未开奖')->where('id',$identity)->update($data);
        if(!$data){
            return -5050000502;//更新失败
        }
        return 1;
    }
    //修改开奖结果
    function updateData($data,$identity){
        $data=$this->where('id',$identity)->update($data);
        if(!$data){
            return -5050000502;//更新失败
        }
        return 1;
    }
    //按期号获取游戏开奖号码
    function getPrizeCodes($no){
        $data=$this->where('info_no',$no)->first();
        if(!$data){
            return -5040100122;//没有该期信息
        }
        return $data->toArray();
    }
}
