| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- <?php
- namespace App\Models;
- use DB;
- class GameSixlottery extends BaseModel {
- public $num=7;//开奖号码个数
- protected $table = "game_sixlottery";
- public $timestamps = false;
-
- //添加六合彩开奖记录
- function addOpenCode($data) {
- $checkno = $this->checkNoreplay($data['info_no']);
- if($checkno<0){
- return $checkno;
- }
- $this->identity = $data['identity'];
- $this->info_identity = $data['info_identity'];
- $this->info_no = $data['info_no'];
- $this->open_time = $data['open_time'];
- $this->time = $data['time'];
- $this->status = $data['status'];
- $this->sealingplate = $data['sealingplate'];
- $res = $this->save();
- if (!$res) {
- return -5051000102; //添加开奖失败
- }
- return 1;
- }
- //修改六合彩开奖信息
- function updateGameopen($data,$identity) {
- $checkno = $this->checkNoreplay($data['info_no'],$identity);
- if($checkno<0){
- return $checkno;
- }
- $res = $this->where('identity',$identity)->update($data);
- if (!$res) {
- return -5051000202; //修改开奖信息失败
- }
- return 1;
- }
- //修改六合彩开奖信息
- function updateGameopenall($data,$no) {
- //DB::connection()->enableQueryLog();
- $res = $this->where('info_no',$no)->update($data);
- /*$queries = DB::getQueryLog();
- print_r($res);
- print_r($queries);*/
- if (!$res) {
- return -5051000202; //修改开奖信息失败
- }
- return 1;
- }
- //验证期号是否重复
- function checkNoreplay($info_no,$notidentity='') {
- if(!empty($notidentity)){
- $res = $this->where('info_no',$info_no)->where('identity','<>',$notidentity)->first();
- }else{
- $res = $this->where('info_no',$info_no)->first();
- }
- if (!$res) {
- return 1;
- }
- return -5051000302; //期号已存在
- }
-
-
- //获取往期开奖记录
- 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 -5040000622;//没有开奖数据
- }
- return $data->toArray();
- }
-
- //获取一个游戏开奖数据
- function getOne(){
- $data=$this->where('status',2)->orderBy('open_time','desc')->first();
- if(!$data){
- return -5040000622;//没有开奖数据
- }
- return $data->toArray();
- }
-
- //获取最新游戏开奖期数
- function getGameno(){
- $data=$this->select('info_no')->orderBy('open_time','desc')->first();
- if(!$data){
- return -5040000102;//没有开奖数据
- }
- return $data->toArray();
- }
-
- //获取游戏所有开奖期数
- function getGameAllno(){
- $data=$this->select('info_no')->orderBy('info_no','desc')->get();
- if(!$data){
- return -5040000202;//没有开奖数据
- }
- return $data->toArray();
- }
-
- //按期号获取游戏开奖号码
- function getPrizeCodes($no){
- $data=$this->where('info_no',$no)->first();
- if(!$data){
- return -5040100122;//没有该期信息
- }
- return $data->toArray();
- }
- protected function getInfoByNo($no){
- return $this->getPrizeCodes($no);
- }
- protected function getSealInfo(){
- $data=$this->where('status',1)->orderBy('id','desc')->first();
- if(!$data){
- return -504404102;
- }
- return $data->toArray();
- }
- protected function updateToWating($no){
- $data=$this->where('info_no',$no)->update(['status'=>3]);
- if(!$data){
- return -504404122;
- }
- return 1;
- }
- //获取开奖信息
- protected function getOpeningInfo(){
- $data=$this->where('status',3)->orderBy('id','desc')->first();
- if(!$data){
- return -504404102;
- }
- return $data->toArray();
- }
- //完成派奖修改状态
- protected function finishPrize($no){
- $res=$this->where('status',3)->where('info_no',$no)->whereNotNull('prizes')->update(['status'=>2]);
- if(!$res){
- return -504414122;
- }
- return 1;
- }
- //修改
- protected function PrizeCode($code,$info_no){
- $res=$this->where('info_no',$info_no)->update(['codes'=>$code,'status'=>3]);
- if(!$res){
- return -504424122;
- }
- return 1;
- }
- protected function PrizeCodes($code,$info_no){
- $res=$this->where('info_no',$info_no)->update(['codes'=>$code,'status'=>1]);
- if(!$res){
- return -504424122;
- }
- return 1;
- }
- }
|