GameSixlottery.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <?php
  2. namespace App\Models;
  3. use DB;
  4. class GameSixlottery extends BaseModel {
  5. public $num=7;//开奖号码个数
  6. protected $table = "game_sixlottery";
  7. public $timestamps = false;
  8. //添加六合彩开奖记录
  9. function addOpenCode($data) {
  10. $checkno = $this->checkNoreplay($data['info_no']);
  11. if($checkno<0){
  12. return $checkno;
  13. }
  14. $this->identity = $data['identity'];
  15. $this->info_identity = $data['info_identity'];
  16. $this->info_no = $data['info_no'];
  17. $this->open_time = $data['open_time'];
  18. $this->time = $data['time'];
  19. $this->status = $data['status'];
  20. $this->sealingplate = $data['sealingplate'];
  21. $res = $this->save();
  22. if (!$res) {
  23. return -5051000102; //添加开奖失败
  24. }
  25. return 1;
  26. }
  27. //修改六合彩开奖信息
  28. function updateGameopen($data,$identity) {
  29. $checkno = $this->checkNoreplay($data['info_no'],$identity);
  30. if($checkno<0){
  31. return $checkno;
  32. }
  33. $res = $this->where('identity',$identity)->update($data);
  34. if (!$res) {
  35. return -5051000202; //修改开奖信息失败
  36. }
  37. return 1;
  38. }
  39. //修改六合彩开奖信息
  40. function updateGameopenall($data,$no) {
  41. //DB::connection()->enableQueryLog();
  42. $res = $this->where('info_no',$no)->update($data);
  43. /*$queries = DB::getQueryLog();
  44. print_r($res);
  45. print_r($queries);*/
  46. if (!$res) {
  47. return -5051000202; //修改开奖信息失败
  48. }
  49. return 1;
  50. }
  51. //验证期号是否重复
  52. function checkNoreplay($info_no,$notidentity='') {
  53. if(!empty($notidentity)){
  54. $res = $this->where('info_no',$info_no)->where('identity','<>',$notidentity)->first();
  55. }else{
  56. $res = $this->where('info_no',$info_no)->first();
  57. }
  58. if (!$res) {
  59. return 1;
  60. }
  61. return -5051000302; //期号已存在
  62. }
  63. //获取往期开奖记录
  64. function getLog($list=20,$fild='id',$order='desc',$where=''){
  65. $data=$this->orderBy($fild,$order);
  66. if(!empty($where)&&is_array($where)){
  67. $data = $data->where($where);
  68. }
  69. $data = $data->paginate($list);
  70. if(!$data){
  71. return -5040000622;//没有开奖数据
  72. }
  73. return $data->toArray();
  74. }
  75. //获取一个游戏开奖数据
  76. function getOne(){
  77. $data=$this->where('status',2)->orderBy('open_time','desc')->first();
  78. if(!$data){
  79. return -5040000622;//没有开奖数据
  80. }
  81. return $data->toArray();
  82. }
  83. //获取最新游戏开奖期数
  84. function getGameno(){
  85. $data=$this->select('info_no')->orderBy('open_time','desc')->first();
  86. if(!$data){
  87. return -5040000102;//没有开奖数据
  88. }
  89. return $data->toArray();
  90. }
  91. //获取游戏所有开奖期数
  92. function getGameAllno(){
  93. $data=$this->select('info_no')->orderBy('info_no','desc')->get();
  94. if(!$data){
  95. return -5040000202;//没有开奖数据
  96. }
  97. return $data->toArray();
  98. }
  99. //按期号获取游戏开奖号码
  100. function getPrizeCodes($no){
  101. $data=$this->where('info_no',$no)->first();
  102. if(!$data){
  103. return -5040100122;//没有该期信息
  104. }
  105. return $data->toArray();
  106. }
  107. protected function getInfoByNo($no){
  108. return $this->getPrizeCodes($no);
  109. }
  110. protected function getSealInfo(){
  111. $data=$this->where('status',1)->orderBy('id','desc')->first();
  112. if(!$data){
  113. return -504404102;
  114. }
  115. return $data->toArray();
  116. }
  117. protected function updateToWating($no){
  118. $data=$this->where('info_no',$no)->update(['status'=>3]);
  119. if(!$data){
  120. return -504404122;
  121. }
  122. return 1;
  123. }
  124. //获取开奖信息
  125. protected function getOpeningInfo(){
  126. $data=$this->where('status',3)->orderBy('id','desc')->first();
  127. if(!$data){
  128. return -504404102;
  129. }
  130. return $data->toArray();
  131. }
  132. //完成派奖修改状态
  133. protected function finishPrize($no){
  134. $res=$this->where('status',3)->where('info_no',$no)->whereNotNull('prizes')->update(['status'=>2]);
  135. if(!$res){
  136. return -504414122;
  137. }
  138. return 1;
  139. }
  140. //修改
  141. protected function PrizeCode($code,$info_no){
  142. $res=$this->where('info_no',$info_no)->update(['codes'=>$code,'status'=>3]);
  143. if(!$res){
  144. return -504424122;
  145. }
  146. return 1;
  147. }
  148. protected function PrizeCodes($code,$info_no){
  149. $res=$this->where('info_no',$info_no)->update(['codes'=>$code,'status'=>1]);
  150. if(!$res){
  151. return -504424122;
  152. }
  153. return 1;
  154. }
  155. }