<?php
namespace App\Models;
class GameSixlottery_Buy extends BaseModel
{
    public $num=3;//开奖号码个数
    protected $table="game_sixlottery_buy";
    public $timestamps = false;
    //撤单
    function Cancel($where){
        $res=$this->where($where)->where('status',0)->update(['delstatus'=>2]);
        if($res){
            return -5051262422;//作废失败
        }
        return 1;
    }
    function cancel_order($order_id){
        $res=$this->where('order_id',$order_id)->update(['delstatus'=>2]);
        if(!$res){
            return -7021021122;
        }
        return 1;
    }

    protected function getNoprizeInfo($info_no){
        $res=$this->where('no',$info_no)->where('prize_status',2)->first();
        if(!$res){
            return -5030010002;
        }
        return 1;
    }

    protected function getPrizeInfo($info_no){
        $res=$this->where('no',$info_no)->where('prize_status',1)->where('delstatus',1)->first();
        if(!$res){
            return -5030010302;
        }
        return 1;
    }

    protected function getBuyprizeInfo($info_no){
        $res=$this->where('no',$info_no)->where('prize_status',1)->first();
        if(!$res){
            return -5030010202;
        }
        return 1;
    }

    //修改可重新开奖注单状态
    protected function updatePrizeinfo($info_no){
        $res=$this->where('no',$info_no)->update(['prize_status'=>1]);
        if(!$res){
            return -5030010102;
        }
        return $this->where('no',$info_no)->where('delstatus',1)->count();
    }
    //重置
    protected function reSet($no){
        $res=$this->where('no',$no)->update(['status'=>0,'prize_status'=>1]);
        if(!$res){
            return -30081;
        }
        return 1;
    }
}
